Java Code Examples for org.openide.util.RequestProcessor#getDefault()

The following examples show how to use org.openide.util.RequestProcessor#getDefault() . 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: Annotations.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private JMenu createMenu(BaseKit kit, int line, boolean backgroundInit){
    final DelayedMenu pm = new DelayedMenu(NbBundle.getBundle(BaseKit.class).getString("generate-gutter-popup"));
    final BaseKit fKit = kit;
    final int fLine = line;

    if (backgroundInit){
        RequestProcessor rp = RequestProcessor.getDefault();
        RequestProcessor.Task task = rp.create(new Runnable(){
            public void run(){
                initMenu(pm, fKit, fLine);
                pm.clearTask(); // clear the finished task reference to avoid leaking
            }
        });
        pm.setTask(task); // set before task execution so that always cleaned properly
        task.schedule(0);
    }else{
        initMenu(pm, fKit, fLine);
    }

    return pm;
}
 
Example 2
Source File: ClickableIcon.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void invokeAction() {
    final boolean suspended = isThreadSupended;
    RequestProcessor rp;
    try {
        Session s = dvThread.getDVSupport().getSession();
        rp = s.lookupFirst(null, RequestProcessor.class);
    } catch (Exception e) {
        Exceptions.printStackTrace(e);
        return ;
    }
    if (rp == null) {
        // debugger finishing?
        rp = RequestProcessor.getDefault();
    }
    rp.post(new Runnable() {
        public void run() {
            if (suspended) {
                dvThread.resume();
            } else {
                dvThread.suspend();
            }
        }
    });
    isThreadSupended = !isThreadSupended;
}
 
Example 3
Source File: DebuggingTreeModel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private RequestProcessor.Task createTask() {
    RequestProcessor rp = null;
    try {
        Session s = (Session) debugger.getClass().getMethod("getSession").invoke(debugger);
        rp = s.lookupFirst(null, RequestProcessor.class);
    } catch (Exception e) {
        Exceptions.printStackTrace(e);
    }
    if (rp == null) {
        rp = RequestProcessor.getDefault();
    }
    RequestProcessor.Task task = rp.create(new RefreshTree());
    return task;
}
 
Example 4
Source File: RequestProcessorParallelTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@RandomlyFails // NB-Core-Build #8322: There shall be a warning about parallel execution(len=0): ''
public void testParallelExecutionOnDefaultRequestProcessorReported() {
    final RequestProcessor rp = RequestProcessor.getDefault();
    Para p = new Para(rp, 3);

    CharSequence log = Log.enable("org.openide.util.RequestProcessor", Level.WARNING);
    rp.post(p).waitFinished();
    if (log.length() == 0) {
        fail("There shall be a warning about parallel execution(len=" + log.length() + "):\n'" + log + "'");
    }
}
 
Example 5
Source File: SimpleIO.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Reads a newly included InputSreams
 *
 * @param inputStreams InputStreams to read
 */
public void readInputStreams(InputStream... inputStreams) {
    RequestProcessor rp = RequestProcessor.getDefault();
    for(InputStream inputStream : inputStreams){
        rp.post(new IOReader(inputStream));
    }
}
 
Example 6
Source File: SimpleIO.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Reads a newly included InputSreams
 *
 * @param inputStreams InputStreams to read
 */
public void readInputStreams(InputStream... inputStreams) {
    RequestProcessor rp = RequestProcessor.getDefault();
    for(InputStream inputStream : inputStreams){
        rp.post(new IOReader(inputStream));
    }
}
 
Example 7
Source File: ToolTipAnnotation.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public String getShortDescription () {
    // [TODO] hack for org.netbeans.modules.debugger.jpda.actions.MethodChooser that disables tooltips
    if ("true".equals(System.getProperty("org.netbeans.modules.debugger.jpda.doNotShowTooltips"))) { // NOI18N
        return null;
    }
    DebuggerEngine currentEngine = DebuggerManager.getDebuggerManager ().
        getCurrentEngine ();
    if (currentEngine == null) {
        return null;
    }
    JPDADebugger d = currentEngine.lookupFirst(null, JPDADebugger.class);
    if (d == null) {
        return null;
    }

    Part lp = (Part) getAttachedAnnotatable();
    if (lp == null) {
        return null;
    }
    Line line = lp.getLine ();
    DataObject dob = DataEditorSupport.findDataObject (line);
    if (dob == null) {
        return null;
    }
    EditorCookie ec = dob.getLookup().lookup(EditorCookie.class);
    if (ec == null) {
        return null;
        // Only for editable dataobjects
    }

    this.lp = lp;
    this.ec = ec;
    RequestProcessor rp = currentEngine.lookupFirst(null, RequestProcessor.class);
    if (rp == null) {
        // Debugger is likely finishing...
        rp = RequestProcessor.getDefault();
    }
    rp.post (this);
    return null;
}