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


Java RequestProcessor.create方法代碼示例

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


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

示例1: createMenu

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

示例2: ProjectChooserAccessory

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
/** Creates new form ProjectChooserAccessory */
public ProjectChooserAccessory(JFileChooser chooser, boolean isOpenSubprojects) {
    initComponents();

    modelUpdater = new ModelUpdater();
    //#98080
    RP = new RequestProcessor(ModelUpdater.class.getName(), 1);
    RP2 = new RequestProcessor(ModelUpdater.class.getName(), 1);
    updateSubprojectsTask = RP.create(modelUpdater);
    updateSubprojectsTask.setPriority( Thread.MIN_PRIORITY );

    // Listen on the subproject checkbox to change the option accordingly
    jCheckBoxSubprojects.setSelected( isOpenSubprojects );
    jCheckBoxSubprojects.addActionListener( this );

    // Listen on the chooser to update the Accessory
    chooser.addPropertyChangeListener( this );

    // Set default list model for the subprojects list
    jListSubprojects.setModel( new DefaultListModel() );

    // Disable the Accessory. JFileChooser does not select a file
    // by default
    setAccessoryEnablement( false, 0 );
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:ProjectChooserAccessory.java

示例3: testStopAndSchedule

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
public void testStopAndSchedule() throws Exception {
    final boolean executed[] = { false };
    class R implements Runnable {
        @Override
        public void run() {
            executed[0] = true;
        }
    }
    
    RequestProcessor rp = new RequestProcessor("stopped");
    RequestProcessor.Task task = rp.create(new R());
    assertTrue("No runnables", rp.shutdownNow().isEmpty());
    task.schedule(0);
    task.waitFinished(500);
    assertFalse("Not executed at all", executed[0]);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:RequestProcessorTest.java

示例4: doCheckFinished

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
private void doCheckFinished(boolean usefalse) {
        RequestProcessor rp = new RequestProcessor ("Finish");

class R extends Object implements Runnable {
    RequestProcessor.Task t;
    
    public void run () {
        if (t.isFinished ()) {
            fail ("Finished when running");
        }
    }
}
        
        R r = new R ();
        RequestProcessor.Task task = usefalse ? rp.create(r, false) : rp.create (r);
        r.t = task;

        if (task.isFinished ()) {
            fail ("Finished after creation");
        }
     
        doCommonTestWithScheduling(task);
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:RequestProcessorTest.java

示例5: testCheckFinishedWithTrue

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
public void testCheckFinishedWithTrue () {
    RequestProcessor rp = new RequestProcessor ("Finish");
    
    class R extends Object implements Runnable {
        RequestProcessor.Task t;
        
        public void run () {
            if (t.isFinished ()) {
                fail ("Finished when running");
            }
        }
    }
    
    R r = new R ();
    RequestProcessor.Task task = rp.create(r, true);
    r.t = task;

    assertTrue("It has to be finished after creation", task.isFinished());

    task.waitFinished();

    // rest is the same
    doCommonTestWithScheduling(task);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:RequestProcessorTest.java

示例6: createTask

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

示例7: HudsonInstanceImpl

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
private HudsonInstanceImpl(HudsonInstanceProperties properties, boolean interactive, BuilderConnector builderConnector, Persistence persistence) {
    this.builderConnector = builderConnector;
    this.properties = properties;
    this.persistence = persistence != null ? persistence : Persistence.persistent();

    RP = new RequestProcessor(getUrl(), 1, true);
    final AtomicBoolean firstSynch = new AtomicBoolean(interactive); // #200643
    synchronization = RP.create(new Runnable() {
        private boolean firstRun = true;

        @Override
        public void run() {
            String s = getProperties().get(INSTANCE_SYNC);
            int pause = Integer.parseInt(s) * 60 * 1000;
            if (pause > 0 || firstSynch.compareAndSet(true, false)) {
                doSynchronize(false, firstRun);
                firstRun = false;
            }
            if (pause > 0) {
                synchronization.schedule(pause);
            }
        }
    });
    synchronization.schedule(0);
    this.properties.addPropertyChangeListener(new PropertyChangeListener() {
        @Override public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals(INSTANCE_SYNC)) {
                synchronization.schedule(0);
            }
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:33,代碼來源:HudsonInstanceImpl.java

示例8: NotificationsManager

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
private NotificationsManager () {
    files = new HashSet<File>();
    rp = new RequestProcessor("SubversionNotifications", 1, true);  //NOI18N
    notificationTask = rp.create(new NotificationTask());
    cache = Subversion.getInstance().getStatusCache();
    kenaiAccessor = SvnKenaiAccessor.getInstance();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:NotificationsManager.java

示例9: DocumentModel

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
DocumentModel(Document doc, DocumentModelProvider provider) throws DocumentModelException {
    this.doc = (BaseDocument)doc; //type changed in DocumentModel.getDocumentModel(document);
    this.provider = provider;
    
    //init RP & RP task
    requestProcessor = new RequestProcessor(DocumentModel.class.getName());
    task = requestProcessor.create(new Runnable() {
        public void run() {
            updateModel();
        }
    });
    
    //create a new root element - this element comprises the entire document
    addRootElement();
    
    /*create a sorted set which sorts its elements according to their
    startoffsets and endoffsets.
    - lets have elements E1 and E2:
     
    if E1.startOffset > E2.startOffset then the E1 is before E2.
    if E1.startOffset == E2.startOffset then
       if E1.endOffset > E2.endOffset then the E1 is before E2
     */
    initDocumentModel();
    
    this.changesWatcher = new DocumentChangesWatcher();
    getDocument().addDocumentListener(WeakListeners.document(changesWatcher, doc));
    
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:30,代碼來源:DocumentModel.java

示例10: performAction

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

示例11: 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

示例12: testTheCancelOfNonStartedTask

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
public void testTheCancelOfNonStartedTask() {
    Counter x = new Counter ();
    RequestProcessor rp = new RequestProcessor ("testTheCancelOfNonStartedTask");
    final RequestProcessor.Task task = rp.create (x);
    assertFalse("Not started tasks cannot be cancelled", task.cancel());
    assertFalse("But not finished", task.isFinished());
    assertFalse("Can be cancelled only once", task.cancel());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:RequestProcessorTest.java

示例13: testTheCancelOfFutureTask

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
public void testTheCancelOfFutureTask() {
    Counter x = new Counter ();
    RequestProcessor rp = new RequestProcessor ("testTheCancelOfFutureTask");
    final RequestProcessor.Task task = rp.create (x);
    task.schedule(20000);
    assertTrue("Sure, that one can be cancelled", task.cancel());
    assertTrue("After cancle we are finished", task.isFinished());
    assertFalse("Can be cancelled only once", task.cancel());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:RequestProcessorTest.java

示例14: 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

示例15: testRunOutOfMemory

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
public void testRunOutOfMemory() throws Exception {
    RequestProcessor rp = new RequestProcessor("testRunOutOfMemory", 1, false, false);
    final int[] cnt = { 0 };
    RequestProcessor.Task task = rp.create(new Runnable() {
        @Override
        public void run() {
            cnt[0]++;
        }
    });
    for (int i = 0; i < 10000000; i++) {
        task.schedule(2000000);
    }
    assertEquals("Still zero", 0, cnt[0]);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:RequestProcessorMemoryTest.java


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