use of org.talend.commons.ui.runtime.swt.tableviewer.celleditor.DateDialog 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('*');
}
}
use of org.talend.commons.ui.runtime.swt.tableviewer.celleditor.DateDialog in project tdi-studio-se by Talend.
the class DateController method createCommand.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createCommand()
*/
public Command createCommand(Button button) {
DateDialog dateDial = new DateDialog(composite.getShell());
int returnValue = dateDial.open();
if (returnValue == DateDialog.OK) {
String propertyName = (String) button.getData(PARAMETER_NAME);
String date = dateDial.getTalendDateString();
if (date != null && !date.equals(elem.getPropertyValue(propertyName))) {
elem.setPropertyValue(EParameterName.UPDATE_COMPONENTS.getName(), Boolean.TRUE);
return new PropertyChangeCommand(elem, propertyName, TalendTextUtils.addQuotes(date));
}
}
return null;
}
Aggregations