use of org.eclipse.jface.wizard.ProgressMonitorPart in project eclipse.platform.text by eclipse.
the class ExtendedDialogWindow method createDialogArea.
/**
* Creates the layout of the extended dialog window.
* @param parent The parent composite
* @return The created control
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite result = (Composite) super.createDialogArea(parent);
fContents = createPageArea(result);
fContents.setLayoutData(new GridData(GridData.FILL_BOTH));
if (fUseEmbeddedProgressMonitorPart) {
// Insert a progress monitor
fProgressMonitorPart = new ProgressMonitorPart(result, new GridLayout(), SWT.DEFAULT);
fProgressMonitorPart.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fProgressMonitorPart.setVisible(false);
applyDialogFont(fProgressMonitorPart);
}
Label separator = new Label(result, SWT.SEPARATOR | SWT.HORIZONTAL);
separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
return result;
}
use of org.eclipse.jface.wizard.ProgressMonitorPart in project linuxtools by eclipse.
the class RunScriptHandler method tryEditorSave.
/**
* If an editor containing the file to be run is open & dirty, save it, if appropriate.
* @param event
*/
private void tryEditorSave(final ExecutionEvent event) {
// No need to save if the script will already be saved with its project when launched.
if (project != null) {
return;
}
if (targetEditor != null && targetEditor.isDirty()) {
Display.getDefault().syncExec(() -> {
Shell shell = event != null ? HandlerUtil.getActiveShell(event) : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
targetEditor.doSave(new ProgressMonitorPart(shell, new FillLayout()));
});
}
}
use of org.eclipse.jface.wizard.ProgressMonitorPart in project eclipse-integration-commons by spring-projects.
the class DashboardExtensionsPage method createFormContent.
@Override
protected void createFormContent(final IManagedForm managedForm) {
Composite body = managedForm.getForm().getBody();
body.setLayout(new GridLayout(5, false));
discoveryViewer = new DashboardDiscoveryViewer(getSite(), this);
initialize(discoveryViewer);
discoveryViewer.setDirectoryUrl(ResourceProvider.getUrl(RESOURCE_DISCOVERY_DIRECTORY).replace("%VERSION%", IdeUiUtils.getShortVersion()));
discoveryViewer.setShowConnectorDescriptorKindFilter(false);
discoveryViewer.createControl(body);
FormToolkit toolkit = managedForm.getToolkit();
adaptRecursively(discoveryViewer.getControl(), toolkit);
GridDataFactory.fillDefaults().span(5, 1).grab(true, true).applyTo(discoveryViewer.getControl());
findUpdatesButton = toolkit.createButton(body, "&Find Updates", SWT.NONE);
findUpdatesButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
try {
handlerService.executeCommand("org.eclipse.equinox.p2.ui.sdk.update", new Event());
} catch (Exception e) {
StatusManager.getManager().handle(new Status(IStatus.ERROR, IdeUiPlugin.PLUGIN_ID, "Find updates failed with an unexpected error.", e), StatusManager.SHOW | StatusManager.LOG);
}
}
});
Hyperlink configureLink = toolkit.createHyperlink(body, "Configure Extensions...", SWT.NONE);
configureLink.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent event) {
PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getSite().getShell(), ID_PREFERENCE_PAGE, new String[] { ID_PREFERENCE_PAGE }, null);
dialog.open();
}
});
progressMonitorPart = new ProgressMonitorPart(body, null);
monitor.attach(progressMonitorPart);
progressMonitorPart.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
monitor.setCanceled(true);
monitor.detach(progressMonitorPart);
}
});
adaptRecursively(progressMonitorPart, toolkit);
GridDataFactory.fillDefaults().grab(true, false).applyTo(progressMonitorPart);
// Button refreshButton = toolkit.createButton(body, "Refresh",
// SWT.NONE);
// refreshButton.addSelectionListener(new SelectionAdapter() {
// @Override
// public void widgetSelected(SelectionEvent e) {
// pane.updateDiscovery();
// }
// });
cancelButton = toolkit.createButton(body, "&Cancel", SWT.NONE);
cancelButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
cancelButton.setEnabled(false);
progressMonitorPart.setCanceled(true);
}
});
installButton = toolkit.createButton(body, "&Install", SWT.NONE);
installButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// check for conflicts
List<ConnectorDescriptor> selection = discoveryViewer.getInstallableConnectors();
IStatus conflictStatus = new MultiStatus(IdeUiPlugin.PLUGIN_ID, -1, new IStatus[] { checkForConflicts(SVN_FEATURES, " Please select only one SVN team provider.", selection), checkForConflicts(M2E_EXTENSION_IDS, " Please select only one m2e version to install.", selection) }, "Could not perform install due to conflicts.", null);
if (!conflictStatus.isOK()) {
StatusManager.getManager().handle(conflictStatus, StatusManager.SHOW | StatusManager.BLOCK);
return;
}
// now, if m2e is going to be installed, ensure that all other
// versions of m2e are uninstalled first.
Set<String> featuresToUninstall = chooseUnwantedFeatures(selection);
if (!featuresToUninstall.isEmpty()) {
IStatus uninstallResult = uninstallFeatures(featuresToUninstall);
if (!uninstallResult.isOK()) {
if (uninstallResult.getSeverity() != IStatus.CANCEL) {
StatusManager.getManager().handle(uninstallResult, StatusManager.SHOW | StatusManager.LOG | StatusManager.BLOCK);
}
return;
}
}
DiscoveryUi.install(discoveryViewer.getInstallableConnectors(), DashboardExtensionsPage.this);
}
private IStatus uninstallFeatures(final Set<String> featuresToUninstall) {
String allInstalled = findFeaturesToUninstall(featuresToUninstall, discoveryViewer.getInstalledFeatures());
if (allInstalled.length() == 0) {
return Status.OK_STATUS;
}
boolean res = MessageDialog.openQuestion(getPartControl().getShell(), "Perform uninstall?", "In order to switch versions of m2eclipse, the following features will be uninstalled:\n" + allInstalled + "Do you want to continue?");
if (!res) {
return Status.CANCEL_STATUS;
}
// uninstall previous Maven tooling
AbstractInstallJob job = DiscoveryUi.createInstallJob();
try {
return job.uninstall(new UninstallRequest() {
/**
* Uninstall all features that are somehow related to
* m2eclipse
*/
@Override
public boolean select(InstalledItem item) {
String featureId = item.getId();
return isRelatedToM2e(featuresToUninstall, featureId);
}
}, new NullProgressMonitor());
} catch (Exception e) {
return new Status(IStatus.ERROR, IdeUiPlugin.PLUGIN_ID, NLS.bind("Could not uninstall features:\n{0},\n try uninstalling manually.", featuresToUninstall), e);
}
}
private String findFeaturesToUninstall(Set<String> featuresToUninstall, Set<String> installedFeatures) {
StringBuilder sb = new StringBuilder();
for (String featureId : installedFeatures) {
if (isRelatedToM2e(featuresToUninstall, featureId)) {
if (featureId.endsWith(".feature.group")) {
featureId = featureId.substring(0, featureId.length() - ".feature.group".length());
}
sb.append(" " + featureId + "\n");
}
}
return sb.toString();
}
private Set<String> chooseUnwantedFeatures(List<ConnectorDescriptor> selection) {
boolean uninstallOld = false;
boolean uninstallNew = false;
for (ConnectorDescriptor feature : selection) {
// first and vice versa
if (feature.getId().equals(NEW_M2E_EXTENSION_ID)) {
uninstallOld = true;
} else if (feature.getId().equals(OLD_M2E_EXTENSION_ID)) {
uninstallNew = true;
}
}
Set<String> maybeUninstall;
if (uninstallOld) {
maybeUninstall = OLD_M2E_FEATURES;
} else if (uninstallNew) {
maybeUninstall = NEW_M2E_FEATURES;
} else {
maybeUninstall = Collections.emptySet();
}
Set<String> installedFeatures = DashboardExtensionsPage.this.discoveryViewer.getInstalledFeatures();
Set<String> definitelyUninstall = new HashSet<String>();
for (String feature : maybeUninstall) {
if (installedFeatures.contains(feature)) {
definitelyUninstall.add(feature);
}
}
if (definitelyUninstall.size() > 0) {
IdeUiPlugin.log(new Status(IStatus.INFO, IdeUiPlugin.PLUGIN_ID, "To make way for a new version of m2eclipse, we will uninstall these features: " + definitelyUninstall));
}
return definitelyUninstall;
}
/**
* This method checks for conflicts with requested installs. If a
* conflict is found, this method will pop up a dialog explaining
* the conflict and it will return true.
* @param featuresToCheck set of features of which only one can be
* installed at once.
* @param message message to add if there is an error
* @param selection
*
* @return true iff there is a conflict.
*/
public IStatus checkForConflicts(Set<String> featuresToCheck, String prependedMessage, List<ConnectorDescriptor> selection) {
StringBuilder message = new StringBuilder();
List<ConnectorDescriptor> conflicting = new ArrayList<ConnectorDescriptor>();
for (ConnectorDescriptor descriptor : selection) {
if (featuresToCheck.contains(descriptor.getId())) {
conflicting.add(descriptor);
if (message.length() > 0) {
message.append(", ");
}
message.append(descriptor.getName());
}
}
if (conflicting.size() > 1) {
return new Status(IStatus.WARNING, IdeUiPlugin.PLUGIN_ID, NLS.bind("The following extensions can not be installed at the same time: {0}.", message.toString()));
} else {
return Status.OK_STATUS;
}
}
});
Display.getCurrent().asyncExec(new Runnable() {
public void run() {
if (!managedForm.getForm().isDisposed()) {
discoveryViewer.updateDiscovery();
}
}
});
discoveryViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
installButton.setEnabled(discoveryViewer.isComplete());
}
});
}
use of org.eclipse.jface.wizard.ProgressMonitorPart in project dbeaver by serge-rider.
the class BaseProgressDialog method createButtonBar.
@Override
protected Control createButtonBar(Composite parent) {
// Horizontal separator
// new Label(mainComposite, SWT.HORIZONTAL | SWT.SEPARATOR)
// .setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// Progress monitor
monitorPart = new ProgressMonitorPart(mainComposite, null, true) {
@Override
public void setCanceled(boolean b) {
super.setCanceled(b);
if (b) {
cancelCurrentOperation();
}
}
};
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
gd.horizontalIndent = 20;
gd.verticalIndent = 0;
gd.exclude = true;
monitorPart.setLayoutData(gd);
monitorPart.setVisible(false);
return super.createButtonBar(parent);
}
use of org.eclipse.jface.wizard.ProgressMonitorPart in project dbeaver by serge-rider.
the class MultiPageWizardDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
wizard.addPages();
wizardSash = new SashForm(composite, SWT.HORIZONTAL);
wizardSash.setLayoutData(new GridData(GridData.FILL_BOTH));
pagesTree = new Tree(wizardSash, SWT.SINGLE);
pagesTree.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite pageContainer = UIUtils.createPlaceholder(wizardSash, 2);
// Vertical separator
new Label(pageContainer, SWT.SEPARATOR | SWT.VERTICAL).setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true));
pageArea = UIUtils.createPlaceholder(pageContainer, 1);
GridData gd = new GridData(GridData.FILL_BOTH);
pageArea.setLayoutData(gd);
pageArea.setLayout(new GridLayout(1, true));
wizardSash.setWeights(new int[] { 300, 700 });
Point maxSize = new Point(0, 0);
IWizardPage[] pages = wizard.getPages();
for (IWizardPage page : pages) {
addPage(null, page, maxSize);
}
pagesTree.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
changePage();
}
});
// Select first page
pagesTree.select(pagesTree.getItem(0));
changePage();
// Set title and image from first page
IDialogPage firstPage = (IDialogPage) pagesTree.getItem(0).getData();
setTitle(firstPage.getTitle());
setTitleImage(firstPage.getImage());
setMessage(firstPage.getDescription());
// Horizontal separator
new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// Progress monitor
monitorPart = new ProgressMonitorPart(composite, null, true) {
@Override
public void setCanceled(boolean b) {
super.setCanceled(b);
if (b) {
cancelCurrentOperation();
}
}
};
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
gd.horizontalIndent = 20;
gd.verticalIndent = 0;
monitorPart.setLayoutData(gd);
monitorPart.setVisible(false);
return composite;
}
Aggregations