use of org.eclipse.jface.window.DefaultToolTip in project pentaho-kettle by pentaho.
the class ControlSpaceKeyAdapter method keyPressed.
public void keyPressed(KeyEvent e) {
// CTRL-<SPACE> --> Insert a variable
if (isHotKey(e)) {
e.doit = false;
// textField.setData(TRUE) indicates we have transitioned from the textbox to list mode...
// This will be set to false when the list selection has been processed
// and the list is being disposed of.
control.setData(Boolean.TRUE);
final int position;
if (getCaretPositionInterface != null) {
position = getCaretPositionInterface.getCaretPosition();
} else {
position = -1;
}
// Drop down a list of variables...
//
Rectangle bounds = control.getBounds();
Point location = GUIResource.calculateControlPosition(control);
final Shell shell = new Shell(control.getShell(), SWT.NONE);
shell.setSize(bounds.width > 300 ? bounds.width : 300, 200);
shell.setLocation(location.x, location.y + bounds.height);
shell.setLayout(new FillLayout());
final List list = new List(shell, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
props.setLook(list);
list.setItems(getVariableNames(variables));
final DefaultToolTip toolTip = new DefaultToolTip(list, ToolTip.RECREATE, true);
toolTip.setImage(GUIResource.getInstance().getImageVariable());
toolTip.setHideOnMouseDown(true);
toolTip.setRespectMonitorBounds(true);
toolTip.setRespectDisplayBounds(true);
toolTip.setPopupDelay(350);
list.addSelectionListener(new SelectionAdapter() {
// Enter or double-click: picks the variable
//
public synchronized void widgetDefaultSelected(SelectionEvent e) {
applyChanges(shell, list, control, position, insertTextInterface);
}
// Select a variable name: display the value in a tool tip
//
public void widgetSelected(SelectionEvent event) {
if (list.getSelectionCount() <= 0) {
return;
}
String name = list.getSelection()[0];
String value = variables.getVariable(name);
Rectangle shellBounds = shell.getBounds();
String message = BaseMessages.getString(PKG, "TextVar.VariableValue.Message", name, value);
if (name.startsWith(Const.INTERNAL_VARIABLE_PREFIX)) {
message += BaseMessages.getString(PKG, "TextVar.InternalVariable.Message");
}
toolTip.setText(message);
toolTip.hide();
toolTip.show(new Point(shellBounds.width, 0));
}
});
list.addKeyListener(new KeyAdapter() {
public synchronized void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.CR && ((e.keyCode & SWT.CONTROL) == 0) && ((e.keyCode & SWT.SHIFT) == 0)) {
applyChanges(shell, list, control, position, insertTextInterface);
}
}
});
list.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent event) {
shell.dispose();
if (!control.isDisposed()) {
control.setData(Boolean.FALSE);
}
}
});
shell.open();
}
}
use of org.eclipse.jface.window.DefaultToolTip in project pentaho-kettle by pentaho.
the class Spoon method addCoreObjectsTree.
public void addCoreObjectsTree() {
// Now create a new expand bar inside that item
// We're going to put the core object in there
//
coreObjectsTree = new Tree(variableComposite, SWT.V_SCROLL | SWT.SINGLE);
props.setLook(coreObjectsTree);
coreObjectsTree.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
//
if (props.getAutoCollapseCoreObjectsTree()) {
TreeItem[] selection = coreObjectsTree.getSelection();
if (selection.length == 1) {
// expand if clicked on the the top level entry only...
//
TreeItem top = selection[0];
while (top.getParentItem() != null) {
top = top.getParentItem();
}
if (top == selection[0]) {
boolean expanded = top.getExpanded();
for (TreeItem item : coreObjectsTree.getItems()) {
item.setExpanded(false);
}
top.setExpanded(!expanded);
}
}
}
}
});
coreObjectsTree.addTreeListener(new TreeAdapter() {
@Override
public void treeExpanded(TreeEvent treeEvent) {
if (props.getAutoCollapseCoreObjectsTree()) {
TreeItem treeItem = (TreeItem) treeEvent.item;
/*
* Trick for WSWT on Windows systems: a SelectionEvent is called after the TreeEvent if setSelection() is not
* used here. Otherwise the first item in the list is selected as default and collapsed again but wrong, see
* PDI-1480
*/
coreObjectsTree.setSelection(treeItem);
//
for (TreeItem item : coreObjectsTree.getItems()) {
if (item != treeItem) {
item.setExpanded(false);
} else {
treeItem.setExpanded(true);
}
}
}
}
});
coreObjectsTree.addMouseMoveListener(new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent move) {
// don't show tooltips in the tree if the option is not set
if (!getProperties().showToolTips()) {
return;
}
toolTip.hide();
TreeItem item = searchMouseOverTreeItem(coreObjectsTree.getItems(), move.x, move.y);
if (item != null) {
String name = item.getText();
String tip = coreStepToolTipMap.get(name);
if (tip != null) {
PluginInterface plugin = PluginRegistry.getInstance().findPluginWithName(StepPluginType.class, name);
if (plugin != null) {
Image image = GUIResource.getInstance().getImagesSteps().get(plugin.getIds()[0]).getAsBitmapForSize(display, ConstUI.ICON_SIZE, ConstUI.ICON_SIZE);
if (image == null) {
toolTip.hide();
}
toolTip.setImage(image);
toolTip.setText(name + Const.CR + Const.CR + tip);
toolTip.setBackgroundColor(GUIResource.getInstance().getColor(255, 254, 225));
toolTip.setForegroundColor(GUIResource.getInstance().getColor(0, 0, 0));
toolTip.show(new org.eclipse.swt.graphics.Point(move.x + 10, move.y + 10));
}
}
tip = coreJobToolTipMap.get(name);
if (tip != null) {
PluginInterface plugin = PluginRegistry.getInstance().findPluginWithName(JobEntryPluginType.class, name);
if (plugin != null) {
Image image = GUIResource.getInstance().getImagesJobentries().get(plugin.getIds()[0]).getAsBitmapForSize(display, ConstUI.ICON_SIZE, ConstUI.ICON_SIZE);
toolTip.setImage(image);
toolTip.setText(name + Const.CR + Const.CR + tip);
toolTip.setBackgroundColor(GUIResource.getInstance().getColor(255, 254, 225));
toolTip.setForegroundColor(GUIResource.getInstance().getColor(0, 0, 0));
toolTip.show(new org.eclipse.swt.graphics.Point(move.x + 10, move.y + 10));
}
}
}
}
});
addDragSourceToTree(coreObjectsTree);
addDefaultKeyListeners(coreObjectsTree);
coreObjectsTree.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent event) {
boolean shift = (event.stateMask & SWT.SHIFT) != 0;
doubleClickedInTree(coreObjectsTree, shift);
}
});
toolTip = new DefaultToolTip(variableComposite, ToolTip.RECREATE, true);
toolTip.setRespectMonitorBounds(true);
toolTip.setRespectDisplayBounds(true);
toolTip.setPopupDelay(350);
toolTip.setHideDelay(5000);
toolTip.setShift(new org.eclipse.swt.graphics.Point(ConstUI.TOOLTIP_OFFSET, ConstUI.TOOLTIP_OFFSET));
}
use of org.eclipse.jface.window.DefaultToolTip in project nebula.widgets.nattable by eclipse.
the class Tooltips method attachToolTip.
private void attachToolTip(NatTable natTable) {
DefaultToolTip toolTip = new ExampleNatTableToolTip(natTable);
toolTip.setBackgroundColor(natTable.getDisplay().getSystemColor(SWT.COLOR_RED));
toolTip.setPopupDelay(500);
toolTip.activate();
toolTip.setShift(new Point(10, 10));
}
use of org.eclipse.jface.window.DefaultToolTip in project jbosstools-openshift by jbosstools.
the class NewApplicationSummaryFromTemplateDialog method notifyCopied.
private void notifyCopied(Control control, String notification) {
DefaultToolTip copiedNotification = new DefaultToolTip(control, ToolTip.NO_RECREATE, true);
copiedNotification.setText(notification);
copiedNotification.setHideDelay(COPIED_NOTIFICATION_SHOW_DURATION);
copiedNotification.show(control.getLocation());
copiedNotification.deactivate();
}
use of org.eclipse.jface.window.DefaultToolTip in project jbosstools-openshift by jbosstools.
the class WebHooksComponent method notifyCopied.
private void notifyCopied(final Text uriText) {
DefaultToolTip copiedNotification = new DefaultToolTip(uriText, ToolTip.NO_RECREATE, true);
copiedNotification.setText("Webhook copied to clipboard");
copiedNotification.setHideDelay(COPIED_NOTIFICATION_SHOW_DURATION);
copiedNotification.show(uriText.getLocation());
copiedNotification.deactivate();
}
Aggregations