Java 类org.openide.util.TaskListener 实例源码

项目:incubator-netbeans    文件:JAXBDeleteSchemaAction.java   
public void performAction(Node[] nodes) {
    JAXBWizardSchemaNode schemaNode = 
            nodes[0].getLookup().lookup(JAXBWizardSchemaNode.class);
    if (schemaNode != null){
        Schema schema = schemaNode.getSchema();
        final Project prj = schemaNode.getProject();
        ProjectHelper.deleteSchemaFromModel(prj, schema);
        ProjectHelper.cleanupLocalSchemaDir(prj, schema);
        ProjectHelper.cleanCompileXSDs(prj, false, new TaskListener() {

            @Override
            public void taskFinished( Task arg0 ) {
                ProjectHelper.checkAndDeregisterScript(prj);
            }
        });
    }        
}
项目:incubator-netbeans    文件:ProjectRunnerImpl.java   
private synchronized void setResult(final Union2<ExecutorTask,Throwable> result) {
    this.result = result;
    if (result.hasFirst()) {
        result.first().addTaskListener(new TaskListener() {
            @Override
            public void taskFinished(Task task) {
                callBack.get().run();
            }
        });
        if (stopped) {
            result.first().stop();
        }
    } else {
        callBack.get().run();
    }
    this.notifyAll();
}
项目:incubator-netbeans    文件:AutoupdateCheckScheduler.java   
private static void scheduleRefreshProviders () {
    refreshUpdateCenters (null);
    final int delay = 500;
    final long startTime = System.currentTimeMillis ();
    RequestProcessor.Task t = Installer.RP.post (doCheckAvailableUpdates, delay);
    t.addTaskListener (new TaskListener () {
        @Override
        public void taskFinished (Task task) {
            task.removeTaskListener (this);
            long time = (System.currentTimeMillis () - startTime - delay) / 1000;
            if (time > 0) {
                Utilities.putTimeOfInitialization (time);
            }
        }
    });
}
项目:incubator-netbeans    文件:UnitTab.java   
@Override
public void setEnabled (boolean enabled) {
    if (isEnabled () != enabled) {
        if (enabled) {
            RequestProcessor.Task t = PluginManagerUI.getRunningTask (new Runnable () {

                @Override
                public void run() {
                    setEnabled (true);
                }
            });
            if (t != null && ! t.isFinished ()) {
                t.addTaskListener (new TaskListener () {
                    @Override
                    public void taskFinished (org.openide.util.Task task) {
                        setEnabled (true);
                    }
                });
            } else {
                super.setEnabled (true);
            }
        } else {
            super.setEnabled (false);
        }
    }
}
项目:incubator-netbeans    文件:OptionsDisplayerImpl.java   
private void setUpApplyChecker(final OptionsPanel optsPanel) {
final RequestProcessor.Task applyChecker = RP.post(new Runnable() {
    @Override
    public void run() {
               SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                       if (!savingInProgress) {
                           bAPPLY.setEnabled(optsPanel.isChanged() && optsPanel.dataValid());
                       }
                   }
               });
    }
});
applyChecker.addTaskListener(new TaskListener() {
    @Override
    public void taskFinished(Task task) {
    if (dialog != null) {
        applyChecker.schedule(DELAY);
    }
    }
});
   }
项目:BART    文件:CheckCleanInstance.java   
@Override
    public void actionPerformed(ActionEvent ev) {
        final Dialog d = BusyDialog.getBusyDialog();

        RequestProcessor.Task T = RequestProcessor.getDefault().post(new checkCleanRunnable());
        T.addTaskListener(new TaskListener() {

            @Override
            public void taskFinished(Task task) {
//                d.setVisible(false);
                if(esito)   {                
                    StatusBar.setStatus(Bundle.MSG_STATUS_Clean(), 10,5000);
                    DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                        Bundle.MSG_CheckCleanInstanceClean(), 
                        NotifyDescriptor.INFORMATION_MESSAGE));
                }else{
                    StatusBar.setStatus(Bundle.MSG_STATUS_Violated(), 10, 5000);
                    DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                            message.toString(), 
                            NotifyDescriptor.WARNING_MESSAGE));
                }
            }
        });
//        d.setVisible(true);
    }
项目:BART    文件:SaveEGTask.java   
@Override
    public void save() throws IOException {
        dto = CentralLookup.getDefLookup().lookup(EGTaskDataObjectDataObject.class);
        final InputOutput io = IOProvider.getDefault().getIO(dto.getPrimaryFile().getName(), false);
        io.select();
        OutputWindow.openOutputWindowStream(io.getOut(), io.getErr());
        final Dialog d = BusyDialog.getBusyDialog();
        RequestProcessor.Task T = RequestProcessor.getDefault().post(new SaveEgtaskRunnable());
        T.addTaskListener(new TaskListener() {

            @Override
            public void taskFinished(Task task) {
//                d.setVisible(false);
                if(esito)   {
                    System.out.println(Bundle.MSG_SaveEGTask_OK(dto.getPrimaryFile().getName()));
                }else{
                    System.err.println(Bundle.MSG_SaveEGTask_Failed(dto.getPrimaryFile().getName()));                  
                }
                OutputWindow.closeOutputWindowStream(io.getOut(), io.getErr());
//                d.setVisible(false);
            }

        });
//        d.setVisible(true);
    }
项目:incubator-netbeans    文件:Manager.java   
/**
 */
private TaskListener getTaskListener() {
    if (taskListener == null) {
        taskListener = new MyTaskListener();
    }
    return taskListener;
}
项目:incubator-netbeans    文件:MavenCommandLineExecutor.java   
public ExecutorTask execute(RunConfig config, InputOutput io, TabContext tc) {
    LifecycleManager.getDefault().saveAll();
    MavenExecutor exec = new MavenCommandLineExecutor(config, io, tc);
    ExecutorTask task = ExecutionEngine.getDefault().execute(config.getTaskDisplayName(), exec, new ProxyNonSelectableInputOutput(exec.getInputOutput()));
    exec.setTask(task);
    task.addTaskListener(new TaskListener() {
        @Override
        public void taskFinished(Task t) {
            MavenProject mp = config.getMavenProject();
            if (mp == null) {
                return;
            }
            final List<Artifact> arts = new ArrayList<Artifact>();
            Artifact main = mp.getArtifact();
            if (main != null) {
                arts.add(main);
            }
            arts.addAll(mp.getArtifacts());
            UPDATE_INDEX_RP.post(new Runnable() {
                @Override
                public void run() {
                    RepositoryIndexer.updateIndexWithArtifacts(RepositoryPreferences.getInstance().getLocalRepository(), arts);
                }
            });
        }
    });
    return task;
}
项目:incubator-netbeans    文件:TestMethodDebuggerAction.java   
@Override
protected void performAction(final Node[] activatedNodes) {
    final Collection<? extends TestMethodDebuggerProvider> providers = Lookup.getDefault().lookupAll(TestMethodDebuggerProvider.class);
    RequestProcessor RP = new RequestProcessor("TestMethodDebuggerAction", 1, true);   // NOI18N
    debugMethodTask = RP.create(new Runnable() {
        @Override
        public void run() {
            for (TestMethodDebuggerProvider provider : providers) {
                if (provider.canHandle(activatedNodes[0])) {
                    debugMethodProvider = provider;
                    break;
                }
            }
        }
    });
    final ProgressHandle ph = ProgressHandleFactory.createHandle(Bundle.Search_For_Provider(), debugMethodTask);
    debugMethodTask.addTaskListener(new TaskListener() {
        @Override
        public void taskFinished(org.openide.util.Task task) {
            ph.finish();
            if (debugMethodProvider == null) {
                StatusDisplayer.getDefault().setStatusText(Bundle.No_Provider_Found());
            } else {
                debugMethodProvider.debugTestMethod(activatedNodes[0]);
            }
        }
    });
    ph.start();
    debugMethodTask.schedule(0);
}
项目:incubator-netbeans    文件:GenerateBeanInfoAction.java   
/** This method is called by one of the "invokers" as a result of
* some user's action that should lead to actual "performing" of the action.
* This default implementation calls the assigned actionPerformer if it
* is not null otherwise the action is ignored.
*/
public void performAction ( final Node[] nodes ) {

    if (nodes.length != 1)
        return;

    // Open the diaog for bean info generation

    final BiPanel biPanel = new BiPanel();

    // Get pattern analyser & bean info and create BiAnalyser & BiNode

    FileObject javaFile = findFileObject(nodes[0]);
    final BeanInfoWorker performer = new BeanInfoWorker(javaFile, biPanel);

    class Task implements TaskListener, Runnable {

        public void taskFinished(org.openide.util.Task task) {
            EventQueue.invokeLater(this);
        }

        public void run() {
            if (performer.error != null) {
                DialogDisplayer.getDefault().notify(performer.error);
            }
            if (performer.bia != null) {
                performer.bia.openSource();
            }
        }

    }

    performer.analyzePatterns().addTaskListener(new Task());

}
项目:incubator-netbeans    文件:BIEditorSupport.java   
private void initialize() {
    if (!isInitialized) {
        setLayout(new BorderLayout());
        biPanel = new BiPanel();
        add(biPanel, BorderLayout.CENTER);
        isInitialized = true;
    } else {
        biPanel.setContext(new BiNode.Wait());
    }

    FileObject biFile = dataObject.getPrimaryFile();
    String name = biFile.getName();
    name = name.substring(0, name.length() - "BeanInfo".length()); // NOI18N
    FileObject javaFile = biFile.getParent().getFileObject(name, biFile.getExt());
    BIEditorSupport editor = findEditor(dataObject);
    if (javaFile != null) {
        final BeanInfoWorker beanInfoWorker = new GenerateBeanInfoAction.BeanInfoWorker(javaFile, biPanel);
        editor.worker = beanInfoWorker;
        beanInfoWorker.analyzePatterns().addTaskListener(new TaskListener() {

            public void taskFinished(Task task) {
                beanInfoWorker.updateUI();
            }
        });
    } else {
        // notify missing source file
        biPanel.setContext(BiNode.createNoSourceNode(biFile));
    }
}
项目:incubator-netbeans    文件:FolderInstance.java   
public HoldInstance (DataObject source, InstanceCookie cookie) {
    this.cookie = cookie;
    this.source = source;

    if (cookie instanceof Task) {
        // for example FolderInstance ;-) attach itself for changes
        // in the cookie
        Task t = (Task)cookie;
        t.addTaskListener(WeakListeners.create(TaskListener.class, this, t));
    }
}
项目:incubator-netbeans    文件:AntDebugger.java   
void setExecutor(ExecutorTask execTask) {
    this.execTask = execTask;
    if (execTask != null) {
        execTask.addTaskListener(new TaskListener() {
            @Override
            public void taskFinished(org.openide.util.Task task) {
                // The ANT task was finished
                finish();
            }
        });
    }
}
项目:incubator-netbeans    文件:PropertiesEditorSupport.java   
@Override
protected Task reloadDocument(){
    Task tsk = super.reloadDocument();
    tsk.addTaskListener(new TaskListener(){
        public void taskFinished(Task task){
            myEntry.getHandler().autoParse();
        }
    });
    return tsk;
}
项目:incubator-netbeans    文件:Actions.java   
public void runTarget(FileObject scriptFile, String[] targetNameArray, Properties props, final ActionProgress listener) {
    try {
        ActionUtils.runTarget(scriptFile, targetNameArray, props).addTaskListener(new TaskListener() {
            @Override public void taskFinished(Task task) {
                listener.finished(((ExecutorTask) task).result() == 0);
            }
        });
    } catch (IOException e) {
        ErrorManager.getDefault().notify(e);
        listener.finished(false);
    }
}
项目:incubator-netbeans    文件:PluginManagerUI.java   
private UnitTable createTabForModel(final UnitCategoryTableModel model) {
    final UnitTable table = new UnitTable(model);
    selectFirstRow(table);

    final UnitTab tab = new UnitTab(table, new UnitDetails(), this);
    if (initTask != null) {
        tab.setWaitingState(! initTask.isFinished());
        initTask.addTaskListener(new TaskListener() {

            @Override
            public void taskFinished(Task task) {
                SwingUtilities.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        tab.setWaitingState(false);
                    }
                });
            }
        });
    }
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            tpTabs.add(tab, model.getTabIndex());
            decorateTabTitle(table);
        }
    });
    return table;
}
项目:incubator-netbeans    文件:RequestProcessorTest.java   
/** Make sure it is safe to call waitFinished() on a task from within
 * a task listener.
 */
public void testWaitFinishedFromNotification() throws Exception {
    class X implements Runnable {
        private Task task;
        private int cnt;
        public synchronized Task start() {
            if (task == null) {
                task = RequestProcessor.postRequest(this);
            }
            return task;
        }
        public void run() {
            cnt++;
        }
        public int getCount() {
            return cnt;
        }
        public void block() {
            start().waitFinished();
        }
    }
    final X x = new X();
    final Object lock = "wait for task to finish";
    final boolean[] finished = new boolean[1];
    x.start().addTaskListener(new TaskListener() {
        public void taskFinished(Task t) {
            x.block();
            finished[0] = true;
            synchronized (lock) {
                lock.notify();
            }
        }
    });
    synchronized (lock) {
        lock.wait(5000);
    }
    assertTrue(finished[0]);
    assertEquals(1, x.getCount());
}
项目:incubator-netbeans    文件:RequestProcessorTest.java   
/** Make sure that successfully canceled task is not performed.
 */
public void testCancel() throws Exception {
    class X implements Runnable {
        public boolean performed = false;
        public void run() {
            performed = true;
        }
    }

    X x = new X();
    final boolean[] finished = new boolean[1];
    finished[0] = false;

    // post task with some delay
    RequestProcessor.Task task = RequestProcessor.postRequest(x, 1000);
    task.addTaskListener(new TaskListener() {
        @Override
        public void taskFinished(Task t) {
            finished[0] = true;
        }
    });

    boolean canceled = task.cancel();
    assertTrue("Task is canceled now", canceled);
    assertTrue("Cancelling actually means finished", finished[0]);
    Thread.sleep(1500); // wait longer than task delay
    assertFalse("Task should not be performed", x.performed);
}
项目:BART    文件:Export.java   
@Override
    public void actionPerformed(ActionEvent ev) {
        if ((map == null) || (map.isEmpty())) {
            DialogDisplayer.getDefault()
                    .notify(new NotifyDescriptor.Message(Bundle.MSG_NO_CHANGES(), NotifyDescriptor.INFORMATION_MESSAGE));
            return;
        }
        File toSave = chooseFile();
        if (toSave == null) return;
        if (!(toSave.getName().contains(".csv") || toSave.getName().contains(".CSV"))) {
            StringBuilder sb = new StringBuilder(toSave.getAbsolutePath());
            sb.append(".csv");
            toSave = new File(sb.toString());
        }
        final InputOutput io = IOProvider.getDefault().getIO(dtoFileName, false);
        io.select();
        OutputWindow.openOutputWindowStream(io.getOut(), io.getErr());
        final Dialog d = BusyDialog.getBusyDialog();
        final String fileName = toSave.getName();
        RequestProcessor.Task T = RequestProcessor.getDefault().post(new ExportRunnable(toSave));
        T.addTaskListener(new TaskListener() {
            @Override
            public void taskFinished(Task task) {
//                d.setVisible(false);
                if (result) {
                    System.out.println(Bundle.MSG_SAVE_OK(fileName));
                } else {
                    System.err.println(Bundle.MSG_NOT_SAVE(fileName));
                }
                OutputWindow.closeOutputWindowStream(io.getOut(), io.getErr());
            }
        });
//        d.setVisible(true);
    }
项目:BART    文件:ReloadDependencies.java   
@Override// closeDependencyViewTopComponent
    public void actionPerformed(ActionEvent ev) {
        if(dto == null || dto.getEgtask() == null)return;       
        if(textPanel.getText().isEmpty())return;
        if((egtask.getTarget() == null) || (egtask.getTarget() instanceof EmptyDB))   {
                DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                        Bundle.MSG_ReloadDependenciesNoDBTarget(), 
                        NotifyDescriptor.INFORMATION_MESSAGE));
            return;
        }   
        final InputOutput io = IOProvider.getDefault().getIO(dto.getPrimaryFile().getName(), false);
        io.select();
        OutputWindow.openOutputWindowStream(io.getOut(), io.getErr());
        final Dialog d = BusyDialog.getBusyDialog();
        RequestProcessor.Task T = RequestProcessor.getDefault().post(new reloadDependeciesRunnable());
        T.addTaskListener(new TaskListener() {
            @Override
            public void taskFinished(Task task) {
//                d.setVisible(false);
                if(esito)   {     
                    dto.setEgtModified(true);
                    StatusBar.setStatus(Bundle.MSG_ReloadDependenciesExecuted(), 10,5000);
                    System.out.println(Bundle.MSG_ReloadDependenciesExecuted());
                    DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                            Bundle.MSG_ReloadDependenciesExecuted(), 
                            NotifyDescriptor.INFORMATION_MESSAGE));
                }else{
                    System.err.println(Bundle.MSG_ReloadDependenciesException());
                    StatusBar.setStatus(Bundle.MSG_ReloadDependenciesExecuted(), 10,5000);
                }
                OutputWindow.closeOutputWindowStream(io.getOut(), io.getErr());
            }
        });
//        d.setVisible(true);
    }
项目:studio    文件:FolderInstance.java   
public HoldInstance (DataObject source, InstanceCookie cookie) {
    this.cookie = cookie;
    this.source = source;

    if (cookie instanceof Task) {
        // for example FolderInstance ;-) attach itself for changes
        // in the cookie
        Task t = (Task)cookie;
        t.addTaskListener (
            (TaskListener)WeakListener.create (TaskListener.class, this, t)
        );
    }
}
项目:JRLib    文件:ClipboardUtil.java   
private void doPaste() {
    String msg = Bundle.MSG_ClipboardUtil_Pasting(client.getPrimaryFile().getPath());
    final ProgressHandle ph = ProgressHandleFactory.createHandle(msg);
    ph.start();
    ph.switchToIndeterminate();
    TaskUtil.execute(this, new TaskListener() {
        @Override
        public void taskFinished(Task task) {
            ph.finish();
        }
    });
}
项目:incubator-netbeans    文件:TextDetail.java   
/**
 * Shows the search detail on the DataObject.
 * The document is opened in the editor, the caret is positioned on the
 * right line and column and searched string is marked.
 *
 * @param how indicates how to show detail. 
 * @see #DH_GOTO 
 * @see #DH_SHOW 
 * @see #DH_HIDE */
@NbBundle.Messages({
    "MSG_CannotShowTextDetai=The text match cannot be shown."
})
public void showDetail(final int how) {
    prepareLine();
    if (lineObj == null) {
        Toolkit.getDefaultToolkit().beep();
        EditCookie ed = dobj.getLookup().lookup(EditCookie.class);
        if (ed != null) {
            ed.edit();
            showAfterDataObjectUpdated = true; // show correct line later
        }
        return;
    }
    if (how == DH_HIDE) {
        return;
    }
    final EditorCookie edCookie = dobj.getLookup().lookup(EditorCookie.class);
    if (edCookie != null) {
        Task prepareTask = edCookie.prepareDocument();             //#227989
        prepareTask.addTaskListener(new TaskListener() {
            @Override
            public void taskFinished(Task task) {
                EventQueue.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        edCookie.open();
                        showLine(how);
                        highlightDetail(edCookie);
                    }
                });
            }
        });
    } else {
        showLine(how);
    }
    SearchHistory.getDefault().add(
            SearchPattern.create(
            searchPattern.getSearchExpression(),
            searchPattern.isWholeWords(), searchPattern.isMatchCase(),
            searchPattern.isRegExp()));
}
项目:incubator-netbeans    文件:JFXProjectProblems.java   
@Override
@NbBundle.Messages({
    "LBL_FX_Not_Supported_By_JDK=Java Platform Does Not Support FX",
    "HINT_FX_Not_Supported_By_JDK=The active project platform is not JavaFX-enabled."
})
public Collection<? extends ProjectProblem> getProblems() {
    if(updater == null) {
        updater = prj.getLookup().lookup(JFXPlatformUpdater.class);
        if(updater != null) {
            updater.addListener(this);
        }
    }
    if(updater != null) {
        if(!updater.hasUpdated()) {
            return Collections.<ProjectProblem>emptySet();
        }
    } else {
        return Collections.<ProjectProblem>emptySet();
    }
    // initiate or evaluate classpathextension correctness test
    if((updater == null || updater.hasUpdated()) && !testedCorrectClassPathExtension.get()) {
        // if async evaluation does not run yet, launch it, otherwise cancel this problem check
        if (updateClassPathExtensionTask.get() == null || updateClassPathExtensionTask.get().isFinished()) {
            updateClassPathExtensionTask.set(RP.create(new Runnable() { // NOI18N
                @Override
                public void run() {
                    updatedClassPathExtension.set(false);
                    try {
                        if(!JFXProjectUtils.hasCorrectClassPathExtension(prj)) {
                            JFXProjectUtils.updateClassPathExtension(prj);
                            updatedClassPathExtension.set(true);
                        }
                        testedCorrectClassPathExtension.set(true);

                    } catch (IOException ex) {
                        LOGGER.log(Level.WARNING, "Can't access project properties: {0}", ex); // NOI18N
                    }
                }
            }));
            updateClassPathExtensionTask.get().addTaskListener(new TaskListener() {
                @Override
                public void taskFinished(org.openide.util.Task task) {
                    if (updatedClassPathExtension.get()) {
                        problemsProviderSupport.fireProblemsChange();
                    }
                }
            });
            updateClassPathExtensionTask.get().schedule(0);
        }
        return Collections.<ProjectProblem>emptySet();
    }
    testedCorrectClassPathExtension.set(false);

    if(!isFXProject(eval)) {
        return Collections.<ProjectProblem>emptySet();
    }

    return problemsProviderSupport.getProblems(new ProjectProblemsProviderSupport.ProblemsCollector() {
        @Override
        public Collection<? extends ProjectProblemsProvider.ProjectProblem> collectProblems() {
            Collection<? extends ProjectProblemsProvider.ProjectProblem> currentProblems = ProjectManager.mutex().readAccess(
                    new Mutex.Action<Collection<? extends ProjectProblem>>() {
                        @Override
                        public Collection<? extends ProjectProblem> run() {
                            final JavaPlatform activePlatform = platformSetter.getProjectPlatform();
                            boolean hasFXProblem = activePlatform != null && !JavaFXPlatformUtils.isJavaFXEnabled(activePlatform);
                            return !hasFXProblem  ? Collections.<ProjectProblem>emptySet() :
                                Collections.singleton(ProjectProblem.createError(
                                    Bundle.LBL_FX_Not_Supported_By_JDK(),
                                    Bundle.HINT_FX_Not_Supported_By_JDK(),
                                    new JFXProjectProblems.NonFXPlatformResolver(
                                        prj,
                                        platformSetter,
                                        null,
                                        JavaPlatform.getDefault().getSpecification().getName()))) ;
                        }
                });
            return currentProblems;
        }
    });
}
项目:incubator-netbeans    文件:ActionProviderImpl.java   
private void invokeAction(final String action, final Lookup lookup, boolean checkCompiler) {
    if (!checkSurefire(action) || (checkCompiler && !checkCompilerPlugin(action))) {
        return;
    }

    if (COMMAND_DELETE.equals(action)) {
        DefaultProjectOperations.performDefaultDeleteOperation(proj);
        return;
    }
    if (COMMAND_COPY.equals(action)) {
        DefaultProjectOperations.performDefaultCopyOperation(proj);
        return;
    }
    if (COMMAND_MOVE.equals(action)) {
        DefaultProjectOperations.performDefaultMoveOperation(proj);
        return;
    }

    if (COMMAND_RENAME.equals(action)) {
        Operations.renameProject(proj.getLookup().lookup(NbMavenProjectImpl.class));
        return;
    }

    if (SwingUtilities.isEventDispatchThread()) {
        RP.post(new Runnable() {
            @Override
            public void run() {
                invokeAction(action, lookup, false);
            }
        });
        return;
    }
    //TODO if order is important, use the lookupmerger
    Collection<? extends ActionConvertor> convertors = proj.getLookup().lookupAll(ActionConvertor.class);
    String convertedAction = null;
    for (ActionConvertor convertor : convertors) {
        convertedAction = convertor.convert(action, lookup);
        if (convertedAction != null) {
            break;
        }
    }
    if (convertedAction == null) {
        convertedAction = action;
    }

    Lookup enhanced = new ProxyLookup(lookup, Lookups.fixed(replacements(proj, convertedAction, lookup)));

    RunConfig rc = ActionToGoalUtils.createRunConfig(convertedAction, proj.getLookup().lookup(NbMavenProjectImpl.class), enhanced);
    if (rc == null) {
        Logger.getLogger(ActionProviderImpl.class.getName()).log(Level.INFO, "No handling for action: {0}. Ignoring.", action); //NOI18N

    } else {
        setupTaskName(action, rc, lookup);
        final ActionProgress listener = ActionProgress.start(lookup);
        final ExecutorTask task = RunUtils.run(rc);
        if (task != null) {
            task.addTaskListener(new TaskListener() {
                @Override public void taskFinished(Task t) {
                    listener.finished(task.result() == 0);
                }
            });
        } else {
            listener.finished(false);
        }
    }
}
项目:incubator-netbeans    文件:TestMethodDebuggerProvider.java   
/**
    * Handle/Debug the selected test method
    * @param activatedNode the selected node
    */
   public final void debugTestMethod(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("TestMethodDebuggerProvider", 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);
}
   }
项目:incubator-netbeans    文件:TestMethodRunnerProvider.java   
/**
    * 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);
}
   }
项目:BART    文件:LoadEGTask.java   
@Override
    public void load(FileObject file) {

        log.fine("Close EGTaskDataObjectDataObject");
        EGTaskDataObjectDataObject oldDto = CentralLookup.getDefLookup().lookup(EGTaskDataObjectDataObject.class);
        if ((oldDto != null) && (!oldDto.close())) return;

        log.fine("Close TopComponents");
        for (TopComponent tc : WindowManager.getDefault().getRegistry().getOpened()) {
            if (WindowManager.getDefault().isEditorTopComponent(tc)) {
                tc.close();
            }
        }

        try {
            log.fine("Find DataObject for a file");
            egtDO = DataObject.find(file);
        } catch (DataObjectNotFoundException donf) {
            ErrorManager.getDefault().notify(ErrorManager.ERROR, donf);
            StatusBar.setStatus(Bundle.MSG_STATUS_ConfNotLoaded(), 10, 3000);
            log.log(Level.SEVERE, "DataObject notFound", donf);
            return;
        }

        final Dialog d = BusyDialog.getBusyDialog();
        RequestProcessor.Task T = RequestProcessor.getDefault().post(new LoadEGTaskRunnable());
        T.addTaskListener(new TaskListener() {

            @Override
            public void taskFinished(Task task) {
//                d.setVisible(false);
                if (esito) {
                    log.fine("Esito true -> Dataobject to CentralLookup");
                    RootNodeNotifier.fire();
                    CentralLookup.getDefLookup().add(egtDO);
                    log.fine("Set Node Statistic");
                    CentralLookup.getDefLookup().add(new RootNodeStatistic(Children.create(new StatisticNodeFactory(), true)));
                    StatusBar.setStatus(Bundle.MSG_STATUS_ConfLoaded(), 10, 3000);
                } else {
                    log.fine("Esito false -> ");
                    RootNodeNotifier.fire();
                    CentralLookup.getDefLookup().add(egtDO);
                    egtDO.getLookup().lookup(OpenCookie.class).open();
                    StatusBar.setStatus(Bundle.MSG_STATUS_ConfLoadError(), 10, 3000);
                }
//                d.setVisible(false);
            }
        });
//        d.setVisible(true);
    }
项目:BART    文件:RunEGTask.java   
@Override
    public void runEGTask() {
        log.setLevel(Level.INFO);
        log.fine("Load DataObject from CentralLookup");
        DataObject dObj = CentralLookup.getDefLookup().lookup(DataObject.class);
        if(dObj == null)return;
        EGTaskDataObjectDataObject dto = (EGTaskDataObjectDataObject)dObj;
        if(dto.isRun() == true)   {
            System.out.println("EGTask is runnig....");
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(Bundle.MSG_RunEGTask_IS_RUN()
                                                    , NotifyDescriptor.INFORMATION_MESSAGE));
            return;
        }
        if(dto.getEgtask() == null)   {
                log.log(Level.SEVERE, "EGTASK NULL IN DATAOBJECT");
                System.err.println("EGTASK NULL IN DATAOBJECT");
                DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(Bundle.MSG_RunEGTask_NO_DataObj()
                                                    , NotifyDescriptor.INFORMATION_MESSAGE));
                return;
        }


        if((dto.getEgtask().getTarget() == null) || (dto.getEgtask().getTarget() instanceof EmptyDB))  {
            log.fine("DB Target is not in correct state");
                DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(Bundle.MSG_RunEGTask_NO_DB_Target()
                                                    , NotifyDescriptor.INFORMATION_MESSAGE));
                return;
        }
//        if((dto.getDependencies() == null) || dto.getDependencies().isEmpty())  {
//            log.fine("No Dependencies");
//                DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(Bundle.MSG_RunEGTask_NO_DEPendencies()
//                                                    , NotifyDescriptor.INFORMATION_MESSAGE));
//                return;
//        }

        generator = new APrioriGenerator();

        final Dialog d = BusyDialog.getBusyDialog();
        RequestProcessor.Task T =  RequestProcessor.getDefault().post(new RunEGTaskRunnable(dto));
        T.addTaskListener(new TaskListener() {
            @Override
            public void taskFinished(Task task) {
//                d.setVisible(false);
                if(esito)   {
                    log.fine("RUN Executed OK");
                    DataBaseConfigurationNotifier.fire();
                    StatusBar.setStatus(Bundle.MSG_STATUS_RUN_OK(), 10, 3000);                    
                }else{
                    log.fine("RUN NOT Executed correctly");
                    StatusBar.setStatus(Bundle.MSG_STATUS_RUN_NO(), 10, 3000);
                }
            }
        });
//        d.setVisible(true);
    }
项目:batmass    文件:SpectraViewerTopComponent.java   
public void setData(final LCMSData data) {
    if (this.data != null) {
        // if the data is being changed to a new one
        this.data.getScans().isAutoloadSpectra(scansAutoloadOriginal);
    }

    this.data = data;
    scansAutoloadOriginal = data.getScans().isAutoloadSpectra();
    data.getScans().isAutoloadSpectra(true);

    // this will set the name of the window before we try to load the data
    final Runnable preDataLoaded = new Runnable() {
        @Override
        public void run() {
            initComponentsManually();
        }
    };

    // when the data is loaded, everything else needs to be run on EDT.
    final Runnable onDataLoaded = new Runnable() {
        @Override
        public void run() {
            scans = data.getScans();
            if (scans == null) {
                NotifyDescriptor.Message notice = new NotifyDescriptor.Message("There was no appropriate parser for this file to represent it in this view.");
                DialogDisplayer.getDefault().notify(notice);
                throw new NullPointerException("ScanCollection could not be obtained from the MSFile");
            }
            initComponentsManually();
            initSpectrumPanel(scans);
            SpectraViewerTopComponent.this.makeBusy(false);
            UnloadableLCMSData unloadable = new UnloadableLCMSData(data);
            addToLookup(unloadable);
            requestActive();
        }
    };

    SwingHelper.invokeOnEDT(preDataLoaded);
    SpectraViewerTopComponent.this.makeBusy(true);
    RequestProcessor.Task loadDataTask = LCMSDataUtils
            .loadData(data, INITIAL_SUBSET, SpectraViewerTopComponent.this, false);
    TaskListener loadDataTaskFinishedListener = new TaskListener() {
        @Override
        public void taskFinished(Task task) {
            SwingHelper.invokeOnEDT(onDataLoaded);
        }
    };

    // If the data was already loaded, thena the returned Task will be null.
    // In this case we can safely trigger taskFinished() manually.
    if (loadDataTask != null) {
        loadDataTask.addTaskListener(loadDataTaskFinishedListener);
    } else {
        loadDataTaskFinishedListener.taskFinished(null);
    }
}
项目:batmass    文件:ChromatogramViewTopComponent.java   
/**
 * Initiates the component. <b>MUST NOT BE CALLED FROM EDT.</b><br/>
 * @param data if required data wasn't loaded yet, it will be loaded
 */
public void setData(final LCMSData data) {
    this.data = data;

    // this will set the name of the window before we try to load the data
    final Runnable preDataLoaded = new Runnable() {
        @Override
        public void run() {
            initComponentsManually();
        }
    };

    // when the data is loaded, everything else needs to be run on EDT.
    final Runnable onDataLoaded = new Runnable() {
        @Override
        public void run() {
            scans = data.getScans();
            if (scans == null) {
                NotifyDescriptor.Message notice = new NotifyDescriptor.Message("There was no appropriate parser for this file to represent it in this view.");
                DialogDisplayer.getDefault().notify(notice);
                throw new NullPointerException("ScanCollection could not be obtained from the MSFile");
            }
            initComponentsManually();
            initChromatogramPanel();
            setScansForPanel(scans);
            ChromatogramViewTopComponent.this.makeBusy(false);
            UnloadableLCMSData unloadable = new UnloadableLCMSData(data);
            addToLookup(unloadable);
        }
    };

    SwingHelper.invokeOnEDT(preDataLoaded);
    ChromatogramViewTopComponent.this.makeBusy(true);
    RequestProcessor.Task loadDataTask = LCMSDataUtils
            .loadData(data, INITIAL_SUBSET, ChromatogramViewTopComponent.this, false);
    TaskListener loadDataTaskFinishedListener = new TaskListener() {
        @Override
        public void taskFinished(Task task) {
            SwingHelper.invokeOnEDT(onDataLoaded);
        }
    };

    // If the data was already loaded, thena the returned Task will be null.
    // In this case we can safely trigger taskFinished() manually.
    if (loadDataTask != null) {
        loadDataTask.addTaskListener(loadDataTaskFinishedListener);
    } else {
        loadDataTaskFinishedListener.taskFinished(null);
    }
}
项目:studio    文件:CloneableEditor.java   
/** Performs needed initialization  */
  private void initialize() {
      final Task prepareTask = support.prepareDocument ();

      setLayout (new BorderLayout ());

      final QuietEditorPane pane = new QuietEditorPane ();

      pane.getAccessibleContext().setAccessibleName(
NbBundle.getMessage(CloneableEditor.class, 
"ACS_CloneableEditor_QuietEditorPane", this.getName()));
      pane.getAccessibleContext().setAccessibleDescription(
NbBundle.getMessage(CloneableEditor.class, 
"ACSD_CloneableEditor_QuietEditorPane",
this.getAccessibleContext().getAccessibleDescription()));

      this.pane = pane;

      pane.setEditorKit (support.kit ());

      Document doc = support.getDocumentHack ();

      pane.setDocument (doc);

      if (doc instanceof NbDocument.CustomEditor) {
          NbDocument.CustomEditor ce = (NbDocument.CustomEditor)doc;
          customComponent = ce.createEditor(pane);

          if(customComponent == null) {
              throw new IllegalStateException("Document:" + doc // NOI18N
                  + " implementing NbDocument.CustomEditor may not" // NOI18N
                  + " return null component"); // NOI18N
          }

          add(customComponent, BorderLayout.CENTER);
      } else { // not custom editor
          add (new JScrollPane (pane), BorderLayout.CENTER);
      }

      pane.setWorking(QuietEditorPane.ALL);

      // Init action map: cut,copy,delete,paste actions.
      javax.swing.ActionMap am = getActionMap();
      am.put(DefaultEditorKit.cutAction, getAction(DefaultEditorKit.cutAction));
      am.put(DefaultEditorKit.copyAction, getAction(DefaultEditorKit.copyAction));
      am.put("delete", getAction(DefaultEditorKit.deleteNextCharAction)); // NOI18N
      am.put(DefaultEditorKit.pasteAction, getAction(DefaultEditorKit.pasteAction));

      // set the caret to right possition if this component was deserialized
      if (cursorPosition != -1) {
          prepareTask.addTaskListener(new TaskListener () {
              public void taskFinished(Task t) {
                  Caret caret = pane.getCaret();
                  if(caret != null) {
                      caret.setDot(cursorPosition);
                  }
                  prepareTask.removeTaskListener(this);
              }
          });
      }
  }
项目:studio    文件:CloneableEditorSupport.java   
/** Reload the document in response to external modification.
* @return task that reloads the document. It can be also obtained
*  by calling <tt>prepareDocument()</tt>.
*/
protected Task reloadDocument() {
    synchronized (getLock ()) {
        if (doc != null) {
            // UndoManager must be detached from document here because it will be attached in loadDocument()
            doc.removeUndoableEditListener (getUndoRedo ());
            // Remember caret positions in all opened panes
            final JEditorPane[] panes = getOpenedPanes();
            final int[] carets;
            if (panes != null) {
                carets = new int[panes.length];
                for(int i = 0; i < panes.length; i++) {
                    carets[i] =  panes[i].getCaretPosition();
                }
            } else {
                carets = new int[0];
            }

            prepareTask = null; // make sure new loading will occur
            final Task docLoadTask = prepareDocument(true);

            docLoadTask.addTaskListener(
              new TaskListener() {
                  public void taskFinished (Task task) {
                      //Bugfix #12338: This Swing code replanned to AWT thread
                      SwingUtilities.invokeLater(new Runnable() {
                          public void run () {
                              if (panes != null) {
                                  for (int i = 0; i < panes.length; i++) {
                                      // #26407 Adjusts caret position,
                                      // (reloaded doc could be shorter).
                                      int textLength = panes[i].getText().length();
                                      if(carets[i] > textLength) {
                                          carets[i] = textLength;
                                      }

                                      panes[i].setCaretPosition(carets[i]);
                                  }
                              }
                              getUndoRedo().discardAllEdits(); // reset undo manager
                              // Insert before-save undo event to enable unmodifying undo
                              getUndoRedo().undoableEditHappened(
                                  new UndoableEditEvent(
                                      CloneableEditorSupport.this,
                                      new BeforeSaveEdit(lastSaveTime)
                                  )
                              );

                              notifyUnmodified ();
                              updateLineSet(true);
                          }
                      });
                      docLoadTask.removeTaskListener(this);
                  }
                }
              );


            return docLoadTask;
        }
    }

    return prepareDocument();
}
项目:studio    文件:CloneableEditorSupport.java   
/** Forcibly create one editor component. Then set the caret
* to the given position.
* @param pos where to place the caret
* @return always non-<code>null</code> editor
*/
final CloneableEditor openAt(final PositionRef pos, final int column) {
    final CloneableEditor e = openEditorComponent();
    final Task t = prepareDocument ();
    e.open();
    e.requestVisible();

    class Selector implements TaskListener, Runnable {
        public void taskFinished (org.openide.util.Task t2) {
            javax.swing.SwingUtilities.invokeLater (this);
            t2.removeTaskListener (this);
        }

        public void run () {
            // #25435. Pane can be null.
            JEditorPane ePane = e.pane;
            if(ePane == null) {
                return;
            }
            Caret caret = ePane.getCaret();
            if(caret == null) {
                return;
            }

            int offset;
            if (column >= 0) {
                javax.swing.text.Element el = NbDocument.findLineRootElement (getDocument ());
                el = el.getElement (el.getElementIndex (pos.getOffset ()));
                offset = el.getStartOffset () + column;
                if (offset > el.getEndOffset ()) {
                    offset = el.getEndOffset ();
                }
            } else {
                offset = pos.getOffset ();
            }

            caret.setDot(offset);
        }
    }


    t.addTaskListener (new Selector ());
    return e;
}
项目:netbeans-jogl2    文件:Jzy3DDemoTopComponent.java   
private void createChart() {
        if (chartCreated.compareAndSet(false, true)) {
            System.out.println("Creating chart!");
            Runnable worker = new Runnable() {

                @Override
                public void run() {
                    ProgressHandle ph = ProgressHandleFactory.createHandle("Opening Jzy3D View!");
                    ph.start();
                    ph.switchToIndeterminate();
                    try {
                        AWTChartComponentFactory accf = new AWTChartComponentFactory();
                        final Chart chart = accf.newChart(Quality.Advanced, Toolkit.newt.name());
                        chart.getView().setMaximized(true);
                        canvas = (CanvasNewtAwt) chart.getCanvas();
                        final CameraThreadController ctc = new CameraThreadController(chart);
                        //signature change in latest upstream jogl causes java.lang.NoSuchMethodError: com.jogamp.newt.event.MouseEvent.getClickCount()I
//                      NewtCameraMouseController camMouse = new NewtCameraMouseController(chart);
                        WorkaroundNewtCameraMouseController camMouse = new WorkaroundNewtCameraMouseController(chart);
                        // Create a surface drawing that function
                        // Define a function to plot
                        Mapper mapper = new Mapper() {
                            public double f(double x, double y) {
                                return 10 * Math.sin(x / 10) * Math.cos(y / 20) * x;
                            }
                        };
                        // Define range and precision for the function to plot
                        Range range = new Range(-150, 150);
                        int steps = 50;
                        Shape surface = Builder.buildOrthonormal(new OrthonormalGrid(range, steps, range, steps), mapper);
                        surface.setColorMapper(new ColorMapper(new ColorMapRainbow(), surface.getBounds().getZmin(), surface.getBounds().getZmax(), new Color(1, 1, 1, .5f)));
                        surface.setFaceDisplayed(true);
                        surface.setWireframeDisplayed(false);
                        surface.setWireframeColor(Color.BLACK);
                        chart.getScene().getGraph().add(surface, true);
                        SwingUtilities.invokeLater(new Runnable() {

                            @Override
                            public void run() {
                                setChart(chart);
                                canvas.setMinimumSize(getMinimumSize());
                                canvas.setMaximumSize(getMaximumSize());
                                canvas.setPreferredSize(getPreferredSize());
                                add(canvas, BorderLayout.CENTER);
                                setCameraThreadController(ctc);
                                if (toggleAnimation.isSelected()) {
                                    ctc.start();
                                }
                                //need to update complete component tree
                                invalidate();
                                getTopLevelAncestor().invalidate();
                                getTopLevelAncestor().revalidate();
                            }
                        });
                    } finally {
                        ph.finish();
                    }
                }

            };
            Task t = RequestProcessor.getDefault().post(worker);
            t.addTaskListener(new TaskListener() {

                @Override
                public void taskFinished(Task task) {
                    if (task.isFinished()) {
                        requestAttention(true);
                    }
                }
            });
        } else {
            System.out.println("Chart already created!");
        }
    }
项目:JRLib    文件:TaskUtil.java   
public static void executeSwingCallback(Runnable task, final TaskListener listener) {
    if(listener == null)
        throw new NullPointerException("TaskListener is null!");
    execute(task, new SwingTaskListener(listener));
}
项目:JRLib    文件:TaskUtil.java   
public static void execute(Runnable task, TaskListener listener) {
    Task t = getRP().create(task);
    if(listener != null)
        t.addTaskListener(listener);
    getRP().submit(t);
}
项目:JRLib    文件:TaskUtil.java   
private SwingTaskListener(TaskListener listener) {
    this.listener = listener;
}