Skip to content

Commit

Permalink
Defining the project archetype in a layer
Browse files Browse the repository at this point in the history
  • Loading branch information
dukescript committed Mar 15, 2019
1 parent 86c7002 commit 03c5e39
Show file tree
Hide file tree
Showing 17 changed files with 513 additions and 1 deletion.
1 change: 1 addition & 0 deletions groovy/gradle.htmlui/manifest.mf
@@ -1,6 +1,7 @@
Manifest-Version: 1.0
AutoUpdate-Show-In-Client: true
OpenIDE-Module: org.netbeans.modules.gradle.htmlui
OpenIDE-Module-Layer: org/netbeans/modules/gradle/htmlui/resources/layer.xml
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/gradle/htmlui/Bundle.properties
OpenIDE-Module-Recommends: org.netbeans.modules.debugger.jpda.ui
OpenIDE-Module-Specification-Version: 1.0
Expand Down
3 changes: 2 additions & 1 deletion groovy/gradle.htmlui/nbproject/project.xml
Expand Up @@ -75,8 +75,9 @@
<test-type>
<name>unit</name>
<test-dependency>
<code-name-base>org.netbeans.libs.junit4</code-name-base>
<code-name-base>org.netbeans.modules.nbjunit</code-name-base>
<compile-dependency/>
<recursive/>
</test-dependency>
</test-type>
</test-dependencies>
Expand Down
@@ -0,0 +1,55 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.modules.gradle.htmlui;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Enumeration;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;

final class GradleArchetype {
private final FileObject root;
private final FileObject projectDir;

GradleArchetype(FileObject root, FileObject projectDir) {
this.root = root;
this.projectDir = projectDir;
}

final void copyTemplates() throws IOException {
Enumeration<? extends FileObject> en = root.getChildren(true);
while (en.hasMoreElements()) {
FileObject template = en.nextElement();
if (!template.isData()) {
continue;
}
String relative = FileUtil.getRelativePath(root, template);
FileObject destination = FileUtil.createData(projectDir, relative);
try (
OutputStream os = destination.getOutputStream();
InputStream is = template.getInputStream()
) {
FileUtil.copy(is, os);
}
}
}

}
@@ -0,0 +1,55 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:2.3.0"
}
}

def localProperties = new File(project.rootDir, "local.properties")
if (System.getenv("ANDROID_HOME") == null && !localProperties.exists()) {
return;
}

apply plugin: "com.android.application"

def commonProject = project.parent

dependencies {
compile commonProject
compile "com.dukescript.presenters:android:1.5.1"
compile "org.netbeans.html:ko4j:1.6"
}

android {
compileSdkVersion 23
buildToolsVersion "25.0.3"
sourceSets {
main.assets.srcDirs += "${commonProject.projectDir}/src/main/webapp"
println("after android" + main.assets.srcDirs);
}
defaultConfig {
applicationId "com.kt.mvvm.demo"
minSdkVersion 16
targetSdkVersion 16
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/DISCLAIMER'
}
}
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kt.mvvm.demo">

<application
android:allowBackup="true"
android:label="KtMvvmDemo"
android:supportsRtl="true"
>
<activity android:name="com.dukescript.presenters.Android"
android:configChanges="keyboardHidden|orientation|screenSize"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="loadPage" android:value="file:///android_asset/pages/index.html"/>
<meta-data android:name="loadClass" android:value="com.kt.mvvm.demo.Demo"/>
<meta-data android:name="invoke" android:value="onPageLoad"/>
</application>
</manifest>
@@ -0,0 +1,23 @@

apply plugin: 'java'
apply plugin: 'application'

def commonProject = project.parent

mainClassName = 'com.kt.mvvm.demo.DesktopMain'
distributions {
main {
baseName = commonProject.name + '-desktop'
contents {
from "${commonProject.projectDir}/src/main/webapp/"
}
}
}
tasks.run {
jvmArgs "-Dbrowser.rootdir=${commonProject.projectDir}/src/main/webapp/"
}
dependencies {
compile commonProject
compile "org.netbeans.html:net.java.html.boot:1.6"
runtime "org.netbeans.html:net.java.html.boot.fx:1.6"
}
@@ -0,0 +1,35 @@
/**
* The MIT License (MIT)
*
* Copyright (C) 2017 Anton Epple <toni.epple@eppleton.de>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.kt.mvvm.demo;

import net.java.html.boot.BrowserBuilder;

class desktop_src_main_java_DesktopMain {
public static void main(String[] args) {
BrowserBuilder.newBrowser().loadPage("pages/index.html")
.loadFinished(Demo::onPageLoad)
.showAndWait();
System.exit(0);
}
}
@@ -0,0 +1,9 @@
action.run.args=bck2brwsrShow
action.run.reload.rule=NEVER

action.debug.args=run --debug-jvm
action.debug.reload.rule=NEVER

action.custom-1=Run in Browser
action.custom-1.args=bck2brwsrShow
action.custom-1.reload.rule=NEVER
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN"
"http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<filesystem>
<folder name="Templates">
<folder name="Project">
<folder name="Gradle">
<folder name="org-netbeans-modules-gradle-htmlui-HtmlJavaApplicationProjectWizard.dir">
<file name="build.gradle" url="root_build.gradle"/>
<file name="gradle.properties" url="gradle.properties"/>
<file name="settings.gradle" url="settings.gradle"/>
<folder name="app">
<file name="build.gradle" url="app_build.gradle"/>
<folder name="src">
<folder name="main">
<file name="AndroidManifest.xml" url="app_src_main_AndroidManifest.xml"/>
</folder>
</folder>
</folder>
<folder name="desktop">
<file name="build.gradle" url="desktop_build.gradle"/>
<folder name="src">
<folder name="main">
<folder name="java">
<file name="DesktopMain.java" url="desktop_src_main_java_DesktopMain.fmk"/>
</folder>
<folder name="webapp">
<folder name="pages">
<file name="index.css" url="src_main_webapp_pages_index.css"/>
<file name="index.html" url="src_main_webapp_pages_index.html"/>
</folder>
</folder>
</folder>
</folder>
</folder>
<folder name="web">
<file name="build.gradle" url="web_build.gradle"/>
<folder name="src">
<folder name="main">
<folder name="java">
<file name="BrowserMain.java" url="web_src_main_java_BrowserMain.fmk"/>
</folder>
</folder>
</folder>
</folder>
<folder name="src">
<folder name="main">
<folder name="java">
<file name="Demo.java" url="src_main_java_Demo.fmk"/>
</folder>
</folder>
</folder>
</folder>
</folder>
</folder>
</folder>
</filesystem>
@@ -0,0 +1,24 @@
plugins {
id "me.tatarka.retrolambda" version "3.7.0"
}

apply plugin: 'java'

group 'com.dukescript.demo'
version '1.0-SNAPSHOT'

allprojects {
repositories {
mavenCentral()
}
}

targetCompatibility = '1.8'
sourceCompatibility = '1.8'

dependencies {
compile "org.netbeans.html:net.java.html.json:1.6"
compile "com.dukescript.api:javafx.base:8.60.11"
compile "com.dukescript.api:javafx.beaninfo:0.5"
runtime "org.netbeans.html:ko4j:1.6"
}
@@ -0,0 +1,5 @@
include 'desktop'
include 'app'
include 'web'
include 'ios'

@@ -0,0 +1,63 @@
/**
* The MIT License (MIT)
*
* Copyright (C) 2017 Anton Epple <toni.epple@eppleton.de>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.kt.mvvm.demo;

import com.dukescript.api.javafx.beans.FXBeanInfo;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.IntegerBinding;
import javafx.beans.property.ListProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import static net.java.html.json.Models.applyBindings;

public final class src_main_java_Demo implements FXBeanInfo.Provider {
private final StringProperty desc = new SimpleStringProperty(this, "desc", "Buy Milk");
private final ListProperty<String> todos = new SimpleListProperty<>(this, "todos", FXCollections.observableArrayList());
private final IntegerBinding numTodos = Bindings.createIntegerBinding(todos::size, todos);

void addTodo() {
todos.getValue().add(desc.getValue());
desc.setValue("");
}

private final FXBeanInfo info = FXBeanInfo.newBuilder(this)
.property(desc)
.property(todos)
.property("numTodos", numTodos)
.action("addTodo", this::addTodo)
.build();

@Override
public FXBeanInfo getFXBeanInfo() {
return info;
}

public static void onPageLoad() {
src_main_java_Demo model = new src_main_java_Demo();
applyBindings(model);
}

}

0 comments on commit 03c5e39

Please sign in to comment.