use of org.eclipse.swt.events.ModifyListener in project tdi-studio-se by Talend.
the class DeploymentComposite method addListeners.
private void addListeners() {
groupIdCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (groupIdCheckbox.getSelection()) {
groupIdText.setEnabled(true);
groupIdText.setText(groupId);
} else {
groupIdText.setEnabled(false);
groupIdText.setText(defaultGroupId);
// remove key, so will be default groupId
Command cmd = new MavenDeploymentValueChangeCommand(process, MavenConstants.NAME_GROUP_ID, null);
getCommandStack().execute(cmd);
}
}
});
groupIdText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String currentGroupId = groupIdText.getText();
if (currentGroupId != null && !currentGroupId.trim().equals("")) {
//$NON-NLS-1$
groupIdText.setBackground(getBackground());
//$NON-NLS-1$
groupIdText.setToolTipText("");
if (!defaultGroupId.equals(currentGroupId)) {
groupId = currentGroupId;
} else {
currentGroupId = null;
}
Command cmd = new MavenDeploymentValueChangeCommand(process, MavenConstants.NAME_GROUP_ID, currentGroupId);
getCommandStack().execute(cmd);
} else {
groupIdText.setBackground(COLOR_RED);
//$NON-NLS-1$
groupIdText.setToolTipText(Messages.getString("DeploymentComposite.valueWarning"));
}
}
});
versionCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (versionCheckbox.getSelection()) {
versionText.setEnabled(true);
versionText.setText(version);
} else {
versionText.setEnabled(false);
versionText.setText(defaultVersion);
// remove key, so will be default version
Command cmd = new MavenDeploymentValueChangeCommand(process, MavenConstants.NAME_USER_VERSION, null);
getCommandStack().execute(cmd);
}
}
});
versionText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String currentVersion = versionText.getText();
if (//$NON-NLS-1$
currentVersion != null && !currentVersion.trim().equals("") && !MavenVersionUtils.isValidMavenVersion(currentVersion)) {
//$NON-NLS-1$
versionText.setToolTipText(Messages.getString("DeploymentComposite.valueWarning"));
versionText.setBackground(COLOR_RED);
} else {
//$NON-NLS-1$
versionText.setToolTipText("");
versionText.setBackground(getBackground());
if (!defaultVersion.equals(currentVersion)) {
version = currentVersion;
} else {
currentVersion = null;
}
// if empty, remove it from job, else will set the new value
Command cmd = new MavenDeploymentValueChangeCommand(process, MavenConstants.NAME_USER_VERSION, currentVersion);
getCommandStack().execute(cmd);
}
}
});
buildTypeCombo.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
final ISelection selection = event.getSelection();
if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
final Object elem = ((IStructuredSelection) selection).getFirstElement();
if (elem instanceof BuildType) {
Command cmd = new MavenDeploymentValueChangeCommand(process, TalendProcessArgumentConstant.ARG_BUILD_TYPE, ((BuildType) elem).getName());
getCommandStack().execute(cmd);
}
}
}
});
}
use of org.eclipse.swt.events.ModifyListener in project tdi-studio-se by Talend.
the class StyledTextHandler method addListeners.
/**
* DOC amaumont Comment method "addListeners".
*/
private void addListeners() {
styledText.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
refreshProposalSize();
}
public void focusLost(FocusEvent e) {
}
});
styledText.addControlListener(new ControlListener() {
public void controlMoved(ControlEvent e) {
}
public void controlResized(ControlEvent e) {
refreshProposalSize();
}
});
styledText.addExtendedModifyListener(new ExtendedModifyListener() {
public void modifyText(ExtendedModifyEvent event) {
// System.out.println("ExtendedModifyListener modify text");
updateCellExpression();
}
});
styledText.getContent().addTextChangeListener(new TextChangeListener() {
public void textChanged(TextChangedEvent event) {
highlightLineOfCursorPosition(styledText.getSelection());
}
public void textChanging(TextChangingEvent event) {
// System.out.println("textChanging");
}
public void textSet(TextChangedEvent event) {
// System.out.println("textSet");
}
});
styledText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
highlightLineOfCursorPosition(styledText.getSelection());
}
});
styledText.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
highlightLineOfCursorPosition(styledText.getSelection());
}
public void keyReleased(KeyEvent e) {
// TODO Auto-generated method stub
}
});
styledText.addVerifyKeyListener(new VerifyKeyListener() {
public void verifyKey(VerifyEvent verifyEvent) {
if (verifyEvent.character == '\r' && contentProposalAdapter != null && contentProposalAdapter.isProposalOpened()) {
verifyEvent.doit = false;
} else {
verifyEvent.doit = true;
}
}
});
styledText.addMouseListener(new MouseListener() {
public void mouseDoubleClick(MouseEvent e) {
highlightLineOfCursorPosition(styledText.getSelection());
}
public void mouseDown(MouseEvent e) {
highlightLineOfCursorPosition(styledText.getSelection());
}
public void mouseUp(MouseEvent e) {
}
});
}
use of org.eclipse.swt.events.ModifyListener 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.eclipse.swt.events.ModifyListener in project tdi-studio-se by Talend.
the class TraceDebugProcessComposite method createLineLimitedControl.
private void createLineLimitedControl(Composite container) {
Composite composite = new Composite(container, SWT.NONE);
composite.setLayoutData(new GridData());
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = 7;
formLayout.marginHeight = 4;
formLayout.spacing = 7;
composite.setLayout(formLayout);
enableLineLimitButton = new Button(composite, SWT.CHECK);
//$NON-NLS-1$
enableLineLimitButton.setText(Messages.getString("ProcessComposite.lineLimited"));
FormData formData = new FormData();
enableLineLimitButton.setLayoutData(formData);
enableLineLimitButton.setEnabled(false);
enableLineLimitButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
lineLimitText.setEditable(enableLineLimitButton.getSelection());
RunProcessPlugin.getDefault().getPluginPreferences().setValue(RunprocessConstants.ENABLE_CONSOLE_LINE_LIMIT, enableLineLimitButton.getSelection());
}
});
lineLimitText = new Text(composite, SWT.BORDER);
formData = new FormData();
formData.width = 120;
formData.left = new FormAttachment(enableLineLimitButton, 0, SWT.RIGHT);
lineLimitText.setLayoutData(formData);
lineLimitText.setEnabled(false);
lineLimitText.addListener(SWT.Verify, new Listener() {
// this text only receive number here.
@Override
public void handleEvent(Event e) {
String s = e.text;
if (!s.equals("")) {
//$NON-NLS-1$
try {
Integer.parseInt(s);
RunProcessPlugin.getDefault().getPluginPreferences().setValue(RunprocessConstants.CONSOLE_LINE_LIMIT_COUNT, lineLimitText.getText() + s);
} catch (Exception ex) {
e.doit = false;
}
}
}
});
lineLimitText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
RunProcessPlugin.getDefault().getPluginPreferences().setValue(RunprocessConstants.CONSOLE_LINE_LIMIT_COUNT, lineLimitText.getText());
}
});
boolean enable = RunProcessPlugin.getDefault().getPluginPreferences().getBoolean(RunprocessConstants.ENABLE_CONSOLE_LINE_LIMIT);
enableLineLimitButton.setSelection(enable);
lineLimitText.setEditable(enable);
String count = RunProcessPlugin.getDefault().getPluginPreferences().getString(RunprocessConstants.CONSOLE_LINE_LIMIT_COUNT);
if (count.equals("")) {
//$NON-NLS-1$
//$NON-NLS-1$
count = "100";
}
lineLimitText.setText(count);
}
use of org.eclipse.swt.events.ModifyListener in project tdi-studio-se by Talend.
the class ConfigureChartDialog method createChartConfigControls.
/**
* Creates the controls for chart configuration.
*
* @param parent The parent composite
*/
private void createChartConfigControls(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
new Label(composite, SWT.NONE).setText(Messages.chartTitleLabel);
chartTitleText = new Text(composite, SWT.BORDER);
chartTitleText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
chartTitleText.setText(chartTitle);
chartTitleText.setSelection(0, chartTitle.length());
chartTitleText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
validate(chartTitleText.getText());
}
});
new Label(composite, SWT.NONE).setText(Messages.yAxisUnitLabel);
axisUnitCombo = new Combo(composite, SWT.READ_ONLY);
List<String> items = new ArrayList<String>();
int initialSelection = -1;
AxisUnit[] values = AxisUnit.values();
for (int i = 0; i < values.length; i++) {
items.add(values[i].name());
if (values[i] == unit) {
initialSelection = i;
}
}
axisUnitCombo.setItems(items.toArray(new String[items.size()]));
if (initialSelection == -1) {
initialSelection = items.size() - 1;
}
axisUnitCombo.select(initialSelection);
axisUnitCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
Aggregations