use of org.eclipse.jface.dialogs.Dialog in project eclipse.platform.ui by eclipse-platform.
the class KeyAssistDialog method open.
/**
* Opens this dialog with the list of bindings for the user to select from.
*
* @return The return code from this dialog.
* @since 3.3
*/
public int open(Collection<Binding> bindings) {
matches = new TreeSet<>((a, b) -> {
Binding bindingA = a;
Binding bindingB = b;
ParameterizedCommand commandA = bindingA.getParameterizedCommand();
ParameterizedCommand commandB = bindingB.getParameterizedCommand();
try {
return commandA.getName().compareTo(commandB.getName());
} catch (NotDefinedException e) {
// should not happen
return 0;
}
});
matches.addAll(bindings);
// If the dialog is already open, dispose the shell and recreate it.
Shell shell = getShell();
if (shell != null) {
close(false, false);
return Window.OK;
}
create();
// Bug 369860. Stop ShellActivationListener from creating a context for this.
// $NON-NLS-1$
getShell().setData("org.eclipse.e4.ui.ignoreDialog", Boolean.TRUE);
// Configure the size and location.
Point size = configureSize();
configureLocation(size);
// Call the super method.
return super.open();
}
use of org.eclipse.jface.dialogs.Dialog in project eclipse.platform.ui by eclipse-platform.
the class ChooseWorkspaceDialog method createRecentWorkspacesComposite.
/**
* The Recent Workspaces area of the dialog is only shown if Recent
* Workspaces are defined. It provides a faster way to launch a specific
* Workspace
*/
private void createRecentWorkspacesComposite(final Composite composite) {
FormToolkit toolkit = new FormToolkit(composite.getDisplay());
composite.addDisposeListener(c -> toolkit.dispose());
recentWorkspacesForm = toolkit.createForm(composite);
recentWorkspacesForm.setBackground(composite.getBackground());
recentWorkspacesForm.getBody().setLayout(new GridLayout());
ExpandableComposite recentWorkspacesExpandable = toolkit.createExpandableComposite(recentWorkspacesForm.getBody(), ExpandableComposite.TWISTIE);
recentWorkspacesForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
recentWorkspacesExpandable.setBackground(composite.getBackground());
recentWorkspacesExpandable.setText(IDEWorkbenchMessages.ChooseWorkspaceDialog_recentWorkspaces);
recentWorkspacesExpandable.setExpanded(launchData.isShowRecentWorkspaces());
recentWorkspacesExpandable.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent e) {
launchData.setShowRecentWorkspaces(((ExpandableComposite) e.getSource()).isExpanded());
Point size = getInitialSize();
Shell shell = getShell();
shell.setBounds(getConstrainedShellBounds(new Rectangle(shell.getLocation().x, shell.getLocation().y, size.x, size.y)));
}
});
Composite panel = new Composite(recentWorkspacesExpandable, SWT.NONE);
recentWorkspacesExpandable.setClient(panel);
RowLayout layout = new RowLayout(SWT.VERTICAL);
layout.marginLeft = 14;
layout.spacing = 6;
panel.setLayout(layout);
recentWorkspacesLinks = new HashMap<>(launchData.getRecentWorkspaces().length);
Map<String, String> uniqueWorkspaceNames = createUniqueWorkspaceNameMap();
List<String> recentWorkspacesList = Arrays.asList(launchData.getRecentWorkspaces()).stream().filter(s -> s != null && !s.isEmpty()).collect(Collectors.toList());
List<Entry<String, String>> sortedList = uniqueWorkspaceNames.entrySet().stream().sorted((e1, e2) -> Integer.compare(recentWorkspacesList.indexOf(e1.getValue()), recentWorkspacesList.indexOf(e2.getValue()))).collect(Collectors.toList());
for (Entry<String, String> uniqueWorkspaceEntry : sortedList) {
final String recentWorkspace = uniqueWorkspaceEntry.getValue();
Link link = new Link(panel, SWT.WRAP);
link.setLayoutData(new RowData(SWT.DEFAULT, SWT.DEFAULT));
// $NON-NLS-1$ //$NON-NLS-2$
link.setText("<a>" + uniqueWorkspaceEntry.getKey() + "</a>");
link.setToolTipText(recentWorkspace);
link.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
workspaceSelected(recentWorkspace);
}
});
recentWorkspacesLinks.put(recentWorkspace, link);
Menu menu = new Menu(link);
MenuItem forgetItem = new MenuItem(menu, SWT.PUSH);
forgetItem.setText(IDEWorkbenchMessages.ChooseWorkspaceDialog_removeWorkspaceSelection);
forgetItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
removeWorkspaceFromLauncher(recentWorkspace);
}
});
link.setMenu(menu);
}
}
use of org.eclipse.jface.dialogs.Dialog in project eclipse.platform.ui by eclipse-platform.
the class EditorSelectionDialog method createDialogArea.
/**
* Creates and returns the contents of the upper part of the dialog (above the
* button bar).
*
* Subclasses should overide.
*
* @param parent the parent composite to contain the dialog area
* @return the dialog area control
*/
@Override
protected Control createDialogArea(Composite parent) {
Font font = parent.getFont();
// create main group
Composite contents = (Composite) super.createDialogArea(parent);
((GridLayout) contents.getLayout()).numColumns = 2;
// begin the layout
Label textLabel = new Label(contents, SWT.WRAP);
textLabel.setText(message);
GridData data = new GridData();
data.horizontalSpan = 2;
data.horizontalAlignment = SWT.FILL;
data.widthHint = TABLE_WIDTH;
textLabel.setLayoutData(data);
textLabel.setFont(font);
Composite group = new Composite(contents, SWT.SHADOW_NONE);
data = new GridData();
data.grabExcessHorizontalSpace = true;
data.horizontalAlignment = SWT.FILL;
data.horizontalSpan = 2;
group.setLayout(new RowLayout(SWT.HORIZONTAL));
group.setLayoutData(data);
internalButton = new Button(group, SWT.RADIO | SWT.LEFT);
internalButton.setText(WorkbenchMessages.EditorSelection_internal);
internalButton.addListener(SWT.Selection, listener);
internalButton.setFont(font);
externalButton = new Button(group, SWT.RADIO | SWT.LEFT);
externalButton.setText(WorkbenchMessages.EditorSelection_external);
externalButton.addListener(SWT.Selection, listener);
externalButton.setFont(font);
editorTable = new FilteredTree(contents, SWT.SINGLE | SWT.BORDER, new PatternFilter(), true);
editorTableViewer = editorTable.getViewer();
Tree tree = editorTableViewer.getTree();
tree.addListener(SWT.Selection, listener);
tree.addListener(SWT.DefaultSelection, listener);
tree.addListener(SWT.MouseDoubleClick, listener);
data = new GridData();
data.widthHint = convertHorizontalDLUsToPixels(TABLE_WIDTH);
data.horizontalAlignment = GridData.FILL;
data.grabExcessHorizontalSpace = true;
data.verticalAlignment = GridData.FILL;
data.grabExcessVerticalSpace = true;
data.horizontalSpan = 2;
editorTable.setLayoutData(data);
editorTable.setFont(font);
data.heightHint = tree.getItemHeight() * 12;
editorTableViewer.setContentProvider(new TreeArrayContentProvider());
editorTableViewer.setLabelProvider(createTextImageProvider(element -> {
IEditorDescriptor d = (IEditorDescriptor) element;
// $NON-NLS-1$
return TextProcessor.process(d.getLabel(), ".");
}, element -> {
IEditorDescriptor d = (IEditorDescriptor) element;
return (Image) resourceManager.get(d.getImageDescriptor());
}));
browseExternalEditorsButton = new Button(contents, SWT.PUSH);
browseExternalEditorsButton.setText(WorkbenchMessages.EditorSelection_browse);
browseExternalEditorsButton.addListener(SWT.Selection, listener);
data = new GridData();
int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
data.widthHint = Math.max(widthHint, browseExternalEditorsButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
data.horizontalSpan = 2;
browseExternalEditorsButton.setLayoutData(data);
browseExternalEditorsButton.setFont(font);
if (fileName != null) {
rememberEditorButton = new Button(contents, SWT.CHECK | SWT.LEFT);
rememberEditorButton.setText(NLS.bind(WorkbenchMessages.EditorSelection_rememberEditor, fileName));
rememberEditorButton.addListener(SWT.Selection, listener);
data = new GridData();
data.horizontalSpan = 2;
rememberEditorButton.setLayoutData(data);
rememberEditorButton.setFont(font);
String fileType = getFileType();
if (!fileType.isEmpty()) {
rememberTypeButton = new Button(contents, SWT.CHECK | SWT.LEFT);
rememberTypeButton.setText(NLS.bind(WorkbenchMessages.EditorSelection_rememberType, fileType));
rememberTypeButton.addListener(SWT.Selection, listener);
data = new GridData();
data.horizontalSpan = 2;
rememberTypeButton.setLayoutData(data);
rememberTypeButton.setFont(font);
}
}
initializeSuggestion();
// Place buttons to the appropriate state
restoreWidgetValues();
// Run async to restore selection on *visible* dialog - otherwise three won't
// scroll
PlatformUI.getWorkbench().getDisplay().asyncExec(() -> {
if (editorTable.isDisposed()) {
return;
}
fillEditorTable();
updateEnableState();
});
return contents;
}
use of org.eclipse.jface.dialogs.Dialog in project eclipse.platform.ui by eclipse-platform.
the class InfoAboutHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
Dialog dialog = new InfoAboutDialog(window.getShell());
dialog.open();
return null;
}
use of org.eclipse.jface.dialogs.Dialog in project eclipse.platform.ui by eclipse-platform.
the class DeprecatedUIPreferences method testPerspectivesPref.
@Test
public void testPerspectivesPref() {
Dialog dialog = getPreferenceDialog("org.eclipse.ui.preferencePages.Perspectives");
DialogCheck.assertDialog(dialog);
}
Aggregations