src/com/github/isarthur/netbeans/editor/generator/java/FieldGenerator.java
@Override
    public void invoke() {
        dialog = GenerateFieldsDialog.createAndShow();
        if (dialog.isOkButtonPushed()) {
            try {
                javaSource.runModificationTask(workingCopy -> {
                    workingCopy.toPhase(JavaSource.Phase.RESOLVED);
                    compilationUnit = workingCopy.getCompilationUnit();
                    trees = workingCopy.getTrees();
                    treeUtilities = workingCopy.getTreeUtilities();
                    currentPath = treeUtilities.pathFor(caretPosition);
                    TreePath classInterfaceOrEnumPath =
                            treeUtilities.getPathElementOfKind(
                                    Set.of(Tree.Kind.CLASS, Tree.Kind.ENUM, Tree.Kind.INTERFACE), currentPath);
                    if (classInterfaceOrEnumPath == null) {
                        return;
                    }
                    ClassTree currentTree = (ClassTree) classInterfaceOrEnumPath.getLeaf();
                    setInsertIndex(currentTree);
                    insertFieldsIntoClassInterfaceOrEnum(workingCopy);
                }).commit();
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
        dialog.saveBounds();
        dialog.dispose();
    }
/**
     * This will be invoked when user chooses this Generator from Insert Code dialog
     */
This will be invoked when user chooses this Generator from Insert Code dialog
This will be invoked when user chooses this Generator from Insert Code dialog
@Override
    public void invoke() {
        dialog = GenerateFieldsDialog.createAndShow();
        if (dialog.isOkButtonPushed()) {
            try {
                javaSource.runModificationTask(workingCopy -> {
                    workingCopy.toPhase(JavaSource.Phase.RESOLVED);
                    compilationUnit = workingCopy.getCompilationUnit();
                    trees = workingCopy.getTrees();
                    treeUtilities = workingCopy.getTreeUtilities();
                    currentPath = treeUtilities.pathFor(caretPosition);
                    TreePath classInterfaceOrEnumPath =
                            treeUtilities.getPathElementOfKind(
                                    Set.of(Tree.Kind.CLASS, Tree.Kind.ENUM, Tree.Kind.INTERFACE), currentPath);
                    if (classInterfaceOrEnumPath == null) {
                        return;
                    }
                    ClassTree currentTree = (ClassTree) classInterfaceOrEnumPath.getLeaf();
                    setInsertIndex(currentTree);
                    insertFieldsIntoClassInterfaceOrEnum(workingCopy);
                }).commit();
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
        dialog.saveBounds();
        dialog.dispose();
    }
@ Override public void invoke ( ) { dialog = GenerateFieldsDialog . createAndShow ( ) ; if ( dialog . isOkButtonPushed ( ) ) { try { javaSource . runModificationTask ( workingCopy -> { workingCopy . toPhase ( JavaSource . Phase . RESOLVED ) ; compilationUnit = workingCopy . getCompilationUnit ( ) ; trees = workingCopy . getTrees ( ) ; treeUtilities = workingCopy . getTreeUtilities ( ) ; currentPath = treeUtilities . pathFor ( caretPosition ) ; TreePath classInterfaceOrEnumPath = treeUtilities . getPathElementOfKind ( Set . of ( Tree . Kind . CLASS , Tree . Kind . ENUM , Tree . Kind . INTERFACE ) , currentPath ) ; if ( classInterfaceOrEnumPath == null ) { return ; } ClassTree currentTree = ( ClassTree ) classInterfaceOrEnumPath . getLeaf ( ) ; setInsertIndex ( currentTree ) ; insertFieldsIntoClassInterfaceOrEnum ( workingCopy ) ; } ) . commit ( ) ; } catch ( IOException ex ) { Exceptions . printStackTrace ( ex ) ; } } dialog . saveBounds ( ) ; dialog . dispose ( ) ; }
This will be invoked when user chooses this Generator from Insert Code dialog
This will be invoked when user chooses this Generator from Insert Code dialog