use of org.eclipse.swt.widgets.DirectoryDialog in project bndtools by bndtools.
the class WorkspaceLocationPart method createControl.
public Control createControl(final Composite parent) {
// Create Controls
group = new Group(parent, SWT.NONE);
group.setText("Location");
GridLayout layout = new GridLayout(3, false);
group.setLayout(layout);
File workspace = getUpdate();
if (workspace == null) {
final Button btnCreateInEclipseWorkspace = new Button(group, SWT.RADIO);
btnCreateInEclipseWorkspace.setText("Create in current Eclipse Workspace");
btnCreateInEclipseWorkspace.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1));
Label lblEclipseWorkspace = new Label(group, SWT.NONE);
lblEclipseWorkspace.setText(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
lblEclipseWorkspace.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
final Button btnCreateExternal = new Button(group, SWT.RADIO);
btnCreateExternal.setText("Create in:");
final Text txtExternalLocation = new Text(group, SWT.BORDER);
txtExternalLocation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
final Button btnBrowseExternal = new Button(group, SWT.PUSH);
btnBrowseExternal.setText("Browse");
updateFields = new Runnable() {
@Override
public void run() {
btnCreateInEclipseWorkspace.setSelection(location.eclipseWorkspace);
btnCreateExternal.setSelection(!location.eclipseWorkspace);
txtExternalLocation.setText(location.externalPath != null ? location.externalPath : "");
}
};
updateEnablement = new Runnable() {
@Override
public void run() {
txtExternalLocation.setEnabled(!location.eclipseWorkspace);
btnBrowseExternal.setEnabled(!location.eclipseWorkspace);
}
};
// Load initial state
updateFields.run();
updateEnablement.run();
// Event listeners
final Listener locationListener = new Listener() {
@Override
public void handleEvent(Event ev) {
modifyLock.modifyOperation(new Runnable() {
@Override
public void run() {
setLocation(new LocationSelection(btnCreateInEclipseWorkspace.getSelection(), txtExternalLocation.getText()));
}
});
}
};
btnCreateExternal.addListener(SWT.Selection, locationListener);
btnCreateInEclipseWorkspace.addListener(SWT.Selection, locationListener);
txtExternalLocation.addListener(SWT.Modify, locationListener);
btnBrowseExternal.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog(parent.getShell());
String path = dialog.open();
if (path != null)
txtExternalLocation.setText(path);
}
});
} else {
final Label txtUpdateLocation = new Label(group, SWT.BORDER);
txtUpdateLocation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
txtUpdateLocation.setText("Update in current Bnd Workspace");
Label lblEclipseWorkspace = new Label(group, SWT.NONE);
lblEclipseWorkspace.setText(workspace.getAbsolutePath());
lblEclipseWorkspace.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
setLocation(new LocationSelection(false, workspace.getAbsolutePath()));
}
return group;
}
use of org.eclipse.swt.widgets.DirectoryDialog in project bndtools by bndtools.
the class ProjectLocationGroup method createControl.
/**
* @wbp.parser.entryPoint
*/
public Control createControl(Composite parent) {
container = new Composite(parent, SWT.NONE);
container.setLayout(new GridLayout(3, false));
btnUseBndWorkspace = new Button(container, SWT.CHECK);
btnUseBndWorkspace.setText("Use bnd workspace location");
btnUseBndWorkspace.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
lblOtherLocation = new Label(container, SWT.NONE);
lblOtherLocation.setText("Location:");
txtLocation = new Text(container, SWT.BORDER);
txtLocation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
txtLocation.setText("[WorkspaceLocation]");
btnBrowse = new Button(container, SWT.NONE);
btnBrowse.setText("Browse...");
btnBrowse.setLayoutData(getButtonLayoutData(btnBrowse));
updateUI();
txtLocation.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
IPath oldValue = getLocation();
if (!useBndWorkspace) {
externalPath = txtLocation.getText();
}
IPath newValue = getLocation();
if (!programmaticChange) {
propSupport.firePropertyChange(PROP_LOCATION, oldValue, newValue);
validate();
}
}
});
btnUseBndWorkspace.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IPath oldValue = getLocation();
useBndWorkspace = btnUseBndWorkspace.getSelection();
IPath newValue = getLocation();
if (!programmaticChange) {
propSupport.firePropertyChange(PROP_LOCATION, oldValue, newValue);
updateUI();
validate();
}
}
});
btnBrowse.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog(container.getShell());
dialog.setMessage("Choose a directory for the project contents:");
String directoryName = txtLocation.getText().trim();
if (directoryName == null || directoryName.length() == 0) {
String previous = JavaPlugin.getDefault().getDialogSettings().get(DIALOGSTORE_LAST_EXTERNAL_LOC);
if (previous != null)
directoryName = previous;
}
assert (directoryName != null);
if (directoryName.length() > 0) {
File path = new File(directoryName);
if (path.exists())
dialog.setFilterPath(directoryName);
}
String selected = dialog.open();
if (selected != null) {
IPath path = new Path(selected);
if (projectName != null && !projectName.equals(path.lastSegment()))
selected = path.append(projectName).toString();
txtLocation.setText(selected);
}
}
});
return container;
}
use of org.eclipse.swt.widgets.DirectoryDialog in project bndtools by bndtools.
the class ExecutableJarWizardPage method createControl.
/**
* Create contents of the wizard.
*
* @param parent
*/
@Override
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
setControl(container);
container.setLayout(new GridLayout(1, false));
Group grpDestination = new Group(container, SWT.NONE);
grpDestination.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
grpDestination.setText("Destination:");
grpDestination.setLayout(new GridLayout(3, false));
final Button btnJar = new Button(grpDestination, SWT.RADIO);
btnJar.setText("Export to JAR:");
btnJar.setSelection(jar);
txtJarPath = new Text(grpDestination, SWT.BORDER);
txtJarPath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
txtJarPath.setText(jarPath != null ? jarPath : "");
btnBrowseJar = new Button(grpDestination, SWT.NONE);
btnBrowseJar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
btnBrowseJar.setText("Browse");
final Button btnFolder = new Button(grpDestination, SWT.RADIO);
btnFolder.setText("Export to folder:");
btnFolder.setSelection(folder);
txtFolderPath = new Text(grpDestination, SWT.BORDER);
txtFolderPath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
txtFolderPath.setText(folderPath != null ? folderPath : "");
btnBrowseFolder = new Button(grpDestination, SWT.NONE);
btnBrowseFolder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
btnBrowseFolder.setText("Browse");
btnBrowseFolder.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog(getShell());
String path = dialog.open();
if (path != null)
txtFolderPath.setText(path);
}
});
loadLastExport();
updateEnablement();
validate();
Listener listener = new Listener() {
@Override
public void handleEvent(Event event) {
jar = btnJar.getSelection();
jarPath = txtJarPath.getText();
folder = btnFolder.getSelection();
folderPath = txtFolderPath.getText();
updateEnablement();
validate();
}
};
txtJarPath.addListener(SWT.Modify, listener);
btnJar.addListener(SWT.Selection, listener);
txtFolderPath.addListener(SWT.Modify, listener);
btnFolder.addListener(SWT.Selection, listener);
btnBrowseJar.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
dialog.setFilterExtensions(new String[] { "*.jar" });
dialog.setFilterNames(new String[] { "JAR Files" });
String path = dialog.open();
if (path != null)
txtJarPath.setText(path);
}
});
}
use of org.eclipse.swt.widgets.DirectoryDialog in project eclipse.platform.swt by eclipse.
the class ClipboardExample method createFileTransfer.
void createFileTransfer(Composite copyParent, Composite pasteParent) {
// File Transfer
Label l = new Label(copyParent, SWT.NONE);
// $NON-NLS-1$
l.setText("FileTransfer:");
GridData data = new GridData();
data.verticalSpan = 3;
l.setLayoutData(data);
final Table copyFileTable = new Table(copyParent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
data = new GridData(GridData.FILL_BOTH);
data.widthHint = HSIZE;
data.heightHint = VSIZE;
data.verticalSpan = 3;
copyFileTable.setLayoutData(data);
Button b = new Button(copyParent, SWT.PUSH);
b.setText("Select file(s)");
b.addSelectionListener(widgetSelectedAdapter(e -> {
FileDialog dialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
String result = dialog.open();
if (result != null && result.length() > 0) {
String path = dialog.getFilterPath();
String[] names = dialog.getFileNames();
for (String name : names) {
TableItem item = new TableItem(copyFileTable, SWT.NONE);
item.setText(path + File.separator + name);
}
}
}));
b = new Button(copyParent, SWT.PUSH);
b.setText("Select directory");
b.addSelectionListener(widgetSelectedAdapter(e -> {
DirectoryDialog dialog = new DirectoryDialog(shell, SWT.OPEN);
String result = dialog.open();
if (result != null && result.length() > 0) {
// copyFileTable.removeAll();
TableItem item = new TableItem(copyFileTable, SWT.NONE);
item.setText(result);
}
}));
b = new Button(copyParent, SWT.PUSH);
b.setText("Copy");
b.addSelectionListener(widgetSelectedAdapter(e -> {
TableItem[] items = copyFileTable.getItems();
if (items.length > 0) {
status.setText("");
String[] itemsData = new String[items.length];
for (int i = 0; i < itemsData.length; i++) {
itemsData[i] = items[i].getText();
}
clipboard.setContents(new Object[] { itemsData }, new Transfer[] { FileTransfer.getInstance() });
} else {
status.setText("No file to copy");
}
}));
l = new Label(pasteParent, SWT.NONE);
// $NON-NLS-1$
l.setText("FileTransfer:");
final Table pasteFileTable = new Table(pasteParent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
data = new GridData(GridData.FILL_BOTH);
data.widthHint = HSIZE;
data.heightHint = VSIZE;
pasteFileTable.setLayoutData(data);
b = new Button(pasteParent, SWT.PUSH);
b.setText("Paste");
b.addSelectionListener(widgetSelectedAdapter(e -> {
String[] textData = (String[]) clipboard.getContents(FileTransfer.getInstance());
if (textData != null && textData.length > 0) {
status.setText("");
pasteFileTable.removeAll();
for (String element : textData) {
TableItem item = new TableItem(pasteFileTable, SWT.NONE);
item.setText(element);
}
} else {
status.setText("No file to paste");
}
}));
}
use of org.eclipse.swt.widgets.DirectoryDialog in project eclipse.platform.swt by eclipse.
the class DialogTab method createControlWidgets.
/**
* Creates the "Control" widget children.
*/
@Override
void createControlWidgets() {
/* Create the combo */
String[] strings = { ControlExample.getResourceString("ColorDialog"), ControlExample.getResourceString("DirectoryDialog"), ControlExample.getResourceString("FileDialog"), ControlExample.getResourceString("FontDialog"), ControlExample.getResourceString("PrintDialog"), ControlExample.getResourceString("MessageBox") };
dialogCombo = new Combo(dialogStyleGroup, SWT.READ_ONLY);
dialogCombo.setItems(strings);
dialogCombo.setText(strings[0]);
dialogCombo.setVisibleItemCount(strings.length);
/* Create the create dialog button */
createButton = new Button(dialogStyleGroup, SWT.NONE);
createButton.setText(ControlExample.getResourceString("Create_Dialog"));
createButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
/* Create a group for the various dialog button style controls */
Group buttonStyleGroup = new Group(controlGroup, SWT.NONE);
buttonStyleGroup.setLayout(new GridLayout());
buttonStyleGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
buttonStyleGroup.setText(ControlExample.getResourceString("Button_Styles"));
/* Create the button style buttons */
okButton = new Button(buttonStyleGroup, SWT.CHECK);
okButton.setText("SWT.OK");
cancelButton = new Button(buttonStyleGroup, SWT.CHECK);
cancelButton.setText("SWT.CANCEL");
yesButton = new Button(buttonStyleGroup, SWT.CHECK);
yesButton.setText("SWT.YES");
noButton = new Button(buttonStyleGroup, SWT.CHECK);
noButton.setText("SWT.NO");
retryButton = new Button(buttonStyleGroup, SWT.CHECK);
retryButton.setText("SWT.RETRY");
abortButton = new Button(buttonStyleGroup, SWT.CHECK);
abortButton.setText("SWT.ABORT");
ignoreButton = new Button(buttonStyleGroup, SWT.CHECK);
ignoreButton.setText("SWT.IGNORE");
/* Create a group for the icon style controls */
Group iconStyleGroup = new Group(controlGroup, SWT.NONE);
iconStyleGroup.setLayout(new GridLayout());
iconStyleGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
iconStyleGroup.setText(ControlExample.getResourceString("Icon_Styles"));
/* Create the icon style buttons */
iconErrorButton = new Button(iconStyleGroup, SWT.RADIO);
iconErrorButton.setText("SWT.ICON_ERROR");
iconInformationButton = new Button(iconStyleGroup, SWT.RADIO);
iconInformationButton.setText("SWT.ICON_INFORMATION");
iconQuestionButton = new Button(iconStyleGroup, SWT.RADIO);
iconQuestionButton.setText("SWT.ICON_QUESTION");
iconWarningButton = new Button(iconStyleGroup, SWT.RADIO);
iconWarningButton.setText("SWT.ICON_WARNING");
iconWorkingButton = new Button(iconStyleGroup, SWT.RADIO);
iconWorkingButton.setText("SWT.ICON_WORKING");
noIconButton = new Button(iconStyleGroup, SWT.RADIO);
noIconButton.setText(ControlExample.getResourceString("No_Icon"));
/* Create a group for the modal style controls */
Group modalStyleGroup = new Group(controlGroup, SWT.NONE);
modalStyleGroup.setLayout(new GridLayout());
modalStyleGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
modalStyleGroup.setText(ControlExample.getResourceString("Modal_Styles"));
/* Create the modal style buttons */
primaryModalButton = new Button(modalStyleGroup, SWT.RADIO);
primaryModalButton.setText("SWT.PRIMARY_MODAL");
applicationModalButton = new Button(modalStyleGroup, SWT.RADIO);
applicationModalButton.setText("SWT.APPLICATION_MODAL");
systemModalButton = new Button(modalStyleGroup, SWT.RADIO);
systemModalButton.setText("SWT.SYSTEM_MODAL");
/* Create a group for the file dialog style controls */
Group fileDialogStyleGroup = new Group(controlGroup, SWT.NONE);
fileDialogStyleGroup.setLayout(new GridLayout());
fileDialogStyleGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
fileDialogStyleGroup.setText(ControlExample.getResourceString("File_Dialog_Styles"));
/* Create the file dialog style buttons */
openButton = new Button(fileDialogStyleGroup, SWT.RADIO);
openButton.setText("SWT.OPEN");
saveButton = new Button(fileDialogStyleGroup, SWT.RADIO);
saveButton.setText("SWT.SAVE");
multiButton = new Button(fileDialogStyleGroup, SWT.CHECK);
multiButton.setText("SWT.MULTI");
/* Create the orientation group */
if (RTL_SUPPORT_ENABLE) {
createOrientationGroup();
}
/* Create a group for other style and setting controls */
Group otherGroup = new Group(controlGroup, SWT.NONE);
otherGroup.setLayout(new GridLayout());
otherGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
otherGroup.setText(ControlExample.getResourceString("Other"));
/* Create the other style and setting controls */
sheetButton = new Button(otherGroup, SWT.CHECK);
sheetButton.setText("SWT.SHEET");
usePreviousResultButton = new Button(otherGroup, SWT.CHECK);
usePreviousResultButton.setText(ControlExample.getResourceString("Use_Previous_Result"));
effectsVisibleButton = new Button(otherGroup, SWT.CHECK);
effectsVisibleButton.setText("FontDialog.setEffectsVisible");
/* Add the listeners */
dialogCombo.addSelectionListener(widgetSelectedAdapter(event -> dialogSelected(event)));
createButton.addSelectionListener(widgetSelectedAdapter(event -> createButtonSelected(event)));
SelectionListener buttonStyleListener = widgetSelectedAdapter(event -> buttonStyleSelected(event));
okButton.addSelectionListener(buttonStyleListener);
cancelButton.addSelectionListener(buttonStyleListener);
yesButton.addSelectionListener(buttonStyleListener);
noButton.addSelectionListener(buttonStyleListener);
retryButton.addSelectionListener(buttonStyleListener);
abortButton.addSelectionListener(buttonStyleListener);
ignoreButton.addSelectionListener(buttonStyleListener);
/* Set default values for style buttons */
okButton.setEnabled(false);
cancelButton.setEnabled(false);
yesButton.setEnabled(false);
noButton.setEnabled(false);
retryButton.setEnabled(false);
abortButton.setEnabled(false);
ignoreButton.setEnabled(false);
iconErrorButton.setEnabled(false);
iconInformationButton.setEnabled(false);
iconQuestionButton.setEnabled(false);
iconWarningButton.setEnabled(false);
iconWorkingButton.setEnabled(false);
noIconButton.setEnabled(false);
saveButton.setEnabled(false);
openButton.setEnabled(false);
openButton.setSelection(true);
multiButton.setEnabled(false);
noIconButton.setSelection(true);
effectsVisibleButton.setEnabled(false);
effectsVisibleButton.setSelection(true);
}
Aggregations