Java 类org.openide.util.Cancellable 实例源码

项目:incubator-netbeans    文件:GraphicalSearchListener.java   
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));
        }
    }
项目:incubator-netbeans    文件:BaseExecutionService.java   
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();
    }
}
项目:incubator-netbeans    文件:ProblemComponent.java   
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);
     }
}
项目:incubator-netbeans    文件:ExecutionService.java   
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;
}
项目:incubator-netbeans    文件:ProgressAPICompatTest.java   
/**
 * 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());
}
项目:netbeans-wakatime    文件:UpdateHandler.java   
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());
    }
}
项目:opensim-gui    文件:ScaleToolModel.java   
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);
}
项目:incubator-netbeans    文件:J2SEPlatformCustomizer.java   
@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());
}
项目:incubator-netbeans    文件:RegisterDerby.java   
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;
}
项目:incubator-netbeans    文件:ProgressUI.java   
@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);
    }
}
项目:incubator-netbeans    文件:RetrieverEngineImpl.java   
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();
    }
}
项目:incubator-netbeans    文件:UIInternalHandle.java   
public UIInternalHandle(String displayName, 
               Cancellable cancel,
               boolean userInitiated,
               Action view) {
    super(displayName, cancel, userInitiated);
    viewAction = view;
}
项目:incubator-netbeans    文件:ProgressHandleTest.java   
@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();
}
项目:incubator-netbeans    文件:TaskListTopComponent.java   
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;
                }
            }
        }
    };
}
项目:incubator-netbeans    文件:Analyzer.java   
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));
}
项目:incubator-netbeans    文件:InternalHandle.java   
/** Creates a new instance of ProgressHandle */
@PatchedPublic
protected InternalHandle(String displayName, 
               Cancellable cancel,
               boolean userInitiated) {
    this.displayName = displayName;
    this.userInitiated = userInitiated;
    state = STATE_INITIALIZED;
    totalUnits = 0;
    lastMessage = null;
    cancelable = cancel;

    compatInit();
}
项目:incubator-netbeans    文件:AggregateProgressHandle.java   
/** Creates a new instance of AggregateProgressHandle */
AggregateProgressHandle(String displayName, ProgressContributor[] contribs, Cancellable cancellable, boolean systemtask,
        ProgressHandle hdl) {
    handle = hdl;
    finished = false;
    contributors = new ArrayList<ProgressContributor>();
    if (contribs != null) {
        for (int i = 0; i < contribs.length; i++) {
            addContributor(contribs[i]);
        }
    }
    this.displayName = displayName;
}
项目:incubator-netbeans    文件:RecentSearches.java   
/**
 * Find action by display name and run it.
 */
@NbBundle.Messages({
    "LBL_SearchingRecentResult=Searching for a Quick Search Item",
    "MSG_RecentResultNotFound=Recent Quick Search Item was not found."})
private void findAndRunAction() {
    final AtomicBoolean cancelled = new AtomicBoolean(false);
    ProgressHandle handle = ProgressHandleFactory.createHandle(
            Bundle.LBL_SearchingRecentResult(), new Cancellable() {
        @Override
        public boolean cancel() {
            cancelled.set(true);
            return true;
        }
    });
    handle.start();
    ResultsModel model = ResultsModel.getInstance();
    Task evaluate = CommandEvaluator.evaluate(
            stripHTMLandPackageNames(name), model);
    RP.post(evaluate);
    int tries = 0;
    boolean found = false;
    while (tries++ < 30 && !cancelled.get()) {
        if (checkActionWasFound(model, true)) {
            found = true;
            break;
        } else if (evaluate.isFinished()) {
            found = checkActionWasFound(model, false);
            break;
        }
    }
    handle.finish();
    if (!found && !cancelled.get()) {
        NotifyDescriptor nd = new NotifyDescriptor.Message(
                Bundle.MSG_RecentResultNotFound(),
                NotifyDescriptor.INFORMATION_MESSAGE);
        DialogDisplayer.getDefault().notifyLater(nd);
    }
}
项目:incubator-netbeans    文件:QueryController.java   
private void onGotoIssue() {
    String idText = panel.idTextField.getText().trim();
    if(idText == null || idText.trim().equals("") ) {                       // NOI18N
        return;
    }

    final String id = idText.replaceAll("\\s", "");                         // NOI18N

    final Task[] t = new Task[1];
    Cancellable c = new Cancellable() {
        @Override
        public boolean cancel() {
            if(t[0] != null) {
                return t[0].cancel();
            }
            return true;
        }
    };
    final ProgressHandle handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(QueryController.class, "MSG_Opening", new Object[] {id}), c); // NOI18N
    t[0] = Bugzilla.getInstance().getRequestProcessor().create(new Runnable() {
        @Override
        public void run() {
            handle.start();
            try {
                openIssue((BugzillaIssue)repository.getIssue(id));
            } finally {
                handle.finish();
            }
        }
    });
    t[0].schedule(0);
}
项目:incubator-netbeans    文件:ProgressTransferListener.java   
/**
 * Produces a token which may be passed to {@link AggregateProgressFactory#createHandle}
 * in order to permit progress to be canceled.
 * If an event is received after a cancel request has been made, {@link ThreadDeath} will
 * be thrown (which you probably also want to catch and handle gracefully).
 * Due to AETHER-95, {@link IllegalStateException} with a cause of {@link ThreadDeath} might also be thrown.
 * Must be called by the same thread as will call {@link #setAggregateHandle} and runs the process.
 * @return a cancellation token
 */
public static Cancellable cancellable() {
    final AtomicBoolean b = new AtomicBoolean();
    activeListener().cancel = b;
    return new Cancellable() {
        public @Override boolean cancel() {
            return b.compareAndSet(false, true);
        }
    };
}
项目:incubator-netbeans    文件:ActionsManager.java   
@Override
public boolean cancel() {
    for (Iterator it = postedActions.iterator(); it.hasNext(); ) {
        Object action = it.next();
        Cancellable c = getCancellable(action);
        if (c != null) {
            if (!c.cancel()) {
                return false;
            }
        } else {
            return false;
        }
    }
    return true;
}
项目:incubator-netbeans    文件:ActionsManager.java   
private Cancellable getCancellable(Object action) {
    if (action instanceof Cancellable) {
        return (Cancellable) action;
    }
    try {
        // Hack because of ActionsProvider$ContextAware:
        Field delegateField = action.getClass().getDeclaredField("delegate");   // NOI18N
        delegateField.setAccessible(true);
        action = delegateField.get(action);
        if (action instanceof Cancellable) {
            return (Cancellable) action;
        }
    } catch (Exception ex) {}
    return null;
}
项目:incubator-netbeans    文件:Cancellation.java   
public static synchronized boolean cancelAll() {
    boolean ok = true;
    for (Cancellable c : cancellables) {
        boolean result = c.cancel();
        ok &= result;
    }
    return ok;
}
项目:incubator-netbeans    文件:Actions.java   
private ProgressHandle getProgress() {
    return ProgressHandleFactory.createHandle(NbBundle.getMessage(Actions.class, setAsSeen ? "LBL_MarkSeenAllProgress" : "LBL_MarkUnseenAllProgress"), new Cancellable() {
        @Override
        public boolean cancel() {
            canceled = true;
            return canceled;
        }
    });
}
项目:incubator-netbeans    文件:Actions.java   
private ProgressHandle getProgress() {
    return ProgressHandleFactory.createHandle(NbBundle.getMessage(Actions.class, "LBL_SubmitAllProgress"), new Cancellable() {
        @Override
        public boolean cancel() {
            canceled = true;
            return canceled;
        }
    });
}
项目:incubator-netbeans    文件:Actions.java   
private ProgressHandle getProgress() {
    return ProgressHandleFactory.createHandle(NbBundle.getMessage(Actions.class, "LBL_CancelAllProgress"), new Cancellable() {
        @Override
        public boolean cancel() {
            canceled = true;
            return canceled;
        }
    });
}
项目:Analyst    文件:AgeingConfiguration.java   
private void computePointsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_computePointsButtonActionPerformed
    final ProjectTopComponent tc = GUIController.getSelectedProjectTopComponent();
    final Ageing ageing = tc.getProject().getSelectedAgeing();
    if(ageing.getOriginModel() == null) {
        return;
    }

    Runnable r = new Runnable() {
        @Override
        public void run() {
            Cancellable cancelTask = new Cancellable() {
                @Override
                public boolean cancel() {
                    Thread.currentThread().interrupt();
                    return true;
                }
            };
            ArrayList<File> models = new ArrayList<>(1);
            models.add(ageing.getOriginModel().getFile());
            FpResultsBatch result = FpProcessing.instance().calculatePointsBatch(cancelTask, models);
            Model registered = result.getRegisteredModels().get(0);

            List<FacialPoint> pts = result.getFps().get(ageing.getOriginModel().getName());
            tc.getAgeingViewerPanel().getListenerOrigin().setModels(registered);
            tc.getAgeingViewerPanel().getListenerOrigin().setFacialPoints(pts);
            ageing.setOriginFacialPoints(pts);
            ageing.setOriginModel(registered);
            computeButton.setEnabled(true);
        }
    };
    Thread t = new Thread(r);
    t.start();
}
项目:Analyst    文件:BatchRegistrationConfiguration.java   
/**
 * Creates new form RegistrationConfiguration
 */
public BatchRegistrationConfiguration() {
    cancelTask = new Cancellable() {
        @Override
        public boolean cancel() {
            runningTask.interrupt();
            return true;
        }
    };
    initComponents();
    jComboBox2ActionPerformed(null);
}
项目:Analyst    文件:FpProcessing.java   
/**
 * Computes Feature Points for two faces.
 *
 * @param cancelTask - to be able to cancel current thread
 * @param mainModel - main model of pair mode
 * @param secondaryModel - secondary model of pair mode
 * @param registerButton - button to allow registration step
 * @param exportFpButton - button to export computed FP to file
 * @param calculateAutoButton - button to calculate FPs automatically
 * @return FpResultsPair class containing computed Fps for main and
 * secondary face
 */
public FpResultsPair calculatePointsPair(Cancellable cancelTask, Model mainModel, Model secondaryModel,
        JButton registerButton, JButton exportFpButton, JButton calculateAutoButton) {
    List<FacialPoint> mainFP = new ArrayList<>();
    List<FacialPoint> secondaryFP = new ArrayList<>();
    FpResultsPair res = null;

    ProgressHandle p;
    p = ProgressHandleFactory.createHandle("Computing Feature Points...", cancelTask);
    p.start();
    Icp.instance().setP(p);

    //compute FPs for main face
    if (computePointsForSingleFace(p, mainModel, mainFP, registerButton, exportFpButton, calculateAutoButton, mainFP, secondaryFP, 1)) {
        return res;
    }

    //compute FPs for secondary face
    if (computePointsForSingleFace(p, secondaryModel, secondaryFP, registerButton, exportFpButton, calculateAutoButton, mainFP, secondaryFP, 2)) {
        return res;
    }

    res = new FpResultsPair(mainFP, secondaryFP);
    finish(registerButton, exportFpButton, calculateAutoButton, p,
            mainFP, secondaryFP);

    return res;
}
项目:Analyst    文件:FpProcessing.java   
/**
     * Computes and returns feature points for all loaded faces in Batch mode.
     * Faces are reverted to original position after computation of points is
     * finished (since ICP is used to align faces to frankfurt position in
     * process).
     *
     * @param cancelTask - to be able to cancel current thread
     * @param models - list of URLs pointing to where models are stored on the
     * disk
     * @return feature points for N models, along with list of registered models
     */
    public FpResultsBatch calculatePointsBatch(Cancellable cancelTask, List<File> models) {
        int size = models.size();
        float unit = 100f / size;

        ProgressHandle p;
        p = ProgressHandleFactory.createHandle("Computing Feature Points...", cancelTask);
        p.start();

        ModelLoader loader = new ModelLoader();
        Model model;
        List<FacialPoint> facialPoints;
        List<Model> registeredModels = new ArrayList<>();
        Map<String, List<FacialPoint>> allFPs = new HashMap<>();
        FpResultsBatch res = null;

        for (int i = 0; i < size; i++) {
            if (Thread.currentThread().isInterrupted()) {
                p.finish();
                return res;
            }
            model = loader.loadModel(models.get(i), false, true);

            facialPoints = computePointsForSingleFace(p, model);
            registeredModels.add(model);            //needed?
            allFPs.put(model.getName(), facialPoints);

<<<<<<< HEAD
            p.progress(i * 100 / size);
=======
            //p.progress((int) (unit * (i + 1)));
>>>>>>> refs/remotes/origin/development
        }

        res = new FpResultsBatch(allFPs, registeredModels);
        p.finish();
        return res;
    }
项目:netbeansplugins    文件:GzipUncompressOperation.java   
/**
 * Uncompress the FileObject
 *
 * @param sourceFO uncompress this source FileObject
 */
public boolean uncompress(FileObject sourceFO) {
    boolean success = false;

    FileLock fileLock = null;
    ProgressHandle progressHandle = null;

    try {
        // create target
        final String targetFilename = sourceFO.getName();
        FileObject targetFO = FileUtil.createData(sourceFO.getParent(), targetFilename);
        fileLock = targetFO.lock();
        try (OutputStream os = targetFO.getOutputStream(fileLock)) {
            // get input
            ProgressHandleWrapper phw = createProgressHandleWrapper(sourceFO);
            try (InputStream is = new GZIPInputStream(phw.getProgressInputStream())) {

                // process: read from input and write compressed to target
                final Cancellable allowToCancel = phw;
                final String progressLabel = NbBundle.getMessage(StreamOperation.class, "LBL_Uncompress");
                progressHandle = ProgressHandleFactory.createHandle(progressLabel, allowToCancel);
                phw.setProgressHandle(progressHandle);
                success = process(phw, is, os);
            }
        }
    } catch (IOException ioe) {
        ErrorManager.getDefault().notify(ioe);
        success = false;
    } finally {
        releaseLock(fileLock);

        if (progressHandle != null) {
            progressHandle.finish();
        }
    }
    return success;
}
项目:netbeansplugins    文件:GzipCompressOperation.java   
/**
 * Compress the FileObject
 *
 * @param sourceFO the source FileObject which gets compressed
 */
public boolean compress(FileObject sourceFO) {
    boolean success = false;

    FileLock fileLock = null;
    ProgressHandle progressHandle = null;

    try {
        // create target
        final String targetFilename = sourceFO.getNameExt() + ".gz";
        FileObject targetFO = FileUtil.createData(sourceFO.getParent(), targetFilename);
        fileLock = targetFO.lock();
        try (OutputStream os = new GZIPOutputStream(targetFO.getOutputStream(fileLock))) {
            // get input
            final ProgressHandleWrapper phw = createProgressHandleWrapper(sourceFO);
            try (InputStream is = phw.getProgressInputStream()) {

                // process: read from input and write compressed to target
                final Cancellable allowToCancel = phw;
                final String progressLabel = NbBundle.getMessage(StreamOperation.class, "LBL_Compress");
                progressHandle = ProgressHandleFactory.createHandle(progressLabel, allowToCancel);
                phw.setProgressHandle(progressHandle);

                success = process(phw, is, os);
            }
        }
    } catch (IOException ioe) {
        success = false;
        ErrorManager.getDefault().notify(ioe);
    } finally {
        releaseLock(fileLock);

        if (progressHandle != null) {
            progressHandle.finish();
        }
    }
    return success;
}
项目:netbeans-wakatime    文件:UpdateHandler.java   
static UpdateUnitProvider getSilentUpdateProvider() {
    List<UpdateUnitProvider> providers = UpdateUnitProviderFactory.getDefault().getUpdateUnitProviders(true);
    String oldCodename = "org_wakatime_netbeans_plugin_update_center";
    for (UpdateUnitProvider p : providers) {
        if (p.getName().equals(oldCodename) || p.getName().equals(WakaTime.CODENAME)) { // this is our current plugin
            try {
                final String displayName = "Checking for updates to WakaTime plugin...";
                p.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());
            }
            return p;
        }
    }
    return null;
}
项目:netbeans-wakatime    文件:UpdateHandler.java   
static Validator doDownload(InstallSupport support) throws OperationException {
    final String displayName = "Downloading new version of WakaTime plugin...";
    ProgressHandle downloadHandle = ProgressHandleFactory.createHandle(
        displayName,
        new Cancellable () {
            @Override
            public boolean cancel () {
                return true;
            }
        }
    );
    return support.doDownload(downloadHandle, true);
}
项目:netbeans-wakatime    文件:UpdateHandler.java   
static Installer doVerify(InstallSupport support, Validator validator) throws OperationException {
    final String displayName = "Validating WakaTime plugin...";
    ProgressHandle validateHandle = ProgressHandleFactory.createHandle(
        displayName,
        new Cancellable () {
            @Override
            public boolean cancel () {
                return true;
            }
        }
    );
    Installer installer = support.doValidate(validator, validateHandle);
    return installer;
}
项目:netbeans-wakatime    文件:UpdateHandler.java   
static Restarter doInstall(InstallSupport support, Installer installer) throws OperationException {
    final String displayName = "Installing WakaTime plugin...";
    ProgressHandle installHandle = ProgressHandleFactory.createHandle(
        displayName,
        new Cancellable () {
            @Override
            public boolean cancel () {
                return true;
            }
        }
    );
    return support.doInstall(installer, installHandle);
}
项目:goworks    文件:GoActionProvider.java   
private void handleRebuildAction(Lookup lookup) throws IllegalArgumentException {
    String projectName = ProjectUtils.getInformation(_project).getDisplayName();
    InputOutput tab;
    tab = IOProvider.getDefault().getIO(projectName + " (rebuild)", false);
    tab.closeInputOutput();

    Action[] actions = new Action[] {
    };

    tab = IOProvider.getDefault().getIO(projectName + " (rebuild)", actions);
    try {
        tab.getOut().reset();
    } catch (IOException ex) {
    }

    final InputOutput ioTab = tab;

    ProgressHandle progressHandle = ProgressHandleFactory.createHandle(projectName + " (rebuild)", new Cancellable() {

        @Override
        public boolean cancel() {
            return false;
        }

    }, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            ioTab.select();
        }

    });

    progressHandle.setInitialDelay(0);
    progressHandle.start();

    execute(COMMAND_REBUILD, ioTab, progressHandle);
}
项目:goworks    文件:GoActionProvider.java   
private void handleCleanAction(Lookup lookup) throws IllegalArgumentException {
    String projectName = ProjectUtils.getInformation(_project).getDisplayName();
    InputOutput tab;
    tab = IOProvider.getDefault().getIO(projectName + " (clean)", false);
    tab.closeInputOutput();

    Action[] actions = new Action[] {
    };

    tab = IOProvider.getDefault().getIO(projectName + " (clean)", actions);
    try {
        tab.getOut().reset();
    } catch (IOException ex) {
    }

    final InputOutput ioTab = tab;

    ProgressHandle progressHandle = ProgressHandleFactory.createHandle(projectName + " (clean)", new Cancellable() {

        @Override
        public boolean cancel() {
            return false;
        }

    }, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            ioTab.select();
        }

    });

    progressHandle.setInitialDelay(0);
    progressHandle.start();

    execute(COMMAND_CLEAN, ioTab, progressHandle);
}
项目:goworks    文件:GoActionProvider.java   
private void handleTestAction(Lookup lookup) throws IllegalArgumentException {
    String projectName = ProjectUtils.getInformation(_project).getDisplayName();
    InputOutput tab;
    tab = IOProvider.getDefault().getIO(projectName + " (test)", false);
    tab.closeInputOutput();

    Action[] actions = new Action[] {
    };

    tab = IOProvider.getDefault().getIO(projectName + " (test)", actions);
    try {
        tab.getOut().reset();
    } catch (IOException ex) {
    }

    final InputOutput ioTab = tab;

    ProgressHandle progressHandle = ProgressHandleFactory.createHandle(projectName + " (test)", new Cancellable() {

        @Override
        public boolean cancel() {
            return false;
        }

    }, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            ioTab.select();
        }

    });

    progressHandle.setInitialDelay(0);
    progressHandle.start();

    execute(COMMAND_TEST, ioTab, progressHandle);
}
项目:fantomidemodule    文件:FanJarsIndexer.java   
@Override
public void run() {
    done = false;
    try {
        if (!getJarPaths().isEmpty()) {
            ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Fantom java indexing", (Cancellable) null);
            progressHandle.setInitialDelay(5000);
            progressHandle.start();

            for (URL url : getJarPaths()) {
                if (shutdown) {
                    break;
                }
                String file = url.getFile();
                progressHandle.progress("Indexing: " + file);
                if (file.toLowerCase().endsWith(".jar")) {
                    // boot clasppath lists sme jars that do not necerally exists (optional)
                    File jar = new File(file);
                    if (jar.exists()) {
                        FanUtilities.GENERIC_LOGGER.debug("Indexing jar:  " + jar);
                        // listen to changes
                        FileUtil.addFileChangeListener(FanJarsIndexer.this, FileUtil.normalizeFile(jar));
                        // index the pods if not up to date
                        String path = jar.getAbsolutePath();
                        if (FanIndexer.checkIfNeedsReindexing(path, jar.lastModified())) {
                            indexJar(path);
                        }
                    }
                }
                yield();
            }
            progressHandle.finish();
        }
    } catch (Throwable t) {
        log.exception("Pod indexing thread error", t);
    }
    done = true;
}