use of org.eclipse.swt.events.TraverseListener 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.TraverseListener in project tdi-studio-se by Talend.
the class ExpressionCellEditor method createText.
public Text createText(Composite parent) {
text = new Text(parent, SWT.NONE);
text.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
handleDefaultSelection(e);
}
});
text.addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_ESCAPE || e.detail == SWT.TRAVERSE_RETURN) {
e.doit = false;
}
}
});
// We really want a selection listener but it is not supported so we
// use a key listener and a mouse listener to know when selection
// changes
// may have occured
text.addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent e) {
highlightLineAndSetSelectionOfStyledTextFromTextControl(text);
}
@Override
public void mouseUp(MouseEvent e) {
checkSelection();
checkDeleteable();
checkSelectable();
}
});
text.setFont(parent.getFont());
text.setBackground(parent.getBackground());
//$NON-NLS-1$
text.setText("");
text.addModifyListener(getModifyListener());
return text;
}
use of org.eclipse.swt.events.TraverseListener in project tdi-studio-se by Talend.
the class MultiPageSqlBuilderEditor method createContainer.
private CTabFolder createContainer(Composite parent) {
// use SWT.FLAT style so that an extra 1 pixel border is not reserved
// inside the folder
parent.setLayout(new FillLayout());
final CTabFolder newContainer = new CTabFolder(parent, SWT.BOTTOM | SWT.FLAT);
newContainer.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int newPageIndex = newContainer.indexOf((CTabItem) e.item);
pageChange(newPageIndex);
}
});
newContainer.addTraverseListener(new TraverseListener() {
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=199499 : Switching tabs by Ctrl+PageUp/PageDown must not be caught on the inner tab set
@Override
public void keyTraversed(TraverseEvent e) {
switch(e.detail) {
case SWT.TRAVERSE_PAGE_NEXT:
case SWT.TRAVERSE_PAGE_PREVIOUS:
int detail = e.detail;
e.doit = true;
e.detail = SWT.TRAVERSE_NONE;
Control control = newContainer.getParent();
do {
if (control.traverse(detail))
return;
if (control.getListeners(SWT.Traverse).length != 0)
return;
if (control instanceof Shell)
return;
control = control.getParent();
} while (control != null);
}
}
});
return newContainer;
}
use of org.eclipse.swt.events.TraverseListener in project cubrid-manager by CUBRID.
the class JdbcOptionComposite method focusCell.
public void focusCell(final TableItem item, final int row, final int col) {
final StyledText text = new StyledText(jdbcInfoTv.getTable(), SWT.SINGLE);
Listener textListener = new TableItemEditor(text, item, row, col);
text.addListener(SWT.FocusOut, textListener);
text.addListener(SWT.Traverse, textListener);
text.addListener(SWT.FocusIn, textListener);
text.addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
e.doit = false;
int newColumn = col == 0 ? 1 : 0;
focusCell(item, row, newColumn);
} else if (e.detail == SWT.TRAVERSE_RETURN) {
e.doit = false;
addButton.setFocus();
}
}
});
text.setEditable(true);
editor.setEditor(text, item, col);
text.setText(item.getText(col));
text.selectAll();
try {
text.setFocus();
} catch (Exception e) {
}
}
use of org.eclipse.swt.events.TraverseListener in project cubrid-manager by CUBRID.
the class PstmtOneDataDialog method handleValueInPlace.
/**
*
* Edit value in place
*
* @param item TableItem
*/
private void handleValueInPlace(final TableItem item) {
final Text newEditor = new Text(parameterTable, SWT.MULTI | SWT.WRAP);
final int editColumn = 2;
newEditor.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
if (!validate(newEditor.getText(), item)) {
getButton(IDialogConstants.OK_ID).setEnabled(false);
}
}
});
newEditor.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent event) {
if (isChanging) {
return;
}
isChanging = true;
if (validate(newEditor.getText(), item)) {
item.setText(editColumn, newEditor.getText());
}
newEditor.dispose();
isChanging = false;
packTable();
validate();
}
});
// add listener for key pressed
newEditor.addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent event) {
if (event.detail == SWT.TRAVERSE_RETURN) {
if (isChanging) {
return;
}
isChanging = true;
if (validate(newEditor.getText(), item)) {
item.setText(editColumn, newEditor.getText());
}
newEditor.dispose();
isChanging = false;
packTable();
validate();
event.doit = true;
int selItem = 0;
for (int i = 0; i < parameterTable.getItemCount(); i++) {
if (item == parameterTable.getItem(i)) {
selItem = i;
break;
}
}
selItem = selItem + 1;
if (selItem >= parameterTable.getItemCount()) {
getButton(IDialogConstants.OK_ID).setFocus();
} else {
handleType(parameterTable.getItem(selItem));
}
} else if (event.detail == SWT.TRAVERSE_ESCAPE) {
if (isChanging) {
return;
}
isChanging = true;
newEditor.dispose();
event.doit = false;
isChanging = false;
}
}
});
tableEditor.setEditor(newEditor, item, editColumn);
newEditor.setText(item.getText(editColumn));
newEditor.selectAll();
newEditor.setFocus();
}
Aggregations