当前位置: 首页>>代码示例>>Java>>正文


Java Cancellable类代码示例

本文整理汇总了Java中org.openide.util.Cancellable的典型用法代码示例。如果您正苦于以下问题:Java Cancellable类的具体用法?Java Cancellable怎么用?Java Cancellable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Cancellable类属于org.openide.util包,在下文中一共展示了Cancellable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: searchStarted

import org.openide.util.Cancellable; //导入依赖的package包/类
public void searchStarted() {

        progressHandle = ProgressHandleFactory.createHandle(
                NbBundle.getMessage(ResultView.class,
                "TEXT_SEARCHING___"), new Cancellable() {               //NOI18N

            @Override
            public boolean cancel() {
                searchComposition.terminate();
                return true;
            }
        });
        progressHandle.start();
        resultViewPanel.searchStarted();
        searchComposition.getSearchResultsDisplayer().searchStarted();
        Collection<? extends Savable> unsaved =
                Savable.REGISTRY.lookupAll(Savable.class);
        if (unsaved.size() > 0) {
            String msg = NbBundle.getMessage(ResultView.class,
                    "TEXT_INFO_WARNING_UNSAVED");
            eventChildren.addEvent(new EventNode(EventType.WARNING, msg));
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:GraphicalSearchListener.java

示例2: cleanup

import org.openide.util.Cancellable; //导入依赖的package包/类
private void cleanup(final List<InputReaderTask> tasks, final ExecutorService processingExecutor) {
    boolean interrupted = false;
    if (processingExecutor != null) {
        try {
            AccessController.doPrivileged(new PrivilegedAction<Void>() {
                @Override
                public Void run() {
                    processingExecutor.shutdown();
                    return null;
                }
            });
            for (Cancellable cancellable : tasks) {
                cancellable.cancel();
            }
            while (!processingExecutor.awaitTermination(EXECUTOR_SHUTDOWN_SLICE, TimeUnit.MILLISECONDS)) {
                LOGGER.log(Level.INFO, "Awaiting processing finish");
            }
        } catch (InterruptedException ex) {
            interrupted = true;
        }
    }

    if (interrupted) {
        Thread.currentThread().interrupt();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:BaseExecutionService.java

示例3: showDetailsActionPerformed

import org.openide.util.Cancellable; //导入依赖的package包/类
private void showDetailsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showDetailsActionPerformed
     Container c = this;
     while (!(c instanceof ParametersPanel)) {
         c = c.getParent();
     }
     final ParametersPanel parametersPanel = (ParametersPanel) c;
     Cancellable doCloseParent = new Cancellable() {
        @Override
         public boolean cancel() {
             parametersPanel.cancel.doClick();
             return true;
         }
     };
     ProblemDetails details = problem.getDetails();
     if (details != null) {
         details.showDetails(new CallbackAction(ui), doCloseParent);
     }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ProblemComponent.java

示例4: createProgressHandle

import org.openide.util.Cancellable; //导入依赖的package包/类
private ProgressHandle createProgressHandle(InputOutput inputOutput,
        String displayName, Cancellable cancellable) {

    if (!descriptor.showProgress() && !descriptor.showSuspended()) {
        return null;
    }

    ProgressHandle handle = ProgressHandleFactory.createHandle(displayName,
            cancellable, new ProgressAction(inputOutput));

    handle.setInitialDelay(0);
    handle.start();
    handle.switchToIndeterminate();

    if (descriptor.showSuspended()) {
        handle.suspend(NbBundle.getMessage(ExecutionService.class, "Running"));
    }

    return handle;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ExecutionService.java

示例5: testHandleIsCustomPlaced

import org.openide.util.Cancellable; //导入依赖的package包/类
/**
 * Check that if a Swing component is extracted, the progress
 * reports 'customPlaced' = true.
 * @throws Exception 
 */
public void testHandleIsCustomPlaced() throws Exception {
    C c = new C();
    A a = new A();
    Constructor ctor = InternalHandle.class.getConstructor(
            String.class,
            Cancellable.class,
            Boolean.TYPE,
            Action.class
        );
    InternalHandle h = (InternalHandle)ctor.newInstance("Foobar", c, true, a);
    ProgressHandle p = h.createProgressHandle();
    
    Method m = InternalHandle.class.getMethod("extractComponent");
    JComponent comp = (JComponent)m.invoke(h);
    
    assertTrue(h.isCustomPlaced());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ProgressAPICompatTest.java

示例6: refreshSilentUpdateProvider

import org.openide.util.Cancellable; //导入依赖的package包/类
static void refreshSilentUpdateProvider() {
    UpdateUnitProvider silentUpdateProvider = getSilentUpdateProvider();
    if (silentUpdateProvider == null) {
        // have a problem => cannot continue
        WakaTime.info("Missing Silent Update Provider => cannot continue.");
        return ;
    }
    try {
        final String displayName = "Checking for updates to WakaTime plugin...";
        silentUpdateProvider.refresh(
            ProgressHandleFactory.createHandle(
                displayName,
                new Cancellable () {
                    @Override
                    public boolean cancel () {
                        return true;
                    }
                }
            ),
            true
        );
    } catch (IOException ex) {
        // caught a exception
        WakaTime.error("A problem caught while refreshing Update Centers, cause: " + ex.toString());
    }
}
 
开发者ID:wakatime,项目名称:netbeans-wakatime,代码行数:27,代码来源:UpdateHandler.java

示例7: ScaleToolWorker

import org.openide.util.Cancellable; //导入依赖的package包/类
ScaleToolWorker() throws Exception {
   updateScaleTool();
 
   progressHandle = ProgressHandleFactory.createHandle("Executing scaling...",
                        new Cancellable() {
                           public boolean cancel() {
                              result = false;
                              finished();
                              return true;
                           }
                        });
   progressHandle.start();
   // Crash here
   processedModel = new Model(unscaledModel);
   processedModel.setName(scaleTool.getName());
   processedModel.setInputFileName("");
   processedModel.setOriginalModelPathFromModel(unscaledModel); // important to keep track of the original path so bone loading works
   //processedModel.setup();

   setExecuting(true);
}
 
开发者ID:opensim-org,项目名称:opensim-gui,代码行数:22,代码来源:ScaleToolModel.java

示例8: findRoot

import org.openide.util.Cancellable; //导入依赖的package包/类
@NbBundle.Messages({
    "TXT_JavadocSearch=Searching Javadoc in {0}"
})
private static Collection<? extends URL> findRoot(final File file, final int type) throws MalformedURLException {
    if (type != CLASSPATH) {                
        final FileObject fo = URLMapper.findFileObject(FileUtil.urlForArchiveOrDir(file));
        if (fo != null) {
            final Collection<FileObject> result = Collections.synchronizedCollection(new ArrayList<FileObject>());
            if (type == SOURCES) {
                final FileObject root = JavadocAndSourceRootDetection.findSourceRoot(fo);
                if (root != null) {
                    result.add(root);
                }
            } else if (type == JAVADOC) {
                final AtomicBoolean cancel = new AtomicBoolean();
                class Task implements ProgressRunnable<Void>, Cancellable {
                    @Override
                    public Void run(ProgressHandle handle) {
                        result.addAll(JavadocAndSourceRootDetection.findJavadocRoots(fo, cancel));
                        return null;
                    }

                    @Override
                    public boolean cancel() {
                        cancel.set(true);
                        return true;
                    }
                }
                final ProgressRunnable<Void> task = new Task();
                ProgressUtils.showProgressDialogAndRun(task, Bundle.TXT_JavadocSearch(file.getAbsolutePath()), false);
            }
            if (!result.isEmpty()) {
                return result.stream()
                        .map(FileObject::toURL)
                        .collect(Collectors.toList());
            }                    
        }
    }
    return Collections.singleton(Utilities.toURI(file).toURL());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:J2SEPlatformCustomizer.java

示例9: waitStart

import org.openide.util.Cancellable; //导入依赖的package包/类
private boolean waitStart(final ExecSupport execSupport, int waitTime) {
    boolean started = false;
    final Holder<Boolean> forceExit = new Holder<>(false);
    String waitMessage = NbBundle.getMessage(RegisterDerby.class, "MSG_StartingDerby");
    ProgressHandle progress = ProgressHandleFactory.createHandle(waitMessage, new Cancellable() {
        @Override
        public boolean cancel() {
            forceExit.value = true;
            return execSupport.interruptWaiting();
        }
    });
    progress.start();
    try {
        while (!started) {
            started = execSupport.waitForMessage(waitTime * 1000);
            if (!started) {
                if (waitTime > 0 && (!forceExit.value)) {
                    String title = NbBundle.getMessage(RegisterDerby.class, "LBL_DerbyDatabase");
                    String message = NbBundle.getMessage(RegisterDerby.class, "MSG_WaitStart", waitTime);
                    NotifyDescriptor waitConfirmation = new NotifyDescriptor.Confirmation(message, title, NotifyDescriptor.YES_NO_OPTION);
                    if (DialogDisplayer.getDefault().notify(waitConfirmation)
                            != NotifyDescriptor.YES_OPTION) {
                        break;
                    }
                } else {
                    break;
                }
            }
        }
        if (!started) {
            execSupport.terminate();
            LOGGER.log(Level.WARNING, "Derby server failed to start"); // NOI18N
        }
    } finally {
        progress.finish();
    }
    return started;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:RegisterDerby.java

示例10: createHandle

import org.openide.util.Cancellable; //导入依赖的package包/类
@Override
public ProgressHandle createHandle(String displayname, Cancellable c, boolean userInit) {
    if (userInit) {
        return ProgressHandleFactory.createHandle(displayname, c, null);
    } else {
        return ProgressHandleFactory.createSystemHandle(displayname, c, null);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ProgressUI.java

示例11: run

import org.openide.util.Cancellable; //导入依赖的package包/类
public void run() {
    ProgressHandle ph = ProgressHandleFactory.createHandle(
            NbBundle.getMessage(RetrieverEngineImpl.class,"LBL_PROGRESSBAR_Retrieve_XML"),
            new Cancellable(){
        public boolean cancel() {
            synchronized(RetrieverEngineImpl.this){
                if(!RetrieverEngineImpl.this.STOP_PULL){
                    RetrieverEngineImpl.this.STOP_PULL = true;
                    //taskThread.interrupt();
                }
            }
            return true;
        }
    }, new AbstractAction(){
        public void actionPerformed(ActionEvent e) {
            getOPWindow().setOutputVisible(true);
            getOPWindow().select();
        }
    });
    ph.start();
    ph.switchToIndeterminate();
    try{
        pullRecursively();
    }finally{
        ph.finish();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:RetrieverEngineImpl.java

示例12: UIInternalHandle

import org.openide.util.Cancellable; //导入依赖的package包/类
public UIInternalHandle(String displayName, 
               Cancellable cancel,
               boolean userInitiated,
               Action view) {
    super(displayName, cancel, userInitiated);
    viewAction = view;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:UIInternalHandle.java

示例13: setUp

import org.openide.util.Cancellable; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    Controller.defaultInstance = new TestController();
    proghandle = ProgressHandleFactory.createHandle("displayName",new Cancellable() {
        public boolean cancel() {
            // empty
            return true;
        }
    });
    handle = (UIInternalHandle)proghandle.getInternalHandle();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ProgressHandleTest.java

示例14: createChangeListener

import org.openide.util.Cancellable; //导入依赖的package包/类
private PropertyChangeListener createChangeListener() {
    return new PropertyChangeListener() {
        @Override
        public void propertyChange( PropertyChangeEvent e ) {
            synchronized( TaskListTopComponent.this ) {
                if( ((Boolean)e.getNewValue()).booleanValue() ) {
                    if( null == progress ) {
                        progress = ProgressHandleFactory.createHandle(
                                NbBundle.getMessage( TaskListTopComponent.class, "LBL_ScanProgress" ), //NOI18N
                                new Cancellable() { //NOI18N
                                    @Override
                                    public boolean cancel() {
                                        taskManager.abort();
                                        return true;
                                    }
                                });
                        progress.start();
                        progress.switchToIndeterminate();
                    }
                } else {
                    if( null != progress )
                        progress.finish();
                    progress = null;
                }
            }
        }
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:TaskListTopComponent.java

示例15: process

import org.openide.util.Cancellable; //导入依赖的package包/类
public static void process(Lookup context, HintsSettings hintsSettings) {
    final AtomicBoolean abCancel = new AtomicBoolean();
    class Cancel implements Cancellable {
        public boolean cancel() {
            abCancel.set(true);
            return true;
        }
    }
    
    ProgressHandle h = ProgressHandleFactory.createHandle(NbBundle.getMessage(Analyzer.class, "LBL_AnalyzingJavadoc"), new Cancel()); // NOI18N

    RP.post(new Analyzer(context, abCancel, h, hintsSettings));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:Analyzer.java


注:本文中的org.openide.util.Cancellable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。