org.openide.util.RequestProcessor Java Examples

The following examples show how to use org.openide.util.RequestProcessor. 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: JDBCDriverDeployerImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public ProgressObject deployJDBCDrivers(Target target, Set<Datasource> datasources) {
    List urls = JDBCDriverDeployHelper.getMissingDrivers(getDriverLocations(), datasources);
    final MonitorProgressObject startProgress = new MonitorProgressObject(dm,null);
    ProgressObject retVal = JDBCDriverDeployHelper.getProgressObject(driverLoc, urls);
    if (urls.size() > 0) {
        retVal.addProgressListener(new ProgressListener() {

            @Override
            public void handleProgressEvent(ProgressEvent event) {
                // todo -- enable when this is ready
                if (event.getDeploymentStatus().isCompleted()) {
                    commonSupport.restartServer(startProgress);
                } else {
                    startProgress.fireHandleProgressEvent(event.getDeploymentStatus());
                }
            }
        });
    } else {
        startProgress.operationStateChanged(TaskState.COMPLETED,
                TaskEvent.CMD_COMPLETED, "no deployment necessary");
    }
    RequestProcessor.getDefault().post((Runnable) retVal);
    return startProgress; // new JDBCDriverDeployHelper.getProgressObject(dmp.getDriverLocation(), datasources);
}
 
Example #2
Source File: Mercurial.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void asyncInit() {
    gotVersion = false;
    RequestProcessor rp = getRequestProcessor();
    if (LOG.isLoggable(Level.FINEST)) {
        LOG.log(Level.FINEST, "Mercurial subsystem initialized", new Exception()); //NOI18N
    }
    Runnable init = new Runnable() {
        @Override
        public void run() {
            HgKenaiAccessor.getInstance().registerVCSNoficationListener();
            synchronized(Mercurial.this) {
                checkVersionIntern();
            }
        }

    };
    rp.post(init);
}
 
Example #3
Source File: JFRSnapshotFileIOView.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
private void setAggregation(final FileIOViewSupport.Aggregation primary, final FileIOViewSupport.Aggregation secondary) {
    masterView.showProgress();
    dataView.setData(new FileIONode.Root(), false);
    
    new RequestProcessor("JFR FileIO Initializer").post(new Runnable() { // NOI18N
        public void run() {
            final FileIONode.Root root = new FileIONode.Root(primary, secondary);
            model.visitEvents(root);
            
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    dataView.setData(root, !FileIOViewSupport.Aggregation.NONE.equals(secondary));
                    masterView.hideProgress();
                }
            });
        }
    });
}
 
Example #4
Source File: ProfilerFeatures.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
private void saveActivatedFeatures() {
    if (loading) return;
    final Set<ProfilerFeature> _activated = new HashSet(activated);
    RequestProcessor.getDefault().post(new Runnable() {
        public void run() {
            SessionStorage storage = session.getStorage();
            if (_activated.isEmpty()) {
                storage.storeFlag(FLAG_ACTIVATED_FEATURES, null);
            } else {
                StringBuilder b = new StringBuilder();
                for (ProfilerFeature feature : _activated)
                    b.append(getFeatureID(feature));
                storage.storeFlag(FLAG_ACTIVATED_FEATURES, b.toString());
            }
        }
    });
}
 
Example #5
Source File: HgExtProperties.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void setProperties() {
    RequestProcessor rp = Mercurial.getInstance().getRequestProcessor();
    try {
        support = new HgProgressSupport() {
            protected void perform() {
                try {
                    HgModuleConfig.getDefault().clearProperties(root, "extensions"); // NOI18N
                    HgPropertiesNode[] hgPropertiesNodes = propTable.getNodes();
                    for (int i = 0; i < hgPropertiesNodes.length; i++) {
                        String hgPropertyName = hgPropertiesNodes[propTable.getModelIndex(i)].getName();
                        String hgPropertyValue = hgPropertiesNodes[propTable.getModelIndex(i)].getValue();
                        HgModuleConfig.getDefault().setProperty(root, "extensions", hgPropertyName, hgPropertyValue, true); // NOI18N
                    }
                } catch (IOException ex) {
                    HgModuleConfig.notifyParsingError();
                }
            }
        };
        support.start(rp, (HgURL) null, org.openide.util.NbBundle.getMessage(HgExtProperties.class, "LBL_Properties_Progress")); // NOI18N
    } finally {
        support = null;
    }
}
 
Example #6
Source File: CommitAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static void startCommitTask(final CommitPanel panel, final CommitTable data, final Context ctx, final File[] rootFiles, final Collection<SvnHook> hooks) {
    final Map<SvnFileNode, CommitOptions> commitFiles = data.getCommitFiles();
    final String message = panel.getCommitMessage();
    SvnModuleConfig.getDefault().setLastCanceledCommitMessage(""); //NOI18N
    org.netbeans.modules.versioning.util.Utils.insert(SvnModuleConfig.getDefault().getPreferences(), RECENT_COMMIT_MESSAGES, message.trim(), 20);

    SVNUrl repository = null;
    try {
        repository = getSvnUrl(ctx);
    } catch (SVNClientException ex) {
        SvnClientExceptionHandler.notifyException(ex, true, true);
    }
    RequestProcessor rp = Subversion.getInstance().getRequestProcessor(repository);
    SvnProgressSupport support = new SvnProgressSupport() {
        @Override
        public void perform() {
            performCommit(message, commitFiles, ctx, rootFiles, this, hooks);
        }
    };
    support.start(rp, repository, org.openide.util.NbBundle.getMessage(CommitAction.class, "LBL_Commit_Progress")); // NOI18N
}
 
Example #7
Source File: SaveEGTask.java    From BART with MIT License 6 votes vote down vote up
@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);
    }
 
Example #8
Source File: AddSelectMethodStrategy.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected void generateMethod(final MethodModel method, final boolean isOneReturn,
                              final boolean publishToLocal, final  boolean publishToRemote,
                              final String ejbql, FileObject ejbClassFO, String ejbClass) throws IOException {
    final SelectMethodGenerator generator = SelectMethodGenerator.create(ejbClass, ejbClassFO);

    RequestProcessor.getDefault().post(new Runnable() {
        public void run() {
            try {
                generator.generate(method, publishToLocal, publishToRemote, isOneReturn, ejbql);
            } catch (IOException ioe) {
                Logger.getLogger(SelectMethodGenerator.class.getName()).log(Level.WARNING, null, ioe);
            }
        }
    });

}
 
Example #9
Source File: TestUtilities.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void deleteFile(final File workDir, final String path) {
    // delete a file from a different thread
    RequestProcessor.Task task = RequestProcessor.getDefault().post(new Runnable(){
        public void run(){
            try {
                deleteFileImpl(workDir, path);
            } catch (IOException ioe){
                ioe.printStackTrace();
            }
        }
    });
    
    try {
        task.waitFinished(1000);
    } catch (InterruptedException e) {
        // ignore
    }
}
 
Example #10
Source File: VariablesActionsProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void performDefaultAction (final Object node) throws UnknownTypeException {
    if (node == TreeModel.ROOT) 
        return;
    if (node instanceof Field) {
        lookupProvider.lookupFirst(null, RequestProcessor.class).post(new Runnable() {
            @Override
            public void run() {
                goToSource ((Field) node);
            }
        });
        return;
    }
    if (node.toString().startsWith ("SubArray")) // NOI18N
        return ;
    if (node.equals ("NoInfo")) // NOI18N
        return;
    throw new UnknownTypeException (node);
}
 
Example #11
Source File: RequestProcessor180386Test.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testTaskCanRescheduleItself() throws Exception {
    final CountDownLatch latch = new CountDownLatch(2);
    class R implements Runnable {
        volatile RequestProcessor.Task task;
        volatile int runCount;
        @Override
        public void run() {
            runCount++;
            if (runCount == 1) {
                task.schedule(0);
            }
            latch.countDown();
        }
    }
    R r = new R();
    RequestProcessor.Task t = RequestProcessor.getDefault().create(r);
    r.task = t;
    t.schedule(0);
    latch.await ();
    assertEquals (r.runCount, 2);
}
 
Example #12
Source File: InitAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void performInit (VCSContext context) {
    final File rootToManage = selectRootToManage(context);
    if (rootToManage == null) {
        return;
    }

    RequestProcessor rp = Git.getInstance().getRequestProcessor(rootToManage);
    GitProgressSupport support = new GitProgressSupport() {
        @Override
        public void perform() {
            try {
                output(NbBundle.getMessage(InitAction.class, "MSG_INIT", rootToManage)); // NOI18N
                GitClient client = getClient();
                client.init(getProgressMonitor());
                Git.getInstance().getFileStatusCache().refreshAllRoots(rootToManage);
                Git.getInstance().versionedFilesChanged();                       
            } catch (GitException ex) {
                GitClientExceptionHandler.notifyException(ex, true);
            } finally {
                Git.getInstance().clearAncestorCaches();
                VersioningSupport.versionedRootsChanged();
            }
        }            
    };
    support.start(rp, rootToManage, NbBundle.getMessage(InitAction.class, "MSG_Init_Progress")); // NOI18N
}
 
Example #13
Source File: DataFolderSetOrderTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void makeFolderRecognizerBusy () throws Exception {
    if (getName().indexOf ("Busy") < 0) {
        return;
    }
    
    final DataLoader l = DataLoader.getLoader(DataObjectInvalidationTest.SlowDataLoader.class);
    synchronized (l) {
        // this will trigger bb.getChildren
        previous = RequestProcessor.getDefault().post(new Runnable() {
            public void run () {
                DataObject[] arr = bb.getChildren ();
            }
        });
        
        // waits till the recognition blocks in the new SlowDataObject
        l.wait ();
    }
    
    // now the folder recognizer is blocked at least for 2s
}
 
Example #14
Source File: BasicTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void checkNode (Node n, String name, RequestProcessor rp) {
    // init
    //assertEquals (null, n.getShortDescription ());
    Node[] ns = n.getChildren ().getNodes ();
    waitFinished (rp);
    
    ns = n.getChildren ().getNodes ();
    if (name.length () < 4) {
        assertEquals (name, 3, ns.length);
        checkNode (ns [0], name + "a", rp);
        checkNode (ns [1], name + "b", rp);
        checkNode (ns [2], name + "c", rp);
    } else
        assertEquals (ns.length, 0);
    
    if (name.length () > 0) {
        //assertEquals (name, n.getName ());
        n.getDisplayName ();
        String sd = n.getShortDescription ();
        n.getActions (false);
        waitFinished (rp);
        assertEquals (name, n.getDisplayName ());
        assertEquals (name + "WWW", sd);
        assertEquals (1, n.getActions (false).length);
    }
}
 
Example #15
Source File: JSONMinify.java    From minifierbeans with Apache License 2.0 6 votes vote down vote up
public static void execute(final DataObject context, final String content, final boolean notify) {
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            jsonMinify(context, content, notify);
        }
    };
    final RequestProcessor.Task theTask = RP.create(runnable);
    final ProgressHandle ph = ProgressHandleFactory.createHandle("Minifying JSON " + context.getPrimaryFile().getName(), theTask);
    theTask.addTaskListener(new TaskListener() {
        @Override
        public void taskFinished(org.openide.util.Task task) {
            ph.finish();
        }
    });
    ph.start();
    theTask.schedule(0);
}
 
Example #16
Source File: FlashingIcon.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Start flashing of the icon. If the icon is already flashing, the timer
 * is reset.
 * If the icon is visible but not flashing, it starts flashing again
 * and the disappear timer is reset.
 */
public void startFlashing() {
    synchronized( this ) {
        startTime = System.currentTimeMillis();
        isIconVisible = !isIconVisible;
        keepRunning = true;
        keepFlashing = true;
        if( null == timerTask ) {
            timerTask = RequestProcessor.getDefault ().post (new Timer ());
        } else {
            timerTask.run ();
        }
        this.setVisible (true);
    }
    repaint();
}
 
Example #17
Source File: AdminConsoleAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected void performAction (Node[] nodes) {
    for (int i = 0; i < nodes.length; i++) {
        final TomcatInstanceNode cookie = (TomcatInstanceNode)nodes[i].getCookie(TomcatInstanceNode.class);
        if (cookie != null) {
            RequestProcessor.getDefault().post(new Runnable() {
                public void run() {
                    TomcatManager tm = cookie.getTomcatManager();
                    String adminUrl = tm.getServerUri() + "/admin"; // NOI18N
                    try {
                        URLDisplayer.getDefault().showURL(new URL(adminUrl));
                    } catch (MalformedURLException e) {
                        Logger.getLogger(AdminConsoleAction.class.getName()).log(Level.INFO, null, e);
                    }
                }
            });
        }
    }
}
 
Example #18
Source File: JPQLEditorPanel.java    From jeddict with Apache License 2.0 5 votes vote down vote up
private void initCustomComponents() {
    initComponents();
    save_Button = new javax.swing.JButton();
    save_Button.setIcon(new ImageIcon(SaveAction.class.getClassLoader().getResource("org/openide/resources/actions/save.png"))); // NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(save_Button, org.openide.util.NbBundle.getMessage(JPQLEditorPanel.class, "JPQLEditorPanel.save_Button.text")); // NOI18N
    save_Button.addActionListener(this::save_ButtonActionPerformed);

    toolBar.add(save_Button, 0);
    toolBar.add(new JToolBar.Separator(new Dimension(200, 10)),1);
    
    setFocusToEditor();
    requestProcessor = new RequestProcessor("jpql-parser", 1, true);
}
 
Example #19
Source File: POMInheritancePanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
void navigate(DataObject d) {
    if (current != null) {
        current.getPrimaryFile().removeFileChangeListener(adapter);
    }
    current = d;
    current.getPrimaryFile().addFileChangeListener(adapter);
    showWaitNode();
    RequestProcessor.getDefault().post(this);
}
 
Example #20
Source File: BaseUtilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override public Future<Project[]> openProjectsAPI() {
    return RequestProcessor.getDefault().submit(new Callable<Project[]>() {
        @Override public Project[] call() {
            return getOpenProjectsAPI();
        }
    });
}
 
Example #21
Source File: JaxWsUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void modifySoap12Binding(final JavaSource javaSource, 
        final CancellableTask<WorkingCopy> modificationTask, 
        final FileObject implClass, final boolean isIncomplete ) 
{
    RequestProcessor.getDefault().post(new Runnable() {
        @Override
        public void run() {
            doModifySoap12Binding(javaSource, modificationTask, implClass, isIncomplete);
        }
    });
}
 
Example #22
Source File: OutputOptions.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Save default options to persistent storage, in background.
 */
public static void storeDefault() {
    if (saveScheduled.compareAndSet(false, true)) {
        RequestProcessor.getDefault().post(new Runnable() {
            @Override
            public void run() {
                OutputOptions.getDefault().saveTo(
                        NbPreferences.forModule(Controller.class));
                saveScheduled.set(false);
            }
        }, 100);
    }
}
 
Example #23
Source File: HpiPluginWarning.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override public Future<Result> resolve() {
    return RequestProcessor.getDefault().submit(new Callable<Result>() {
        @Override public Result call() throws Exception {
            return Result.create(Status.UNRESOLVED, HpiPluginWarning_unresolved());
        }
    });
}
 
Example #24
Source File: Hk2InstanceNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("LeakingThisInConstructor")
private Hk2InstanceNode(final GlassfishInstance instance, final InstanceContent ic, boolean isFullNode) {
    super(isFullNode ? new Hk2InstanceChildren(instance) : Children.LEAF, 
            new ProxyLookup(new AbstractLookup(ic), instance.getLookup()));
    serverInstance = instance;
    instanceContent = ic;
    this.isFullNode = isFullNode;
    setIconBaseWithExtension(ICON_BASE);
    
    if(isFullNode) {
        serverInstance.getCommonSupport().addChangeListener(
                WeakListeners.change(this, serverInstance));
        instanceContent.add(new RefreshModulesCookie() {
            @Override
            public RequestProcessor.Task refresh() {
                return refresh(null, null);
            }

            @Override
            public RequestProcessor.Task refresh(String expected, String unexpected) {
                Children children = getChildren();
                if(children instanceof Refreshable) {
                    ((Refreshable) children).updateKeys();
                }
                return null;
            }
        });
    }
}
 
Example #25
Source File: JaxWsServiceCreator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void createService() throws IOException {
    serviceType = ((Integer) wiz.getProperty(WizardProperties.WEB_SERVICE_TYPE)).intValue();

    // Use Progress API to display generator messages.
    final ProgressHandle handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(JaxWsServiceCreator.class, "TXT_WebServiceGeneration")); //NOI18N
    handle.start(100);

    Runnable r = new Runnable() {

        @Override
        public void run() {
            try {
                generateWebService(handle);
            } catch (IOException e) {
                //finish progress bar
                handle.finish();
                String message = e.getLocalizedMessage();
                if (message != null) {
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
                    NotifyDescriptor nd = new NotifyDescriptor.Message(message, NotifyDescriptor.ERROR_MESSAGE);
                    DialogDisplayer.getDefault().notify(nd);
                } else {
                    ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, e);
                }
            }
        }
    };
    RequestProcessor.getDefault().post(r);
}
 
Example #26
Source File: InstallStep.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private RequestProcessor.Task createInstallTask () {
    return org.netbeans.modules.autoupdate.ui.actions.Installer.RP.create (new Runnable () {
        @Override
        public void run () {
            doDownloadAndVerificationAndInstall ();
        }
    });
}
 
Example #27
Source File: MultiDiffPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void refreshStatuses() {
    commitButton.setEnabled(false);
    if ((context == null || context.getRootFiles().isEmpty())) {
        return;
    }

    if(executeStatusSupport!=null) {
        executeStatusSupport.cancel();
        executeStatusSupport = null;
    }
    
    LifecycleManager.getDefault().saveAll();
    RequestProcessor rp = Mercurial.getInstance().getRequestProcessor();
    executeStatusSupport = new HgProgressSupport() {
        @Override
        public void perform() {
            if (context != null && revisionLeft == HgRevision.BASE && isLocal()) {
                StatusAction.executeStatus(context, this);
            }
            refreshSetups();
        }
    };
    File repositoryRoot = HgUtils.getRootFile(context);
    if (repositoryRoot == null) {
        LOG.log(Level.INFO, "getSelectedRevision: No repository for {0}", context.getRootFiles()); //NOI18N
        return;
    }
    executeStatusSupport.start(rp, repositoryRoot, NbBundle.getMessage(MultiDiffPanel.class, "MSG_Refresh_Progress"));
}
 
Example #28
Source File: CreateCopyAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void performCopy(final CreateCopy createCopy, final RequestProcessor rp, final Node[] nodes, final File[] roots) {
    if (!createCopy.showDialog()) {
        return;
    }
    rp.post(new Runnable() {
        @Override
        public void run() {
            String errorText = validateTargetPath(createCopy);
            if (errorText == null) {
                ContextAction.ProgressSupport support = new ContextAction.ProgressSupport(CreateCopyAction.this, nodes) {
                    @Override
                    public void perform() {
                        performCopy(createCopy, this, roots);
                    }
                };
                support.start(rp);
            } else {
                SvnClientExceptionHandler.annotate(errorText);
                createCopy.setErrorText(errorText);
                EventQueue.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        performCopy(createCopy, rp, nodes, roots);
                    }
                });
            }
        }
    });
}
 
Example #29
Source File: ExportDiffAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
void performContextAction (final Node[] nodes, final boolean singleDiffSetup) {
    // reevaluate fast enablement logic guess

    if(!Subversion.getInstance().checkClientAvailable()) {            
        return;
    }
    
    boolean noop;
    Context context = getContext(nodes);
    TopComponent activated = TopComponent.getRegistry().getActivated();
    if (activated instanceof DiffSetupSource) {
        noop = ((DiffSetupSource) activated).getSetups().isEmpty();
    } else {
        noop = !Subversion.getInstance().getStatusCache().containsFiles(context, FileInformation.STATUS_LOCAL_CHANGE, true);
    }
    if (noop) {
        NotifyDescriptor msg = new NotifyDescriptor.Message(NbBundle.getMessage(ExportDiffAction.class, "BK3001"), NotifyDescriptor.INFORMATION_MESSAGE);
        DialogDisplayer.getDefault().notify(msg);
        return;
    }

    ExportDiffSupport exportDiffSupport = new ExportDiffSupport(context.getRootFiles(), SvnModuleConfig.getDefault().getPreferences()) {
        @Override
        public void writeDiffFile(final File toFile) {
            RequestProcessor rp = Subversion.getInstance().getRequestProcessor();
            SvnProgressSupport ps = new SvnProgressSupport() {
                @Override
                protected void perform() {
                    async(this, nodes, toFile, singleDiffSetup);
                }
            };
            ps.start(rp, null, getRunningName(nodes)).waitFinished();
        }
    };
    exportDiffSupport.export();
}
 
Example #30
Source File: NewProject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Messages("LBL_NewProjectAction_Tooltip=New Project...")
public NewProject() {
    putValue(SHORT_DESCRIPTION, LBL_NewProjectAction_Tooltip()); // is this actually useful?
    bodyTask = new RequestProcessor( "NewProjectBody" ).create( new Runnable () { // NOI18N
        @Override
        public void run () {
            doPerform ();
        }
    });
}