use of org.eclipse.swt.events.MouseEvent in project tdi-studio-se by Talend.
the class TalendEditorComponentCreationAssist method createComponent.
protected Object createComponent(IComponent component, org.eclipse.swt.graphics.Point location) {
if (component == null) {
return null;
}
Object newNode;
/*
* TODO support to insert the component on Connection
*/
Event e = new Event();
e.x = location.x;
e.y = location.y;
e.button = 1;
e.count = 1;
e.stateMask = 0;
e.widget = graphicControl;
MouseEvent mouseEvent = new MouseEvent(e);
TalendAssistantCreationTool creationTool = new TalendAssistantCreationTool(new PaletteComponentFactory(component));
newNode = creationTool.getCreateRequest().getNewObject();
if (!canCreateAt(newNode, new Point(e.x, e.y))) {
return null;
}
creationTool.mouseMove(mouseEvent, graphicViewer);
graphicViewer.getEditDomain().setActiveTool(creationTool);
graphicViewer.getEditDomain().mouseMove(mouseEvent, graphicViewer);
graphicViewer.getEditDomain().mouseDown(mouseEvent, graphicViewer);
graphicViewer.getEditDomain().mouseUp(mouseEvent, graphicViewer);
return newNode;
}
use of org.eclipse.swt.events.MouseEvent in project tdi-studio-se by Talend.
the class AbstractScdDialog method addContextHelp.
public void addContextHelp(Control control, final String contextId) {
final IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
helpSystem.setHelp(control, contextId);
control.addMouseTrackListener(new MouseTrackAdapter() {
@Override
public void mouseEnter(MouseEvent e) {
if (getTray() != null) {
helpSystem.displayHelp(contextId);
}
}
});
}
use of org.eclipse.swt.events.MouseEvent 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.MouseEvent 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;
}
use of org.eclipse.swt.events.MouseEvent in project eclipse.platform.swt by eclipse.
the class Tab method log.
/**
* Logs an untyped event to the event console.
*/
void log(Event event) {
int i = 0;
while (i < EVENT_INFO.length) {
if (EVENT_INFO[i].type == event.type)
break;
i++;
}
String toString = EVENT_INFO[i].name + " [" + event.type + "]: ";
if (!untypedEvents) {
switch(event.type) {
case SWT.KeyDown:
case SWT.KeyUp:
toString += new KeyEvent(event).toString();
break;
case SWT.MouseDown:
case SWT.MouseUp:
case SWT.MouseMove:
case SWT.MouseEnter:
case SWT.MouseExit:
case SWT.MouseDoubleClick:
case SWT.MouseWheel:
case SWT.MouseHover:
toString += new MouseEvent(event).toString();
break;
case SWT.Paint:
toString += new PaintEvent(event).toString();
break;
case SWT.Move:
case SWT.Resize:
toString += new ControlEvent(event).toString();
break;
case SWT.Dispose:
toString += new DisposeEvent(event).toString();
break;
case SWT.Selection:
case SWT.DefaultSelection:
toString += new SelectionEvent(event).toString();
break;
case SWT.FocusIn:
case SWT.FocusOut:
toString += new FocusEvent(event).toString();
break;
case SWT.Expand:
case SWT.Collapse:
toString += new TreeEvent(event).toString();
break;
case SWT.Iconify:
case SWT.Deiconify:
case SWT.Close:
case SWT.Activate:
case SWT.Deactivate:
toString += new ShellEvent(event).toString();
break;
case SWT.Show:
case SWT.Hide:
toString += (event.widget instanceof Menu) ? new MenuEvent(event).toString() : event.toString();
break;
case SWT.Modify:
toString += new ModifyEvent(event).toString();
break;
case SWT.Verify:
toString += new VerifyEvent(event).toString();
break;
case SWT.Help:
toString += new HelpEvent(event).toString();
break;
case SWT.Arm:
toString += new ArmEvent(event).toString();
break;
case SWT.Traverse:
toString += new TraverseEvent(event).toString();
break;
case SWT.HardKeyDown:
case SWT.HardKeyUp:
case SWT.DragDetect:
case SWT.MenuDetect:
case SWT.SetData:
default:
toString += event.toString();
}
} else {
toString += event.toString();
}
log(toString);
/* Return values for event fields. */
int mask = EVENT_INFO[i].setFields;
if (!ignore && mask != 0) {
Event setFieldsEvent = EVENT_INFO[i].event;
if ((mask & DOIT) != 0)
event.doit = setFieldsEvent.doit;
if ((mask & DETAIL) != 0)
event.detail = setFieldsEvent.detail;
if ((mask & TEXT) != 0)
event.text = setFieldsEvent.text;
if ((mask & X) != 0)
event.x = setFieldsEvent.x;
if ((mask & Y) != 0)
event.y = setFieldsEvent.y;
if ((mask & WIDTH) != 0)
event.width = setFieldsEvent.width;
if ((mask & HEIGHT) != 0)
event.height = setFieldsEvent.height;
eventConsole.append(ControlExample.getResourceString("Returning"));
ignore = true;
log(event);
ignore = false;
}
}
Aggregations