use of org.eclipse.ui.dialogs.ContainerSelectionDialog in project eclipse.platform.ui by eclipse-platform.
the class UIDialogsAuto method testCopyMoveResource.
@Test
public void testCopyMoveResource() {
Dialog dialog = new ContainerSelectionDialog(getShell(), null, true, "Copy Resources");
DialogCheck.assertDialogTexts(dialog);
}
use of org.eclipse.ui.dialogs.ContainerSelectionDialog in project Pydev by fabioz.
the class PyMoveResourceAction method pyQueryDestinationResource.
private IPath pyQueryDestinationResource() {
// start traversal at root resource, should probably start at a
// better location in the tree
String title;
if (selected.size() == 1) {
title = "Choose destination for ''" + selected.get(0).getName() + "'':";
} else {
title = "Choose destination for " + selected.size() + " selected resources:";
}
ContainerSelectionDialog dialog = new ContainerSelectionDialog(shellProvider.getShell(), selected.get(0).getParent(), true, title);
dialog.setTitle("Move Resources");
dialog.setValidator(this);
dialog.showClosedProjects(false);
dialog.open();
Object[] result = dialog.getResult();
if (result != null && result.length == 1) {
return (IPath) result[0];
}
return null;
}
use of org.eclipse.ui.dialogs.ContainerSelectionDialog in project dbeaver by dbeaver.
the class PrefPageProjectResourceSettings method createContents.
@Override
protected Control createContents(final Composite parent) {
Composite composite = UIUtils.createComposite(parent, 1);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
{
UIUtils.createControlLabel(composite, UINavigatorMessages.pref_page_projects_settings_label_resource_location);
resourceTable = new Table(composite, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 400;
gd.heightHint = 300;
resourceTable.setLayoutData(gd);
resourceTable.setHeaderVisible(true);
resourceTable.setLinesVisible(true);
UIUtils.createTableColumn(resourceTable, SWT.LEFT, UINavigatorMessages.pref_page_projects_settings_label_resource);
UIUtils.createTableColumn(resourceTable, SWT.LEFT, UINavigatorMessages.pref_page_projects_settings_label_folder);
resourceTable.setHeaderVisible(true);
handlerTableEditor = new TableEditor(resourceTable);
handlerTableEditor.verticalAlignment = SWT.TOP;
handlerTableEditor.horizontalAlignment = SWT.RIGHT;
handlerTableEditor.grabHorizontal = true;
handlerTableEditor.grabVertical = true;
resourceTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
disposeOldEditor();
final TableItem item = resourceTable.getItem(new Point(0, e.y));
if (item == null) {
return;
}
int columnIndex = UIUtils.getColumnAtPos(item, e.x, e.y);
if (columnIndex <= 0) {
return;
}
if (columnIndex == 1) {
final String resourcePath = item.getText(1);
if (project != null) {
final IFolder folder = project.getFolder(resourcePath);
ContainerSelectionDialog dialog = new ContainerSelectionDialog(resourceTable.getShell(), folder, true, UINavigatorMessages.pref_page_projects_settings_label_select + item.getText(0) + UINavigatorMessages.pref_page_projects_settings_label_root_folder);
dialog.showClosedProjects(false);
dialog.setValidator(selection -> {
if (selection instanceof IPath) {
final File file = ((IPath) selection).toFile();
if (file.isHidden() || file.getName().startsWith(".")) {
return UINavigatorMessages.pref_page_projects_settings_label_not_use_hidden_folders;
}
final String[] segments = ((IPath) selection).segments();
if (!project.getName().equals(segments[0])) {
return UINavigatorMessages.pref_page_projects_settings_label_not_store_resources_in_another_project;
}
}
return null;
});
if (dialog.open() == IDialogConstants.OK_ID) {
final Object[] result = dialog.getResult();
if (result.length == 1 && result[0] instanceof IPath) {
final IPath plainPath = ((IPath) result[0]).removeFirstSegments(1).removeTrailingSeparator();
item.setText(1, plainPath.toString());
}
}
} else {
final Text editor = new Text(resourceTable, SWT.NONE);
editor.setText(resourcePath);
editor.selectAll();
handlerTableEditor.setEditor(editor, item, 1);
editor.setFocus();
editor.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
item.setText(1, editor.getText());
}
});
}
}
}
});
UIUtils.createInfoLabel(composite, UINavigatorMessages.pref_page_projects_settings_label_restart_require_refresh_global_settings);
}
performDefaults();
return composite;
}
use of org.eclipse.ui.dialogs.ContainerSelectionDialog in project bndtools by bndtools.
the class IndexerWizardPage method createControl.
@Override
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NULL);
setControl(composite);
// Create controls
new Label(composite, SWT.NONE).setText(Messages.IndexerWizardPage_baseDir);
txtBaseDir = new Text(composite, SWT.BORDER);
newSpacer(composite);
Composite cmpButtonBar = new Composite(composite, SWT.NONE);
Button btnBrowseWorkspace = new Button(cmpButtonBar, SWT.PUSH);
btnBrowseWorkspace.setText(Messages.IndexerWizardPage_browse);
Button btnBrowseExternal = new Button(cmpButtonBar, SWT.PUSH);
btnBrowseExternal.setText(Messages.IndexerWizardPage_browseExternal);
new Label(composite, SWT.NONE).setText(Messages.IndexerWizardPage_resourcePattern);
txtResourcePattern = new Text(composite, SWT.BORDER);
ControlDecoration decorResourcePattern = new ControlDecoration(txtResourcePattern, SWT.LEFT | SWT.TOP, composite);
decorResourcePattern.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
decorResourcePattern.setMarginWidth(3);
decorResourcePattern.setDescriptionText(Messages.IndexerWizardPage_resourcePatternHelp);
decorResourcePattern.setShowHover(true);
decorResourcePattern.setShowOnlyOnFocus(false);
Label lblInputs = new Label(composite, SWT.NONE);
lblInputs.setText(Messages.IndexerWizardPage_inputs);
Table tblInputs = new Table(composite, SWT.MULTI | SWT.BORDER);
vwrInputs = new TableViewer(tblInputs);
vwrInputs.setContentProvider(ArrayContentProvider.getInstance());
vwrInputs.setLabelProvider(new StyledCellLabelProvider() {
@Override
public void update(ViewerCell cell) {
Object elem = cell.getElement();
if (elem instanceof Path) {
cell.setText(elem.toString());
cell.setImage(imgFile);
} else if (elem instanceof IStatus) {
IStatus status = (IStatus) elem;
cell.setText(status.getMessage());
if (status.getSeverity() == IStatus.ERROR)
cell.setImage(imgError);
else if (status.getSeverity() == IStatus.WARNING)
cell.setImage(imgWarning);
}
}
});
newSpacer(composite);
lblInputCount = new Label(composite, SWT.NONE);
Label lblOutputs = new Label(composite, SWT.NONE);
lblOutputs.setText(Messages.IndexerWizardPage_output);
Group grpOutput = new Group(composite, SWT.NONE);
new Label(grpOutput, SWT.NONE).setText(Messages.IndexerWizardPage_prefix);
txtOutputPrefix = new Text(grpOutput, SWT.BORDER);
newSpacer(grpOutput);
btnOutputPretty = new Button(grpOutput, SWT.RADIO);
btnOutputPretty.setText(Messages.IndexerWizardPage_prettyPrint);
newSpacer(grpOutput);
btnOutputCompressed = new Button(grpOutput, SWT.RADIO);
btnOutputCompressed.setText(Messages.IndexerWizardPage_compressed);
newSpacer(grpOutput);
lblOutputName = new Label(grpOutput, SWT.NONE);
// LAYOUT
GridLayout gl;
GridData gd;
gl = new GridLayout(2, false);
gl.horizontalSpacing = 10;
composite.setLayout(gl);
txtBaseDir.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
cmpButtonBar.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false));
gl = new GridLayout(2, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
cmpButtonBar.setLayout(gl);
btnBrowseWorkspace.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
btnBrowseExternal.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
txtResourcePattern.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
lblInputs.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
gd.heightHint = 120;
gd.widthHint = 100;
tblInputs.setLayoutData(gd);
lblInputCount.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));
lblOutputs.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
grpOutput.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
grpOutput.setLayout(new GridLayout(2, false));
txtOutputPrefix.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
btnOutputCompressed.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
btnOutputPretty.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
lblOutputName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
// LOAD DATA
if (baseDir != null)
txtBaseDir.setText(baseDir.getAbsolutePath());
if (resourcePattern != null)
txtResourcePattern.setText(resourcePattern);
// $NON-NLS-1$
txtOutputPrefix.setText("index");
btnOutputCompressed.setSelection(outputStyle == IndexFormatStyle.COMPRESSED);
btnOutputPretty.setSelection(outputStyle == IndexFormatStyle.PRETTY_UNCOMPRESSED);
updateOutputFileName();
updateInputs();
// LISTENERS
txtBaseDir.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent me) {
String baseDirStr = txtBaseDir.getText();
baseDir = baseDirStr.isEmpty() ? null : new File(baseDirStr);
validate();
updateInputs();
}
});
txtResourcePattern.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent me) {
resourcePattern = txtResourcePattern.getText();
updateInputs();
}
});
btnBrowseWorkspace.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
ContainerSelectionDialog containerDlg = new ContainerSelectionDialog(getShell(), root, false, Messages.IndexerWizardPage_selectBaseDir);
containerDlg.showClosedProjects(false);
if (containerDlg.open() == Window.OK) {
Object[] selection = containerDlg.getResult();
if (selection != null && selection.length > 0) {
IPath workspacePath = (IPath) selection[0];
IResource resource = root.findMember(workspacePath);
if (resource == null)
MessageDialog.openError(getShell(), "Error", "Could not find resource for path " + workspacePath);
else
txtBaseDir.setText(resource.getLocation().toString());
}
}
}
});
btnBrowseExternal.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dirDialog = new DirectoryDialog(getShell());
dirDialog.setMessage(Messages.IndexerWizardPage_selectBaseDir);
String selectedPath = dirDialog.open();
if (selectedPath != null)
txtBaseDir.setText(selectedPath);
}
});
txtOutputPrefix.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent me) {
updateOutputFileName();
validate();
}
});
Listener outputRadioListener = new Listener() {
@Override
public void handleEvent(Event ev) {
outputStyle = btnOutputCompressed.getSelection() ? IndexFormatStyle.COMPRESSED : IndexFormatStyle.PRETTY_UNCOMPRESSED;
updateOutputFileName();
validate();
}
};
btnOutputCompressed.addListener(SWT.Selection, outputRadioListener);
btnOutputPretty.addListener(SWT.Selection, outputRadioListener);
validate();
}
use of org.eclipse.ui.dialogs.ContainerSelectionDialog in project xtext-eclipse by eclipse.
the class NewFileWizardPrimaryPage method createHeader.
private void createHeader(Composite parent) {
Composite main = new Composite(parent, SWT.NONE);
main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
main.setLayout(new GridLayout(3, false));
Label folderLabel = new Label(main, SWT.NONE);
folderLabel.setText(Messages.NewFileWizardPrimaryPage_folder_label);
folderLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
folderText = new Text(main, SWT.SINGLE | SWT.BORDER);
folderText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
Button folderBrowseButton = new Button(main, SWT.PUSH);
folderBrowseButton.setText(Messages.NewFileWizardPrimaryPage_browse_button);
folderBrowseButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
Label fileLabel = new Label(main, SWT.NONE);
fileLabel.setText(Messages.NewFileWizardPrimaryPage_name_label);
fileLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
fileText = new Text(main, SWT.SINGLE | SWT.BORDER);
fileText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
fileText.setFocus();
folderText.setText(initFolderText());
fileText.setText(initFileText());
folderText.addModifyListener(e -> validate());
fileText.addModifyListener(e -> validate());
folderBrowseButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ContainerSelectionDialog dialog = new ContainerSelectionDialog(Display.getDefault().getActiveShell(), ResourcesPlugin.getWorkspace().getRoot(), false, Messages.NewFileWizardPrimaryPage_selection_description);
if (dialog.open() == Window.OK) {
folderText.setText(getFolderFromPath((IPath) dialog.getResult()[0]));
}
}
});
}
Aggregations