Search in sources :

Example 6 with MouseEvent

use of org.eclipse.draw2d.MouseEvent in project cubrid-manager by CUBRID.

the class RelationshipPart method addHoverListener.

/**
	 * Add hovering listener for the figure
	 */
protected void addHoverListener() {
    final IFigure figure = this.getFigure();
    hoverListener = new MouseMotionListener() {

        public void mouseEntered(MouseEvent me) {
            setHoverState(true);
            setRelationLinesFocus(true);
        }

        public void mouseExited(MouseEvent me) {
            setHoverState(false);
            setRelationLinesFocus(false);
            setSelectedTableColor();
        }

        public void mouseHover(MouseEvent me) {
        }

        public void mouseDragged(MouseEvent me) {
        }

        public void mouseMoved(MouseEvent me) {
        }
    };
    figure.addMouseMotionListener(hoverListener);
}
Also used : MouseEvent(org.eclipse.draw2d.MouseEvent) MouseMotionListener(org.eclipse.draw2d.MouseMotionListener) IFigure(org.eclipse.draw2d.IFigure)

Example 7 with MouseEvent

use of org.eclipse.draw2d.MouseEvent in project cubrid-manager by CUBRID.

the class TablePart method addHoverListener.

/**
	 * Add hovering listener for the figure
	 */
protected void addHoverListener() {
    final TablePart tablePart = this;
    final IFigure figure = this.getFigure();
    hoverListener = new MouseMotionListener() {

        public void mouseEntered(MouseEvent me) {
            if (hasChildPartSelected(tablePart) || tablePart.isDisableState()) {
                return;
            }
            setHoverState(true);
            setRelationLinesFocus(true);
            setRelationLinesSyncColor(false);
            figure.revalidate();
        }

        public void mouseExited(MouseEvent me) {
            if (hasChildPartSelected(tablePart) || tablePart.isDisableState()) {
                return;
            }
            setHoverState(false);
            setRelationLinesFocus(false);
            setRelationLinesSyncColor(true);
            figure.revalidate();
        }

        public void mouseHover(MouseEvent me) {
        }

        public void mouseDragged(MouseEvent me) {
        }

        public void mouseMoved(MouseEvent me) {
        }
    };
    figure.addMouseMotionListener(hoverListener);
}
Also used : MouseEvent(org.eclipse.draw2d.MouseEvent) MouseMotionListener(org.eclipse.draw2d.MouseMotionListener) IFigure(org.eclipse.draw2d.IFigure)

Example 8 with MouseEvent

use of org.eclipse.draw2d.MouseEvent in project knime-core by knime.

the class WorkflowInPortEditPart method createFigure.

/**
 * Creates {@link WorkflowInPortFigure}, sets the tooltip and adds a
 * {@link MouseListener} to the figure in order to detect if the figure was
 * clicked and a context menu entry should be provided to open the port
 * view.
 *
 * @see WorkflowContextMenuProvider#buildContextMenu(
 * org.eclipse.jface.action.IMenuManager)
 * @see WorkflowInPortFigure
 *
 * {@inheritDoc}
 */
@Override
protected IFigure createFigure() {
    NodeOutPortUI port = getManager().getInPort(getIndex()).getUnderlyingPort();
    String tooltip = getTooltipText(PORT_NAME + ": " + getIndex(), port);
    WorkflowInPortFigure f = new WorkflowInPortFigure(getType(), getManager().getNrInPorts(), getIndex(), tooltip);
    f.addMouseListener(new MouseListener() {

        @Override
        public void mouseDoubleClicked(final MouseEvent me) {
        }

        /**
         * Set the selection state of the figure to true. This is
         * evaluated in the context menu. If it is selected a context menu
         * entry is provided to open the port view.
         *
         * @see WorkflowContextMenuProvider#buildContextMenu(
         *  org.eclipse.jface.action.IMenuManager)
         *
         * {@inheritDoc}
         */
        @Override
        public void mousePressed(final MouseEvent me) {
            setSelected(true);
        }

        /**
         * Set the selection state of the figure to true. This is
         * evaluated in the context menu. If it is selected a context menu
         * entry is provided to open the port view.
         *
         * @see WorkflowContextMenuProvider#buildContextMenu(
         *  org.eclipse.jface.action.IMenuManager)
         *
         * {@inheritDoc}
         */
        @Override
        public void mouseReleased(final MouseEvent me) {
            setSelected(false);
        }
    });
    return f;
}
Also used : WorkflowInPortFigure(org.knime.workbench.editor2.figures.WorkflowInPortFigure) NodeOutPortUI(org.knime.core.ui.node.workflow.NodeOutPortUI) MouseListener(org.eclipse.draw2d.MouseListener) MouseEvent(org.eclipse.draw2d.MouseEvent)

Example 9 with MouseEvent

use of org.eclipse.draw2d.MouseEvent 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 10 with MouseEvent

use of org.eclipse.draw2d.MouseEvent in project yamcs-studio by yamcs.

the class TabFigure method createTabLabel.

private Label createTabLabel(String title, int index) {
    Label tabLabel = new Label(title) {

        @Override
        protected void paintFigure(Graphics graphics) {
            graphics.pushState();
            graphics.setForegroundColor(TAB_3D_COLOR);
            graphics.fillGradient(getClientArea(), horizontal);
            graphics.popState();
            super.paintFigure(graphics);
        }
    };
    tabLabel.setLabelAlignment(PositionConstants.CENTER);
    tabLabel.setOpaque(false);
    tabLabel.setBorder(new LineBorder(BORDER_COLOR));
    tabLabel.setBackgroundColor(getDarkColor(DEFAULT_TABCOLOR));
    // tabLabel.setCursor(Cursors.HAND);
    tabLabel.addMouseListener(new MouseListener.Stub() {

        @Override
        public void mousePressed(MouseEvent me) {
            if (me.button != 1) {
                return;
            }
            setActiveTabIndex(tabLabelList.indexOf(tabLabel));
        }
    });
    return tabLabel;
}
Also used : Graphics(org.eclipse.draw2d.Graphics) MouseListener(org.eclipse.draw2d.MouseListener) MouseEvent(org.eclipse.draw2d.MouseEvent) LineBorder(org.eclipse.draw2d.LineBorder) Label(org.eclipse.draw2d.Label)

Aggregations

MouseEvent (org.eclipse.draw2d.MouseEvent)18 MouseListener (org.eclipse.draw2d.MouseListener)15 MouseMotionListener (org.eclipse.draw2d.MouseMotionListener)9 Label (org.eclipse.draw2d.Label)6 Figure (org.eclipse.draw2d.Figure)4 IFigure (org.eclipse.draw2d.IFigure)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 Graphics (org.eclipse.draw2d.Graphics)2 Dimension (org.eclipse.draw2d.geometry.Dimension)2 Point (org.eclipse.draw2d.geometry.Point)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 CellFigure (eu.esdihumboldt.hale.ui.common.graph.figures.CellFigure)1