use of org.eclipse.swt.events.MouseAdapter in project azure-tools-for-java by Microsoft.
the class ServiceExplorerView method hookMouseActions.
private void hookMouseActions() {
viewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
doubleClickAction.run();
}
});
Tree tree = (Tree) viewer.getControl();
tree.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
if (e.button == 1) {
// left button
TreeItem[] selection = ((Tree) e.widget).getSelection();
if (selection.length > 0) {
TreeItem item = ((Tree) e.widget).getSelection()[0];
Node node = ((TreeNode) item.getData()).node;
// we do not propagate the click event to it
if (!node.isLoading()) {
node.getClickAction().fireNodeActionEvent();
}
}
}
}
});
}
use of org.eclipse.swt.events.MouseAdapter in project KaiZen-OpenAPI-Editor by RepreZen.
the class QuickOutline method createTreeViewer.
protected TreeViewer createTreeViewer(Composite parent) {
final Tree tree = new Tree(parent, SWT.SINGLE);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = tree.getItemHeight();
tree.setLayoutData(gd);
final TreeViewer treeViewer = new TreeViewer(tree);
treeViewer.setContentProvider(new OutlineContentProvider());
treeViewer.setLabelProvider(new OutlineStyledLabelProvider());
treeViewer.addFilter(new NamePatternFilter());
// Using ALL_LEVELS will cause editor to hang on large specs
treeViewer.setAutoExpandLevel(2);
treeViewer.setUseHashlookup(true);
tree.addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent e) {
// TODO Auto-generated method stub
}
@Override
public void keyPressed(KeyEvent e) {
if (isInvocationEvent(e)) {
e.doit = false;
handleMultiView();
} else if (e.keyCode == SWT.CR) {
handleSelection();
QuickOutline.this.close();
}
}
});
tree.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
super.mouseDown(e);
}
public void mouseUp(MouseEvent e) {
if (tree.getSelectionCount() < 1) {
return;
}
if (e.button != 1) {
return;
}
if (tree.equals(e.getSource())) {
Object o = tree.getItem(new Point(e.x, e.y));
TreeItem selection = tree.getSelection()[0];
if (selection.equals(o)) {
handleSelection();
}
}
}
});
tree.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
// do nothing
}
public void widgetDefaultSelected(SelectionEvent e) {
handleSelection();
}
});
return treeViewer;
}
use of org.eclipse.swt.events.MouseAdapter in project tesb-studio-se by Talend.
the class SearchControl method initialize.
private void initialize(int style) {
text = new Text(this, style);
text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
text.setMessage("search what you want");
text.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
text.selectAll();
}
});
text.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
text.selectAll();
}
});
clear = new ToolBar(this, SWT.FLAT);
ToolItem item = new ToolItem(clear, SWT.PUSH);
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
text.setText("");
}
});
Point computeSize = clear.computeSize(SWT.DEFAULT, SWT.DEFAULT);
int height = computeSize.y + 2;
arcSize = height > arcSize ? height : arcSize;
GridLayout layout = new GridLayout(2, false);
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
layout.marginBottom = 0;
layout.marginHeight = 0;
layout.marginLeft = marginHorizon;
layout.marginRight = marginHorizon;
layout.marginTop = 1;
layout.marginWidth = 0;
setLayout(layout);
setBackground(backgroundColor);
}
use of org.eclipse.swt.events.MouseAdapter in project tdi-studio-se by Talend.
the class VersionManagementPage method addItemElements.
@Override
protected void addItemElements(List<ItemVersionObject> elements) {
if (elements == null || elements.isEmpty()) {
return;
}
itemTable.setRedraw(false);
final Color redColor = Display.getDefault().getSystemColor(SWT.COLOR_RED);
for (final ItemVersionObject object : elements) {
final TableItem tableItem = new TableItem(itemTable, SWT.NONE);
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, object.getOldVersion());
TableEditor versionEditor = null;
if (isFixedVersion()) {
String version = fixedVersionText.getText();
tableItem.setText(2, version);
if (VersionUtils.compareTo(version, object.getOldVersion()) > 0) {
tableItem.setForeground(2, redColor);
} else {
tableItem.setForeground(2, Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
}
} else {
// new version
versionEditor = new TableEditor(itemTable);
Composite versionComposit = new Composite(itemTable, SWT.NONE);
GridLayout layout = new GridLayout(3, false);
layout.horizontalSpacing = 1;
layout.verticalSpacing = 0;
layout.marginHeight = 0;
layout.marginWidth = 0;
versionComposit.setLayout(layout);
final Text text = new Text(versionComposit, SWT.BORDER | SWT.READ_ONLY);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
text.setLayoutData(data);
text.setEditable(false);
text.setText(object.getNewVersion());
if (VersionUtils.compareTo(object.getNewVersion(), object.getOldVersion()) > 0) {
text.setForeground(redColor);
} else {
text.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
}
Button tableMajorBtn = new Button(versionComposit, SWT.NONE);
//$NON-NLS-1$
tableMajorBtn.setText("M");
//$NON-NLS-1$
tableMajorBtn.setToolTipText(Messages.getString("VersionManagementDialog.MajorVersionTip"));
Button tableMinorBtn = new Button(versionComposit, SWT.NONE);
//$NON-NLS-1$
tableMinorBtn.setText("m");
//$NON-NLS-1$
tableMinorBtn.setToolTipText(Messages.getString("VersionManagementDialog.MinorVersionTip"));
tableMajorBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String version = object.getNewVersion();
version = VersionUtils.upMajor(version);
text.setText(version);
text.setForeground(redColor);
object.setNewVersion(version);
}
});
tableMinorBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String version = object.getNewVersion();
version = VersionUtils.upMinor(version);
text.setText(version);
text.setForeground(redColor);
object.setNewVersion(version);
}
});
versionEditor.minimumWidth = itemTable.getColumn(2).getWidth();
versionEditor.setEditor(versionComposit, 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 (isFixedVersion()) {
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 bndtools by bndtools.
the class ResolutionChoiceSelectionDialog method createDialogArea.
@SuppressWarnings("unused")
@Override
protected Control createDialogArea(Composite parent) {
setTitle("Multiple Provider Candidates");
setMessage("Use the candidate list to specify your preferences. Candidates at the top of the list will be preferred by the resolver.");
// Create controls
Composite outer = (Composite) super.createDialogArea(parent);
Composite contents = new Composite(outer, SWT.NONE);
Label lblRequirement = new Label(contents, SWT.NONE);
lblRequirement.setText("Requirement Info");
lblRequirement.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
StyledText txtRequirement = new StyledText(contents, SWT.WRAP | SWT.BORDER);
txtRequirement.setEditable(false);
txtRequirement.setCaret(null);
// txtRequirement.setBackground(contents.getBackground());
txtRequirement.setCursor(parent.getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
new Label(contents, SWT.NONE);
Label lblCandidates = new Label(contents, SWT.NONE);
lblCandidates.setText("Candidates");
lblCandidates.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
Composite lowerPanel = new Composite(contents, SWT.NONE);
Table tbl = new Table(lowerPanel, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
viewer = new CheckboxTableViewer(tbl);
viewer.setContentProvider(ArrayContentProvider.getInstance());
viewer.setLabelProvider(new CapabilityLabelProvider());
btnUp = new Button(lowerPanel, SWT.PUSH);
btnUp.setText("Move Up");
btnUp.setEnabled(false);
btnDown = new Button(lowerPanel, SWT.PUSH);
btnDown.setText("Move Down");
btnDown.setEnabled(false);
Composite cmpPreferences = new Composite(contents, SWT.NONE);
btnSavePreference = new Button(cmpPreferences, SWT.CHECK | SWT.WRAP);
txtSavePreference = new StyledText(cmpPreferences, SWT.WRAP);
txtSavePreference.setEditable(false);
txtSavePreference.setCaret(null);
txtSavePreference.setBackground(contents.getBackground());
txtSavePreference.setCursor(parent.getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
// Events
txtSavePreference.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
btnSavePreference.setSelection(!btnSavePreference.getSelection());
}
});
// Load data
StyledString label = createRequirementText();
txtRequirement.setText(label.getString());
txtRequirement.setStyleRanges(label.getStyleRanges());
viewer.setInput(candidates);
updateSavePreferenceText();
// Layout
GridLayout layout;
GridData gd;
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
contents.setLayoutData(gd);
layout = new GridLayout(1, false);
contents.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.NONE, true, false);
gd.horizontalIndent = 5;
txtRequirement.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.NONE, true, false);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
lowerPanel.setLayoutData(gd);
layout = new GridLayout(2, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
lowerPanel.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3);
gd.widthHint = 450;
gd.heightHint = 250;
tbl.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.NONE, false, false);
btnUp.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.NONE, false, false);
btnDown.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.NONE, true, false);
cmpPreferences.setLayoutData(gd);
layout = new GridLayout(2, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
cmpPreferences.setLayout(layout);
gd = new GridData(SWT.LEFT, SWT.CENTER, false, false);
btnSavePreference.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
txtSavePreference.setLayoutData(gd);
return contents;
}
Aggregations