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

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

Introduction

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

Prototype

public IProgressMonitor getProgressMonitor() 

Source Link

Document

Returns the progress monitor to use for operations run in this progress dialog.

Usage

From source file:BMVirtualFindAction.java

License:Open Source License

public void run() {
    final VirtualViewerListener listener = new VirtualViewerListener();
    VirtualTreeModelViewer virtualViewer = initVirtualViewer(fClientViewer, listener);

    ProgressMonitorDialog dialog = new TimeTriggeredProgressMonitorDialog(fClientViewer.getControl().getShell(),
            500);//from   w  w  w .j a  va 2  s.  c om
    final IProgressMonitor monitor = dialog.getProgressMonitor();
    dialog.setCancelable(true);

    try {
        dialog.run(true, true, new IRunnableWithProgress() {
            public void run(final IProgressMonitor m) throws InvocationTargetException, InterruptedException {
                synchronized (listener) {
                    listener.fProgressMonitor = m;
                    listener.fProgressMonitor.beginTask(DebugUIPlugin.removeAccelerators(getText()),
                            listener.fRemainingUpdatesCount);
                }

                while ((!listener.fLabelUpdatesComplete || !listener.fViewerUpdatesComplete)
                        && !listener.fProgressMonitor.isCanceled()) {
                    Thread.sleep(1);
                }
                synchronized (listener) {
                    listener.fProgressMonitor = null;
                }
            }
        });
    } catch (InvocationTargetException e) {
        DebugUIPlugin.log(e);
        return;
    } catch (InterruptedException e) {
        return;
    }

    VirtualItem root = virtualViewer.getTree();
    if (!monitor.isCanceled()) {
        List<VirtualItem> list = new ArrayList<VirtualItem>();
        collectAllChildren(root, list);
        FindLabelProvider labelProvider = new FindLabelProvider(virtualViewer, list);
        VirtualItem result = performFind(list, labelProvider);
        if (result != null) {
            setSelectionToClient(virtualViewer, labelProvider, result);
        }
    }

    virtualViewer.removeLabelUpdateListener(listener);
    virtualViewer.removeViewerUpdateListener(listener);
    virtualViewer.dispose();
}

From source file:be.ibridge.kettle.spoon.SpoonGraph.java

License:LGPL

/**
 * Display the input- or outputfields for a step.
 * //from  w ww  .j a v a  2  s  .co m
 * @param stepMeta The step (it's metadata) to query
 * @param before set to true if you want to have the fields going INTO the step, false if you want to see all the
 * fields that exit the step.
 */
private void inputOutputFields(StepMeta stepMeta, boolean before) {
    spoon.refreshGraph();

    SearchFieldsProgressDialog op = new SearchFieldsProgressDialog(transMeta, stepMeta, before);
    try {
        final Thread parentThread = Thread.currentThread();
        final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);

        // Run something in the background to cancel active database queries, forecably if needed!
        Runnable run = new Runnable() {
            public void run() {
                // This is running in a new process: copy some KettleVariables info
                LocalVariables.getInstance().createKettleVariables(Thread.currentThread().getName(),
                        parentThread.getName(), true);

                IProgressMonitor monitor = pmd.getProgressMonitor();
                while (pmd.getShell() == null || (!pmd.getShell().isDisposed() && !monitor.isCanceled())) {
                    try {
                        Thread.sleep(250);
                    } catch (InterruptedException e) {
                    }
                    ;
                }

                if (monitor.isCanceled()) // Disconnect and see what happens!
                {
                    try {
                        transMeta.cancelQueries();
                    } catch (Exception e) {
                    }
                    ;
                }
            }
        };
        // Dump the cancel looker in the background!
        new Thread(run).start();

        pmd.run(true, true, op);
    } catch (InvocationTargetException e) {
        new ErrorDialog(shell, Messages.getString("SpoonGraph.Dialog.GettingFields.Title"), //$NON-NLS-1$
                Messages.getString("SpoonGraph.Dialog.GettingFields.Message"), e); //$NON-NLS-1$
    } catch (InterruptedException e) {
        new ErrorDialog(shell, Messages.getString("SpoonGraph.Dialog.GettingFields.Title"), //$NON-NLS-1$
                Messages.getString("SpoonGraph.Dialog.GettingFields.Message"), e); //$NON-NLS-1$
    }

    Row fields = op.getFields();

    if (fields != null && fields.size() > 0) {
        StepFieldsDialog sfd = new StepFieldsDialog(shell, SWT.NONE, stepMeta.getName(), fields);
        String sn = (String) sfd.open();
        if (sn != null) {
            StepMeta esi = transMeta.findStep(sn);
            if (esi != null) {
                editStep(esi);
            }
        }
    } else {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
        mb.setMessage(Messages.getString("SpoonGraph.Dialog.CouldntFindFields.Message")); //$NON-NLS-1$
        mb.setText(Messages.getString("SpoonGraph.Dialog.CouldntFindFields.Title")); //$NON-NLS-1$
        mb.open();
    }

}

From source file:ch.hsr.ifs.cdt.metriculator.tagcloud.views.TagCloudViewPart.java

License:Open Source License

private void createSideTab(SashForm form) {
    Composite parent = new Composite(form, SWT.NONE);
    parent.setLayout(new GridLayout());
    parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    options = new CloudOptionsComposite(parent, SWT.NONE, viewer) {

        protected Group addLayoutButtons(Composite parent) {
            Group buttons = super.addLayoutButtons(parent);

            Label l = new Label(buttons, SWT.NONE);
            l.setText("Scale");
            final Combo scale = new Combo(buttons, SWT.DROP_DOWN | SWT.READ_ONLY);
            scale.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
            scale.setItems(new String[] { "linear", "logarithmic" });
            scale.select(1);/*from  w  ww. j  av a  2 s .c  o  m*/
            scale.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    switch (scale.getSelectionIndex()) {
                    case 0:
                        labelProvider.setScale(TypeLabelProvider.Scaling.LINEAR);
                        break;
                    case 1:
                        labelProvider.setScale(TypeLabelProvider.Scaling.LOGARITHMIC);
                        break;
                    default:
                        break;
                    }
                }

                @Override
                public void widgetDefaultSelected(SelectionEvent e) {
                }
            });
            l = new Label(buttons, SWT.NONE);
            l.setText("X Axis Variation");
            final Combo xAxis = new Combo(buttons, SWT.DROP_DOWN | SWT.READ_ONLY);
            xAxis.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
            xAxis.setItems(new String[] { "0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100" });
            xAxis.select(2);
            xAxis.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    String item = xAxis.getItem(xAxis.getSelectionIndex());
                    layouter.setOption(DefaultLayouter.X_AXIS_VARIATION, Integer.parseInt(item));

                }

                @Override
                public void widgetDefaultSelected(SelectionEvent e) {
                }
            });

            l = new Label(buttons, SWT.NONE);
            l.setText("Y Axis Variation");
            final Combo yAxis = new Combo(buttons, SWT.DROP_DOWN | SWT.READ_ONLY);
            yAxis.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
            yAxis.setItems(new String[] { "0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100" });
            yAxis.select(1);
            yAxis.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    String item = yAxis.getItem(yAxis.getSelectionIndex());
                    layouter.setOption(DefaultLayouter.Y_AXIS_VARIATION, Integer.parseInt(item));
                }

                @Override
                public void widgetDefaultSelected(SelectionEvent e) {
                }
            });

            Button run = new Button(buttons, SWT.NONE);
            run.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
            run.setText("Re-Position");
            run.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    final ProgressMonitorDialog dialog = new ProgressMonitorDialog(
                            viewer.getControl().getShell());
                    dialog.setBlockOnOpen(false);
                    dialog.open();
                    dialog.getProgressMonitor().beginTask("Layouting tag cloud...", 100);
                    viewer.reset(dialog.getProgressMonitor(), false);
                    dialog.close();
                }

                @Override
                public void widgetDefaultSelected(SelectionEvent e) {
                }
            });
            Button layout = new Button(buttons, SWT.NONE);
            layout.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
            layout.setText("Re-Layout");
            layout.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    ProgressMonitorDialog dialog = new ProgressMonitorDialog(viewer.getControl().getShell());
                    dialog.setBlockOnOpen(false);
                    dialog.open();
                    dialog.getProgressMonitor().beginTask("Layouting tag cloud...", 200);
                    viewer.setInput(viewer.getInput(), dialog.getProgressMonitor());
                    viewer.reset(dialog.getProgressMonitor(), false);
                    dialog.close();
                }

                @Override
                public void widgetDefaultSelected(SelectionEvent e) {
                }
            });
            return buttons;
        };

    };
    GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    options.setLayoutData(gd);
}

From source file:com.android.glesv2debugger.CodeGen.java

License:Apache License

void codeGenFrames(final DebugContext dbgCtx, int count, final Shell shell) {
    this.dbgCtx = dbgCtx;
    this.count = count;
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
    this.progress = dialog.getProgressMonitor();
    try {/*from   w  w w  . j  a  v a 2s . c  o m*/
        dialog.run(false, true, this);
    } catch (InvocationTargetException e) {
        e.printStackTrace();
        assert false;
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    this.dbgCtx = null;
    this.count = 0;
    progress = null;
}

From source file:com.beck.ep.team.internal.TeamListBuilder.java

License:BSD License

public String[] createList(Shell shell, IProject project) throws Exception {
    error = null;/*from w  ww  . j a  va2s .  c  o m*/
    RepositoryProvider provider = RepositoryProvider.getProvider(project);
    if (provider == null) {
        error = "No Repository provider exist. Project: " + project.getName();
        return null;
    }
    IListBuilder lb = newListBuilder(provider.getID());
    if (lb != null) {
        String[] sa = lb.createList(shell, project);
        error = lb.getError();
        return sa;
    }

    Subscriber subscriber = provider.getSubscriber();

    SyncInfoSet set = new SyncInfoSet();
    //set.add(SyncInfo.CONFLICTING);

    Filter filter = new Filter();
    ProgressMonitorDialog monitor = new ProgressMonitorDialog(shell);
    monitor.setCancelable(true);
    monitor.open();
    IResource[] members = project.members();
    subscriber.collectOutOfSync(members, IResource.DEPTH_INFINITE, set, monitor.getProgressMonitor());
    monitor.close();

    SyncInfo[] infos = set.getNodes(filter);
    String[] sa = new String[infos.length];
    for (int i = 0; i < infos.length; i++) {
        sa[i] = infos[i].getLocal().getProjectRelativePath().toString();
    }
    return sa;
}

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

License:GNU General Public License

/**
 * @see IActionDelegate#run(IAction)//from   w w  w. ja v a  2 s . com
 */
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.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;/*  w w  w.  ja  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.salesforce.ide.schemabrowser.ui.SchemaBrowser.java

License:Open Source License

private void createTree(Composite composite) {
    imageNotChecked = ForceImages.get(ForceImages.IMAGE_NOT_CHECKED);
    imageChecked = ForceImages.get(ForceImages.IMAGE_CHECKED);
    imageArrowDown = ForceImages.get(ForceImages.IMAGE_ARROW_DOWN);
    imageArrowUp = ForceImages.get(ForceImages.IMAGE_ARROW_UP);
    imageBlank = ForceImages.get(ForceImages.IMAGE_BLANK);

    final Composite thisComposite = composite;

    provider = new SchemaTreeLabelProvider();

    Tree tree = this.schemaEditorComposite.getTree();
    tree.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            if (event.item instanceof TreeItem) {
                selectedItem = (TreeItem) event.item;
            } else {
                selectedItem = null;//from  ww w .  ja  v  a 2 s . c  o  m
            }
        }

    });
    tree.addTreeListener(new org.eclipse.swt.events.TreeListener() {
        public void treeExpanded(org.eclipse.swt.events.TreeEvent e) {
            final TreeItem selectedItem = (TreeItem) e.item;
            Boolean isTopLevel = (Boolean) selectedItem.getData(IS_TOP_LEVEL);
            if ((isTopLevel != null) && isTopLevel.booleanValue()) {
                if (selectedItem.getItemCount() == 1) {
                    Runnable lt = new Runnable() {
                        public void run() {
                            ProgressMonitorDialog mon = new ProgressMonitorDialog(getShell());
                            mon.getProgressMonitor();
                            mon.setBlockOnOpen(false);
                            mon.open();
                            loadTreeData(selectedItem, thisComposite, mon.getProgressMonitor());
                            setHasCheckableChildren(selectedItem, Boolean.TRUE);
                            setIsTopLevel(selectedItem, Boolean.TRUE);
                            setItemNotChecked(selectedItem);
                            selectedItem.setImage(
                                    provider.getImage(0, selectedItem.getText(), selectedItem.getParent()));
                            mon.close();
                        }
                    };
                    Runnable lb = new Runnable() {
                        public void run() {
                            ProgressMonitorDialog mon = new ProgressMonitorDialog(getShell());
                            mon.getProgressMonitor();
                            mon.setBlockOnOpen(false);
                            mon.open();
                            mon.getProgressMonitor().beginTask("Get object definition...", 2);
                            loadObject(selectedItem.getText(), mon.getProgressMonitor());
                            mon.close();
                        }
                    };

                    getSite().getShell().getDisplay().asyncExec(lb);
                    getSite().getShell().getDisplay().asyncExec(lt);
                }
            } else {
                Integer type = (Integer) selectedItem.getData(TYPE);
                if (type != null) {
                    if (type.equals(SchemaBrowser.CHILD_RELATIONSHIP_NODE)
                            && selectedItem.getData(LOADED).equals(Boolean.FALSE)) {
                        Runnable getThisChildSchema = new Runnable() {
                            public void run() {
                                ProgressMonitorDialog mon = new ProgressMonitorDialog(getShell());
                                mon.getProgressMonitor();
                                mon.setBlockOnOpen(false);
                                mon.open();
                                mon.getProgressMonitor().beginTask(MESSAGE_GETTING_CHILD, 2);
                                loadOneChildRelationship(selectedItem, mon.getProgressMonitor());
                                mon.close();
                            }
                        };

                        getSite().getShell().getDisplay().asyncExec(getThisChildSchema);

                    } else if (SchemaBrowser.LOOKUP_RELATIONSHIP_NODE.equals(type)
                            && Boolean.FALSE.equals(selectedItem.getData(LOADED))) {
                        Runnable getThisChildSchema = new Runnable() {
                            public void run() {
                                ProgressMonitorDialog mon = new ProgressMonitorDialog(getShell());
                                mon.getProgressMonitor();
                                mon.setBlockOnOpen(false);
                                mon.open();
                                mon.getProgressMonitor().beginTask(MESSAGE_GETTING_LOOKUP, 2);
                                loadOneChildRelationship(selectedItem, mon.getProgressMonitor());
                                mon.close();
                            }
                        };

                        getSite().getShell().getDisplay().asyncExec(getThisChildSchema);
                    }
                }

            }
            wasExpanded = true;
        }

        public void treeCollapsed(org.eclipse.swt.events.TreeEvent e) {
            wasExpanded = true;
        }
    });

    tree.addMouseListener(new org.eclipse.swt.events.MouseListener() {
        public void mouseUp(org.eclipse.swt.events.MouseEvent e) {
            if (!wasExpanded) {
                if (selectedItem != null) {
                    if (selectedItem.getImage() != null) {
                        Rectangle rect = selectedItem.getBounds();
                        Image img = selectedItem.getImage();
                        Rectangle imgRect = img.getBounds();
                        int leftMost = rect.x - imgRect.width - 3;
                        int rightMost = rect.x - 3;
                        if ((e.x >= leftMost) && (e.x <= rightMost)) {
                            Integer imageType = (Integer) selectedItem.getData(IMAGE_TYPE);
                            if (imageType != null) {
                                if (imageType.intValue() == IMAGE_TYPE_CHECKED) {
                                    setItemChecked(selectedItem);
                                } else {
                                    setItemNotChecked(selectedItem);
                                }

                                Integer type = (Integer) selectedItem.getData(TYPE);
                                if (SchemaBrowser.CHILD_RELATIONSHIP_NODE.equals(type)
                                        && Boolean.FALSE.equals(selectedItem.getData(LOADED))) {
                                    if ((selectedItem.getData(LOADED) != null)
                                            && Boolean.FALSE.equals(selectedItem.getData(LOADED))) {
                                        Runnable getThisChildSchema = new Runnable() {
                                            public void run() {
                                                ProgressMonitorDialog mon = new ProgressMonitorDialog(
                                                        getShell());
                                                mon.getProgressMonitor();
                                                mon.setBlockOnOpen(false);
                                                mon.open();
                                                mon.getProgressMonitor().beginTask(MESSAGE_GETTING_CHILD, 2);
                                                loadOneChildRelationship(selectedItem,
                                                        mon.getProgressMonitor());
                                                mon.close();
                                            }
                                        };

                                        getSite().getShell().getDisplay().syncExec(getThisChildSchema);

                                    }
                                } else if (SchemaBrowser.LOOKUP_RELATIONSHIP_NODE.equals(type)
                                        && Boolean.FALSE.equals(selectedItem.getData(LOADED))) {
                                    Runnable getThisChildSchema = new Runnable() {
                                        public void run() {
                                            ProgressMonitorDialog mon = new ProgressMonitorDialog(getShell());
                                            mon.getProgressMonitor();
                                            mon.setBlockOnOpen(false);
                                            mon.open();
                                            mon.getProgressMonitor().beginTask(MESSAGE_GETTING_LOOKUP, 2);
                                            loadOneChildRelationship(selectedItem, mon.getProgressMonitor());
                                            mon.close();
                                        }
                                    };

                                    getSite().getShell().getDisplay().asyncExec(getThisChildSchema);
                                }

                                setChildren(selectedItem,
                                        ((Integer) selectedItem.getData(IMAGE_TYPE)).intValue());

                                while (selectedItem.getParentItem() != null) {
                                    TreeItem parent = selectedItem.getParentItem();
                                    boolean setParent = true;
                                    for (int i = 0; i < parent.getItemCount(); i++) {
                                        if (!parent.getItem(i).equals(selectedItem)
                                                && parent.getItem(i).getImage().equals(imageChecked)) {
                                            setParent = false;
                                            break;
                                        }
                                    }

                                    if (!setParent) {
                                        break;
                                    }
                                    if (imageType.intValue() == 0) {
                                        setItemChecked(parent);
                                    } else {
                                        setItemNotChecked(parent);
                                    }
                                    selectedItem = parent;
                                }
                                fireSelectionChanged(selectedItem);
                            }
                        }
                    }
                }
            }
            wasExpanded = false;
        }

        public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e) {
        }

        public void mouseDown(org.eclipse.swt.events.MouseEvent e) {
        }
    });
    initialize();
}

From source file:com.salesforce.ide.upgrade.ui.wizards.CompareDialog.java

License:Open Source License

public int open() {

    int rc = super.open();

    if (rc == OK && fCompareEditorInput.isSaveNeeded()) {

        WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
            public void execute(IProgressMonitor pm) throws CoreException {
                fCompareEditorInput.saveChanges(pm);
            }/*from   w ww. jav  a 2  s  .co m*/
        };

        Shell shell = getParentShell();
        ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
        try {
            operation.run(pmd.getProgressMonitor());

        } catch (InterruptedException x) {
            // NeedWork
        } catch (OperationCanceledException x) {
            // NeedWork
        } catch (InvocationTargetException x) {
            String title = Utilities.getString("CompareDialog.saveErrorTitle"); //$NON-NLS-1$
            String msg = Utilities.getString("CompareDialog.saveErrorMessage"); //$NON-NLS-1$
            MessageDialog.openError(shell, title, msg + x.getTargetException().getMessage());
        }
    }

    return rc;
}

From source file:de.jcup.egradle.eclipse.ide.ui.RootProjectConfigUIDelegate.java

License:Apache License

private void createValidationGroup(Composite parent) {
    if (!mode.isValidationGroupNeeded()) {
        return;/*from   w w w .ja  v a 2 s. c o  m*/
    }
    /* ------------------------------------ */
    /* - Check output - */
    /* ------------------------------------ */
    GridData groupLayoutData = new GridData();
    groupLayoutData.horizontalAlignment = GridData.FILL;
    groupLayoutData.verticalAlignment = GridData.FILL;
    groupLayoutData.grabExcessHorizontalSpace = true;
    groupLayoutData.grabExcessVerticalSpace = true;
    groupLayoutData.verticalSpan = 2;
    groupLayoutData.horizontalSpan = 3;

    Group validationGroup = SWTFactory.createGroup(parent, "Validate preferences correct", 1, 10, SWT.FILL);
    validationGroup.setLayoutData(groupLayoutData);

    GridData labelGridData = new GridData();
    labelGridData.horizontalAlignment = GridData.FILL;
    labelGridData.verticalAlignment = GridData.BEGINNING;
    labelGridData.grabExcessHorizontalSpace = false;
    labelGridData.grabExcessVerticalSpace = false;

    GridData gridDataLastColumn = new GridData();
    gridDataLastColumn.horizontalAlignment = GridData.FILL;
    gridDataLastColumn.verticalAlignment = GridData.FILL;
    gridDataLastColumn.grabExcessHorizontalSpace = true;
    gridDataLastColumn.grabExcessVerticalSpace = true;
    gridDataLastColumn.verticalSpan = 2;
    gridDataLastColumn.horizontalSpan = 2;
    gridDataLastColumn.minimumHeight = 50;
    gridDataLastColumn.heightHint = 100;

    validationOutputField = new Text(validationGroup, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY);
    validationOutputField.setLayoutData(gridDataLastColumn);

    validationButton = new Button(validationGroup, SWT.NONE);
    validationButton.setText("Start validation");
    validationButton.setImage(getValidationButtonImage());

    validationButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (validationRunning == true) {
                return;
            }
            setValid(false);
            handleValidationRunning(true);
            validationOutputField.setText("Start validation...\n");

            OutputHandler validationOutputHandler = new OutputHandler() {

                @Override
                public void output(String line) {
                    EclipseUtil.safeAsyncExec(new Runnable() {

                        @Override
                        public void run() {
                            validationOutputField.append(line + "\n");
                        }
                    });
                }

            };

            MutableGradleConfiguration configuration = new MutableGradleConfiguration();
            configuration.setGradleCommand(getGradleCommand());
            configuration.setGradleBinDirectory(getGradleBinDirectory());
            configuration.setShellCommand(getShellCommand());
            configuration.setWorkingDirectory(getWorkingDirectory());
            configuration.setJavaHome(getGlobalJavaHomePath());

            startValidation(validationOutputHandler, configuration);
        }

        private void startValidation(OutputHandler validationOutputHandler,
                MutableGradleConfiguration configuration) {
            try {
                RootProjectConfigUIDelegate observer = RootProjectConfigUIDelegate.this;
                ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(
                        EclipseUtil.getActiveWorkbenchShell());

                RootProjectValidationProgressRunnable runnable = new RootProjectValidationProgressRunnable(
                        new CancelStateProvider() {

                            @Override
                            public boolean isCanceled() {
                                return progressMonitorDialog.getProgressMonitor().isCanceled();
                            }

                        }, configuration, observer, validationOutputHandler);
                /*
                 * use own progress monitor dialog here - progress service
                 * did not work well because this is in model state
                 */
                progressMonitorDialog.run(true, true, runnable);
            } catch (InvocationTargetException | InterruptedException e1) {
                IDEUtil.logError("Was not able to execute validation", e1);
            }
        }
    });
}