List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog getProgressMonitor
public IProgressMonitor getProgressMonitor()
From source file:org.eclipse.emf.emfstore.client.ui.views.emfstorebrowser.dialogs.admin.acimport.wizard.AcUserImportPageOne.java
License:Open Source License
/** * @param parent/* ww w . j av a2 s .c om*/ * The parent Composite which gets filled here. * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ public void createControl(Composite parent) { // Set the specific help (performHelp() didn't work as expected). // See: // http://stackoverflow.com/questions/1012929/eclipse-contextual-help/1021718 // http://dev.eclipse.org/newslists/news.eclipse.platform.ua/msg00359.html PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, Activator.PLUGIN_ID + ".help_import_wizard_page_one"); final Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(1, false)); Label label = new Label(composite, SWT.None); label.setText("Choose your import source."); Button[] radios = new Button[list.size()]; int i = 0; for (final ImportSource src : list) { radios[i] = new Button(composite, SWT.RADIO); radios[i].setText(src.getLabel()); radios[i].setBounds(30, 5, 200, 30); radios[i].addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // do this only if item gets checked, not unchecked! boolean isCurrentrlySelected = ((Button) e.getSource()).getSelection(); if (isCurrentrlySelected) { AcUserImportPageTwo nextPage = (AcUserImportPageTwo) getNextPage(); AcUserImportWizard wizard = (AcUserImportWizard) getWizard(); wizard.getController().setImportSource(src); if (src.init(getShell())) { ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(getShell()); progressMonitorDialog.open(); progressMonitorDialog.getProgressMonitor().beginTask("loading", IProgressMonitor.UNKNOWN); nextPage.init(src); progressMonitorDialog.close(); setPageComplete(true); getContainer().showPage(getNextPage()); } } } }); i++; } setControl(composite); setPageComplete(false); }
From source file:org.eclipse.emf.emfstore.client.ui.views.emfstorebrowser.dialogs.admin.acimport.wizard.AcUserImportWizard.java
License:Open Source License
/** * @see org.eclipse.jface.wizard.Wizard#performFinish() * @return a boolean which indicates, if there are items selected or not. *//*from w w w . jav a 2s . c o m*/ @Override public boolean performFinish() { ArrayList<ImportItemWrapper> wrappedOrgUnits = ((AcUserImportPageTwo) this.getPages()[1]).getCheckedItems(); if (wrappedOrgUnits.size() > 0) { ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(getShell()); progressMonitorDialog.open(); progressMonitorDialog.getProgressMonitor().beginTask("Importing users", IProgressMonitor.UNKNOWN); importController.importOrgUnits(wrappedOrgUnits); progressMonitorDialog.close(); return true; } else { return false; } }
From source file:org.eclipse.emf.emfstore.internal.client.ui.dialogs.admin.acimport.LdapSourceDialog.java
License:Open Source License
/** * {@inheritDoc}/*www. j a v a2 s.c o m*/ */ @Override public void okPressed() { ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(getShell()); progressMonitorDialog.open(); progressMonitorDialog.getProgressMonitor().beginTask(Messages.LdapSourceDialog_Connecting, IProgressMonitor.UNKNOWN); Properties serverProperties = new Properties(); serverProperties.put(Context.PROVIDER_URL, serverName.getText()); serverProperties.put(LdapImportSource.LDAP_BASE, ldapBase.getText()); this.ldapImport.setProperties(serverProperties); try { this.ldapImport.connect(); this.isInitFinished = true; progressMonitorDialog.close(); } catch (CorruptedSourceException e) { progressMonitorDialog.close(); this.isInitFinished = false; EMFStoreMessageDialog.showExceptionDialog(Messages.LdapSourceDialog_ExceptionMessage, e); } this.isOkPressed = true; close(); }
From source file:org.eclipse.emf.emfstore.internal.client.ui.dialogs.admin.acimport.wizard.AcUserImportPageOne.java
License:Open Source License
/** * @param parent//from www. java 2 s. c om * The parent Composite which gets filled here. * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ public void createControl(Composite parent) { // Set the specific help (performHelp() didn't work as expected). // See: // http://stackoverflow.com/questions/1012929/eclipse-contextual-help/1021718 // http://dev.eclipse.org/newslists/news.eclipse.platform.ua/msg00359.html PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, Activator.PLUGIN_ID + ".help_import_wizard_page_one"); //$NON-NLS-1$ final Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(1, false)); final Label label = new Label(composite, SWT.None); label.setText(Messages.AcUserImportPageOne_ChooseImportSource + "."); //$NON-NLS-1$ final Button[] radios = new Button[list.size()]; int i = 0; for (final ImportSource src : list) { radios[i] = new Button(composite, SWT.RADIO); radios[i].setText(src.getLabel()); radios[i].setBounds(30, 5, 200, 30); radios[i].addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // do this only if item gets checked, not unchecked! final boolean isCurrentrlySelected = ((Button) e.getSource()).getSelection(); if (isCurrentrlySelected) { final AcUserImportPageTwo nextPage = (AcUserImportPageTwo) getNextPage(); final AcUserImportWizard wizard = (AcUserImportWizard) getWizard(); wizard.getController().setImportSource(src); if (src.init(getShell())) { final ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog( getShell()); progressMonitorDialog.open(); progressMonitorDialog.getProgressMonitor() .beginTask(Messages.AcUserImportPageOne_Loading, IProgressMonitor.UNKNOWN); nextPage.init(src); progressMonitorDialog.close(); setPageComplete(true); getContainer().showPage(getNextPage()); } } } }); i++; } setControl(composite); setPageComplete(false); }
From source file:org.eclipse.emf.emfstore.internal.client.ui.dialogs.admin.acimport.wizard.AcUserImportWizard.java
License:Open Source License
/** * @see org.eclipse.jface.wizard.Wizard#performFinish() * @return a boolean which indicates, if there are items selected or not. *///from ww w . j av a 2s. c o m @Override public boolean performFinish() { final ArrayList<ImportItemWrapper> wrappedOrgUnits = ((AcUserImportPageTwo) getPages()[1]) .getCheckedItems(); if (wrappedOrgUnits.size() > 0) { final ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(getShell()); progressMonitorDialog.open(); progressMonitorDialog.getProgressMonitor().beginTask(Messages.AcUserImportWizard_ImportingUsers, IProgressMonitor.UNKNOWN); importController.importOrgUnits(wrappedOrgUnits); progressMonitorDialog.close(); return true; } return false; }
From source file:org.eclipse.equinox.p2.ui.RevertProfilePage.java
License:Open Source License
boolean revert() { final IProfile snapshot = getSelectedSnapshot(); if (snapshot == null) return false; final IProvisioningPlan[] plan = new IProvisioningPlan[1]; IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { IProfile currentProfile;// ww w.j a v a 2 s.c o m IProfileRegistry registry = ProvUI.getProfileRegistry(getSession()); IPlanner planner = (IPlanner) getSession().getProvisioningAgent().getService(IPlanner.SERVICE_NAME); currentProfile = registry.getProfile(profileId); plan[0] = planner.getDiffPlan(currentProfile, snapshot, monitor); } }; ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); try { dialog.run(true, true, runnable); } catch (InvocationTargetException e) { ProvUI.handleException(e.getCause(), null, StatusManager.SHOW | StatusManager.LOG); } catch (InterruptedException e) { // nothing to report } // the dialog does not throw OperationCanceledException so we have to // check the monitor if (dialog.getProgressMonitor().isCanceled()) return false; boolean reverted = false; if (plan[0] != null) { if (plan[0].getStatus().isOK()) { // We use a default provisioning context (all repos) because we have no other // way currently to figure out which sites the user wants to contact ProfileModificationJob op = new ProfileModificationJob( ProvUIMessages.RevertDialog_RevertOperationLabel, getSession(), profileId, plan[0], new ProvisioningContext(getSession().getProvisioningAgent())); // we want to force a restart (not allow apply changes) op.setRestartPolicy(ProvisioningJob.RESTART_ONLY); getProvisioningUI().schedule(op, StatusManager.SHOW | StatusManager.LOG); reverted = true; } else if (plan[0].getStatus().getSeverity() != IStatus.CANCEL) { ProvUI.reportStatus(plan[0].getStatus(), StatusManager.LOG | StatusManager.SHOW); // This message has no effect in an installation dialog // setMessage(ProvUIMessages.ProfileModificationWizardPage_UnexpectedError, IMessageProvider.ERROR); } } return reverted; }
From source file:org.eclipse.gef4.cloudio.examples.application.actions.LoadFileAction.java
License:Open Source License
@Override public void run(IAction action) { FileDialog dialog = new FileDialog(getShell(), SWT.OPEN); dialog.setText("Select text file..."); String sourceFile = dialog.open(); if (sourceFile == null) return;/*from w ww .ja v a 2s . co m*/ ProgressMonitorDialog pd = new ProgressMonitorDialog(getShell()); try { List<Type> types = TypeCollector.getData(new File(sourceFile), "UTF-8"); pd.setBlockOnOpen(false); pd.open(); pd.getProgressMonitor().beginTask("Generating cloud...", 200); TagCloudViewer viewer = getViewer(); viewer.setInput(types, pd.getProgressMonitor()); //viewer.getCloud().layoutCloud(pd.getProgressMonitor(), false); } catch (IOException e) { e.printStackTrace(); } finally { pd.close(); } }
From source file:org.eclipse.gef4.cloudio.examples.application.ui.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 addMaskButton(Composite parent) { Group buttons = new Group(parent, SWT.SHADOW_IN); buttons.setLayout(new GridLayout(2, true)); buttons.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); Label l = new Label(buttons, SWT.NONE); l.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); l.setText("Mask"); Button file = new Button(buttons, SWT.FLAT); file.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); file.setText("Open..."); file.addListener(SWT.Selection, new Listener() { @Override//from www. j a v a2 s . co m public void handleEvent(Event event) { FileDialog fd = new FileDialog(getShell(), SWT.OPEN); fd.setText("Select a square b&w png image as mask..."); String sourceFile = fd.open(); if (sourceFile == null) return; try { ImageLoader loader = new ImageLoader(); BufferedInputStream in = new BufferedInputStream( new FileInputStream(new File(sourceFile))); ImageData[] data = loader.load(in); in.close(); viewer.getCloud().setBackgroundMask(data[0]); } catch (Exception e) { e.printStackTrace(); } } }); return buttons; } protected void addGroups() { addMaskButton(this); super.addGroups(); } 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.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) { } }); scale.select(1); 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:org.eclipse.gef4.cloudio.internal.ui.actions.LoadFileAction.java
License:Open Source License
@Override public void run(IAction action) { FileDialog dialog = new FileDialog(getShell(), SWT.OPEN); dialog.setText("Select text file..."); String sourceFile = dialog.open(); if (sourceFile == null) return;// ww w. j a v a 2s . c om ProgressMonitorDialog pd = new ProgressMonitorDialog(getShell()); try { List<Type> types = TypeCollector.getData(new File(sourceFile), "UTF-8"); pd.setBlockOnOpen(false); pd.open(); pd.getProgressMonitor().beginTask("Generating cloud...", 200); TagCloudViewer viewer = getViewer(); viewer.setInput(types, pd.getProgressMonitor()); // viewer.getCloud().layoutCloud(pd.getProgressMonitor(), false); } catch (IOException e) { e.printStackTrace(); } finally { pd.close(); } }
From source file:org.eclipse.gef4.cloudio.internal.ui.view.TagCloudView.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 addMaskButton(Composite parent) { Group buttons = new Group(parent, SWT.SHADOW_IN); buttons.setLayout(new GridLayout(2, true)); buttons.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); Label l = new Label(buttons, SWT.NONE); l.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); l.setText("Mask"); Button file = new Button(buttons, SWT.FLAT); file.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); file.setText("Open..."); file.addListener(SWT.Selection, new Listener() { @Override/*from w w w . j av a 2 s. c o m*/ public void handleEvent(Event event) { FileDialog fd = new FileDialog(getShell(), SWT.OPEN); fd.setText("Select a square b&w png image as mask..."); String sourceFile = fd.open(); if (sourceFile == null) return; try { ImageLoader loader = new ImageLoader(); BufferedInputStream in = new BufferedInputStream( new FileInputStream(new File(sourceFile))); ImageData[] data = loader.load(in); in.close(); viewer.getCloud().setBackgroundMask(data[0]); } catch (Exception e) { e.printStackTrace(); } } }); return buttons; } protected void addGroups() { addMaskButton(this); super.addGroups(); } 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.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) { } }); scale.select(1); 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); }