Search in sources :

Example 6 with MouseListener

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;
}
Also used : MouseListener(org.eclipse.draw2d.MouseListener) CenteredIconFigure(org.eclipse.wst.xsd.ui.internal.design.figures.CenteredIconFigure) SetInputToGraphView(org.eclipse.wst.xsd.ui.internal.adt.actions.SetInputToGraphView)

Example 7 with MouseListener

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;
}
Also used : MenuButtonFigure(org.csstudio.opibuilder.widgets.figures.MenuButtonFigure) MouseListener(org.eclipse.draw2d.MouseListener) MouseEvent(org.eclipse.draw2d.MouseEvent) MouseMotionListener(org.eclipse.draw2d.MouseMotionListener) RGB(org.eclipse.swt.graphics.RGB)

Example 8 with MouseListener

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);
}
Also used : Cell(eu.esdihumboldt.hale.common.align.model.Cell) PlatformUI(org.eclipse.ui.PlatformUI) ALogger(de.fhg.igd.slf4jplus.ALogger) Collection(java.util.Collection) HaleUI(eu.esdihumboldt.hale.ui.HaleUI) Image(org.eclipse.swt.graphics.Image) CellFigure(eu.esdihumboldt.hale.ui.common.graph.figures.CellFigure) MouseEvent(org.eclipse.draw2d.MouseEvent) ALoggerFactory(de.fhg.igd.slf4jplus.ALoggerFactory) ResolvedTask(eu.esdihumboldt.hale.common.tasks.ResolvedTask) MouseListener(org.eclipse.draw2d.MouseListener) CommonSharedImages(eu.esdihumboldt.hale.ui.common.CommonSharedImages) CellFigureContribution(eu.esdihumboldt.hale.ui.common.graph.figures.CellFigureContribution) Collectors(java.util.stream.Collectors) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) MessageFormat(java.text.MessageFormat) TaskService(eu.esdihumboldt.hale.common.tasks.TaskService) GridData(org.eclipse.draw2d.GridData) PartInitException(org.eclipse.ui.PartInitException) Label(org.eclipse.draw2d.Label) IViewPart(org.eclipse.ui.IViewPart) IViewPart(org.eclipse.ui.IViewPart) MouseEvent(org.eclipse.draw2d.MouseEvent) TaskService(eu.esdihumboldt.hale.common.tasks.TaskService) Label(org.eclipse.draw2d.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Image(org.eclipse.swt.graphics.Image) MouseListener(org.eclipse.draw2d.MouseListener) ResolvedTask(eu.esdihumboldt.hale.common.tasks.ResolvedTask) GridData(org.eclipse.draw2d.GridData) PartInitException(org.eclipse.ui.PartInitException)

Example 9 with MouseListener

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) {
        }
    });
}
Also used : RowBorder(org.talend.designer.gefabstractmap.figures.borders.RowBorder) MouseEvent(org.eclipse.draw2d.MouseEvent) ComboCellLabel(org.talend.designer.gefabstractmap.figures.ComboCellLabel) Label(org.eclipse.draw2d.Label) ComboCellLabel(org.talend.designer.gefabstractmap.figures.ComboCellLabel) ColumnSash(org.talend.designer.gefabstractmap.figures.table.ColumnSash) ColumnBorder(org.talend.designer.gefabstractmap.figures.borders.ColumnBorder) TableColumn(org.talend.designer.gefabstractmap.figures.table.TableColumn) Figure(org.eclipse.draw2d.Figure) MouseListener(org.eclipse.draw2d.MouseListener) RowLayout(org.talend.designer.gefabstractmap.figures.layout.RowLayout) CompoundBorder(org.eclipse.draw2d.CompoundBorder)

Example 10 with MouseListener

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();
            }
        }
    });
}
Also used : MouseListener(org.eclipse.draw2d.MouseListener) MouseEvent(org.eclipse.draw2d.MouseEvent) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point) MouseMotionListener(org.eclipse.draw2d.MouseMotionListener) Figure(org.eclipse.draw2d.Figure)

Aggregations

MouseListener (org.eclipse.draw2d.MouseListener)13 MouseEvent (org.eclipse.draw2d.MouseEvent)12 MouseMotionListener (org.eclipse.draw2d.MouseMotionListener)5 Figure (org.eclipse.draw2d.Figure)4 Label (org.eclipse.draw2d.Label)3 ColumnSash (org.talend.designer.gefabstractmap.figures.table.ColumnSash)3 TableColumn (org.talend.designer.gefabstractmap.figures.table.TableColumn)3 CompoundBorder (org.eclipse.draw2d.CompoundBorder)2 Dimension (org.eclipse.draw2d.geometry.Dimension)2 Point (org.eclipse.draw2d.geometry.Point)2 ComboCellLabel (org.talend.designer.gefabstractmap.figures.ComboCellLabel)2 ColumnBorder (org.talend.designer.gefabstractmap.figures.borders.ColumnBorder)2 RowBorder (org.talend.designer.gefabstractmap.figures.borders.RowBorder)2 ALogger (de.fhg.igd.slf4jplus.ALogger)1 ALoggerFactory (de.fhg.igd.slf4jplus.ALoggerFactory)1 Cell (eu.esdihumboldt.hale.common.align.model.Cell)1 ResolvedTask (eu.esdihumboldt.hale.common.tasks.ResolvedTask)1 TaskService (eu.esdihumboldt.hale.common.tasks.TaskService)1 HaleUI (eu.esdihumboldt.hale.ui.HaleUI)1 CommonSharedImages (eu.esdihumboldt.hale.ui.common.CommonSharedImages)1