use of org.eclipse.draw2d.MouseListener in project webtools.sourceediting by eclipse.
the class BackToSchemaEditPart method createFigure.
protected IFigure createFigure() {
backToSchema = new CenteredIconFigure();
backToSchema.setBackgroundColor(ColorConstants.white);
backToSchema.image = XSDEditorPlugin.getPlugin().getIcon("elcl16/schemaview_co.gif");
// TODO, look at why the editpolicy doesn't work
mouseListener = new MouseListener() {
public void mouseDoubleClicked(org.eclipse.draw2d.MouseEvent me) {
}
public void mousePressed(org.eclipse.draw2d.MouseEvent me) {
if (isEnabled) {
addFeedback();
}
}
public void mouseReleased(org.eclipse.draw2d.MouseEvent me) {
if (isEnabled) {
removeFeedback();
SetInputToGraphView action = new SetInputToGraphView(multipageEditor, getModel());
action.run();
}
}
};
backToSchema.addMouseListener(mouseListener);
return backToSchema;
}
use of org.eclipse.draw2d.MouseListener in project yamcs-studio by yamcs.
the class MenuButtonEditPart method doCreateFigure.
@Override
protected IFigure doCreateFigure() {
var model = getWidgetModel();
updatePropSheet(model.isActionsFromPV());
var figure = new MenuButtonFigure();
figure.setOpaque(!model.isTransparent());
figure.setText(model.getLabel());
figure.setDownArrowVisible(model.showDownArrow());
if (getExecutionMode() == ExecutionMode.RUN_MODE) {
figure.addMouseListener(new MouseListener() {
@Override
public void mouseDoubleClicked(MouseEvent me) {
}
@Override
public void mousePressed(MouseEvent me) {
if (me.button == 1 && figure.containsPoint(me.getLocation())) {
me.consume();
}
}
@Override
public void mouseReleased(MouseEvent me) {
// see https://github.com/ControlSystemStudio/cs-studio/issues/1818
if (me.button == 1 && getExecutionMode().equals(ExecutionMode.RUN_MODE) && figure.containsPoint(me.getLocation())) {
var cursorLocation = Display.getCurrent().getCursorLocation();
showMenu(me.getLocation(), cursorLocation.x, cursorLocation.y);
}
}
});
}
figure.addMouseMotionListener(new MouseMotionListener.Stub() {
@Override
public void mouseEntered(MouseEvent me) {
if (getExecutionMode().equals(ExecutionMode.RUN_MODE)) {
var backColor = figure.getBackgroundColor();
var darkColor = GraphicsUtil.mixColors(backColor.getRGB(), new RGB(0, 0, 0), 0.9);
figure.setBackgroundColor(CustomMediaFactory.getInstance().getColor(darkColor));
}
}
@Override
public void mouseExited(MouseEvent me) {
if (getExecutionMode().equals(ExecutionMode.RUN_MODE)) {
figure.setBackgroundColor(CustomMediaFactory.getInstance().getColor(getWidgetModel().getBackgroundColor()));
}
}
});
markAsControlPV(PROP_PVNAME, PROP_PVVALUE);
return figure;
}
use of org.eclipse.draw2d.MouseListener in project hale by halestudio.
the class CellFigureTaskLabelContribution method contribute.
// private TaskServiceListener taskServiceListener;
@Override
public void contribute(CellFigure figure, Cell cell) {
TaskService taskService = HaleUI.getServiceProvider().getService(TaskService.class);
Collection<ResolvedTask<Cell>> tasks = taskService.getTasks(cell).stream().map(t -> taskService.resolveTask(t)).collect(Collectors.toList());
tasks = tasks.stream().filter(t -> t.isOpen()).collect(Collectors.toList());
if (tasks.isEmpty()) {
return;
}
Label tasksLabel = new Label();
Image tasksImage = null;
tasksImage = CommonSharedImages.getImageRegistry().get(CommonSharedImages.IMG_TASKS);
tasksLabel.setIcon(tasksImage);
tasksLabel.addMouseListener(new MouseListener() {
@Override
public void mouseReleased(MouseEvent me) {
try {
IViewPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(TaskTreeView.ID);
// the alignment/mapping view
if (part instanceof TaskTreeView) {
((TaskTreeView) part).update(new StructuredSelection(cell));
}
me.consume();
} catch (PartInitException e) {
log.error("Error creating task view", e);
}
}
@Override
public void mousePressed(MouseEvent me) {
// ignore
}
@Override
public void mouseDoubleClicked(MouseEvent me) {
// ignore
}
});
if (tasksImage != null) {
Label priorityTip = new Label(MessageFormat.format("There {0} {1} open tasks for this cell. Please refer to the Tasks view for details.", (tasks.size() == 1) ? "is" : "are", tasks.size()));
tasksLabel.setToolTip(priorityTip);
}
GridData tasksLabelGD = new GridData(GridData.CENTER, GridData.FILL, false, true);
figure.add(tasksLabel, tasksLabelGD);
}
use of org.eclipse.draw2d.MouseListener in project tdi-studio-se by Talend.
the class InputTreeSettingTable method createColumns.
/*
* (non-Javadoc)
*
* @see org.talend.designer.newabstractmap.figures.table.AbstractTable#createColumns()
*/
@Override
protected void createColumns() {
TableColumn column = new TableColumn(ColumnKeyConstant.TREE_SETTING_PROPERTY);
column.setText("Property");
addColumn(column);
ColumnSash sash = new ColumnSash(this);
sash.setLeftColumn(column);
addSeparator(sash);
column = new TableColumn(ColumnKeyConstant.TREE_SETTING_VALUE);
column.setText("Value");
sash.setRightColumn(column);
addColumn(column);
Figure container = getTableItemContainer();
lookupModelRow = new Figure();
lookupModelRow.setLayoutManager(new RowLayout());
Label label = new Label();
label.setText("Lookup Model");
label.setLabelAlignment(PositionConstants.LEFT);
CompoundBorder compoundBorder = new CompoundBorder(new ColumnBorder(), new RowBorder(2, 5, 2, -1));
label.setBorder(compoundBorder);
lookupModelRow.add(label);
lookupModel = new ComboCellLabel();
lookupModel.setDirectEditType(DirectEditType.LOOKUP_MODEL);
lookupModel.setText(getLookupDisplayName(inputxmlTree.getLookupMode()));
lookupModel.setLabelAlignment(PositionConstants.LEFT);
lookupModel.setBorder(new RowBorder(2, 5, 2, -1));
lookupModelRow.add(lookupModel);
container.add(lookupModelRow);
matchModelRow = new Figure();
matchModelRow.setLayoutManager(new RowLayout());
label = new Label();
label.setText("Match Model");
label.setLabelAlignment(PositionConstants.LEFT);
compoundBorder = new CompoundBorder(new ColumnBorder(), new RowBorder(2, 5, 2, -1));
label.setBorder(compoundBorder);
matchModelRow.add(label);
matchModel = new ComboCellLabel();
matchModel.setDirectEditType(DirectEditType.MATCH_MODEL);
matchModel.setText(getMatchModelDisplayName(inputxmlTree.getMatchingMode()));
matchModel.setLabelAlignment(PositionConstants.LEFT);
matchModel.setBorder(new RowBorder(2, 5, 2, -1));
matchModelRow.add(matchModel);
container.add(matchModelRow);
joinModelRow = new Figure();
joinModelRow.setLayoutManager(new RowLayout());
label = new Label();
label.setText("Join Model");
label.setLabelAlignment(PositionConstants.LEFT);
compoundBorder = new CompoundBorder(new ColumnBorder(), new RowBorder(2, 5, 2, -1));
label.setBorder(compoundBorder);
joinModelRow.add(label);
joinModel = new ComboCellLabel();
joinModel.setDirectEditType(DirectEditType.JOIN_MODEL);
String join = "";
if (inputxmlTree.isInnerJoin()) {
join = TreeSettingsConstant.INNER_JOIN;
} else {
join = TreeSettingsConstant.LEFT_OUTER_JOIN;
}
joinModel.setText(join);
joinModel.setLabelAlignment(PositionConstants.LEFT);
joinModel.setBorder(new RowBorder(2, 5, 2, -1));
joinModelRow.add(joinModel);
container.add(joinModelRow);
// TDI-17714:remove the true option in the Store temp data lookup property.
// persistentModelRow = new Figure();
// persistentModelRow.setLayoutManager(new TableItemLayout());
// label = new Label();
// label.setText("Store Temp Data");
// label.setLabelAlignment(PositionConstants.LEFT);
// compoundBorder = new CompoundBorder(new RowBorder(), new ColumnBorder());
// label.setBorder(compoundBorder);
// persistentModelRow.add(label);
// persistentModel = new ComboCellLabel();
// persistentModel.setDirectEditType(DirectEditType.PERSISTENT_MODEL);
// persistentModel.setText(String.valueOf(inputxmlTree.isPersistent()));
// persistentModel.setLabelAlignment(PositionConstants.LEFT);
// persistentModel.setBorder(new RowBorder(2, 5, 2, -1));
// persistentModelRow.add(persistentModel);
// container.add(persistentModelRow);
container.setOpaque(true);
container.setBackgroundColor(ColorConstants.white);
container.addMouseListener(new MouseListener() {
Figure selectedFigure = null;
@Override
public void mousePressed(MouseEvent me) {
boolean lookup = lookupModelRow.containsPoint(me.x, me.y);
if (lookup) {
if (selectedFigure != lookupModelRow) {
lookupModelRow.setOpaque(true);
lookupModelRow.setBackgroundColor(ColorProviderMapper.getColor(ColorInfo.COLOR_COLUMN_TREE_SETTING));
matchModelRow.setOpaque(false);
joinModelRow.setOpaque(false);
// persistentModelRow.setOpaque(false);
}
return;
}
boolean matchModel = matchModelRow.containsPoint(me.x, me.y);
if (matchModel) {
if (selectedFigure != matchModelRow) {
matchModelRow.setOpaque(true);
matchModelRow.setBackgroundColor(ColorProviderMapper.getColor(ColorInfo.COLOR_COLUMN_TREE_SETTING));
lookupModelRow.setOpaque(false);
joinModelRow.setOpaque(false);
// persistentModelRow.setOpaque(false);
}
return;
}
boolean joinModel = joinModelRow.containsPoint(me.x, me.y);
if (joinModel) {
if (selectedFigure != joinModelRow) {
joinModelRow.setOpaque(true);
joinModelRow.setBackgroundColor(ColorProviderMapper.getColor(ColorInfo.COLOR_COLUMN_TREE_SETTING));
lookupModelRow.setOpaque(false);
matchModelRow.setOpaque(false);
// persistentModelRow.setOpaque(false);
}
return;
}
// boolean persistentModel = persistentModelRow.containsPoint(me.x, me.y);
// if (persistentModel) {
// if (selectedFigure != persistentModelRow) {
// persistentModelRow.setOpaque(true);
// persistentModelRow.setBackgroundColor(ColorProviderMapper.getColor(ColorInfo.COLOR_SELECTION));
// lookupModelRow.setOpaque(false);
// matchModelRow.setOpaque(false);
// joinModelRow.setOpaque(false);
// }
// }
}
@Override
public void mouseReleased(MouseEvent me) {
}
@Override
public void mouseDoubleClicked(MouseEvent me) {
}
});
}
use of org.eclipse.draw2d.MouseListener in project netxms by netxms.
the class DecorationFigure method createResizeHandle.
/**
* Create resize handle
*/
private void createResizeHandle(int pos) {
final Figure handle = new Figure();
add(handle);
Dimension size = getSize();
handle.setSize(8, 8);
switch(pos) {
case TOP_LEFT:
handle.setLocation(new Point(-1, -1));
handle.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_SIZENWSE));
break;
case TOP_RIGHT:
handle.setLocation(new Point(size.width - 7, -1));
handle.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_SIZENESW));
break;
case BOTTOM_LEFT:
handle.setLocation(new Point(-1, size.height - 7));
handle.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_SIZENESW));
break;
case BOTTOM_RIGHT:
handle.setLocation(new Point(size.width - 7, size.height - 7));
handle.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_SIZENWSE));
break;
}
handle.addMouseListener(new MouseListener() {
@Override
public void mouseReleased(MouseEvent me) {
if (resize) {
resize = false;
Dimension size = getSize();
decoration.setSize(size.width, size.height);
}
}
@Override
public void mousePressed(MouseEvent me) {
if (me.button == 1) {
resize = true;
lastX = me.x;
lastY = me.y;
me.consume();
}
}
@Override
public void mouseDoubleClicked(MouseEvent me) {
}
});
handle.addMouseMotionListener(new MouseMotionListener() {
@Override
public void mouseMoved(MouseEvent me) {
}
@Override
public void mouseHover(MouseEvent me) {
}
@Override
public void mouseExited(MouseEvent me) {
}
@Override
public void mouseEntered(MouseEvent me) {
}
@Override
public void mouseDragged(MouseEvent me) {
if (resize) {
Dimension size = getSize();
int dx = me.x - lastX;
int dy = me.y - lastY;
if ((dx < 0) && (size.width <= 40))
dx = 0;
if ((dy < 0) && (size.height <= 20))
dy = 0;
size.width += dx;
size.height += dy;
setSize(size);
Point p = handle.getLocation();
p.performTranslate(dx, dy);
handle.setLocation(p);
lastX = me.x;
lastY = me.y;
me.consume();
}
}
});
}
Aggregations