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


Java RequestProcessor.Task方法代碼示例

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


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

示例1: getRefreshAnnotationsTask

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
private RequestProcessor.Task getRefreshAnnotationsTask () {
    assert EventQueue.isDispatchThread();
    if (refreshAnnotationsTask == null) {
        refreshAnnotationsTask = getRequestProcessor().create(new Runnable() {
            @Override
            public void run () {
                EventQueue.invokeLater(new Runnable() {
                    @Override
                    public void run () {
                        if (textComponent instanceof JEditorPane && refreshing) {
                            AnnotateAction.showAnnotations((JEditorPane) textComponent, getCurrentFile(), null, false);
                        }
                    }
                });
            }
        });
    }
    return refreshAnnotationsTask;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:AnnotationBar.java

示例2: deleteCreateChangeCase_issue_157373

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
public void deleteCreateChangeCase_issue_157373 () throws Exception {
    // init
    final File fileA = new File(wc, "file");
    FileUtil.toFileObject(wc).createData(fileA.getName());
    assertCachedStatus(fileA, FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY);
    commit(wc);
    assertEquals(FileInformation.STATUS_VERSIONED_UPTODATE, getStatus(fileA));

    // rename
    fileA.delete();
    Handler h = new SVNInterceptor();
    Subversion.LOG.addHandler(h);
    RequestProcessor.Task r = Subversion.getInstance().getParallelRequestProcessor().create(new Runnable() {
        public void run() {
            FileUtil.refreshFor(fileA);
        }
    });
    r.run();
    assertFalse(fileA.exists());
    final File fileB = new File(wc, fileA.getName().toUpperCase());
    fileB.createNewFile();
    Thread.sleep(3000);
    assertTrue(fileB.exists());
    assertEquals(FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY, getStatus(fileB));
    Subversion.LOG.removeHandler(h);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:InteceptorTest.java

示例3: deleteFile

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

示例4: setUpApplyChecker

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

示例5: getRunningTask

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
public static RequestProcessor.Task getRunningTask (Runnable onCancel) {
    if (runningTask != null) {
        if (runOnCancel == null) {
            runOnCancel = new HashSet<Runnable>();
        }
        runOnCancel.add(onCancel);
    }
    return runningTask;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:PluginManagerUI.java

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

示例7: getPopupMenu

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
public @Override JPopupMenu getPopupMenu() {
    RequestProcessor.Task t = task;
    if (t!=null && !t.isFinished()){
        t.waitFinished();
    }
    return super.getPopupMenu();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:Annotations.java

示例8: testCancel

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

示例9: createInstallTask

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
private RequestProcessor.Task createInstallTask () {
    return org.netbeans.modules.autoupdate.ui.actions.Installer.RP.create (new Runnable () {
        @Override
        public void run () {
            doDownloadAndVerificationAndInstall ();
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:InstallStep.java

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

示例11: performCheckout

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
public static RequestProcessor.Task performCheckout(
    final SVNUrl repository,
    final SvnClient client,
    final RepositoryFile[] repositoryFiles,
    final File workingDir,
    final boolean atWorkingDirLevel,
    final boolean doExport,
    final boolean showCheckoutCompleted)
{
    SvnProgressSupport support = new SvnProgressSupport() {
        @Override
        public void perform() {
            try {
                setDisplayName(java.util.ResourceBundle.getBundle("org/netbeans/modules/subversion/ui/checkout/Bundle").getString("LBL_Checkout_Progress"));
                setCancellableDelegate(client);
                client.addNotifyListener(this);
                checkout(client, repository, repositoryFiles, workingDir, atWorkingDirLevel, doExport, this);
            } catch (SVNClientException ex) {
                annotate(ex);
                return;
            } finally {
                Subversion.getInstance().versionedFilesChanged();
                client.removeNotifyListener(this);
            }
            if(isCanceled()) {
                return;
            }
            setDisplayName(java.util.ResourceBundle.getBundle("org/netbeans/modules/subversion/ui/checkout/Bundle").getString("LBL_ScanFolders_Progress"));
            if(showCheckoutCompleted) showCheckoutCompletet(repositoryFiles, workingDir, atWorkingDirLevel, doExport, this);
        }
    };
    return support.start(Subversion.getInstance().getRequestProcessor(repository), repository, java.util.ResourceBundle.getBundle("org/netbeans/modules/subversion/ui/checkout/Bundle").getString("LBL_Checkout_Progress"));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:34,代碼來源:CheckoutAction.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: 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

示例14: performAction

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
@Override
protected RequestProcessor.Task performAction (final File repository, final File[] roots, final VCSContext context) {
    openSearch(repository, roots, Utils.getContextDisplayName(context));
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:6,代碼來源:SearchIncoming.java

示例15: run

import org.openide.util.RequestProcessor; //導入方法依賴的package包/類
/** Refreshes the system.
*/
public void run() {
    // this code is executed only in RequestProcessor thread
    int ms;
    RequestProcessor.Task t;

    synchronized (this) {
        // the synchronization is here to be sure
        // that 
        ms = refreshTime;

        if (ms <= 0) {
            // finish silently if already stopped
            return;
        }

        t = task;

        // by setting task to null we indicate that we are currently processing
        // files and that any stop should wait till the processing is over
        task = null;
    }

    try {
        doLoop(ms);
    } finally {
        synchronized (this) {
            // reseting task variable back to indicate that 
            // the processing is over
            task = t;

            notifyAll();
        }

        // plan the task for next execution
        if ((system != null) && (system.get() != null)) {
            t.schedule(ms);
        } else {
            refreshTime = 0;
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:44,代碼來源:RefreshRequest.java


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