當前位置: 首頁>>代碼示例>>Java>>正文


Java RequestProcessor.post方法代碼示例

本文整理匯總了Java中org.openide.util.RequestProcessor.post方法的典型用法代碼示例。如果您正苦於以下問題:Java RequestProcessor.post方法的具體用法?Java RequestProcessor.post怎麽用?Java RequestProcessor.post使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openide.util.RequestProcessor的用法示例。


在下文中一共展示了RequestProcessor.post方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: view

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
private void view(final HistoryEntry entry, final boolean showAnnotations, final Set<File> files) {
    final File root = Mercurial.getInstance().getRepositoryRoot(files.iterator().next());
    RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(root);
    rp.post(new Runnable() {
        @Override
        public void run() {
            for (File f : files) {
                try {
                    HgUtils.openInRevision(f, -1, getHgRevision(entry), showAnnotations);
                } catch (IOException ex) {
                    // Ignore if file not available in cache
                }
            }
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:HgHistoryProvider.java

示例2: doSurviveTest

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
private void doSurviveTest(final boolean error) throws Exception {
    RequestProcessor rp = new RequestProcessor("SurvivesTest");
    Counter x = new Counter ();
    
    final Locker lock = new Locker();
    
    rp.post (new Runnable() {
        public void run() {
            lock.waitOn();
            
            if (error) {
                throw new AssertionError();
            } else {
                throw new NullPointerException();
            }
        }
    });
    
    rp.post(x);
    lock.notifyOn();
    
    x.assertCntWaiting("Second task not performed after " +
                 (error ? "error" : "exception"), 1);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:RequestProcessorTest.java

示例3: checkEnabledLazySingleAction

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
/**
 * Call this from {@link #checkEnabled(int)} when the code needs to be run outside of AWT.
 * Override {@link #checkEnabledLazyImpl(int)} method, which will be called
 * in the provided RequestProcessor. The returned enabled status is set through
 * {@link #setEnabledSingleAction(boolean)}.
 * <p>
 * Do not call {@link #setEnabled(java.lang.Object, boolean)} method! When
 * you also need to set the status directly, use {@link #setEnabledSingleAction(boolean)},
 * which correctly cooperates with the lazy code.
 * 
 * @param debuggerState
 * @param rp
 */
protected final void checkEnabledLazySingleAction(final int debuggerState, RequestProcessor rp) {
    canApplyLazyEnabled = true;
    rp.post(new Runnable() {
        @Override
        public void run() {
            final boolean enabled = checkEnabledLazyImpl(debuggerState);
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    if (canApplyLazyEnabled) {
                        setEnabledSingleAction(enabled);
                        canApplyLazyEnabled = true; // In case there were several lazy invocations
                    }
                }
            });
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:32,代碼來源:JPDADebuggerAction.java

示例4: invokeAction

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:ClickableIcon.java

示例5: resumeDebuggerDeadlockButtonActionPerformed

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
private void resumeDebuggerDeadlockButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resumeDebuggerDeadlockButtonActionPerformed
    //final List<DVThread> threadsToResume = debuggerDeadlockThreads;
    final DVThread blockedThread = debuggerDeadlockThread;
    RequestProcessor rp;
    try {
        DVSupport debugger = blockedThread.getDVSupport();
        rp = getRP(debugger);
        if (rp == null) {
            return ;
        }
    } catch (Exception e) {
        Exceptions.printStackTrace(e);
        return ;
    }
    rp.post(new Runnable() {
        public void run() {
            blockedThread.resumeBlockingThreads();
            //resumeThreadToFreeMonitor(blockedThread);
        }
    });
    hideDebuggerDeadlockPanel();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:InfoPanel.java

示例6: setVarFromMirror

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
private void setVarFromMirror(final MutableVariable var, final Object mirror) {
    Runnable run = new Runnable() {
        @Override
        public void run() {
            String javaInitStr = delegatePropertyEditor.getJavaInitializationString();
            boolean setFromMirror = false;
            try {
                var.setValue(javaInitStr);
                if (mirror == null || ((JDIVariable) var).getJDIValue() != null) {
                    setFromMirror = true;
                } // false when mirror != null and JDI value is null (set value was not successful)
            } catch (InvalidExpressionException ex) {
                logger.log(Level.INFO, "InvalidExpressionException when evaluating "+javaInitStr+":", ex);
            }
            if (!setFromMirror) {
                try {
                    var.setFromMirrorObject(mirror);
                } catch (InvalidObjectException ioex) {
                    NotifyDescriptor nd = new NotifyDescriptor.Message(ioex.getLocalizedMessage(), NotifyDescriptor.ERROR_MESSAGE);
                    DialogDisplayer.getDefault().notify(nd);
                }
            }
        }
    };
    if (SwingUtilities.isEventDispatchThread()) {
        RequestProcessor rp = contextProvider.lookupFirst(null, RequestProcessor.class);
        rp.post(run);
    } else {
        run.run();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:32,代碼來源:ValuePropertyEditor.java

示例7: start

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
public RequestProcessor.Task start (RequestProcessor rp, File repositoryRoot, String displayName) {
    this.error = false;
    this.originalDisplayName = displayName;
    setDisplayName(displayName);
    this.repositoryRoot = repositoryRoot;
    startProgress();
    setProgressQueued();
    task = rp.post(this);
    return task;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:GitProgressSupport.java

示例8: testTheCancelOfRunningTask

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
public void testTheCancelOfRunningTask() throws InterruptedException {
    final CountDownLatch started = new CountDownLatch(1);
    final CountDownLatch allowedToFinish = new CountDownLatch(1);
    Counter x = new Counter () {
        @Override
        public void run() {
            started.countDown();
            super.run();
            for (;;) try {
                allowedToFinish.await();
                break;
            } catch (InterruptedException ex) {
                continue;
            }
        }
    };
    RequestProcessor rp = new RequestProcessor ("testTheCancelOfRunningTask");
    final RequestProcessor.Task task = rp.post(x);
    started.await();
    assertFalse("Finished", task.isFinished());
    assertFalse("Too late to cancel", task.cancel());
    allowedToFinish.countDown();
    assertFalse("nothing to cancel", task.cancel());
    task.waitFinished();
    assertTrue("Now it is finished", task.isFinished());
    assertFalse("Still nothing to cancel", task.cancel());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:28,代碼來源:RequestProcessorTest.java

示例9: testWhenWaitingForALimitedTimeFromTheSameProcessorThenInterruptedExceptionIsThrownImmediatelly

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
public void testWhenWaitingForALimitedTimeFromTheSameProcessorThenInterruptedExceptionIsThrownImmediatelly () throws Exception {
    Counter x = new Counter ();
    RequestProcessor rp = new RequestProcessor ("testWaitFinishedOnNotStartedTaskFromRPThread");
    final RequestProcessor.Task task = rp.create (x);
    
    class WaitTask implements Runnable {
        public boolean finished;
        
        public synchronized void run () {
            long time = System.currentTimeMillis ();
            try {
                task.waitFinished (1000);
                fail ("This should throw an exception. Btw time was: " + (System.currentTimeMillis () - time));
            } catch (InterruptedException ex) {
                // ok, this is expected
            } finally {
                time = System.currentTimeMillis () - time;
                notifyAll ();
            }
            if (time > 100) {
                fail ("Exception should be thrown quickly. Was: " + time);
            }
            finished = true;
        }
        
    }
    WaitTask wt = new WaitTask ();
    synchronized (wt) {
        rp.post (wt);
        wt.wait ();
    }
    assertTrue ("The task.waitFinished has to finish", wt.finished);
    x.assertCnt ("The task has NOT been executed", 0);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:35,代碼來源:RequestProcessorTest.java

示例10: testAIsBlockedButBCanBeCreated

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
public void testAIsBlockedButBCanBeCreated() throws Exception {
    final SlowND objA = (SlowND) DataObject.find(a);
    SlowND objB = (SlowND) DataObject.find(b);
    
    final RequestProcessor RP = new RequestProcessor("Node for A");
    final Node[] nodeA = { null };
    RequestProcessor.Task task = RP.post(new Runnable() {
        @Override
        public void run() {
            nodeA[0] = objA.getNodeDelegate();
        }
    });
    assertFalse("Did not finish yet", task.waitFinished(500));
    assertNull("Node not yet created", nodeA[0]);
    
    Node nodeB = objB.getNodeDelegate();
    assertNotNull("Meanwhile other nodes can be created", nodeB);
    
    
    assertNull("Node A still not created", nodeA[0]);
    synchronized (objA) {
        objA.notifyAll();
    }
    task.waitFinished();
    
    assertNotNull("Node A also created", nodeA[0]);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:28,代碼來源:SlowNodeDelegateTest.java

示例11: testParralelMods

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
public void testParralelMods() throws Exception {
        loggingOn();
        RandomTestContainer container = createContainer();
        JEditorPane pane = container.getInstance(JEditorPane.class);
        final Document doc = pane.getDocument();
        doc.putProperty("mimeType", "text/x-java");
        final RandomTestContainer.Context context = container.context();
        DocumentTesting.setSameThreadInvoke(context, true); // Do not post to EDT
        // (Done automatically) Logger.getLogger("org.netbeans.editor.BaseDocument.EDT").setLevel(Level.OFF);
//        ViewHierarchyRandomTesting.disableHighlighting(container);
        int opCount = 100;
        final int throughput = 5; // How many truly parallel invocations
        RequestProcessor rp = new RequestProcessor("Doc-Mod", throughput, false, false);
        Task task = null;
        for (int i = opCount - 1; i >= 0; i--) {
            task = rp.post(new Runnable() {
                @Override
                public void run() {
                    // make sure insert won't fail for multiple threads
                    int offset = Math.max(doc.getLength() - throughput, 0);
                    try {
                        DocumentTesting.insert(context, offset, "ab");
                        DocumentTesting.remove(context, offset, 1);
                    } catch (Exception ex) {
                        throw new IllegalStateException(ex);
                    }
                }
            });
        }
        task.waitFinished();
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:32,代碼來源:JavaViewHierarchyRandomTest.java

示例12: performContextAction

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
@Override
protected void performContextAction(Node[] nodes) {
    VCSContext context = HgUtils.getCurrentContext(nodes);
    final File roots[] = HgUtils.getActionRoots(context);
    if (roots == null || roots.length == 0) return;
    final File root = Mercurial.getInstance().getRepositoryRoot(roots[0]);

    String repository = root.getAbsolutePath();
    RequestProcessor rp = Mercurial.getInstance().getParallelRequestProcessor();
    rp.post(new Runnable() {
        public void run() {
            performView(root);
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:ViewAction.java

示例13: testWaitFinishedOnNotStartedTaskFromRPThread

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
/** Test to check the waiting in request processor.
*/
public void testWaitFinishedOnNotStartedTaskFromRPThread () throws Exception {
    Counter x = new Counter ();
    RequestProcessor rp = new RequestProcessor ("testWaitFinishedOnNotStartedTaskFromRPThread");
    final RequestProcessor.Task task = rp.post(x, Integer.MAX_VALUE);
    
    //
    // Following code tests whether the RP.create().waitFinished really blocks
    // until somebody schedules the task.
    //
    class WaitTask implements Runnable {
        public boolean finished;
        
        public synchronized void run () {
            task.waitFinished ();
            finished = true;
            notifyAll ();
        }
        
        public synchronized void w (int timeOut) throws Exception {
            if (!finished) {
                wait (timeOut);
            }
        }
    }
    WaitTask wt = new WaitTask ();
    rp.post (wt);
    wt.w (0);
    assertTrue ("The task.waitFinished has to finish, otherwise the RequestProcessor thread will stay occupied forever", wt.finished);
    x.assertCnt ("The task has been executed - wait from RP made it start", 1);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:33,代碼來源:RequestProcessorTest.java

示例14: testUseAsInCND

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
public void testUseAsInCND() throws Exception {
    final RequestProcessor processor = new RequestProcessor("testUseAsInCND");
    final AtomicReference<String> threadName = new AtomicReference<String>();
    final Runnable task = new Runnable() {
        @Override
        public void run() {
            threadName.set(Thread.currentThread().getName());
        }
    };
    final String taskName = "MyTask";
    final RequestProcessor.Task rpTask = processor.create(new Runnable() {
        @Override
        public void run() {
            String oldName = Thread.currentThread().getName();
            Thread.currentThread().setName(taskName);
            try {
                task.run();
            } finally {
                Thread.currentThread().setName(oldName);
            }
        }
    });
    processor.post(rpTask);
    rpTask.waitFinished();
    
    assertEquals("Executed and named OK", taskName, threadName.get());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:28,代碼來源:RequestProcessorTest.java

示例15: testPriorityInversionProblemAndItsDiagnosis

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
/** Test priority inversion and whether it is properly notified
 */
public void testPriorityInversionProblemAndItsDiagnosis () throws Exception {
    RequestProcessor rp = new RequestProcessor ("testPriorityInversionProblemAndItsDiagnosis");
    
    final Runnable[] arr = new Runnable[3];
    
    class R implements Runnable {
        
        public int index;
        public Task t;
        
        public R (int i) {
            index = i;
        }
        
        public synchronized void run () {
            for (int i = 0; /*i < arr.length*/; i++) {
                if (arr[i] == null) {
                    arr[i] = this;
                    break;
                }
            }
            
            if (t != null) {
                t.waitFinished ();
            }
        }
        
        @Override
        public String toString () {
            return " R index " + index;
        }
    }
     
    R r1 = new R (1);
    R r2 = new R (2);
    R r3 = new R (3);
    
    Task t1;
    Task t2;
    Task t3;
    
    synchronized (r1) {
        t1 = rp.post (r1);
        t2 = rp.post (r2);
        
        // r1 will call the waitFinished of r3
        r1.t = t3 = rp.post (r3);
    }
    
    t1.waitFinished ();
    t2.waitFinished ();
    t3.waitFinished ();
    
    assertEquals ("First started is t1", r1, arr[0]);
    assertEquals ("Second started is t3", r3, arr[1]);
    assertEquals ("Last started is t2", r2, arr[2]);
    
    // now we should ensure that the RP warned everyone about the 
    // priority inheritance and all its possible complications (t2 running
    // later than t3)
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:64,代碼來源:RequestProcessorTest.java


注:本文中的org.openide.util.RequestProcessor.post方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。