use of org.eclipse.swt.events.ModifyListener in project tdi-studio-se by Talend.
the class ExportItemWizardPage method createItemRoot.
@SuppressWarnings("restriction")
private void createItemRoot(Composite workArea) {
Composite projectGroup = new Composite(workArea, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
layout.makeColumnsEqualWidth = false;
layout.marginWidth = 0;
projectGroup.setLayout(layout);
projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
itemFromDirectoryRadio = new Button(projectGroup, SWT.RADIO);
// itemFromDirectoryRadio.setText(DataTransferMessages.WizardProjectsImportPage_RootSelectTitle);
//$NON-NLS-1$
itemFromDirectoryRadio.setText(Messages.getString("DataTransferMessages.WizardProjectsImportPage_RootSelectTitle"));
this.directoryPathField = new Text(projectGroup, SWT.BORDER);
String arcFileName = null;
if (selection != null && selection.getFirstElement() instanceof RepositoryNode) {
RepositoryNode node = (RepositoryNode) selection.getFirstElement();
if (node.getObject() == null) {
arcFileName = node.getLabel();
} else {
arcFileName = node.getObject().getLabel();
}
}
this.directoryPathField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
String exportDirPath = reloadExportPath(DIRECTORY_PATH);
if (exportDirPath != null) {
if (arcFileName != null) {
if (new Path(exportDirPath).lastSegment() != null && !new Path(exportDirPath).lastSegment().equals(arcFileName)) {
exportDirPath = exportDirPath + File.separator + arcFileName;
}
}
this.directoryPathField.setText(exportDirPath);
this.lastPath = exportDirPath;
}
browseDirectoriesButton = new Button(projectGroup, SWT.PUSH);
// browseDirectoriesButton.setText(DataTransferMessages.DataTransfer_browse);
//$NON-NLS-1$
browseDirectoriesButton.setText(Messages.getString("DataTransferMessages.DataTransfer_browse"));
setButtonLayoutData(browseDirectoriesButton);
// new project from archive radio button
itemFromArchiveRadio = new Button(projectGroup, SWT.RADIO);
// itemFromArchiveRadio.setText(DataTransferMessages.WizardProjectsImportPage_ArchiveSelectTitle);
//$NON-NLS-1$
itemFromArchiveRadio.setText(Messages.getString("DataTransferMessages.WizardProjectsImportPage_ArchiveSelectTitle"));
// project location entry field
archivePathField = new Text(projectGroup, SWT.BORDER);
archivePathField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
if (arcFileName != null) {
String exportArchivePath = reloadExportPath(ARCHIVE_PATH);
// when first open the exportItem dialog ,the exportPath maybe empty,need judge
if (exportArchivePath != null && exportArchivePath.trim().length() > 0) {
File beforeExportArchiveFolder = new File(exportArchivePath).getParentFile();
/*
* TDI-22791, when the exportArchivePath is only name without path. No need check the existed or not.
* Because will be create the parent folders, when export item.
*/
if (beforeExportArchiveFolder != null) /* && beforeExportArchiveFolder.exists() */
{
String newPath = new File(beforeExportArchiveFolder, arcFileName + FileConstants.ZIP_FILE_SUFFIX).getAbsolutePath();
this.archivePathField.setText(newPath);
}
} else if (exportDirPath != null && exportDirPath.trim().length() > 0) {
String newPath = exportDirPath + File.separator + arcFileName + FileConstants.ZIP_FILE_SUFFIX;
this.archivePathField.setText(newPath);
}
}
// browse button
browseArchivesButton = new Button(projectGroup, SWT.PUSH);
// browseArchivesButton.setText(DataTransferMessages.DataTransfer_browse);
//$NON-NLS-1$
browseArchivesButton.setText(Messages.getString("DataTransferMessages.DataTransfer_browse"));
setButtonLayoutData(browseArchivesButton);
itemFromDirectoryRadio.setSelection(true);
archivePathField.setEnabled(false);
browseArchivesButton.setEnabled(false);
browseDirectoriesButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleLocationDirectoryButtonPressed();
}
});
browseArchivesButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleLocationArchiveButtonPressed();
}
});
directoryPathField.addTraverseListener(new TraverseListener() {
@Override
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_RETURN) {
e.doit = false;
lastPath = directoryPathField.getText().trim();
}
}
});
directoryPathField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
lastPath = directoryPathField.getText().trim();
}
});
directoryPathField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String exportPath = resetExportPath(directoryPathField.getText());
saveExportPath(DIRECTORY_PATH, exportPath);
}
});
archivePathField.addTraverseListener(new TraverseListener() {
@Override
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_RETURN) {
e.doit = false;
lastPath = archivePathField.getText().trim();
}
}
});
archivePathField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
lastPath = archivePathField.getText().trim();
}
});
archivePathField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
saveExportPath(ARCHIVE_PATH, archivePathField.getText());
}
});
itemFromDirectoryRadio.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
directoryRadioSelected();
}
});
itemFromArchiveRadio.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
archiveRadioSelected();
}
});
exportDependencies = new Button(workArea, SWT.CHECK);
//$NON-NLS-1$
exportDependencies.setText(Messages.getString("ExportItemWizardPage.exportDependenciesText"));
exportDependencies.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
checkedDependency.clear();
implicitDependences.clear();
CheckboxTreeViewer exportItemsTreeViewer = getItemsTreeViewer();
Set allNode = new HashSet();
if (exportDependencies.getSelection()) {
refreshExportDependNodes();
exportDependenciesSelected();
allNode.addAll(checkedDependency);
allNode.addAll(implicitDependences);
} else {
allNode.addAll(initcheckedNodes);
}
Set toselect = new HashSet();
for (Object obj : allNode) {
ERepositoryObjectType objectType = getObjectType(obj);
expandRoot(objectType);
expandParent(exportItemsTreeViewer, obj, objectType);
checkElement(obj, toselect);
}
exportItemsTreeViewer.setCheckedElements(toselect.toArray());
if (!exportDependencies.getSelection()) {
for (Object unchecked : uncheckedNodes) {
exportItemsTreeViewer.setChecked(unchecked, false);
}
}
}
});
}
use of org.eclipse.swt.events.ModifyListener in project tdi-studio-se by Talend.
the class CommandController method createControl.
@Override
public Control createControl(Composite subComposite, final IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
this.curParameter = param;
this.paramFieldType = param.getFieldType();
FormData data;
// button
final Button btnCmd = getWidgetFactory().createButton(subComposite, null, SWT.PUSH);
btnCmd.setText(LAUNCH);
data = new FormData();
GC gc = new GC(btnCmd);
Point labelSize = gc.stringExtent(LAUNCH);
gc.dispose();
int currentLabelWidth = STANDARD_BUTTON_WIDTH;
if ((labelSize.x + ITabbedPropertyConstants.HSPACE * 2) > STANDARD_BUTTON_WIDTH) {
currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE * 2;
}
data.left = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), -currentLabelWidth);
data.right = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), 0);
data.top = new FormAttachment(0, top);
data.height = STANDARD_HEIGHT + 2;
btnCmd.setLayoutData(data);
btnCmd.setData(PARAMETER_NAME, param.getName());
btnCmd.setData(NAME, COMMANDS);
btnCmd.setData(COMMANDS, checkQuotes((String) param.getValue()));
btnCmd.setEnabled(!param.isReadOnly());
btnCmd.addSelectionListener(btnListenerSelection);
// text
DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new SelectAllTextControlCreator());
if (param.isRequired()) {
FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
}
Control cLayout = dField.getLayoutControl();
final Text commandText = (Text) dField.getControl();
commandText.setData(PARAMETER_NAME, param.getName());
cLayout.setBackground(subComposite.getBackground());
commandText.setEditable(!param.isReadOnly());
// init the commands from definded xml
commandText.setText(checkQuotes((String) param.getValue()));
commandText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String string = checkQuotes(commandText.getText());
param.setValue(string);
btnCmd.setData(COMMANDS, param.getValue());
}
});
editionControlHelper.register(param.getName(), commandText);
addDragAndDropTarget(commandText);
if (elem instanceof Node) {
commandText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
}
hashCurControls.put(param.getName(), commandText);
// label
CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
data = new FormData();
if (lastControl != null) {
data.left = new FormAttachment(lastControl, 0);
} else {
data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
}
data.top = new FormAttachment(0, top);
labelLabel.setLayoutData(data);
if (numInRow != 1) {
labelLabel.setAlignment(SWT.RIGHT);
}
// **************************
data = new FormData();
currentLabelWidth = STANDARD_LABEL_WIDTH;
gc = new GC(labelLabel);
labelSize = gc.stringExtent(param.getDisplayName());
gc.dispose();
if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
}
if (numInRow == 1) {
if (lastControl != null) {
data.left = new FormAttachment(lastControl, currentLabelWidth);
} else {
data.left = new FormAttachment(0, currentLabelWidth);
}
} else {
data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
}
data.right = new FormAttachment(btnCmd, 0);
data.top = new FormAttachment(btnCmd, 0, SWT.CENTER);
cLayout.setLayoutData(data);
Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
return btnCmd;
}
use of org.eclipse.swt.events.ModifyListener in project tdi-studio-se by Talend.
the class DataMapTableView method attachCellExpressionToStyledTextEditor.
/**
* DOC amaumont Comment method "attachCellExpressionToStyledTextEditor".
*
* @param tableViewerCreator TODO
* @param styledTextHandler
* @param expressionEditorText2
*/
protected void attachCellExpressionToStyledTextEditor(final TableViewerCreator tableViewerCreator, final Text expressionTextEditor, final StyledTextHandler styledTextHandler) {
expressionTextEditor.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
ITableEntry currentModifiedEntry = (ITableEntry) tableViewerCreator.getModifiedObjectInfo().getCurrentModifiedBean();
styledTextHandler.setCurrentEntry(currentModifiedEntry);
Text text = (Text) e.widget;
if (Math.abs(text.getText().length() - styledTextHandler.getStyledText().getText().length()) > 1) {
styledTextHandler.setTextWithoutNotifyListeners(text.getText());
// highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
}
}
});
expressionTextEditor.addKeyListener(new KeyListener() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent)
*/
@Override
public void keyPressed(KeyEvent e) {
// System.out.println("e.character=" + e.character);
// System.out.println("keyCode=" + e.keyCode);
boolean ctrl = (e.stateMask & SWT.CTRL) != 0;
boolean altgr = (e.stateMask & SWT.ALT) != 0;
if (e.character == '\0' || ctrl && !altgr) {
highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
} else {
UnnotifiableColorStyledText mapperColorStyledText = (UnnotifiableColorStyledText) styledTextHandler.getStyledText();
Point selection = expressionTextEditor.getSelection();
if (e.character == '\r' || e.character == '') {
e.doit = false;
styledTextHandler.setTextWithoutNotifyListeners(expressionTextEditor.getText());
highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
} else {
if (e.character == SWT.BS || e.character == SWT.DEL) {
if (selection.x == selection.y) {
if (e.character == SWT.BS) {
if (selection.x - 1 > 0 && mapperColorStyledText.getText().length() > selection.x - 1) {
char previousChar = mapperColorStyledText.getText().charAt(selection.x - 1);
if (previousChar == '\n') {
//$NON-NLS-1$
mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x - 2, 2, "");
} else {
//$NON-NLS-1$
mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x - 1, 1, "");
}
}
} else {
if (selection.x < mapperColorStyledText.getText().length()) {
char nextChar = mapperColorStyledText.getText().charAt(selection.x);
if (nextChar == '\r') {
//$NON-NLS-1$
mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x, 2, "");
} else {
//$NON-NLS-1$
mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x, 1, "");
}
}
}
} else {
if (selection.y <= mapperColorStyledText.getCharCount()) {
mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x, selection.y - selection.x, //$NON-NLS-1$
"");
}
highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
}
} else {
// System.out.println("mapperColorStyledText.getText()="+mapperColorStyledText.getText().length());
if (selection.y <= mapperColorStyledText.getCharCount()) {
mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x, selection.y - selection.x, String.valueOf(e.character));
}
highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
}
}
}
}
@Override
public void keyReleased(KeyEvent e) {
// highlightLineOfCursorPosition();
}
});
expressionTextEditor.addMouseListener(new MouseListener() {
@Override
public void mouseDoubleClick(MouseEvent e) {
highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
}
@Override
public void mouseDown(MouseEvent e) {
highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
}
@Override
public void mouseUp(MouseEvent e) {
}
});
}
use of org.eclipse.swt.events.ModifyListener in project tdi-studio-se by Talend.
the class NewJvmConnectionWizardPage method addTextField.
/**
* Adds the text field.
*
* @param composite The composite
* @param labelString The label string
* @return The text widget
*/
private Text addTextField(Composite composite, String labelString) {
Label label = new Label(composite, SWT.NONE);
label.setText(labelString);
Text text = new Text(composite, SWT.BORDER);
text.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
text.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
validate();
}
});
return text;
}
use of org.eclipse.swt.events.ModifyListener in project tdi-studio-se by Talend.
the class JSONFileOutputStep3Form method addFieldsListeners.
@Override
protected void addFieldsListeners() {
metadataNameText.addModifyListener(new ModifyListener() {
public void modifyText(final ModifyEvent e) {
MetadataToolHelper.validateSchema(metadataNameText.getText());
metadataTable.setLabel(metadataNameText.getText());
checkFieldsValue();
}
});
metadataNameText.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
MetadataToolHelper.checkSchema(getShell(), e);
}
});
metadataCommentText.addModifyListener(new ModifyListener() {
public void modifyText(final ModifyEvent e) {
metadataTable.setComment(metadataCommentText.getText());
}
});
tableEditorView.getMetadataEditor().addAfterOperationListListener(new IListenableListListener() {
public void handleEvent(ListenableListEvent event) {
checkFieldsValue();
}
});
}
Aggregations