Java Code Examples for org.netbeans.api.progress.BaseProgressUtils#showProgressDialogAndRun()

The following examples show how to use org.netbeans.api.progress.BaseProgressUtils#showProgressDialogAndRun() . 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: ProjectPropertiesSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages("ProjectPropertiesSupport.project.metadata.saving=Saving project metadata...")
private static void saveTestSources(final PhpProject project, final String propertyName, final File testDir) {
    BaseProgressUtils.showProgressDialogAndRun(new Runnable() {
        @Override
        public void run() {
            // XXX reference helper
            // relativize text path
            File projectDirectory = FileUtil.toFile(project.getProjectDirectory());
            String testPath = PropertyUtils.relativizeFile(projectDirectory, testDir);
            if (testPath == null) {
                // path cannot be relativized => use absolute path (any VCS can be hardly use, of course)
                testPath = testDir.getAbsolutePath();
            }
            PhpProjectProperties.save(project, Collections.singletonMap(propertyName, testPath), Collections.<String, String>emptyMap());
        }
    }, Bundle.ProjectPropertiesSupport_project_metadata_saving());
}
 
Example 2
Source File: PhpExecutable.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Debug this executable with the given execution descriptor and optional output processor factory, <b>blocking but not blocking the UI thread</b>
 * (it displays progress dialog if it is running in it).
 * @param startFile the start file
 * @param executionDescriptor execution descriptor to be used (never controllable)
 * @param outProcessorFactory output processor factory to be used, can be {@code null}
 * @return exit code of the process or {@code null} if any error occured
 * @throws ExecutionException if any error occurs
 * @see #debug(FileObject)
 * @see #debug(FileObject, ExecutionDescriptor)
 * @since 0.28
 */
@NbBundle.Messages("PhpExecutable.debug.progress=Debugging...")
@CheckForNull
public Integer debug(@NonNull final FileObject startFile, @NonNull final ExecutionDescriptor executionDescriptor,
        @NullAllowed final ExecutionDescriptor.InputProcessorFactory2 outProcessorFactory) throws ExecutionException {
    if (!EventQueue.isDispatchThread()) {
        return debugInternal(startFile, executionDescriptor, outProcessorFactory);
    }
    // ui thread
    final AtomicReference<Integer> executionResult = new AtomicReference<>();
    final AtomicReference<ExecutionException> executionException = new AtomicReference<>();
    BaseProgressUtils.showProgressDialogAndRun(new Runnable() {
        @Override
        public void run() {
            try {
                executionResult.set(debugInternal(startFile, executionDescriptor, outProcessorFactory));
            } catch (ExecutionException ex) {
                executionException.set(ex);
            }
        }
    }, Bundle.PhpExecutable_debug_progress());
    if (executionException.get() != null) {
        throw executionException.get();
    }
    return executionResult.get();
}
 
Example 3
Source File: CustomizerGeneral.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "MSG_ContactingServer=Contacting the server",
    "MSG_ConnectionFailed=Could not connect to the server. It is either not running or not accessible at the moment."
})
private void certificateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_certificateButtonActionPerformed
    manager.getInstanceProperties().setProperty(WLTrustHandler.TRUST_EXCEPTION_PROPERTY, null);
    BaseProgressUtils.showProgressDialogAndRun(new Runnable() {

        @Override
        public void run() {
            boolean connected = WLTrustHandler.check(manager.getCommonConfiguration());
            if (!connected) {
                NotifyDescriptor desc = new NotifyDescriptor.Message(Bundle.MSG_ConnectionFailed(),
                        NotifyDescriptor.ERROR_MESSAGE);
                DialogDisplayer.getDefault().notify(desc);
            }
        }
    }, Bundle.MSG_ContactingServer());

}
 
Example 4
Source File: PhpExecutable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Run this executable with the given execution descriptor and optional output processor factory, <b>blocking but not blocking the UI thread</b>
 * (it displays progress dialog if it is running in it).
 * @param executionDescriptor execution descriptor to be used
 * @param outProcessorFactory output processor factory to be used, can be {@code null}
 * @param progressMessage message displayed if the task is running in the UI thread
 * @return exit code of the process or {@code null} if any error occured
 * @throws ExecutionException if any error occurs
 * @see #runAndWait(String)
 * @see #runAndWait(ExecutionDescriptor, String)
 * @since 0.28
 */
@CheckForNull
public Integer runAndWait(@NonNull ExecutionDescriptor executionDescriptor, @NullAllowed ExecutionDescriptor.InputProcessorFactory2 outProcessorFactory,
        @NonNull final String progressMessage) throws ExecutionException {
    Parameters.notNull("progressMessage", progressMessage); // NOI18N
    final Future<Integer> result = run(executionDescriptor, outProcessorFactory);
    if (result == null) {
        return null;
    }
    final AtomicReference<ExecutionException> executionException = new AtomicReference<>();
    if (SwingUtilities.isEventDispatchThread()) {
        if (!result.isDone()) {
            try {
                // let's wait in EDT to avoid flashing dialogs
                getResult(result, 90L);
            } catch (TimeoutException ex) {
                BaseProgressUtils.showProgressDialogAndRun(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            getResult(result);
                        } catch (ExecutionException extEx) {
                            executionException.set(extEx);
                        }
                    }
                }, progressMessage);
            }
        }
    }
    if (executionException.get() != null) {
        throw executionException.get();
    }
    return getResult(result);
}
 
Example 5
Source File: RunTagWizard.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({
    "MSG_ReceivingImageInfo=Receiving Image Details",
    "LBL_Run=Run {0}"
})
public void show() {
    DockerImageDetail info = BaseProgressUtils.showProgressDialogAndRun(
            new DockerImageInfoRunnable(tag.getImage()), Bundle.MSG_ReceivingImageInfo(), false);

    List<WizardDescriptor.Panel<WizardDescriptor>> panels = new ArrayList<>();
    panels.add(new RunContainerPropertiesPanel(info));
    panels.add(new RunPortBindingsPanel(info));
    String[] steps = new String[panels.size()];
    for (int i = 0; i < panels.size(); i++) {
        JComponent c = (JComponent) panels.get(i).getComponent();
        // Default step name to component name of panel.
        steps[i] = c.getName();
        c.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
        c.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
        c.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, true);
        c.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, true);
        c.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, true);
    }
    final WizardDescriptor wiz = new WizardDescriptor(new WizardDescriptor.ArrayIterator<>(panels));
    // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
    wiz.setTitleFormat(new MessageFormat("{0}"));
    wiz.setTitle(Bundle.LBL_Run(getImage(tag)));
    if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) {
        run(tag, wiz);
    }
}
 
Example 6
Source File: LibraryChooserGUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({"LBL_Importing=Importing..."})
private void importButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importButtonActionPerformed
    final Set<Library> libs = showChooser(LibraryManager.getDefault(), 
            new IgnoreAlreadyImportedLibrariesFilter(), null, false);
    if (libs != null) {            
        Runnable r = new Runnable() {
            @Override
            public void run() {
                try {
                    final Set<Library> importedLibs = new HashSet<Library>();
                    for (Library lib : libs) {
                        importedLibs.add(importHandler.importLibrary(lib));
                    }
                    EventQueue.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            setRootNode();                                
                            selectLibrary(importedLibs);
                        }
                    });
                } catch (IOException ex) {
                    Exceptions.printStackTrace(ex);
                } finally {
                    enableButtons(true);
                }
            }
        };
        enableButtons(false);
        BaseProgressUtils.showProgressDialogAndRun(r, Bundle.LBL_Importing());
    }
}
 
Example 7
Source File: ExternalExecutable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Run this executable with the given execution descriptor and optional output processor factory, <b>blocking but not blocking the UI thread</b>
 * (it displays progress dialog if it is running in it).
 * @param executionDescriptor execution descriptor to be used
 * @param outProcessorFactory output processor factory to be used, can be {@code null}
 * @param progressMessage message displayed if the task is running in the UI thread
 * @return exit code of the process or {@code null} if any error occured
 * @throws ExecutionException if any error occurs
 * @see #runAndWait(String)
 * @see #runAndWait(ExecutionDescriptor, String)
 */
@CheckForNull
public Integer runAndWait(@NonNull ExecutionDescriptor executionDescriptor, @NullAllowed ExecutionDescriptor.InputProcessorFactory2 outProcessorFactory,
        @NonNull final String progressMessage) throws ExecutionException {
    Parameters.notNull("progressMessage", progressMessage); // NOI18N
    final Future<Integer> result = run(executionDescriptor, outProcessorFactory);
    if (result == null) {
        return null;
    }
    final AtomicReference<ExecutionException> executionException = new AtomicReference<>();
    if (Mutex.EVENT.isReadAccess()) {   // Is EDT
        if (!result.isDone()) {
            try {
                // let's wait in EDT to avoid flashing dialogs
                getResult(result, 90L);
            } catch (TimeoutException ex) {
                BaseProgressUtils.showProgressDialogAndRun(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            getResult(result);
                        } catch (ExecutionException extEx) {
                            executionException.set(extEx);
                        }
                    }
                }, progressMessage);
            }
        }
    }
    if (executionException.get() != null) {
        throw executionException.get();
    }
    return getResult(result);
}
 
Example 8
Source File: ExternalExecutable.java    From minifierbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Run this executable with the given execution descriptor and optional output processor factory, <b>blocking but not blocking the UI thread</b>
 * (it displays progress dialog if it is running in it).
 * @param executionDescriptor execution descriptor to be used
 * @param outProcessorFactory output processor factory to be used, can be {@code null}
 * @param progressMessage message displayed if the task is running in the UI thread
 * @return exit code of the process or {@code null} if any error occured
 * @throws ExecutionException if any error occurs
 * @see #runAndWait(String)
 * @see #runAndWait(ExecutionDescriptor, String)
 */
@CheckForNull
public Integer runAndWait(@NonNull ExecutionDescriptor executionDescriptor, @NullAllowed ExecutionDescriptor.InputProcessorFactory2 outProcessorFactory,
        @NonNull final String progressMessage) throws ExecutionException {
    Parameters.notNull("progressMessage", progressMessage); // NOI18N
    final Future<Integer> result = run(executionDescriptor, outProcessorFactory);
    if (result == null) {
        return null;
    }
    final AtomicReference<ExecutionException> executionException = new AtomicReference<ExecutionException>();
    if (Mutex.EVENT.isReadAccess()) {   // Is EDT
        if (!result.isDone()) {
            try {
                // let's wait in EDT to avoid flashing dialogs
                getResult(result, 90L);
            } catch (TimeoutException ex) {
                BaseProgressUtils.showProgressDialogAndRun(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            getResult(result);
                        } catch (ExecutionException extEx) {
                            executionException.set(extEx);
                        }
                    }
                }, progressMessage);
            }
        }
    }
    if (executionException.get() != null) {
        throw executionException.get();
    }
    return getResult(result);
}