Java Code Examples for org.netbeans.api.progress.ProgressHandleFactory#createHandle()

The following examples show how to use org.netbeans.api.progress.ProgressHandleFactory#createHandle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DetectPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void readSettings(WizardDescriptor settings) {           
    sources = null;
    sourcesString = null;
    javadoc = null;
    javadocString = null;
    this.wiz = settings;
    this.component.progressPanel.setVisible (true);
    this.component.progressLabel.setVisible (true);
    
    this.progressHandle = ProgressHandleFactory.createHandle(NbBundle.getMessage(DetectPanel.class,"TXT_PlatfromDetectProgress"));
    this.component.progressPanel.removeAll();
    this.component.progressPanel.setLayout (new GridBagLayout ());
    GridBagConstraints c = new GridBagConstraints ();
    c.gridx = c.gridy = GridBagConstraints.RELATIVE;
    c.gridheight = c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    JComponent pc = ProgressHandleFactory.createProgressComponent(this.progressHandle);
    ((GridBagLayout)this.component.progressPanel.getLayout ()).setConstraints(pc,c);
    this.component.progressPanel.add (pc);
    this.progressHandle.start ();
    task.schedule(0);
}
 
Example 2
Source File: DataObject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public ProgressInfo(String name, DataObject root) {
    final Cancellable can;
    if (root instanceof DataFolder) {
        can = new Cancellable() {

            @Override
            public boolean cancel() {
                terminated.set(true);
                return true;
            }
        };
    } else {
        can = null;
    }
    ProgressHandle ph = ProgressHandleFactory.createHandle(name, can);
    ph.setInitialDelay(500);
    ph.start();
    this.progressHandle = ph;
    this.root = root;
}
 
Example 3
Source File: DefaultProjectOperationsImplementationTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testCopyWithInnerProjectComplex() throws Exception {
    TestUtil.createFileFromContent(DefaultProjectOperationsImplementationTest.class.getResource("data/test.txt"), projdir, "lib/test.txt");
    FileObject projdir2 = projdir.getFileObject("lib").createFolder("proj2");
    
    createProject(projdir2);
    
    ProgressHandle handle = ProgressHandleFactory.createHandle("test-handle");
    handle.start(DefaultProjectOperationsImplementation.MAX_WORK);
    
    FileObject newTarget = prj.getProjectDirectory().getParent();
    
    DefaultProjectOperationsImplementation.doCopyProject(handle, prj, "projCopy", newTarget);
    
    File newProject = new File(FileUtil.toFile(newTarget), "projCopy");
    
    assertTrue(newProject.isDirectory());
    assertTrue(new File(newProject, "nbproject").isDirectory());
    assertTrue(new File(newProject, "src").isDirectory());
    assertTrue(new File(newProject, "lib").isDirectory());
    assertFalse(new File(new File(newProject, "lib"), "proj2").exists());
}
 
Example 4
Source File: ImageCompress.java    From minifierbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent ev) {
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            compress();
        }
    };
    
    final RequestProcessor.Task theTask = RP.create(runnable);
    final ProgressHandle ph = ProgressHandleFactory.createHandle("Compressing Image " + context.getPrimaryFile().getName(), theTask);
    
    theTask.addTaskListener(new TaskListener() {
        @Override
        public void taskFinished(org.openide.util.Task task) {
            NotificationDisplayer.getDefault().notify("Image compressed successfully", NotificationDisplayer.Priority.NORMAL.getIcon(), "The compression of the image was successful.", null);
            
            ph.finish();
        }
    });
    
    ph.start();
    theTask.schedule(0);

}
 
Example 5
Source File: ResolvePluginsAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
    final ProgressHandle handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(ResolvePluginsAction.class, "LBL_Resolving_Project_Plugins_progress"));

    final Dialog dialog = DialogDisplayer.getDefault().createDialog(
            ProgressSupport.createProgressDialog(NbBundle.getMessage(ResolvePluginsAction.class, "LBL_Resolving_Project_Plugins"),
            handle, null));

    RequestProcessor.getDefault().post(new Runnable() {

        public void run() {
            try {
                handle.start();
                handle.progress(NbBundle.getMessage(ResolvePluginsAction.class, "LBL_Resolving_Project_Plugins_progress"));
                prj.getBuildConfig().reload();
            } finally {
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        dialog.setVisible(false);
                        dialog.dispose();
                        handle.finish();
                    }
                });
            }
        }
    });
    
    dialog.setVisible(true);

}
 
Example 6
Source File: DefaultProjectOperationsImplementationTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testCopyWithLib() throws Exception {
    TestUtil.createFileFromContent(DefaultProjectOperationsImplementationTest.class.getResource("data/test.txt"), projdir, "lib/test.txt");
    ProgressHandle handle = ProgressHandleFactory.createHandle("test-handle");
    handle.start(DefaultProjectOperationsImplementation.MAX_WORK);
    FileObject newTarget = prj.getProjectDirectory().getParent();
    
    DefaultProjectOperationsImplementation.doCopyProject(handle, prj, "projCopy", newTarget);
    
    File newProject = new File(FileUtil.toFile(newTarget), "projCopy");
    
    assertTrue(newProject.isDirectory());
    assertTrue(new File(newProject, "nbproject").isDirectory());
    assertTrue(new File(newProject, "src").isDirectory());
    assertTrue(new File(newProject, "lib").isDirectory());
}
 
Example 7
Source File: StatusProgressPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
public StatusProgressPanel(final StatusProgressMonitor pm) {
    this.pm = pm;

    if(pm != null) {
        p = ProgressHandleFactory.createHandle(pm.getName());
        p.start(100);
        p.switchToDeterminate(100);
        active = true;
        pm.addListener(this);
    } else {
        p = null;
        active = false;
    }
}
 
Example 8
Source File: InternalSampler.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
@Messages("Save_Progress=Saving snapshot")
void openProgress(final int steps) {
    if (EventQueue.isDispatchThread()) {
        // log warnining
        return;
    }
    progress = ProgressHandleFactory.createHandle(Save_Progress());
    progress.start(steps);
}
 
Example 9
Source File: KODoc.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void startLoading() {
    LOG.fine("start loading doc"); //NOI18N
    Collection<KOHelpItem> items = new ArrayList<>();
    //add the data-attribute help item
    items.add(KOHtmlExtension.KO_DATA_BIND_HELP_ITEM);
    //add bindings
    items.addAll(Arrays.asList(Binding.values()));
    
    bindings = items.iterator();        
    progress = ProgressHandleFactory.createHandle(Bundle.doc_building());
    progress.start(items.size());

    buildDoc();
}
 
Example 10
Source File: QueryController.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected void postPopulate(final String urlParameters, final boolean forceRefresh) {

        final Task[] t = new Task[1];
        Cancellable c = new Cancellable() {
            @Override
            public boolean cancel() {
                if(t[0] != null) {
                    return t[0].cancel();
                }
                return true;
            }
        };

        final String msgPopulating = NbBundle.getMessage(QueryController.class, "MSG_Populating", new Object[]{repository.getDisplayName()});    // NOI18N
        final ProgressHandle handle = ProgressHandleFactory.createHandle(msgPopulating, c);

        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                enableFields(false);
                panel.showRetrievingProgress(true, msgPopulating, !query.isSaved());
                handle.start();
            }
        });   

        t[0] = rp.post(new Runnable() {
            @Override
            public void run() {
                try {
                    if(forceRefresh) {
                        repository.refreshConfiguration();
                    }
                    populate(urlParameters);
                } finally {
                    EventQueue.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            enableFields(true);
                            setChanged();
                            handle.finish();
                            panel.showRetrievingProgress(false, null, !query.isSaved());
                        }
                    });
                }
            }
        });
    }
 
Example 11
Source File: ProgressHandleMonitor.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
public static ProgressHandleMonitor create(String displayName, Cancellable cancellable) {
    ProgressHandleMonitor progressMonitor = new ProgressHandleMonitor(cancellable);
    ProgressHandle progressHandle = ProgressHandleFactory.createHandle(displayName, progressMonitor);
    progressMonitor.setProgressHandle(progressHandle);
    return progressMonitor;
}
 
Example 12
Source File: CoreDumpProvider.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private static void createCoreDumpImpl(String coreDumpFile, final String displayName, String jdkHome, boolean deleteCoreDump) {
    
    // TODO: check if the same coredump isn't already imported (can happen for moved coredumps)
    
    final CoreDumpImpl knownCoreDump = getCoreDumpByFile(new File(coreDumpFile));
    if (knownCoreDump != null) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                ExplorerSupport.sharedInstance().selectDataSource(knownCoreDump);
                DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.
                        Message(NbBundle.getMessage(CoreDumpProvider.class,
                        "MSG_Core_dump_already_added", new Object[] {displayName, // NOI18N
                        DataSourceDescriptorFactory.getDescriptor(knownCoreDump).
                        getName()}), NotifyDescriptor.ERROR_MESSAGE));
            }
        });
        return;
    }
    
    if (deleteCoreDump) {
        ProgressHandle pHandle = null;
        try {
            pHandle = ProgressHandleFactory.createHandle(NbBundle.getMessage(CoreDumpProvider.class, "MSG_Adding", displayName));   // NOI18N
            pHandle.setInitialDelay(0);
            pHandle.start();
            
            File file = new File(coreDumpFile);
            File copy = Utils.getUniqueFile(CoreDumpSupport.getStorageDirectory(), file.getName());
            if (Utils.copyFile(file, copy)) {
                coreDumpFile = copy.getAbsolutePath();
                if (!file.delete()) file.deleteOnExit();
            }
        } finally {
            final ProgressHandle pHandleF = pHandle;
            SwingUtilities.invokeLater(new Runnable() {
                public void run() { if (pHandleF != null) pHandleF.finish(); }
            });
        }
    }
    
    final String[] propNames = new String[] {
        SNAPSHOT_VERSION,
        Snapshot.PROPERTY_FILE,
        DataSourceDescriptor.PROPERTY_NAME,
        PROPERTY_JAVA_HOME };
    final String[] propValues = new String[] {
        CURRENT_SNAPSHOT_VERSION,
        coreDumpFile,
        displayName,
        jdkHome
    };

    File customPropertiesStorage = Utils.getUniqueFile(CoreDumpSupport.getStorageDirectory(), new File(coreDumpFile).getName(), Storage.DEFAULT_PROPERTIES_EXT);
    Storage storage = new Storage(customPropertiesStorage.getParentFile(), customPropertiesStorage.getName());
    
    try {
        CoreDumpImpl newCoreDump = new CoreDumpImpl(new File(coreDumpFile), new File(jdkHome), storage);
        if (newCoreDump != null) {
            new CoreDumpAdder(newCoreDump, storage, propNames, propValues).execute();
        }
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, "Error creating coredump", e); // NOI18N
        return;
    }
}
 
Example 13
Source File: CustomizationWSEditor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void saveAndRefresh(final Node node, JaxWsModel jaxWsModel) {
    if (wsTopComponent == null) return; // top component cannot be initialized for some reason - see error message from createWSEditorComponent()
    Collection<SaveableSectionInnerPanel> panels = wsTopComponent.getPanels();
    for (SaveableSectionInnerPanel panel : panels) {
        panel.save();
        if (!wsdlIsDirty) {
            wsdlIsDirty = panel.wsdlIsDirty();
        }
        if (!jaxwsDirty) {
            jaxwsDirty = panel.jaxwsIsDirty();
        }
    }

    try {
        if (wsdlIsDirty) {
            Set<WSDLModel> modelSet = wsdlModels.keySet();
            for (WSDLModel wsdlModel : modelSet) {
                ModelSource ms = wsdlModel.getModelSource();
                FileObject fo = (FileObject) ms.getLookup().lookup(FileObject.class);
                DataObject wsdlDO = DataObject.find(fo);
                SaveCookie wsdlSaveCookie = (SaveCookie) wsdlDO.getCookie(SaveCookie.class);
                if (wsdlSaveCookie != null) {
                    wsdlSaveCookie.save();
                }
            }
        }
        if (jaxwsDirty) {
            jaxWsModel.write();
        }
        final ProgressHandle handle = ProgressHandleFactory.createHandle
                (NbBundle.getMessage(CustomizationWSEditor.class, "TXT_Refreshing")); //NOI18N
        handle.start(100);
        handle.switchToIndeterminate();
        Runnable r = new Runnable() {
            public void run() {
                try {
                    if (wsdlIsDirty || jaxwsDirty) {
                        JaxWsRefreshCookie refreshCookie =
                                (JaxWsRefreshCookie) node.getCookie(JaxWsRefreshCookie.class);
                        if (refreshCookie != null) { 
                            refreshCookie.refreshService(false);
                        }
                    }
                } finally {
                    handle.finish();
                }
            }
        };
        RequestProcessor.getDefault().post(r);
    } catch (Exception e) {
        ErrorManager.getDefault().notify(e);
    }
}
 
Example 14
Source File: KillAction.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private Progress(String pid) {
    handle = ProgressHandleFactory.createHandle(Bundle.MSG_Kill(pid));
    handle.setInitialDelay(500);
    handle.start();
    running = true;
}
 
Example 15
Source File: DefaultSuiteProjectOperationsImplementation.java    From netbeans with Apache License 2.0 4 votes vote down vote up
static void deleteProject(final SuiteProject project, UserInputHandler handler) {
    String displayName = getDisplayName(project);
    FileObject projectFolder = project.getProjectDirectory();
    
    LOG.log(Level.FINE, "delete started: {0}", displayName);
    
    final List<FileObject> metadataFiles = ProjectOperations.getMetadataFiles(project);
    final List<FileObject> dataFiles = ProjectOperations.getDataFiles(project);
    final List<FileObject> allFiles = new ArrayList<FileObject>();
    
    allFiles.addAll(metadataFiles);
    allFiles.addAll(dataFiles);
    
    for (Iterator<FileObject> i = allFiles.iterator(); i.hasNext(); ) {
        FileObject f = i.next();
        if (!FileUtil.isParentOf(projectFolder, f)) {
            if (projectFolder.equals(f)) {
                // sources == project directory
                continue;
            }
            i.remove();
        }
    }
    
    
    final SubprojectProvider suiteProvider = project.getLookup().lookup(SubprojectProvider.class);
    final Set<Project> subProjects = (Set<Project>) suiteProvider.getSubprojects();
    final Set<NbModuleProject> subModules = new HashSet<NbModuleProject>();
    for(Project prjIter:subProjects) {
        NbModuleProject nbModulePrj = prjIter.getLookup().lookup(NbModuleProject.class);
        if(nbModulePrj != null) {
            subModules.add(nbModulePrj);
        }
    }
    final Map<NbModuleProject,List<FileObject>> subModulesDataFiles = getSubModulesDataFiles(subModules);
    
    
    final ProgressHandle handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(DefaultSuiteProjectOperationsImplementation.class, "LBL_Delete_Project_Caption"));
    final DefaultSuiteProjectDeletePanel deletePanel = new DefaultSuiteProjectDeletePanel(handle, displayName, FileUtil.getFileDisplayName(projectFolder), !subModulesDataFiles.isEmpty(), !subModules.isEmpty());
    
    String caption = NbBundle.getMessage(DefaultSuiteProjectOperationsImplementation.class, "LBL_Delete_Project_Caption");
    
    handler.showConfirmationDialog(deletePanel, project, caption, "Yes_Button", "No_Button", true, new Executor() { // NOI18N
        public @Override void execute() throws Exception {
            deletePanel.addProgressBar();
            
            close(project);
            
            Map<NbModuleProject,List<FileObject>> subModulesAllFiles = null;
            Map<NbModuleProject,List<FileObject>> subModulesMetadataFiles = null;
            
            if(deletePanel.isDeleteModules()) {
                for(NbModuleProject modulePrjIter:subModules) {
                    close(modulePrjIter);
                }
                subModulesAllFiles = new HashMap<NbModuleProject, List<FileObject>>();
                subModulesAllFiles.putAll(subModulesDataFiles);
                subModulesMetadataFiles = getSubModulesMetadataFiles(subModules, subModulesAllFiles);
            } 
            
            if (deletePanel.isDeleteSources()) {
                performDelete(project, allFiles, subModulesAllFiles, handle);
            } else {
                performDelete(project, metadataFiles, subModulesMetadataFiles, handle);
            }
            deletePanel.removeProgressBar();
        }
    });
    
    LOG.log(Level.FINE, "delete done: {0}", displayName);
}
 
Example 16
Source File: CustomizerDialog.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void actionPerformed( final ActionEvent e ) {
    String command = e.getActionCommand();

    if ( COMMAND_OK.equals( command ) ) {
        // Call the OK option listener
        ProjectManager.mutex().writeAccess(new Mutex.Action<Object>() {
            public Object run() {
                okOptionListener.actionPerformed( e ); // XXX maybe create new event
                actionPerformed(e, categories);
                return null;
            }
        });
        
        final ProgressHandle handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(CustomizerDialog.class, "LBL_Saving_Project_data_progress"));
        JComponent component = ProgressHandleFactory.createProgressComponent(handle);
        Frame mainWindow = WindowManager.getDefault().getMainWindow();
        final JDialog dialog = new JDialog(mainWindow, 
                NbBundle.getMessage(CustomizerDialog.class, "LBL_Saving_Project_data"), true);
        SavingProjectDataPanel panel = new SavingProjectDataPanel(component);
        
        dialog.getContentPane().add(panel);
        dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
        dialog.pack();
        
        Rectangle bounds = mainWindow.getBounds();
        int middleX = bounds.x + bounds.width / 2;
        int middleY = bounds.y + bounds.height / 2;
        Dimension size = dialog.getPreferredSize();
        dialog.setBounds(middleX - size.width / 2, middleY - size.height / 2, size.width, size.height);
        
        // Call storeListeners out of AWT EQ
        RequestProcessor.getDefault().post(new Runnable() {
            @Override
            public void run() {
                try {
                    ProjectManager.mutex().writeAccess(new Mutex.Action<Object>() {
                        @Override
                        public Object run() {
                            FileUtil.runAtomicAction(new Runnable() {
                                @Override
                                public void run() {
                            handle.start();
                            if (storeListener != null) {
                                storeListener.actionPerformed(e);
                            }
                            storePerformed(e, categories);
                            // #97998 related
                            saveModifiedProject();
                                }
                            });
                            return null;
                        }
                    });
                } finally {
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            dialog.setVisible(false);
                            dialog.dispose();
                        }
                    });
                }
            }
        });
        
        dialog.setVisible(true);
        
    }
}
 
Example 17
Source File: TestMethodRunnerProvider.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
    * Handle/Run the selected test method
    * @param activatedNode the selected node
    */
   @NbBundle.Messages({"Search_For_Test_Method=Searching for test method",
"No_Test_Method_Found=No test method found"})
   public final void runTestMethod(Node activatedNode) {
       final Node activeNode = activatedNode;
       final Document doc;
       final int caret;

       final EditorCookie ec = activeNode.getLookup().lookup(EditorCookie.class);
       if (ec != null) {
           JEditorPane pane = Mutex.EVENT.readAccess(new Mutex.Action<JEditorPane>() {
	@Override
	public JEditorPane run() {
	    return NbDocument.findRecentEditorPane(ec);
	}
    });
           if (pane != null) {
               doc = pane.getDocument();
               caret = pane.getCaret().getDot();
           } else {
               doc = null;
               caret = -1;
           }
       } else {
           doc = null;
           caret = -1;
       }

singleMethod = activeNode.getLookup().lookup(SingleMethod.class);
if (singleMethod == null) {
    RequestProcessor RP = new RequestProcessor("TestMethodRunnerProvider", 1, true);   // NOI18N
    singleMethodTask = RP.create(new Runnable() {
	@Override
	public void run() {
	    singleMethod = getTestMethod(doc, caret);
	}
    });
    final ProgressHandle ph = ProgressHandleFactory.createHandle(Bundle.Search_For_Test_Method(), singleMethodTask);
    singleMethodTask.addTaskListener(new TaskListener() {
	@Override
	public void taskFinished(org.openide.util.Task task) {
	    ph.finish();
	    if (singleMethod == null) {
		StatusDisplayer.getDefault().setStatusText(Bundle.No_Test_Method_Found());
	    } else {
		Mutex.EVENT.readAccess(new Runnable() {
		    @Override
		    public void run() {
			ActionProvider ap = CommonUtils.getInstance().getActionProvider(singleMethod.getFile());
			if (ap != null) {
			    if (Arrays.asList(ap.getSupportedActions()).contains(command) && ap.isActionEnabled(command, Lookups.singleton(singleMethod))) {
				ap.invokeAction(command, Lookups.singleton(singleMethod));
			    }
			}
		    }
		});
	    }
	}
    });
    ph.start();
    singleMethodTask.schedule(0);
}
   }
 
Example 18
Source File: IssueTopComponent.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void onRepoSelected() {
    if(prepareTask != null) {
        prepareTask.cancel();
    }
    Cancellable c = new Cancellable() {
        @Override
        public boolean cancel() {
            if(prepareTask != null) {
                prepareTask.cancel();
            }
            return true;
        }
    };
    UIUtils.setWaitCursor(true);
    final ProgressHandle handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(IssueTopComponent.class, "CTL_PreparingIssue"), c); // NOI18N
    prepareTask = rp.post(new Runnable() {
        @Override
        public void run() {
            try {
                handle.start();
                setVisible(preparingLabel, true);
                RepositoryImpl repo = getRepository();
                if (repo == null) {
                    return;
                }
                if(issue != null) {
                    if(controller != null) {
                        issuePanelRemove(controller.getComponent());
                        unregisterListeners();
                        controller.closed();
                    }
                    instanceContent.remove(issue.getIssue());
                }
                issue = repo.createNewIssue();
                if (issue == null) {
                    return;
                }
                instanceContent.add(issue.getIssue());
                
                registerForIssue();
                ((DelegatingUndoRedoManager)getUndoRedo()).init();
                
                if(context != null && NBBugzillaUtils.isNbRepository(repo.getUrl())) {
                    OwnerInfo ownerInfo = TeamAccessorUtils.getOwnerInfo(context);
                    if(ownerInfo != null) {
                        issue.setContext(ownerInfo);
                    }
                }
                
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        controller = getController();
                        issuePanel.add(controller.getComponent(), BorderLayout.CENTER);
                        registerListeners();
                        controller.opened();
                        revalidate();
                        repaint();

                        focusFirstEnabledComponent();
                        
                        if(!IssueTopComponent.this.isShowing()) {
                            // ensure issue exists when TC is opened so 
                            // that we can notify the issue implementation about issue being opened
                            IssueTopComponent.this.open();
                            IssueTopComponent.this.requestActive();
                        }
                    }
                });
            } finally {
                UIUtils.setWaitCursor(false);
                setVisible(preparingLabel, false);
                handle.finish();
                prepareTask = null;
            }
        }
    });
}
 
Example 19
Source File: AbstractMavenExecutor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Messages({
    "ResumeAction_scanning=Searching for faulty module",
    "ResumeAction_could_not_find_module=Could not determine module from which to resume build."
})
@Override public void actionPerformed(ActionEvent e) {
    final Project p = config.getProject();
    if (p == null) {
        setFinder(null);
        StatusDisplayer.getDefault().setStatusText(ResumeAction_could_not_find_module());
        return;
    }
    final AtomicReference<Thread> t = new AtomicReference<Thread>();
    final ProgressHandle handle = ProgressHandleFactory.createHandle(ResumeAction_scanning(), new Cancellable() {
        @Override public boolean cancel() {
            Thread _t = t.get();
            if (_t != null) {
                _t.interrupt();
                return true;
            } else {
                return false;
            }
        }
    });
    RP.post(new Runnable() {
        @Override public void run() {
            t.set(Thread.currentThread());
            handle.start();
            NbMavenProject nbmp;
            try {
                nbmp = finder.find(p);
            } finally {
                handle.finish();
            }
            t.set(null);
            if (nbmp == null || NbMavenProject.isErrorPlaceholder(nbmp.getMavenProject())) {
                setFinder(null);
                StatusDisplayer.getDefault().setStatusText(ResumeAction_could_not_find_module());
                return;
            }
            File root = config.getExecutionDirectory();
            File module = nbmp.getMavenProject().getBasedir();
            String rel = root != null && module != null ? FileUtilities.relativizeFile(root, module) : null;
            String id = rel != null ? rel : nbmp.getMavenProject().getGroupId() + ':' + nbmp.getMavenProject().getArtifactId();
            BeanRunConfig newConfig = new BeanRunConfig(config);
            List<String> goals = new ArrayList<String>(config.getGoals());
            int rf = goals.indexOf("--resume-from");
            if (rf != -1) {
                goals.set(rf + 1, id);
            } else {
                goals.add(0, "--resume-from");
                goals.add(1, id);
            }
            newConfig.setGoals(goals);
            RunUtils.executeMaven(newConfig);
        }
    });
}
 
Example 20
Source File: ToolAdapterExecutionDialog.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onApply() {
    final Product[] sourceProducts = form.getSourceProducts();
    List<ParameterDescriptor> descriptors = Arrays.stream(operatorDescriptor.getParameterDescriptors())
            .filter(p -> ToolAdapterConstants.TOOL_TARGET_PRODUCT_FILE.equals(p.getName()))
            .collect(Collectors.toList());
    String templateContents;
    try {
        //templateContents = ToolAdapterIO.readOperatorTemplate(operatorDescriptor.getName());
        FileTemplate template = operatorDescriptor.getTemplate();
        templateContents = template.getContents();
    } catch (Exception ex) {
        showErrorDialog(String.format("Cannot read operator template [%s]", ex.getMessage()));
        return;
    }
    if (Arrays.stream(sourceProducts).anyMatch(Objects::isNull)) {
        Dialogs.Answer decision = Dialogs.requestDecision("No Product Selected", Bundle.NoSourceProductWarning_Text(), false,
                ToolAdapterOptionsController.PREFERENCE_KEY_SHOW_EMPTY_PRODUCT_WARNING);
        if (decision.equals(Dialogs.Answer.NO)) {
            return;
        }
    }
    if (descriptors.size() == 1 && form.getPropertyValue(ToolAdapterConstants.TOOL_TARGET_PRODUCT_FILE) == null &&
            templateContents.contains("$" + ToolAdapterConstants.TOOL_TARGET_PRODUCT_FILE)) {
        Dialogs.showWarning(Bundle.RequiredTargetProductMissingWarning_Text());
    } else {
        if (!canApply()) {
            displayWarnings();
            AbstractAdapterEditor dialog = AbstractAdapterEditor.createEditorDialog(appContext, getJDialog(), operatorDescriptor, OperationType.FORCED_EDIT);
            final int code = dialog.show();
            if (code == AbstractDialog.ID_OK) {
                onOperatorDescriptorChanged(dialog.getUpdatedOperatorDescriptor());
            }
            dialog.close();
        } else {
            if (validateUserInput()) {
                Map<String, Product> sourceProductMap = new HashMap<>();
                if (sourceProducts.length > 0) {
                    sourceProductMap.put(SOURCE_PRODUCT_FIELD, sourceProducts[0]);
                }
                Operator op = GPF.getDefaultInstance().createOperator(operatorDescriptor.getAlias(), parameterSupport.getParameterMap(), sourceProductMap, null);
                for (Property property : parameterSupport.getPropertySet().getProperties()) {
                    op.setParameter(property.getName(), property.getValue());
                }
                op.setSourceProducts(sourceProducts);
                operatorTask = new OperatorTask(op, ToolAdapterExecutionDialog.this::operatorCompleted);
                ProgressHandle progressHandle = ProgressHandleFactory.createHandle(this.getTitle());
                String progressPattern = operatorDescriptor.getProgressPattern();
                ConsoleConsumer consumer;
                ProgressHandler progressWrapper = new ProgressHandler(progressHandle, progressPattern == null || progressPattern.isEmpty());
                consumer = new ConsoleConsumer(operatorDescriptor.getProgressPattern(),
                        operatorDescriptor.getErrorPattern(),
                        operatorDescriptor.getStepPattern(),
                        progressWrapper,
                        form.console);
                form.console.clear();
                progressWrapper.setConsumer(consumer);
                ((ToolAdapterOp) op).setProgressMonitor(progressWrapper);
                ((ToolAdapterOp) op).setConsumer(consumer);
                ProgressUtils.runOffEventThreadWithProgressDialog(operatorTask, this.getTitle(), progressHandle, true, 1, 1);
            } else {
                if (warnings.size() > 0) {
                    displayWarnings();
                }
            }
        }
    }
}