Example usage for org.eclipse.jface.dialogs ProgressMonitorDialog open

List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog open

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs ProgressMonitorDialog open.

Prototype

@Override
    public int open() 

Source Link

Usage

From source file:com.ecfeed.ui.modelif.StaticTestExecutionSupport.java

License:Open Source License

public void proceed() {
    PrintStream currentOut = System.out;
    ConsoleManager.displayConsole();//from w ww.j a  va  2  s  .c om
    ConsoleManager.redirectSystemOutputToStream(ConsoleManager.getOutputStream());

    try {
        fFailedTests.clear();
        ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
        dialog.open();
        dialog.run(true, true, new ExecuteRunnable());
    } catch (InvocationTargetException e) {
        MessageDialog.openError(Display.getCurrent().getActiveShell(),
                Messages.DIALOG_TEST_EXECUTION_PROBLEM_TITLE, e.getTargetException().getMessage());
    } catch (InterruptedException e) {
        MessageDialog.openError(Display.getCurrent().getActiveShell(),
                Messages.DIALOG_TEST_EXECUTION_PROBLEM_TITLE, e.getMessage());
    }
    if (fFailedTests.size() > 0) {
        String message = "Following tests were not successfull\n\n";
        for (TestCaseNode testCase : fFailedTests) {
            message += testCase.toString() + "\n";
        }
        MessageDialog.openError(Display.getCurrent().getActiveShell(),
                Messages.DIALOG_TEST_EXECUTION_REPORT_TITLE, message);
    }
    displayTestStatusDialog();

    System.setOut(currentOut);
}

From source file:com.google.gdt.eclipse.appsmarketplace.job.BackendJob.java

License:Open Source License

public static ProgressMonitorDialog launchBackendJob(BackendJob job, Shell shell) {
    ProgressMonitorDialog pdlg = new ProgressMonitorDialog(shell);
    job.setProgressDialog(pdlg);// www. j  a va2 s . c om
    pdlg.open();
    pdlg.setCancelable(true);

    Thread thread = new Thread(job);
    thread.start();
    pdlg.setBlockOnOpen(true);
    return pdlg;
}

From source file:com.google.gdt.eclipse.appsmarketplace.ui.AbstractMarketplaceHandler.java

License:Open Source License

protected void executeListOnMarketplace(ExecutionEvent event) throws AbstractMarketplaceHandlerException {
    DataStorage.clearData();//from   www .  j  a  va 2s.c om
    AppsMarketplaceProject appsMktProj = AppsMarketplaceProject.create(project);

    BackendJob job = new BackendJob("Getting Vendor Profile", BackendJob.Type.GetVendorProfile, requestFactory,
            appsMktProj);
    ProgressMonitorDialog pdlg = BackendJob.launchBackendJob(job, getShell());

    if (pdlg.open() != Window.OK) {
        throw new AbstractMarketplaceHandlerException();
    }

    if (job.getOperationStatus() == true) {
        job = new BackendJob("Getting Application Listing", BackendJob.Type.GetAppListing, requestFactory,
                appsMktProj);
        pdlg = BackendJob.launchBackendJob(job, getShell());

        if (pdlg.open() != Window.OK) {
            throw new AbstractMarketplaceHandlerException();
        }
    }

    // Gather deployment parameters
    ListOnMarketplaceDialog dlg = new ListOnMarketplaceDialog(getShell(), requestFactory, appsMktProj);
    if (dlg.open() != Window.OK) {
        throw new AbstractMarketplaceHandlerException();
    }
}

From source file:com.google.gdt.eclipse.appsmarketplace.ui.ListOnMarketplaceDialog.java

License:Open Source License

private boolean deployAppsMarketplaceListing() {
    // Store appUrl and appName
    String appUrl = appUrlText.getText().trim();
    String appName = appNameText.getText().trim();
    Integer categoryId = appCategoryCombo.getSelectionIndex();
    try {/*w ww  .  jav a  2s  .c  om*/
        AppsMarketplaceProjectProperties.setAppListingUrl(project, appUrl);
        AppsMarketplaceProjectProperties.setAppListingName(project, appName);
        AppsMarketplaceProjectProperties.setAppListingCategory(project, categoryId);
        if (listingId != null) {
            AppsMarketplaceProjectProperties.setAppListingId(project, listingId);
        }
    } catch (BackingStoreException e) {
        // Do nothing
        AppsMarketplacePluginLog.logError(e);
    }

    try {
        // set appUrl and appName values in the application-manifest.xml
        this.appsMarketplaceProject.setAppUrl(appUrl);
        this.appsMarketplaceProject.setAppName(appName);
    } catch (CoreException e) {
        MessageDialog.openWarning(AppsMarketplacePlugin.getActiveWorkbenchShell(), "Google Plugin for Eclipse",
                "Could not set application url in application-manifest.xml." + " Please set it manually.");
        return false;
    }
    BackendJob job;
    ProgressMonitorDialog pdlg = null;
    if (createListingButton.getSelection()) {
        job = new BackendJob("Creating Appication Listing on Google Apps Marketplace",
                BackendJob.Type.CreateAppListing, requestFactory, appsMarketplaceProject);
    } else {
        job = new BackendJob("Upgrading Appication Listing on Google Apps Marketplace",
                BackendJob.Type.UpdateAppListing, requestFactory, appsMarketplaceProject);
    }
    pdlg = BackendJob.launchBackendJob(job, getShell());
    return (pdlg.open() == Window.OK && job.getOperationStatus() == true);
}

From source file:com.hsveclipse.phototoolkit.application.handlers.SaveHandler.java

License:Open Source License

@Execute
public void execute(IEclipseContext context, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell,
        @Named(IServiceConstants.ACTIVE_PART) final MContribution contribution)
        throws InvocationTargetException, InterruptedException {

    final IEclipseContext pmContext = context.createChild();

    ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
    dialog.open();
    dialog.run(true, true, new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            pmContext.set(IProgressMonitor.class.getName(), monitor);
            if (contribution != null) {
                Object clientObject = contribution.getObject();
                ContextInjectionFactory.invoke(clientObject, Persist.class, //$NON-NLS-1$
                        pmContext, null);
            }//from  www  .ja  va2  s . c om
        }
    });

    pmContext.dispose();
}

From source file:com.hudson.hibernatesynchronizer.editors.synchronizer.actions.RemoveRelatedFiles.java

License:GNU General Public License

/**
 * @see IActionDelegate#run(IAction)//w  ww  .  j  ava 2 s. c o m
 */
public void run(IAction action) {
    final Shell shell = new Shell();
    if (MessageDialog.openConfirm(shell, "File Removal Confirmation",
            "Are you sure you want to delete all related classes and resources to the selected mapping files?")) {
        ISelectionProvider provider = part.getSite().getSelectionProvider();
        if (null != provider) {
            if (provider.getSelection() instanceof StructuredSelection) {
                StructuredSelection selection = (StructuredSelection) provider.getSelection();
                Object[] obj = selection.toArray();
                final IFile[] files = new IFile[obj.length];
                IProject singleProject = null;
                boolean isSingleProject = true;
                for (int i = 0; i < obj.length; i++) {
                    if (obj[i] instanceof IFile) {
                        IFile file = (IFile) obj[i];
                        files[i] = file;
                        if (null == singleProject)
                            singleProject = file.getProject();
                        if (!singleProject.getName().equals(file.getProject().getName())) {
                            isSingleProject = false;
                        }
                    }
                }
                if (isSingleProject) {
                    final IProject project = singleProject;
                    ProgressMonitorDialog dialog = new ProgressMonitorDialog(part.getSite().getShell());
                    try {
                        dialog.open();

                        ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
                            public void run(IProgressMonitor monitor) throws CoreException {
                                try {
                                    removeRelatedFiles(project, files, shell, monitor);
                                } catch (Exception e) {
                                    throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID,
                                            IStatus.OK, e.getMessage(), e));
                                } finally {
                                    monitor.done();
                                }
                            }
                        }, dialog.getProgressMonitor());
                    } catch (Exception e) {
                        UIUtil.pluginError(e, shell);
                    } finally {
                        dialog.close();
                    }
                } else {
                    UIUtil.pluginError("SingleProjectSelectedFiles", shell);
                }
            }
        }
    }
}

From source file:com.ibm.xsp.extlib.designer.bluemix.manifest.editor.ManifestEditorPage.java

License:Open Source License

private void createServicesArea(Composite parent) {
    Section section = XSPEditorUtil.createSection(_toolkit, parent, "Bound Services", 1, 1); // $NLX-ManifestEditorPage.BoundServices-1$
    Composite container = XSPEditorUtil.createSectionChild(section, 1);

    XSPEditorUtil.createLabel(container, "Specify the bound services for this application.", 1); // $NLX-ManifestEditorPage.Specifytheboundservicesforthisapp-1$

    // Create the Table
    _serviceTableEditor = new ManifestTableEditor(container, 1, new String[] { "service" },
            new String[] { "Service" }, true, true, 3, 60, "bluemix.services", _serviceList, true, this, null,
            null); // $NON-NLS-1$ $NON-NLS-3$ $NLX-ManifestEditorPage.Service-2$

    // Create the Buttons
    Composite btnContainer = new Composite(container, SWT.NONE);
    btnContainer.setLayout(SWTLayoutUtils.createLayoutNoMarginDefaultSpacing(3));
    btnContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    btnContainer.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));

    // Add Button
    Button addBtn = new Button(btnContainer, SWT.PUSH);
    addBtn.setText("Add"); // $NLX-ManifestEditorPage.Add-1$
    addBtn.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            _serviceTableEditor.createItem(new TableEntry("Service")); // $NLX-ManifestEditorPage.Service.1-1$
        }/*  w  w w  .  j  a va  2  s .c  o  m*/
    });

    // Delete Button
    Button delBtn = new Button(btnContainer, SWT.PUSH);
    delBtn.setText("Delete"); // $NLX-ManifestEditorPage.Delete-1$
    delBtn.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            _serviceTableEditor.deleteItem();
        }
    });

    // Choose button
    Button chooseBtn = new Button(btnContainer, SWT.PUSH);
    chooseBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, true, 1, 1));
    chooseBtn.setText("Choose..."); // $NLX-ManifestEditorPage.Choose-1$
    chooseBtn.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            if (BluemixUtil.isServerConfigured()) {
                boolean success = false;
                try {
                    // Retrieve the Services List from the Cloud Space
                    ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
                    dialog.run(true, true, new GetBluemixServices());
                    success = true;
                } catch (InvocationTargetException e) {
                    MessageDialog.openError(getShell(), "Error retrieving services",
                            BluemixUtil.getErrorText(e)); // $NLX-ManifestEditorPage.ErrorRetrievingServices-1$
                } catch (InterruptedException e) {
                    // Ignore
                }
                if (success) {
                    // Open the Services Dialog
                    if (_cloudServices.size() == 0) {
                        MessageDialog.openInformation(getShell(),
                                BluemixUtil.productizeString("%BM_PRODUCT% Services"),
                                "There are no defined services in this Cloud Space"); // $NLX-ManifestEditorPage.IBMBluemixServices-1$ $NLX-ManifestEditorPage.TherearenodefinedServicesinthisCl-2$
                    } else {
                        ManifestServicesDialog dialog = new ManifestServicesDialog(getShell(), _cloudServices,
                                _serviceList);
                        if (dialog.open() == Dialog.OK) {
                            updateServices();
                            _serviceTableEditor.refresh();
                        }
                    }
                }
            }
        }
    });

    section.setClient(container);
}

From source file:com.microsoft.tfs.client.common.ui.framework.runnable.DeferredProgressMonitorDialogContext.java

License:Open Source License

private Job createProgressUIJob(final IRunnableWithProgress inputRunnable,
        final RunnableWithProgressWrapper wrappedRunnable, final ProgressMonitorDialog dialog) {
    return new Job("") //$NON-NLS-1$
    {/*  w  ww.  j av a 2  s. co m*/
        @Override
        protected IStatus run(final IProgressMonitor monitor) {
            Display.getDefault().asyncExec(new Runnable() {
                @Override
                public void run() {
                    setUserInterfaceActive(true);

                    /*
                     * Note that this job is executed regardless of whether
                     * the command is still executing. If it has finished,
                     * the progress monitor dialog will be disposed (and
                     * getShell will return null.)
                     */
                    if (dialog.getShell() != null) {
                        /*
                         * Attempt to avoid a UI hang problem. If there is
                         * already a modal Shell, opening the progress
                         * monitor will result in multiple modal Shells.
                         * Note that this cannot be avoided with a
                         * parent-child relationship on all window managers.
                         *
                         * If this occurs, reschedule this deferred runnable
                         * for another interval of the deferTimeMillis. The
                         * blocking dialog may have been removed in this
                         * time (eg, in the case of an authentication
                         * dialog.)
                         */
                        final Shell blocker = ShellUtils.getModalBlockingShell(dialog.getShell());
                        if (blocker != null) {
                            final String messageFormat = "unsafe modal operation - shell [{0} ({1})] for [{2}] blocked by shell [{3} ({4})]"; //$NON-NLS-1$
                            final String message = MessageFormat.format(messageFormat, dialog.getShell(),
                                    Integer.toHexString(System.identityHashCode(dialog.getShell())),
                                    inputRunnable, blocker,
                                    Integer.toHexString(System.identityHashCode(blocker)));

                            log.info(message);

                            /* Requeue the dialog */
                            final Job showProgressUIJob = createProgressUIJob(inputRunnable, wrappedRunnable,
                                    dialog);

                            showProgressUIJob.setSystem(true);
                            showProgressUIJob.schedule(deferTimeMillis);

                            return;
                        }
                    }

                    if (dialog.getShell() != null) {
                        if (log.isTraceEnabled()) {
                            final String messageFormat = "opening shell [{0} ({1})] for [{2}]"; //$NON-NLS-1$
                            final String message = MessageFormat.format(messageFormat, dialog.getShell(),
                                    Integer.toHexString(System.identityHashCode(dialog.getShell())),
                                    inputRunnable);

                            log.trace(message);
                        }
                    }

                    /*
                     * It is safe to call dialog.open() even when the
                     * command has finished executing.
                     */
                    dialog.open();

                    /*
                     * this line works around a problem with progress
                     * monitor dialog: updates to the task name are not
                     * always displayed if openOnRun is false and the
                     * updates are made before the dialog is opened
                     *
                     * the fix is to cache changes made to the task name
                     * (through the interface wrapper classes defined below)
                     * and re-set the task name to the same value at a same
                     * time (after the dialog has opened)
                     */
                    wrappedRunnable.getCustomProgressMonitor().updateTaskNameIfSet();
                }
            });
            return Status.OK_STATUS;
        }
    };
}

From source file:com.microsoft.tfs.client.eclipse.ui.actions.sync.ExternalCompareAction.java

License:Open Source License

@Override
public void run() {
    final AdaptedSelectionInfo selectionInfo = ActionHelpers.adaptSelectionToStandardResources(
            getStructuredSelection(), PluginResourceFilters.IN_REPOSITORY_FILTER, false);

    if (ActionHelpers.ensureNonZeroResourceCountAndSingleRepository(selectionInfo, getShell()) == false) {
        return;/*from   w w  w. j a v  a 2 s.c o m*/
    }

    final IResource localResource = selectionInfo.getResources()[0];

    String localFile = localResource.exists() ? localResource.getLocation().toOSString() : null;
    String remoteTempFile = null;

    /*
     * Open a progress dialog because we'll be fetching content from the
     * server.
     */
    final ProgressMonitorDialog monitorDialog = new ProgressMonitorDialog(getShell());
    monitorDialog.open();

    final IProgressMonitor progressMonitor = monitorDialog.getProgressMonitor();
    progressMonitor.beginTask(Messages.getString("ExternalCompareAction.ProgressText"), 100); //$NON-NLS-1$

    try {
        /*
         * If the local file doesn't exist (due to deletion or incoming
         * addition, etc) then we need to make a dummy blank file for it so
         * that the external compare tool doesn't choke.
         */
        if (localFile == null) {
            try {
                final File tempDir = TempStorageService.getInstance().createTempDirectory();

                localFile = File.createTempFile("LocalNonexistant", //$NON-NLS-1$
                        "." + localResource.getFileExtension(), //$NON-NLS-1$
                        tempDir).getAbsolutePath();
            } catch (final IOException e) {
                log.error("Error creating an empty local file as substitute for missing resource", e); //$NON-NLS-1$
                // let the localFile == null test show errors
            }
        }

        /*
         * Get the remote file as a temp file.
         */
        try {
            final SyncInfo syncInfo = SynchronizeSubscriber.getInstance().getSyncInfo(localResource);

            if (syncInfo != null) {
                final IResourceVariant variant = syncInfo.getRemote();

                // variant is non-null normally...
                if (variant != null) {
                    final SubProgressMonitor getMonitor = new SubProgressMonitor(progressMonitor, 75);
                    final IStorage storage = variant.getStorage(getMonitor);

                    // if there's a path to the storage, then the remote
                    // item
                    // was found normally
                    if (storage != null && storage.getFullPath() != null) {
                        remoteTempFile = storage.getFullPath().toOSString();
                    }

                    // otherwise, the remote item is a deletion or a rename,
                    // create a blank temp file for the external compare
                    // tool
                    else {
                        final File tempDir = TempStorageService.getInstance().createTempDirectory();

                        remoteTempFile = File.createTempFile("RemoteNonexistant", //$NON-NLS-1$
                                "." + localResource.getFileExtension(), //$NON-NLS-1$
                                tempDir).getAbsolutePath();
                    }
                }
            }
        } catch (final Exception e) {
            log.error("Error getting the remote file contents", e); //$NON-NLS-1$
            // suppress, fall-through to remoteFile == null test
        }
    } finally {
        progressMonitor.done();
        monitorDialog.close();
    }

    // SynchronizeSusbcriber.getSyncInfo().getRemote().getStorage()
    // should always return (even when in-sync, it will hit the
    // server intelligently.)
    if (remoteTempFile == null) {
        MessageDialog.openError(getShell(), Messages.getString("ExternalCompareAction.CompareErrorDialogTitle"), //$NON-NLS-1$
                Messages.getString("ExternalCompareAction.CompareErrorDialogText")); //$NON-NLS-1$
        return;
    }

    final Compare compare = new Compare();

    compare.setModified(CompareUtils.createCompareElementForLocalPath(localFile, ResourceType.FILE));

    compare.setOriginal(CompareUtils.createCompareElementForLocalPath(remoteTempFile, ResourceType.FILE));

    compare.addComparator(TFSItemContentComparator.INSTANCE);

    compare.setExternalCompareHandler(new UserPreferenceExternalCompareHandler(getShell()));
    compare.open();
}

From source file:com.mmyumu.magictome.handlers.SaveHandler.java

License:Open Source License

@Execute
public void execute(IEclipseContext context, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell,
        @Named(IServiceConstants.ACTIVE_PART) final MContribution contribution)
        throws InvocationTargetException, InterruptedException {
    final IEclipseContext pmContext = context.createChild();

    ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
    dialog.open();
    dialog.run(true, true, new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            pmContext.set(IProgressMonitor.class.getName(), monitor);
            if (contribution != null) {
                // Object clientObject = contribution.getObject();
                //               ContextInjectionFactory.invoke(clientObject, Persist.class, //$NON-NLS-1$
                // pmContext, null);
            }//from  ww w  . jav a2  s . c  o m
        }
    });

    pmContext.dispose();
}