use of org.eclipse.swt.widgets.DirectoryDialog in project tdi-studio-se by Talend.
the class ImportComponentDialog method createDialogArea.
/*
* (non-Javadoc) Method declared on Dialog.
*/
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
GridLayout gl = new GridLayout(5, true);
composite.setLayout(gl);
if (message != null) {
Label label = new Label(composite, SWT.WRAP);
label.setText(message);
GridData data = new GridData(GridData.GRAB_HORIZONTAL);
data.horizontalSpan = 5;
label.setLayoutData(data);
label.setFont(parent.getFont());
}
Label label1 = new Label(composite, SWT.NONE);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
gd.horizontalSpan = 2;
label1.setLayoutData(gd);
//$NON-NLS-1$
label1.setText(Messages.getString("ImportComponentDialog.SelectDirectoryLabel"));
text = new Text(composite, SWT.BORDER);
text.setEditable(false);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 2;
text.setLayoutData(gd);
if (paletteComponentsPath == null) {
//$NON-NLS-1$
paletteComponentsPath = "";
}
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validateInput(true);
}
});
Button button = new Button(composite, SWT.NONE);
//$NON-NLS-1$
button.setText(Messages.getString("ImportComponentDialog.Browser"));
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalSpan = 1;
button.setLayoutData(gd);
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dd = new DirectoryDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
String path = dd.open();
if (path != null) {
text.setText(path);
}
}
});
Button showPaletteComponents = new Button(composite, SWT.NONE);
gd = new GridData();
gd.horizontalSpan = 2;
showPaletteComponents.setLayoutData(gd);
//$NON-NLS-1$
showPaletteComponents.setText(Messages.getString("ImportComponentDialog.ShowPaletteComponents"));
showPaletteComponents.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
text.setText(paletteComponentsPath);
}
});
label1 = new Label(composite, SWT.LEFT);
gd = new GridData();
gd.horizontalSpan = 1;
label1.setLayoutData(gd);
//$NON-NLS-1$
label1.setText(Messages.getString("ImportComponentDialog.Filter"));
filterText = new Text(composite, SWT.BORDER);
filterText.setEditable(true);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 2;
filterText.setLayoutData(gd);
filterText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validateInput(false);
}
});
label1 = new Label(composite, SWT.LEFT);
gd = new GridData();
gd.horizontalSpan = 5;
label1.setLayoutData(gd);
//$NON-NLS-1$
label1.setText(Messages.getString("ImportComponentDialog.ChooseComponentsLabel"));
componentList = new List(composite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 5;
componentList.setLayoutData(gd);
componentList.addMouseListener(new MouseListener() {
public void mouseDoubleClick(MouseEvent e) {
}
public void mouseDown(MouseEvent e) {
validateSelected();
}
public void mouseUp(MouseEvent e) {
validateSelected();
}
});
errorMessageText = new Text(composite, SWT.READ_ONLY | SWT.CENTER);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 5;
label1.setLayoutData(gd);
errorMessageText.setLayoutData(gd);
errorMessageText.setBackground(errorMessageText.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
applyDialogFont(composite);
//$NON-NLS-1$
text.setText("");
return composite;
}
use of org.eclipse.swt.widgets.DirectoryDialog in project tdi-studio-se by Talend.
the class DesignerPreferencePage method createFieldEditors.
/**
* Creates the field editors. Field editors are abstractions of the common GUI blocks needed to manipulate various
* types of preferences. Each field editor knows how to save and restore itself.
*/
@Override
public void createFieldEditors() {
StringFieldEditor labelField;
StringFieldEditor hintField;
StringFieldEditor connectionField;
BooleanFieldEditor showHint;
// BooleanFieldEditor displayComponent;
BooleanFieldEditor useRepositoryName;
// BooleanFieldEditor deactiveRepositoryUpdate;
labelField = new StringFieldEditor(TalendDesignerPrefConstants.DEFAULT_LABEL, //$NON-NLS-1$
Messages.getString("DesignerPreferencePage.component.defaultLabel"), getFieldEditorParent());
hintField = new StringFieldEditor(TalendDesignerPrefConstants.DEFAULT_HINT, //$NON-NLS-1$
Messages.getString("DesignerPreferencePage.component.defaultHint"), getFieldEditorParent());
connectionField = new StringFieldEditor(TalendDesignerPrefConstants.DEFAULT_CONNECTION_FORMAT, Messages.getString("DesignerPreferencePage.defaultConnection"), //$NON-NLS-1$
getFieldEditorParent());
showHint = new BooleanFieldEditor(TalendDesignerPrefConstants.DEFAULT_HINT_USED, //$NON-NLS-1$
Messages.getString("DesignerPreferencePage.hintShowed"), getFieldEditorParent());
// displayComponent = new BooleanFieldEditor(TalendDesignerPrefConstants.DEFAULT_DISPLAY, Messages
// .getString("DesignerPreferencePage.display.hiddenComponents"), getFieldEditorParent()); //$NON-NLS-1$
useRepositoryName = new BooleanFieldEditor(TalendDesignerPrefConstants.USE_REPOSITORY_NAME, Messages.getString("DesignerPreferencePage.display.useRepositoryName"), //$NON-NLS-1$
getFieldEditorParent());
// deactiveRepositoryUpdate = new BooleanFieldEditor(ITalendCorePrefConstants.DEACTIVE_REPOSITORY_UPDATE,
// Messages
// .getString("DesignerPreferencePage.display.deactiveRepositoryUpdate"), getFieldEditorParent()); //$NON-NLS-1$
addField(labelField);
addField(hintField);
addField(connectionField);
addField(showHint);
// addField(displayComponent);
addField(useRepositoryName);
// addField(deactiveRepositoryUpdate);
// addField(new BooleanFieldEditor(TalendDesignerPrefConstants.PROPERTY_CODE_CHECK, Messages
// .getString("DesignerPreferencePage.propertyCodeCheck"), getFieldEditorParent())); //$NON-NLS-1$
BooleanFieldEditor antialiasing;
antialiasing = new BooleanFieldEditor(TalendDesignerPrefConstants.EDITOR_ANTIALIASING, Messages.getString("DesignerPreferencePage.actionInJobDesigner"), //$NON-NLS-1$
getFieldEditorParent());
addField(antialiasing);
BooleanFieldEditor lineStyle;
lineStyle = new BooleanFieldEditor(TalendDesignerPrefConstants.EDITOR_LINESTYLE, Messages.getString("DesignerPreferencePage.lineStyle"), //$NON-NLS-1$
getFieldEditorParent());
addField(lineStyle);
if (PluginChecker.isTestCasePluginLoaded()) {
BooleanFieldEditor duplicateTestCases;
duplicateTestCases = new BooleanFieldEditor(TalendDesignerPrefConstants.DUPLICATE_TESTCASE, Messages.getString("DesignerPreferencePage.duplicateTestCases"), //$NON-NLS-1$
getFieldEditorParent());
addField(duplicateTestCases);
}
DirectoryFieldEditor compDefaultFileDir = new DirectoryFieldEditor(TalendDesignerPrefConstants.COMP_DEFAULT_FILE_DIR, Messages.getString("DesignerPreferencePage.defaultFilePathDirectory"), getFieldEditorParent()) {
@Override
protected // wzhang added to set the separator as "/" of default component filePath in preference.
String changePressed() {
File f = new File(getTextControl().getText());
if (!f.exists()) {
f = null;
}
DirectoryDialog fileDialog = new DirectoryDialog(getShell(), SWT.OPEN);
if (f != null) {
fileDialog.setFilterPath(f.getPath());
}
String openDir = fileDialog.open();
if (openDir != null) {
openDir.trim();
if (openDir.length() > 0) {
File filePath = new File(openDir);
if (!filePath.exists()) {
return null;
}
}
return Path.fromOSString(openDir).toPortableString();
}
return null;
}
};
addField(compDefaultFileDir);
RadioGroupFieldEditor largeIconsSizeField = new RadioGroupFieldEditor(TalendDesignerPrefConstants.LARGE_ICONS_SIZE, Messages.getString("DesignerPreferencePage.largeIconsSize"), 2, new String[][] { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
{ Messages.getString("DesignerPreferencePage.iconSize24"), "" + 24 }, { Messages.getString("DesignerPreferencePage.iconSize32"), "" + 32 } }, //$NON-NLS-1$ //$NON-NLS-2$
getFieldEditorParent());
addField(largeIconsSizeField);
// disable this feature 1722 for the M1 release as it's not used yet in Perl or Java.
// RadioGroupFieldEditor schemaOptions = new RadioGroupFieldEditor(
// TalendDesignerPrefConstants.SCHEMA_OPTIONS,
// Messages.getString("DesignerPreferencePage.schemaOptions"), 4, new String[][] { { "do nothing", "nothing" },
// { "die", "die" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
// { "warn", "warn" }, { "enlarge or truncate row", "adapt" } }, getFieldEditorParent(), true); //$NON-NLS-1$
// //$NON-NLS-2$
// addField(schemaOptions);
RadioGroupFieldEditor viewOptions = new RadioGroupFieldEditor(TalendDesignerPrefConstants.VIEW_OPTIONS, Messages.getString("DesignerPreferencePage.viewOptions"), 2, new String[][] { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
{ Messages.getString("DesignerPreferencePage.compactView"), "default" }, { Messages.getString("DesignerPreferencePage.tableView"), "table view" } }, getFieldEditorParent(), //$NON-NLS-1$ //$NON-NLS-2$
true);
addField(viewOptions);
// BooleanFieldEditor viewSubjobs = new BooleanFieldEditor(TalendDesignerPrefConstants.DISPLAY_SUBJOBS,
// "Highlight subjobs in the job designs", getFieldEditorParent());
// addField(viewSubjobs);
// BooleanFieldEditor generateCodeWhenOpenJob = new BooleanFieldEditor(
// TalendDesignerPrefConstants.GENERATE_CODE_WHEN_OPEN_JOB, Messages
// .getString("DesignerPreferencePage.generateCode"), //$NON-NLS-1$
// getFieldEditorParent());
// addField(generateCodeWhenOpenJob);
// When updating jobs or joblets, check only the last version, and checked by default
// BooleanFieldEditor checkOnlyLastVersion = new
// BooleanFieldEditor(TalendDesignerPrefConstants.CHECK_ONLY_LAST_VERSION,
// Messages.getString("DesignerPreferencePage.checkVersion"), getFieldEditorParent()); //$NON-NLS-1$
// addField(checkOnlyLastVersion);
// BooleanFieldEditor propagateContextVariable = new BooleanFieldEditor(
// TalendDesignerPrefConstants.PROPAGATE_CONTEXT_VARIABLE, Messages
// .getString("DesignerPreferencePage.addOrDeleteVariable"), getFieldEditorParent()); //$NON-NLS-1$
// addField(propagateContextVariable);
BooleanFieldEditor displayMethodSize = new BooleanFieldEditor(TalendDesignerPrefConstants.DISPLAY_METHOD_SIZE, Messages.getString("DesignerPreferencePage.computeLength"), //$NON-NLS-1$
getFieldEditorParent());
addField(displayMethodSize);
BooleanFieldEditor allowDelConnWithJLTriggLinkCompField = new BooleanFieldEditor(TalendDesignerPrefConstants.NOT_SHOW_WARNING_WHEN_DELETE_LINK_WITH_JOBLETTRIGGERLINKCOMPONENT, Messages.getString("DesignerPreferencePage.notShowWarningDialog"), //$NON-NLS-1$
getFieldEditorParent());
addField(allowDelConnWithJLTriggLinkCompField);
}
use of org.eclipse.swt.widgets.DirectoryDialog in project tdi-studio-se by Talend.
the class ConfigureConnParamDialog method createDirectoryComponent.
/**
* qiang.zhang Comment method "createDirectoryComponent".
*
* @param key
* @param defaultContext
*/
private void createDirectoryComponent(final EConnectionParameterName key, IContext defaultContext) {
GridLayout gridLayout;
GridData gridData;
Composite hostComposite = new Composite(mainComposite, SWT.NONE);
gridLayout = new GridLayout();
gridLayout.verticalSpacing = 2;
gridLayout.marginTop = 5;
gridLayout.marginBottom = 2;
gridLayout.marginHeight = 0;
gridLayout.marginWidth = 0;
gridLayout.marginLeft = 0;
gridLayout.marginRight = 0;
gridData = new GridData(GridData.FILL_HORIZONTAL);
hostComposite.setLayout(gridLayout);
hostComposite.setLayoutData(gridData);
Label hostLabel = new Label(hostComposite, SWT.NONE);
//$NON-NLS-1$
hostLabel.setText(key.getDisplayName() + ":");
// GridDataFactory.swtDefaults().hint(LABEL_DEFAULT_X, DEFAULT_HEIGHT).applyTo(hostLabel);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
hostLabel.setLayoutData(data);
Composite fileComposite = new Composite(hostComposite, SWT.NONE);
gridLayout = new GridLayout();
gridLayout.numColumns = 2;
gridLayout.verticalSpacing = 0;
gridLayout.marginTop = 0;
gridLayout.marginBottom = 0;
gridLayout.marginHeight = 0;
gridLayout.marginWidth = 0;
gridLayout.marginLeft = 0;
gridLayout.marginRight = 0;
gridData = new GridData(GridData.FILL_HORIZONTAL);
fileComposite.setLayout(gridLayout);
fileComposite.setLayoutData(gridData);
final Text host = new Text(fileComposite, SWT.BORDER);
host.setText(pvValues.get(key));
if (host.getText().trim().length() == 0) {
host.setBackground(ColorConstants.red);
host.redraw();
}
// GridDataFactory.swtDefaults().hint(TEXT_DEFAULT_X, DEFAULT_HEIGHT).applyTo(host);
gridData = new GridData(GridData.FILL_HORIZONTAL);
host.setLayoutData(gridData);
Button button = new Button(fileComposite, SWT.PUSH);
//$NON-NLS-1$
button.setText("...");
button.addSelectionListener(new SelectionListener() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog(mainComposite.getShell(), SWT.NONE);
String path = PathExtractor.extractPath(host.getText());
dialog.setFilterPath(PathUtils.getOSPath(path));
String file = dialog.open();
if (file != null) {
if (!file.equals("")) {
//$NON-NLS-1$
host.setText(PathUtils.getPortablePath(file));
}
}
}
});
final Text hostText = new Text(hostComposite, SWT.NONE);
hostText.setEditable(false);
gridData = new GridData(GridData.FILL_HORIZONTAL);
hostText.setLayoutData(gridData);
hostText.setText(CONTEXT_WITH + ContextParameterUtils.parseScriptContextCode(host.getText(), defaultContext));
host.setData(TEXT_CONTROL, hostText);
host.setData(key);
allParamText.add(host);
host.addModifyListener(new ModifyListener() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
*/
@Override
public void modifyText(ModifyEvent e) {
if (isRequriedValue(key.getName())) {
if (host.getText().trim().length() == 0) {
host.setBackground(ColorConstants.red);
host.redraw();
} else {
host.setBackground(ColorConstants.white);
host.redraw();
}
resetValues(host, hostText);
}
}
});
}
use of org.eclipse.swt.widgets.DirectoryDialog in project tdi-studio-se by Talend.
the class ToolsPreferencePage method createJdkRootDirectoryGroup.
/**
* Creates the JDK root directory group.
*
* @param parent
* The parent composite
*/
private void createJdkRootDirectoryGroup(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(3, false));
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label label = new Label(composite, SWT.NONE);
label.setText(Messages.jdkRootDirectoryLabel);
jdkRootDirectoryText = new Text(composite, SWT.BORDER);
jdkRootDirectoryText.setText(getPreferenceStore().getString(IConstants.JDK_ROOT_DIRECTORY));
jdkRootDirectoryText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
jdkRootDirectoryText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
validateJdkRootDirectory();
}
});
Button button = new Button(composite, SWT.NONE);
button.setText(Messages.browseButton);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog(e.display.getActiveShell());
dialog.setMessage(Messages.selectJdkRootDirectoryMsg);
String path = dialog.open();
if (path == null) {
return;
}
File file = new File(path);
if (file.isDirectory()) {
jdkRootDirectoryText.setText(path);
}
}
});
}
use of org.eclipse.swt.widgets.DirectoryDialog in project tdi-studio-se by Talend.
the class PromptDialog method createParameterComposite.
/**
* DOC qiang.zhang Comment method "createParameterComposite".
*
* @param parent
* @param parameter
* @param label
*/
private void createParameterComposite(final Composite parent, final IContextParameter parameter, Label label) {
final Composite child = new Composite(parent, SWT.NONE);
final GridLayout layout = new GridLayout(2, false);
layout.marginLeft = 0;
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
layout.marginWidth = 0;
layout.marginHeight = 0;
child.setLayout(layout);
child.setLayoutData(new GridData(GridData.FILL_BOTH));
if (DefaultCellEditorFactory.isList(parameter.getType())) {
createListParameterArea(parameter, label, child);
return;
}
final Text text = new Text(child, SWT.SINGLE | SWT.BORDER);
text.setText(parameter.getValue());
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
parameter.setValue(text.getText());
}
});
//$NON-NLS-1$
String stringTip = "";
//$NON-NLS-1$
String comment = "";
if (parameter.getType().equalsIgnoreCase("String") && LanguageManager.getCurrentLanguage() == ECodeLanguage.PERL) {
//$NON-NLS-1$
//$NON-NLS-1$
stringTip = Messages.getString("PromptDialog.stringTip");
}
comment = parameter.getComment();
if (!stringTip.equals("")) {
//$NON-NLS-1$
//$NON-NLS-1$
comment = comment + " " + stringTip;
}
label.setToolTipText(comment);
text.setToolTipText(comment);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.minimumWidth = MINIMUM_WIDTH;
text.setLayoutData(data);
if (DefaultCellEditorFactory.isDate(parameter.getType())) {
text.setEditable(false);
final Button b = new Button(child, SWT.NONE);
//$NON-NLS-1$
b.setText("...");
b.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
DateDialog d = new DateDialog(((Button) e.getSource()).getShell());
int res = d.open();
if (res == Dialog.OK) {
text.setText(DefaultCellEditorFactory.getAddQuoteString(d.getTalendDateString()));
}
}
});
} else if (DefaultCellEditorFactory.isFile(parameter.getType())) {
text.setEditable(false);
final Button b = new Button(child, SWT.NONE);
//$NON-NLS-1$
b.setText("...");
b.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
FileDialog d = new FileDialog(((Button) e.getSource()).getShell());
if (text.getText() != null) {
d.setFileName(PathUtils.getOSPath(DefaultCellEditorFactory.getRemoveQuoteString(text.getText())));
}
String open = d.open();
if (open != null) {
text.setText(DefaultCellEditorFactory.getAddQuoteString(PathUtils.getPortablePath(open)));
}
}
});
} else if (DefaultCellEditorFactory.isDirectory(parameter.getType())) {
text.setEditable(false);
final Button b = new Button(child, SWT.NONE);
//$NON-NLS-1$
b.setText("...");
b.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog d = new DirectoryDialog(((Button) e.getSource()).getShell());
if (text.getText() != null) {
d.setFilterPath(PathUtils.getOSPath(DefaultCellEditorFactory.getRemoveQuoteString(text.getText())));
}
String open = d.open();
if (open != null) {
open = PathUtils.getPortablePath(open);
//$NON-NLS-1$
open += "/";
text.setText(DefaultCellEditorFactory.getAddQuoteString(open));
}
}
});
} else if (DefaultCellEditorFactory.isPassword(parameter.getType())) {
text.setEchoChar('*');
}
}
Aggregations