Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 60 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ private StringProperty name;
public StringProperty getName() {
return name;
}
public void setName( StringProperty name ) {

public void setName(StringProperty name) {
this.name = name;
}
```
Expand All @@ -24,11 +25,11 @@ public final String getName() {
return name.get();
}

public final void setName( String value ) {
public final void setName(String value) {
name.set(value);
}

public final StringProperty nameProperty() {
public StringProperty nameProperty() {
return name;
}
```
Expand All @@ -38,19 +39,46 @@ which will create the following methods:

```java
private StringProperty nameProperty;

public final String getName() {
return nameProperty.get();
}

public final void setName( String value ) {
public final void setName(String value) {
nameProperty.set(value);
}

public final StringProperty nameProperty() {
public StringProperty nameProperty() {
return nameProperty;
}
```

Read-only properties and read-only wrapper types are also supported:

```java
private ReadOnlyStringProperty identifier;

public final String getIdentifier() {
return identifier.get();
}

public ReadOnlyStringProperty identifierProperty() {
return identifier;
}
```

```java
private ReadOnlyStringWrapper identifier;

public final String getIdentifier() {
return identifier.get();
}

public ReadOnlyStringProperty identifierProperty() {
return identifier.getReadOnlyProperty();
}
```



# Usage
Expand All @@ -71,12 +99,35 @@ Methods for supported property types will automatically be generated.
* FloatProperty
* IntegerProperty
* LongProperty



### Unsupported Property Types
* ListProperty
* MapProperty
* ObjectProperty
* SetProperty



### Supported Read-only Property Types
* ReadOnlyStringProperty
* ReadOnlyBooleanProperty
* ReadOnlyDoubleProperty
* ReadOnlyFloatProperty
* ReadOnlyIntegerProperty
* ReadOnlyLongProperty
* ReadOnlyListProperty
* ReadOnlyMapProperty
* ReadOnlyObjectProperty
* ReadOnlySetProperty



### Supported Read-only Wrapper Types
* ReadOnlyStringWrapper
* ReadOnlyBooleanWrapper
* ReadOnlyDoubleWrapper
* ReadOnlyFloatWrapper
* ReadOnlyIntegerWrapper
* ReadOnlyLongWrapper
* ReadOnlyListWrapper
* ReadOnlyMapWrapper
* ReadOnlyObjectWrapper
* ReadOnlySetWrapper
18 changes: 0 additions & 18 deletions nb-configuration.xml

This file was deleted.

25 changes: 15 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<author>Rob Terpilowski</author>
<licenseName>MIT License</licenseName>
<licenseFile>LICENSE</licenseFile>
<keystore>mykeystore</keystore>
<keystore>mykeystore</keystore>
<keystorealias>myself</keystorealias>
</configuration>
</plugin>
Expand Down Expand Up @@ -61,47 +61,52 @@
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-api-annotations-common</artifactId>
<version>RELEASE802</version>
<version>RELEASE81</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-modules-editor-lib2</artifactId>
<version>RELEASE802</version>
<version>RELEASE81</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-modules-editor-mimelookup</artifactId>
<version>RELEASE802</version>
<version>RELEASE81</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-util-lookup</artifactId>
<version>RELEASE802</version>
<version>RELEASE81</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-libs-javacapi</artifactId>
<version>RELEASE802</version>
<version>RELEASE81</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-modules-java-source</artifactId>
<version>RELEASE802</version>
<version>RELEASE81</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-util</artifactId>
<version>RELEASE802</version>
<version>RELEASE81</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-modules-editor-lib</artifactId>
<version>RELEASE802</version>
<version>RELEASE81</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-libs-javafx</artifactId>
<version>RELEASE802</version>
<version>RELEASE81</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-modules-java-source-base</artifactId>
<version>RELEASE81</version>
</dependency>
</dependencies>
<properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,42 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 Lynden, Inc.
*
* 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.lynden.netbeans.javafx;

/**
The MIT License (MIT)

Copyright (c) 2015 Lynden, Inc.

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.
**/

import com.sun.source.tree.ClassTree;
import com.sun.source.tree.Tree;
import com.sun.source.util.TreePath;
import java.io.IOException;
import javax.swing.text.JTextComponent;
import org.netbeans.api.java.source.CancellableTask;
import org.netbeans.api.java.source.JavaSource;
import org.netbeans.api.java.source.TreeUtilities;
import org.netbeans.api.java.source.WorkingCopy;

/**
*
* @author Francesco Illuminati <fillumina@gmail.com>
*/
abstract class CodeGeneratorCancellableTask implements CancellableTask<WorkingCopy> {

private final JTextComponent textComponent;

public CodeGeneratorCancellableTask(JTextComponent textComponent) {
Expand All @@ -51,17 +50,16 @@ public void run(WorkingCopy workingCopy) throws IOException {
generate(workingCopy);
}

public abstract void generateCode(WorkingCopy workingCopy, TreePath path,
int position);

private void generate(WorkingCopy wc) throws IOException {
final int caretOffset = textComponent.getCaretPosition();
TreePath path = wc.getTreeUtilities().pathFor(caretOffset);
path = TreeHelper.getParentElementOfKind(Tree.Kind.CLASS, path);
int idx = TreeHelper.findClassMemberIndex(wc,(ClassTree) path.getLeaf(), caretOffset);
generateCode(wc, path, idx);
TreeUtilities treeUtils = wc.getTreeUtilities();

int caretPosition = textComponent.getCaretPosition();
TreePath treePathAtCaret = treeUtils.pathFor(caretPosition);
generateCode(wc, treePathAtCaret, caretPosition);
}

protected abstract void generateCode(WorkingCopy workingCopy, TreePath treePathAtCaret, int caretPosition);

@Override
public void cancel() {
}
Expand Down
Loading