use of org.eclipse.swt.events.MouseAdapter 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.MouseAdapter in project tdi-studio-se by Talend.
the class MavenVersionManagementProjectSettingPage method addItemElements.
@Override
protected void addItemElements(List<ItemVersionObject> elements) {
if (elements == null || elements.isEmpty()) {
return;
}
itemTable.setRedraw(false);
for (final ItemVersionObject object : elements) {
final TableItem tableItem = new TableItem(itemTable, SWT.CENTER);
tableItem.setData(object);
Item item = object.getItem();
IBaseLabelProvider labelProvider = treeViewer.getLabelProvider();
Image itemsImage = null;
if (labelProvider instanceof NavigatorDecoratingLabelProvider) {
NavigatorDecoratingLabelProvider navigatorProvider = (NavigatorDecoratingLabelProvider) labelProvider;
itemsImage = navigatorProvider.getImage(object.getRepositoryNode());
} else {
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(item);
itemsImage = getItemsImage(CoreImageProvider.getIcon(itemType));
}
tableItem.setImage(itemsImage);
tableItem.setText(item.getProperty().getLabel());
// old version
tableItem.setText(1, MavenVersionUtils.getItemMavenVersion(item.getProperty()));
TableEditor versionEditor = null;
if (fixedVersionButton.getSelection()) {
tableItem.setText(2, appliedFixedVersion);
} else if (useJobVersionButton.getSelection()) {
String jobDefaultVersion = MavenVersionUtils.getDefaultVersion(item.getProperty().getVersion());
tableItem.setText(2, jobDefaultVersion);
object.setNewVersion(jobDefaultVersion);
} else {
// new version
versionEditor = new TableEditor(itemTable);
Composite versionComposite = new Composite(itemTable, SWT.NONE);
GridLayout layout = new GridLayout(1, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.marginLeft = 0;
layout.marginRight = 1;
versionComposite.setLayout(layout);
final Text text = new Text(versionComposite, SWT.CENTER | SWT.BORDER);
GridData data = new GridData(GridData.FILL_BOTH);
text.setLayoutData(data);
String newVersion = object.getNewVersion();
if (newVersion == null || "".equals(newVersion.trim())) {
//$NON-NLS-1$
newVersion = appliedFixedVersion;
object.setNewVersion(newVersion);
}
text.setText(newVersion);
checkVersionPattern(text, newVersion);
text.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String version = text.getText();
checkVersionPattern(text, version);
object.setNewVersion(version);
checkValid();
}
});
versionEditor.minimumWidth = itemTable.getColumn(2).getWidth();
versionEditor.setEditor(versionComposite, tableItem, 2);
}
TableEditor delEditor = new TableEditor(itemTable);
Label delLabel = new Label(itemTable, SWT.CENTER);
delLabel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
delLabel.setImage(ImageProvider.getImage(EImage.DELETE_ICON));
//$NON-NLS-1$
delLabel.setToolTipText(Messages.getString("VersionManagementDialog.DeletedTip"));
delLabel.pack();
delLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
checkedObjects.remove(object);
removeTableItem(tableItem);
refreshCheckedTreeView();
checkButtonsState();
checkButtonsState(false);
}
});
delEditor.minimumWidth = 25;
delEditor.horizontalAlignment = SWT.CENTER;
delEditor.setEditor(delLabel, tableItem, 3);
if (fixedVersionButton.getSelection() || useJobVersionButton.getSelection()) {
tableItem.setData(ITEM_EDITOR_KEY, new TableEditor[] { delEditor });
} else if (versionEditor != null) {
tableItem.setData(ITEM_EDITOR_KEY, new TableEditor[] { versionEditor, delEditor });
}
itemTable.setRedraw(true);
}
}
use of org.eclipse.swt.events.MouseAdapter in project tdi-studio-se by Talend.
the class TestComposite method installListener.
private void installListener() {
buttonAddVar.addMouseListener(new MouseAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
*/
@Override
public void mouseUp(MouseEvent e) {
List<Variable> input = (List<Variable>) variableTableViewer.getInput();
input.add(new Variable(input.size()));
variableTableViewer.refresh();
}
});
buttonRemoveVar.addMouseListener(new MouseAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
*/
@Override
public void mouseUp(MouseEvent e) {
ISelection selection = variableTableViewer.getSelection();
List<Variable> list = ((List<Variable>) variableTableViewer.getInput());
if (!selection.isEmpty() && selection instanceof StructuredSelection) {
Object[] vars = ((StructuredSelection) selection).toArray();
for (Object var : vars) {
list.remove(var);
variableTableViewer.refresh();
}
} else if (!list.isEmpty()) {
list.remove(list.size() - 1);
variableTableViewer.refresh();
}
}
});
testButton.addMouseListener(new MouseAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
*/
@Override
public void mouseUp(MouseEvent e) {
new ExpressionTestMain(CategoryComposite.getSelectedFunction(), testResultText);
}
});
clearButton.addMouseListener(new MouseAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
*/
@Override
public void mouseUp(MouseEvent e) {
//$NON-NLS-1$
testResultText.setText("");
}
});
}
use of org.eclipse.swt.events.MouseAdapter in project tdi-studio-se by Talend.
the class SQLBuilderEditorComposite method createStatusArea.
/**
* Creates UI for status bar.
*
* @param parent
*/
private void createStatusArea(Composite parent) {
// create bottom status bar
Composite statusBar = new Composite(parent, SWT.NULL);
GridLayout statusBarLayout = new GridLayout();
statusBarLayout.numColumns = 3;
statusBarLayout.verticalSpacing = 0;
statusBarLayout.marginHeight = 0;
statusBarLayout.marginWidth = 0;
statusBarLayout.marginTop = 0;
statusBarLayout.marginBottom = 0;
statusBarLayout.marginRight = 5;
statusBarLayout.horizontalSpacing = 5;
statusBarLayout.verticalSpacing = 0;
statusBar.setLayout(statusBarLayout);
GridData statusBarGridData = new GridData(SWT.FILL, SWT.BOTTOM, true, false);
statusBarGridData.verticalIndent = 0;
statusBarGridData.horizontalIndent = 0;
statusBar.setLayoutData(statusBarGridData);
// add status line manager
StatusLineManager statusMgr = new StatusLineManager();
statusMgr.createControl(statusBar);
GridData c1Grid = new GridData();
c1Grid.horizontalAlignment = SWT.FILL;
c1Grid.verticalAlignment = SWT.BOTTOM;
c1Grid.grabExcessHorizontalSpace = true;
c1Grid.grabExcessVerticalSpace = false;
statusMgr.getControl().setLayoutData(c1Grid);
// add checkbox for limiting results
GridData c2Grid = new GridData();
c2Grid.horizontalAlignment = SWT.RIGHT;
c2Grid.verticalAlignment = SWT.CENTER;
c2Grid.grabExcessHorizontalSpace = false;
c2Grid.grabExcessVerticalSpace = false;
final Button limitResults = new Button(statusBar, SWT.CHECK);
//$NON-NLS-1$
limitResults.setText(Messages.getString("SQL_Limit_Rows_2"));
limitResults.setSelection(true);
limitResults.setLayoutData(c2Grid);
// add input field for result limit
GridData c3Grid = new GridData();
c3Grid.horizontalAlignment = SWT.RIGHT;
c3Grid.verticalAlignment = SWT.CENTER;
c3Grid.grabExcessHorizontalSpace = false;
c3Grid.grabExcessVerticalSpace = false;
c3Grid.widthHint = 30;
maxResultText = new Text(statusBar, SWT.BORDER | SWT.SINGLE);
maxResultText.setText(IConstants.MAX_SQL_ROWS);
maxResultText.setLayoutData(c3Grid);
limitResults.addMouseListener(new MouseAdapter() {
// enable/disable input field when checkbox is clicked
@Override
public void mouseUp(MouseEvent e) {
maxResultText.setEnabled(limitResults.getSelection());
ifLimit = limitResults.getSelection();
}
});
}
use of org.eclipse.swt.events.MouseAdapter in project cubrid-manager by CUBRID.
the class CubridNavigatorView method addListener.
/**
*
* Add listener
*
*/
protected void addListener() {
tv.getTree().addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent event) {
if (toolTip.isVisible()) {
toolTip.setVisible(false);
}
}
public void mouseUp(MouseEvent event) {
if (event.button == 1 && LayoutManager.getInstance().isUseClickOnce()) {
ISelection selection = tv.getSelection();
if (selection == null || selection.isEmpty()) {
return;
}
Object obj = ((IStructuredSelection) selection).getFirstElement();
if (!(obj instanceof ICubridNode)) {
return;
}
ICubridNode cubridNode = (ICubridNode) obj;
LayoutManager.getInstance().getWorkbenchContrItem().openEditorOrView(cubridNode);
}
}
});
tv.getTree().addMouseTrackListener(new MouseTrackAdapter() {
public void mouseHover(MouseEvent event) {
if (toolTip.isVisible()) {
toolTip.setVisible(false);
}
int x = event.x;
int y = event.y;
TreeItem item = tv.getTree().getItem(new Point(x, y));
if (item == null) {
return;
}
showToolTip(item);
}
});
tv.getTree().addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent event) {
widgetSelected(event);
}
public void widgetSelected(SelectionEvent event) {
if (toolTip.isVisible()) {
toolTip.setVisible(false);
}
TreeItem[] items = tv.getTree().getSelection();
if (items == null || items.length == 0) {
return;
}
showToolTip(items[0]);
if (items.length == 1) {
showSchemaInfo(items[0]);
} else {
showSchemaInfo(null);
}
}
});
addDragDropSupport(tv.getTree());
tv.getTree().addKeyListener(new KeyListener() {
public void keyReleased(KeyEvent e) {
}
public void keyPressed(KeyEvent e) {
// prevent to make events by key press for a long time
if (e.character == ' ') {
TreeItem[] items = tv.getTree().getSelection();
if (items == null || items.length == 0) {
return;
}
if (items.length == 1) {
showSchemaInfo(items[0]);
} else {
showSchemaInfo(null);
}
}
lastKeyInputTimestamp = System.currentTimeMillis();
// by showing object information tab on the query editor.
if (e.keyCode == SWT.F2) {
TreeItem[] items = tv.getTree().getSelection();
if (items == null || items.length == 0) {
return;
}
for (TreeItem item : items) {
Object obj = item.getData();
if (obj instanceof ICubridNode) {
ICubridNode node = (ICubridNode) obj;
if (NodeType.USER_TABLE.equals(node.getType()) || NodeType.SYSTEM_TABLE.equals(node.getType()) || NodeType.USER_VIEW.equals(node.getType()) || NodeType.SYSTEM_VIEW.equals(node.getType())) {
DefaultSchemaNode table = (DefaultSchemaNode) obj;
OpenTargetAction action = new OpenTargetAction();
action.showObjectInfo(table);
} else if (NodeType.TABLE_FOLDER.equals(node.getType())) {
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(ID_CQB);
if (view == null) {
view = CubridNavigatorView.getNavigatorView(ID_CM);
}
if (view == null) {
return;
}
TreeViewer treeViewer = view.getViewer();
//if not expand ,expand the node and wait until all children be added
if (!treeViewer.getExpandedState(node)) {
treeViewer.expandToLevel(node, 1);
while (node.getChildren().size() == 0) {
try {
Thread.sleep(500);
} catch (Exception ignored) {
}
}
}
CubridDatabase database = (CubridDatabase) node.getParent();
OpenTargetAction action = new OpenTargetAction();
action.showTableDashboard(database);
}
}
}
}
}
});
}
Aggregations