use of org.eclipse.draw2d.MouseEvent 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.MouseEvent in project tdi-studio-se by Talend.
the class BusinessItemShapeEditPart method refreshVisuals.
@Override
public void refreshVisuals() {
super.refreshVisuals();
NodeFigure nodeFigure = getNodeFigure();
for (Object obj : nodeFigure.getChildren()) {
if (obj instanceof BusinessItemShapeFigure) {
BusinessItemShapeFigure shapFigure = (BusinessItemShapeFigure) obj;
for (Object figure : shapFigure.getChildren()) {
if (figure instanceof BusinessItemNameFigure) {
BusinessItemNameFigure nameFigure = (BusinessItemNameFigure) figure;
nameFigure.addMouseMotionListener(new MouseMotionListener() {
@Override
public void mouseMoved(MouseEvent me) {
// TODO Auto-generated method stub
}
@Override
public void mouseHover(MouseEvent me) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent me) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent me) {
elementHelper.updateTooltipFigure(getNodeFigure(), tooltipFigure, editPart);
}
@Override
public void mouseDragged(MouseEvent me) {
// TODO Auto-generated method stub
}
});
EObject object = ((Node) getModel()).getElement();
if (object instanceof BusinessItem) {
BusinessItem item = (BusinessItem) object;
String hAlignment = item.getHAlignment();
if (hAlignment == null) {
hAlignment = BusinessAlignment.LEFT.toString();
}
String vAlignment = item.getVAlignment();
if (vAlignment == null) {
vAlignment = BusinessAlignment.TOP.toString();
}
if (BusinessAlignment.HCENTRE.toString().equals(hAlignment)) {
if (BusinessAlignment.TOP.toString().equals(vAlignment)) {
nameFigure.setAlignment(PositionConstants.TOP);
} else if (BusinessAlignment.BOTTOM.toString().equals(vAlignment)) {
nameFigure.setAlignment(PositionConstants.BOTTOM);
} else {
nameFigure.setAlignment(PositionConstants.CENTER);
}
} else if (BusinessAlignment.VCENTRE.toString().equals(vAlignment)) {
if (BusinessAlignment.LEFT.toString().equals(hAlignment)) {
nameFigure.setAlignment(PositionConstants.LEFT);
} else if (BusinessAlignment.RIGHT.toString().equals(hAlignment)) {
nameFigure.setAlignment(PositionConstants.RIGHT);
} else {
nameFigure.setAlignment(PositionConstants.CENTER);
}
} else {
nameFigure.setAlignment(getPosition(hAlignment, BusinessAlignment.HORIZONTAL, item) | getPosition(vAlignment, BusinessAlignment.VERTICAL, item));
}
}
}
}
}
}
elementHelper.updateTooltipFigure(getNodeFigure(), tooltipFigure, this);
}
use of org.eclipse.draw2d.MouseEvent 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.MouseEvent in project tdi-studio-se by Talend.
the class TalendDrawerFigure method createHoverHelp.
protected void createHoverHelp(final Control control) {
if (control == null) {
return;
}
// If a control was provided, create the tipLabel -- if the text in the
// header is
// truncated, it will display it as a tooltip.
tipLabel = new Label() {
/**
* @see org.eclipse.draw2d.Figure#getToolTip()
*/
@Override
public IFigure getToolTip() {
return buildTooltip();
}
@Override
protected void paintFigure(Graphics graphics) {
Rectangle r = Rectangle.SINGLETON;
r.setBounds(getBounds());
graphics.pushState();
paintToggleGradient(graphics, getBounds());
graphics.popState();
super.paintFigure(graphics);
}
};
tipLabel.setOpaque(false);
tipLabel.setBorder(TOOLTIP_BORDER);
try {
Field tipLabelField = DrawerFigure.class.getDeclaredField("tipLabel");
tipLabelField.setAccessible(true);
tipLabelField.set(this, tipLabel);
} catch (Exception e) {
CommonExceptionHandler.process(e);
}
collapseToggle.addMouseMotionListener(new MouseMotionListener.Stub() {
@Override
public void mouseMoved(MouseEvent e) {
if (!talendDrawerLabel.getBounds().contains(e.getLocation())) {
return;
}
if (skipNextEvent) {
skipNextEvent = false;
return;
}
if (talendDrawerLabel.isTextTruncated() && !TalendEditPartTipHelper.isCurrent(tipHelper)) {
tipLabel.setText(talendDrawerLabel.getText());
tipLabel.setIcon(talendDrawerLabel.getIcon());
tipLabel.setFont(talendDrawerLabel.getFont());
tipHelper = new TalendEditPartTipHelper(control);
Rectangle bounds = talendDrawerLabel.getBounds().getExpanded(2, 2);
talendDrawerLabel.translateToAbsolute(bounds);
org.eclipse.swt.graphics.Rectangle loc = new org.eclipse.swt.graphics.Rectangle(bounds.x, bounds.y, bounds.width, bounds.height);
loc = Display.getCurrent().map(control, null, loc);
tipHelper.displayToolTipAt(tipLabel, loc.x, loc.y);
}
}
});
tipLabel.addMouseListener(new MouseListener.Stub() {
@Override
public void mousePressed(MouseEvent e) {
if (e.button == 1) {
Rectangle original = getCollapseToggle().getBounds().getCopy();
getCollapseToggle().requestFocus();
setExpanded(!isExpanded());
// toggle to move
if (!original.equals(getCollapseToggle().getBounds())) {
tipHelper.hide();
}
} else {
tipHelper.hide();
if (e.button == 3) {
skipNextEvent = true;
}
}
}
});
}
use of org.eclipse.draw2d.MouseEvent 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