org.netbeans.api.progress.ProgressHandleFactory Java Examples

The following examples show how to use org.netbeans.api.progress.ProgressHandleFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Base64Decode.java    From minifierbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent ev) {
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            decode();
        }
    };

    final RequestProcessor.Task theTask = RP.create(runnable);
    final ProgressHandle ph = ProgressHandleFactory.createHandle("Base64 Decoding Image " + context.getPrimaryFile().getName(), theTask);

    theTask.addTaskListener(new TaskListener() {
        @Override
        public void taskFinished(org.openide.util.Task task) {
            ph.finish();
        }
    });

    ph.start();
    theTask.schedule(0);
}
 
Example #2
Source File: UpdateHandler.java    From jeddict with Apache License 2.0 6 votes vote down vote up
static void refreshSilentUpdateProvider() {
    UpdateUnitProvider silentUpdateProvider = getSilentUpdateProvider();
    if (silentUpdateProvider == null) {
        // have a problem => cannot continue
        JeddictInstaller.info("Missing Silent Update Provider => cannot continue.");
        return ;
    }
    try {
        final String displayName = "Checking for updates to Jeddict plugin...";
        silentUpdateProvider.refresh(
            ProgressHandleFactory.createHandle(displayName, () -> true),
            true
        );
    } catch (IOException ex) {
        // caught a exception
        JeddictInstaller.error("A problem caught while refreshing Update Centers, cause: " + ex.toString());
    }
}
 
Example #3
Source File: DataObject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public ProgressInfo(String name, DataObject root) {
    final Cancellable can;
    if (root instanceof DataFolder) {
        can = new Cancellable() {

            @Override
            public boolean cancel() {
                terminated.set(true);
                return true;
            }
        };
    } else {
        can = null;
    }
    ProgressHandle ph = ProgressHandleFactory.createHandle(name, can);
    ph.setInitialDelay(500);
    ph.start();
    this.progressHandle = ph;
    this.root = root;
}
 
Example #4
Source File: Installer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static URL uploadLogs(URL postURL, String id, Map<String,String> attrs,
        List<LogRecord> recs, DataType dataType, boolean isErrorReport,
        SlownessData slownData, boolean isOOM, boolean isAfterRestart) throws IOException {
    ProgressHandle h = null;
    //Do not show progress UI for metrics upload
    if (dataType != DataType.DATA_METRICS) {
        h = ProgressHandleFactory.createHandle(NbBundle.getMessage(Installer.class, "MSG_UploadProgressHandle"));
    }
    try {
        return uLogs(h, postURL, id, attrs, recs, dataType, isErrorReport, slownData, isOOM, isAfterRestart);
    } finally {
        if (h != null) {
            h.finish();
        }
    }
}
 
Example #5
Source File: ImageCompress.java    From minifierbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent ev) {
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            compress();
        }
    };
    
    final RequestProcessor.Task theTask = RP.create(runnable);
    final ProgressHandle ph = ProgressHandleFactory.createHandle("Compressing Image " + context.getPrimaryFile().getName(), theTask);
    
    theTask.addTaskListener(new TaskListener() {
        @Override
        public void taskFinished(org.openide.util.Task task) {
            NotificationDisplayer.getDefault().notify("Image compressed successfully", NotificationDisplayer.Priority.NORMAL.getIcon(), "The compression of the image was successful.", null);
            
            ph.finish();
        }
    });
    
    ph.start();
    theTask.schedule(0);

}
 
Example #6
Source File: ScaleToolModel.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
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());
   String proposedFilename = unscaledModel.getInputFileName().replace(".osim", "_scaled.osim");
   processedModel.setInputFileName(proposedFilename);
   processedModel.setOriginalModelPathFromModel(unscaledModel); // important to keep track of the original path so bone loading works
   //processedModel.setup();

   setExecuting(true);
}
 
Example #7
Source File: AnalyzerTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Test
public void testZeroWorkUnits() {
    ProgressHandle handle = ProgressHandleFactory.createHandle("test");
    handle.start(1000);
    Context ctxInit = new Context(null, null, null, handle, 0, 100);
    
    ctxInit.start(1);
    ctxInit.progress(1);
    ctxInit.finish();
    
    Context ctx = new Context(null, null, null, handle, 100, 100);
    
    ctx.start(0);
    ctx.progress(0);
    ctx.finish();
}
 
Example #8
Source File: Minify.java    From minifierbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent ev) {
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            minify();
        }
    };
    final RequestProcessor.Task theTask = RP.create(runnable);
    final ProgressHandle ph = ProgressHandleFactory.createHandle("Minifying JS , CSS and other WEB Content ", theTask);
    theTask.addTaskListener(new TaskListener() {
        @Override
        public void taskFinished(org.openide.util.Task task) {
            ph.finish();
        }
    });
    ph.start();
    theTask.schedule(0);
}
 
Example #9
Source File: XMLMinify.java    From minifierbeans with Apache License 2.0 6 votes vote down vote up
public static void execute(final DataObject context, final String content, final boolean notify) {
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            xmlMinify(context, content, notify);
        }
    };
    final RequestProcessor.Task theTask = RP.create(runnable);
    final ProgressHandle ph = ProgressHandleFactory.createHandle("Minifying XML " + context.getPrimaryFile().getName(), theTask);
    theTask.addTaskListener(new TaskListener() {
        @Override
        public void taskFinished(org.openide.util.Task task) {
            ph.finish();
        }
    });
    ph.start();
    theTask.schedule(0);
}
 
Example #10
Source File: ExecutionService.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #11
Source File: ProgressDialog.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void createDialog(String title) {
    pHandle = ProgressHandleFactory.createHandle(title);
    JPanel panel = new ProgressPanel(pHandle);
    
    DialogDescriptor descriptor = new DialogDescriptor(
            panel, title
    );
    
    final Object[] OPTIONS = new Object[0];
    descriptor.setOptions(OPTIONS);
    descriptor.setClosingOptions(OPTIONS);
    descriptor.setModal(true);
    descriptor.setOptionsAlign(DialogDescriptor.BOTTOM_ALIGN);
    
    dialog = DialogDisplayer.getDefault().createDialog(descriptor);
    
    Frame mainWindow = WindowManager.getDefault().getMainWindow();
    int windowWidth = mainWindow.getWidth();
    int windowHeight = mainWindow.getHeight();
    int dialogWidth = dialog.getWidth();
    int dialogHeight = dialog.getHeight();
    int dialogX = (int)(windowWidth/2.0) - (int)(dialogWidth/2.0);
    int dialogY = (int)(windowHeight/2.0) - (int)(dialogHeight/2.0);
    
    dialog.setLocation(dialogX, dialogY);
}
 
Example #12
Source File: PanelProgressSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void startProgress() {
    if (panel == null) {
        super.startProgress();
    } else
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            ProgressHandle progress = getProgressHandle(); // NOI18N
            JComponent bar = ProgressHandleFactory.createProgressComponent(progress);
            progressComponent = new JPanel();
            progressComponent.setLayout(new BorderLayout(6, 0));
            progressLabel = new JLabel();
            progressLabel.setText(getDisplayName());
            progressComponent.add(progressLabel, BorderLayout.NORTH);
            progressComponent.add(bar, BorderLayout.CENTER);
            PanelProgressSupport.super.startProgress();
            panel.setVisible(true);
            panel.add(progressComponent);
            panel.revalidate();
        }
    });
}
 
Example #13
Source File: AttachmentsPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void applyPatch() {
    String progressFormat = NbBundle.getMessage(AttachmentsPanel.class,"Attachment.applyPatch.progress"); //NOI18N
    String progressMessage = MessageFormat.format(progressFormat, getFilename());
    final ProgressHandle handle = ProgressHandleFactory.createHandle(progressMessage);
    handle.start();
    handle.switchToIndeterminate();
    Support.getInstance().getParallelRP().post(
        new Runnable() {
            @Override
            public void run() {
                IDEServices ideServices = Support.getInstance().getIDEServices();
                if(ideServices != null) {
                    try {
                        ideServices.applyPatch(saveToTempFile());
                    } catch (IOException ex) {
                        LOG.log(Level.WARNING, ex.getMessage(), ex);
                    } finally {
                        handle.finish();
                    }
                }            
            }
        });
}
 
Example #14
Source File: GradleDistributionManager.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Messages({
    "# {0} - The downloading GradleVersion ",
    "TIT_Download_Gradle=Downloading {0}",
    "# {0} - The downloading GradleVersion ",
    "MSG_Download_Gradle={0} is being downloaded and installed."
})
public DownloadTask(NbGradleVersion version) {
    this.version = version;
    handle = ProgressHandleFactory.createSystemHandle(Bundle.TIT_Download_Gradle(version.getVersion()));
    notification = NotificationDisplayer.getDefault().notify(
            Bundle.TIT_Download_Gradle(version.getVersion()),
            NbGradleProject.getIcon(),
            Bundle.MSG_Download_Gradle(version.getVersion()),
            null,
            NotificationDisplayer.Priority.NORMAL,
            NotificationDisplayer.Category.INFO);
}
 
Example #15
Source File: DetectPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void readSettings(WizardDescriptor settings) {           
    sources = null;
    sourcesString = null;
    javadoc = null;
    javadocString = null;
    this.wiz = settings;
    this.component.progressPanel.setVisible (true);
    this.component.progressLabel.setVisible (true);
    
    this.progressHandle = ProgressHandleFactory.createHandle(NbBundle.getMessage(DetectPanel.class,"TXT_PlatfromDetectProgress"));
    this.component.progressPanel.removeAll();
    this.component.progressPanel.setLayout (new GridBagLayout ());
    GridBagConstraints c = new GridBagConstraints ();
    c.gridx = c.gridy = GridBagConstraints.RELATIVE;
    c.gridheight = c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    JComponent pc = ProgressHandleFactory.createProgressComponent(this.progressHandle);
    ((GridBagLayout)this.component.progressPanel.getLayout ()).setConstraints(pc,c);
    this.component.progressPanel.add (pc);
    this.progressHandle.start ();
    task.schedule(0);
}
 
Example #16
Source File: HTMLMinify.java    From minifierbeans with Apache License 2.0 6 votes vote down vote up
public static void execute(final DataObject context, final String content, final boolean notify) {
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            htmlMinify(context, content, notify);
        }
    };
    final RequestProcessor.Task theTask = RP.create(runnable);
    final ProgressHandle ph = ProgressHandleFactory.createHandle("Minifying HTML " + context.getPrimaryFile().getName(), theTask);
    theTask.addTaskListener(new TaskListener() {
        @Override
        public void taskFinished(org.openide.util.Task task) {
            ph.finish();
        }
    });
    ph.start();
    theTask.schedule(0);
}
 
Example #17
Source File: BindingCustomizer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static JPanel panelForHandle(ProgressHandle handle) {
    JLabel label = ProgressHandleFactory.createDetailLabelComponent(handle);
    JComponent progress = ProgressHandleFactory.createProgressComponent(handle);
    JPanel panel = new JPanel();
    GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addComponent(label)
                .addComponent(progress))
            .addContainerGap())
    );
    layout.setVerticalGroup(
        layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(label)
            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(progress)
            .addContainerGap()
    );
    return panel;
}
 
Example #18
Source File: UpdateHandler.java    From netbeans-wakatime with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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());
    }
}
 
Example #19
Source File: SceneEditorController.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void doAddModel(SpatialAssetDataObject file, Node selected, Vector3f location) {
    ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Adding Model..");
    progressHandle.start();
    try {
        Spatial linkNode = file.loadAsset();
        if (linkNode != null) {
            selected.attachChild(linkNode);
            if (location != null) {
                Vector3f localVec = new Vector3f();
                selected.worldToLocal(location, localVec);
                linkNode.setLocalTranslation(localVec);
            }
        }
        refreshSelected();
        addSpatialUndo(selected, linkNode, null, selectedSpat);
    } catch (Exception ex) {
        Confirmation msg = new NotifyDescriptor.Confirmation(
                "Error importing " + file.getName() + "\n" + ex.toString(),
                NotifyDescriptor.OK_CANCEL_OPTION,
                NotifyDescriptor.ERROR_MESSAGE);
        DialogDisplayer.getDefault().notifyLater(msg);
    }
    progressHandle.finish();
    
}
 
Example #20
Source File: RefactoringPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public ProgressL() {
    final String lab = NbBundle.getMessage(RefactoringPanel.class, "LBL_RefactorProgressLabel");
    handle = ProgressHandleFactory.createHandle(lab);
    JComponent progress = ProgressHandleFactory.createProgressComponent(handle);
    JPanel component = new JPanel();
    component.setLayout(new BorderLayout());
    component.setBorder(new EmptyBorder(12,12,11,11));
    JLabel label = new JLabel(lab);
    label.setBorder(new EmptyBorder(0, 0, 6, 0));
    component.add(label, BorderLayout.NORTH);
    component.add(progress, BorderLayout.CENTER);
    DialogDescriptor desc = new DialogDescriptor(component, NbBundle.getMessage(RefactoringPanel.class, "LBL_RefactoringInProgress"), true, new Object[]{}, null, 0, null, null);
    desc.setLeaf(true);
    d = DialogDisplayer.getDefault().createDialog(desc);
    ((JDialog) d).setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
}
 
Example #21
Source File: ConfirmationPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Messages({
    "LBL_FormattingQuestion=Recursively format the selected files and folders?",
    "LBL_FormattingInProgress=Formatting:"
})
public ConfirmationPanel(ProgressHandle handle) {
    initComponents();
    setLayout(new CardLayout());
    add(new JLabel(Bundle.LBL_FormattingQuestion()), PANEL_QUESTION);
    JPanel progress = new JPanel(new BorderLayout());
    JLabel inProgressLabel = new JLabel(Bundle.LBL_FormattingInProgress());
    inProgressLabel.setBorder(new EmptyBorder(0, 0, 6, 0));
    progress.add(inProgressLabel, BorderLayout.NORTH);
    progress.add(ProgressHandleFactory.createProgressComponent(handle), BorderLayout.CENTER);
    add(progress, PANEL_PROGRESS);
    ((CardLayout) getLayout()).show(this, PANEL_QUESTION);
}
 
Example #22
Source File: EnableStep.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Runnable doEnable (final FeatureInfo info) {
    return new Runnable () {
        public void run () {
            if (! doEnableRunning) {
                doEnableRunning = true;
                FindComponentModules find = new FindComponentModules(info);
                ModulesActivator activator = new ModulesActivator(forEnable, find);
                ProgressHandle enableHandle = ProgressHandleFactory.createHandle (
                        getBundle ("ModulesStep_Enable",
                        presentElementsForEnable (find)));
                JComponent enableComponent = ProgressHandleFactory.createProgressComponent (enableHandle);
                JComponent enableMainLabel = ProgressHandleFactory.createMainLabelComponent (enableHandle);
                JComponent enableDetailLabel = ProgressHandleFactory.createDetailLabelComponent (enableHandle);
                activator.assignEnableHandle (enableHandle);
                component.displayEnableTask (
                        enableMainLabel,
                        enableDetailLabel,
                        enableComponent);
                RequestProcessor.Task enable = activator.getEnableTask ();
                enable.schedule (0);
                enable.waitFinished ();
                FoDLayersProvider.getInstance().refreshForce();
                waitForDelegateWizard ();
            }
        }
    };
}
 
Example #23
Source File: JaxWsServiceCreator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void createServiceFromWsdl() throws IOException {

        //initProjectInfo(project);

        final ProgressHandle handle = ProgressHandleFactory.createHandle(
                NbBundle.getMessage(JaxWsServiceCreator.class, 
                        "TXT_WebServiceGeneration")); //NOI18N

        Runnable r = new Runnable() {

            public void run() {
                try {
                    handle.start();
                    generateWsFromWsdl15(handle);
                } catch (Exception e) {
                    //finish progress bar
                    handle.finish();
                    String message = e.getLocalizedMessage();
                    if (message != null) {
                        ErrorManager.getDefault().notify(
                                ErrorManager.INFORMATIONAL, e);
                        NotifyDescriptor nd = new NotifyDescriptor.Message(
                                message, NotifyDescriptor.ERROR_MESSAGE);
                        DialogDisplayer.getDefault().notify(nd);
                    } else {
                        ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, e);
                    }
                }
            }
        };
        RequestProcessor.getDefault().post(r);
    }
 
Example #24
Source File: ClusterizeVisualPanel1.java    From netbeans with Apache License 2.0 5 votes vote down vote up
ClusterizeVisualPanel1(ClusterizeWizardPanel1 aThis) {
    panel = aThis;
    handle = ProgressHandleFactory.createHandle(java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("MSG_ClusterizeScanning"));
    initComponents();
    progressPanel.add(BorderLayout.CENTER, ProgressHandleFactory.createProgressComponent(handle));
    progressName.add(BorderLayout.CENTER, ProgressHandleFactory.createMainLabelComponent(handle));
    putClientProperty("WizardPanel_contentSelectedIndex", Integer.valueOf(0)); // NOI18N
    putClientProperty("WizardPanel_contentData", panel.settings.getSteps()); // NOI18N
    putClientProperty("WizardPanel_autoWizardStyle", Boolean.TRUE); // NOI18N
    putClientProperty("WizardPanel_contentDisplayed", Boolean.TRUE); // NOI18N
    putClientProperty("WizardPanel_contentNumbered", Boolean.TRUE); // NOI18N
}
 
Example #25
Source File: Actions.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private ProgressHandle getProgress() {
    return ProgressHandleFactory.createHandle(NbBundle.getMessage(Actions.class, "LBL_CancelAllProgress"), new Cancellable() {
        @Override
        public boolean cancel() {
            canceled = true;
            return canceled;
        }
    });
}
 
Example #26
Source File: PackageView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Fills given collection with flattened packages under given folder
 *@param target The collection to be filled
 *@param fo The folder to be scanned
 * @param group the group to scan
 * @param createPackageItems if false the collection will be filled with file objects; if
 *       true PackageItems will be created.
 * @param showProgress whether to show a progress handle or not
 */
@Messages({"# {0} - root folder", "PackageView.find_packages_progress=Finding packages in {0}"})
static void findNonExcludedPackages(PackageViewChildren children, Collection<PackageItem> target, FileObject fo, SourceGroup group, boolean showProgress) {
    if (showProgress) {
        ProgressHandle progress = ProgressHandleFactory.createHandle(PackageView_find_packages_progress(FileUtil.getFileDisplayName(fo)));
        progress.start(1000);
        findNonExcludedPackages(children, target, fo, group, progress, 0, 1000);
        progress.finish();
    } else {
        findNonExcludedPackages(children, target, fo, group, null, 0, 0);
    }
}
 
Example #27
Source File: EditVehicleAction.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void actionPerformed(ActionEvent ev) {
    final ProjectAssetManager manager = context.getLookup().lookup(ProjectAssetManager.class);
    if (manager == null) {
        return;
    }
    Runnable call = new Runnable() {

        public void run() {
            ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Opening in Vehicle Editor");
            progressHandle.start();


            final Spatial asset = context.loadAsset();

            if (asset != null && asset instanceof Node) {
                java.awt.EventQueue.invokeLater(new Runnable() {

                    public void run() {
                        manager.clearCache();
                        VehicleCreatorTopComponent composer = VehicleCreatorTopComponent.findInstance();
                        composer.openFile(context, (Node) asset);
                    }
                });
            } else {
                Confirmation msg = new NotifyDescriptor.Confirmation(
                        "Error opening " + context.getPrimaryFile().getNameExt(),
                        NotifyDescriptor.OK_CANCEL_OPTION,
                        NotifyDescriptor.ERROR_MESSAGE);
                DialogDisplayer.getDefault().notify(msg);
            }
            progressHandle.finish();
        }
    };
    new Thread(call).start();
}
 
Example #28
Source File: UpdateHandler.java    From netbeans-wakatime with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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;
}
 
Example #29
Source File: SnapshotsSupport.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Saves the snapshot to a used-defined file (opens Save File dialog with defined caption).
 * 
 * @param snapshot Snapshot to be saved.
 * @param dialogTitle Save File dialog caption.
 */
public void saveAs(final Snapshot snapshot, String dialogTitle) {
    final File file = snapshot.getFile();
    if (file == null) {
        ProfilerDialogs.displayError(NbBundle.getMessage(SnapshotsSupport.class, "LBL_CannotSave"));  // NOI18N
    } else {
        JFileChooser chooser = new JFileChooser();
        chooser.setDialogTitle(dialogTitle);
        chooser.setSelectedFile(new File(snapshot.getFile().getName()));
        chooser.setAcceptAllFileFilterUsed(false);
        chooser.setFileFilter(snapshot.getCategory().getFileFilter());
//        chooser.setFileView(category.getFileView());
        if (chooser.showSaveDialog(WindowManager.getDefault().getMainWindow()) == JFileChooser.APPROVE_OPTION) {
            String categorySuffix = snapshot.getCategory().getSuffix();
            String filePath = chooser.getSelectedFile().getAbsolutePath();
            if (!filePath.endsWith(categorySuffix)) filePath += categorySuffix;
            final File copy = new File(filePath);
            VisualVM.getInstance().runTask(new Runnable() {
                public void run() {
                    ProgressHandle pHandle = null;
                    try {
                        pHandle = ProgressHandleFactory.createHandle(NbBundle.getMessage(SnapshotsSupport.class, "LBL_Saving",DataSourceDescriptorFactory.getDescriptor(snapshot).getName()));  // NOI18N
                        pHandle.setInitialDelay(0);
                        pHandle.start();
                        Utils.copyFile(file, copy);
                    } finally {
                        final ProgressHandle pHandleF = pHandle;
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() { if (pHandleF != null) pHandleF.finish(); }
                        });
                    }
                }
            });
        }
    }
}
 
Example #30
Source File: TerrainEditorTopComponent.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setMonitorMax(float f) {
            max = f;
//            java.awt.EventQueue.invokeLater(new Runnable() {
//                public void run() {
//                    synchronized(lock){
            if (progressHandle == null) {
                progressHandle = ProgressHandleFactory.createHandle("Calculating terrain entropies...");
                progressHandle.start((int) max);
            }
//                    }
//                }
//            });
        }