Search in sources :

Example 1 with ZoomManager

use of org.eclipse.gef.editparts.ZoomManager in project tdi-studio-se by Talend.

the class MultiPageEditorContributor method setActivePage.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.part.MultiPageEditorActionBarContributor#setActivePage(org.eclipse.ui.IEditorPart)
     */
@Override
public void setActivePage(final IEditorPart activeEditor) {
    if ((activeEditorPart == activeEditor) || (activeEditor == null)) {
        return;
    }
    activeEditorPart = activeEditor;
    if (activeEditor instanceof TalendEditor) {
        RootEditPart editPart = ((TalendEditor) activeEditor).getViewer().getRootEditPart();
        if (editPart != null && editPart instanceof TalendScalableFreeformRootEditPart) {
            ZoomManager manager = ((TalendScalableFreeformRootEditPart) ((TalendEditor) activeEditor).getViewer().getRootEditPart()).getZoomManager();
            item.setZoomManager(manager);
        }
    } else {
        item.setZoomManager(null);
    }
    IActionBars actionBars = getActionBars();
    if (actionBars != null) {
        actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), getAction(activeEditor, ActionFactory.DELETE.getId()));
        actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), getAction(activeEditor, ActionFactory.UNDO.getId()));
        actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), getAction(activeEditor, ActionFactory.REDO.getId()));
        actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), getAction(activeEditor, ActionFactory.CUT.getId()));
        actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), getAction(activeEditor, ActionFactory.COPY.getId()));
        actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), getAction(activeEditor, ActionFactory.PASTE.getId()));
        actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), getAction(activeEditor, ActionFactory.SELECT_ALL.getId()));
        actionBars.setGlobalActionHandler(ToggleSubjobsAction.ID, getAction(activeEditor, ToggleSubjobsAction.ID));
        // see bug 0003656: Actions in the main menu "View" are always disabled.
        activateActionsInViewMenu(activeEditor, actionBars, VIEW_MENU_ACTIONS_ID);
        // MOD mzhao bug 8710
        if (showAndRunProcessAction != null) {
            actionBars.setGlobalActionHandler(showAndRunProcessAction.getActionDefinitionId(), showAndRunProcessAction);
        }
        actionBars.updateActionBars();
    }
}
Also used : TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) ZoomManager(org.eclipse.gef.editparts.ZoomManager) TalendEditor(org.talend.designer.core.ui.editor.TalendEditor) AbstractTalendEditor(org.talend.designer.core.ui.editor.AbstractTalendEditor) IActionBars(org.eclipse.ui.IActionBars) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) RootEditPart(org.eclipse.gef.RootEditPart)

Example 2 with ZoomManager

use of org.eclipse.gef.editparts.ZoomManager in project tdi-studio-se by Talend.

the class FindAssignmentAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
protected void doRun() {
    RepositoryNode repositoryNode = (RepositoryNode) getFirstSelectedObject();
    IEditorPart activeEditor = getActiveEditor();
    // remove frames draw last time
    for (BusinessItemShapeFigure shapFigure : repaintedFigures) {
        shapFigure.setDrawFrame(false);
        shapFigure.revalidate();
        shapFigure.repaint();
    }
    if (activeEditor instanceof BusinessDiagramEditor) {
        BusinessDiagramEditor businessDiagramEditor = (BusinessDiagramEditor) activeEditor;
        Diagram diagram = (Diagram) businessDiagramEditor.getDiagramEditPart().getModel();
        BusinessProcess businessProcess = (BusinessProcess) diagram.getElement();
        // PTODO mhelleboid use OCL or using a visitor
        List list = new ArrayList();
        for (Iterator iter = businessProcess.getBusinessItems().iterator(); iter.hasNext(); ) {
            BusinessItem businessItem = (BusinessItem) iter.next();
            for (Iterator iterator = businessItem.getAssignments().iterator(); iterator.hasNext(); ) {
                BusinessAssignment businessAssignment = (BusinessAssignment) iterator.next();
                TalendItem talendItem = businessAssignment.getTalendItem();
                IRepositoryViewObject obj = repositoryNode.getObject();
                if (talendItem.getId().equals(repositoryNode.getId())) {
                    list.add(businessItem);
                } else if (talendItem instanceof SQLPattern || talendItem instanceof Routine || talendItem instanceof TableMetadata || talendItem instanceof Query || talendItem instanceof SapFunctionMetadata) {
                    if (talendItem.getLabel().equals(repositoryNode.getProperties(EProperties.LABEL))) {
                        list.add(businessItem);
                    }
                }
            }
        }
        IDiagramGraphicalViewer diagramGraphicalViewer = businessDiagramEditor.getDiagramGraphicalViewer();
        List editParts = new ArrayList();
        for (Iterator iter = list.iterator(); iter.hasNext(); ) {
            BusinessItem businessItem = (BusinessItem) iter.next();
            editParts.addAll(diagramGraphicalViewer.findEditPartsForElement(EMFCoreUtil.getProxyID(businessItem), BaseBusinessItemRelationShipEditPart.class));
            editParts.addAll(diagramGraphicalViewer.findEditPartsForElement(EMFCoreUtil.getProxyID(businessItem), BusinessItemShapeEditPart.class));
        }
        diagramGraphicalViewer.deselectAll();
        // add a frame when use findAassignment
        for (Iterator iter = editParts.iterator(); iter.hasNext(); ) {
            EditPart editPart = (EditPart) iter.next();
            if (editPart instanceof BusinessItemShapeEditPart) {
                BusinessItemShapeEditPart shapEditPart = (BusinessItemShapeEditPart) editPart;
                IFigure figure = shapEditPart.getFigure();
                for (Object child : figure.getChildren()) {
                    if (child instanceof BusinessItemShapeFigure) {
                        BusinessItemShapeFigure shapFigure = (BusinessItemShapeFigure) child;
                        shapFigure.setDrawFrame(true);
                        shapFigure.revalidate();
                        shapFigure.repaint();
                        repaintedFigures.add(shapFigure);
                    }
                }
            }
            diagramGraphicalViewer.getSelectionManager().appendSelection(editPart);
        }
        ZoomManager zoomManager = (ZoomManager) businessDiagramEditor.getAdapter(ZoomManager.class);
        zoomFitSelection(zoomManager, editParts, businessDiagramEditor.getDiagramEditPart(), true);
    }
}
Also used : IDiagramGraphicalViewer(org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer) SapFunctionMetadata(org.talend.designer.business.model.business.SapFunctionMetadata) BusinessDiagramEditor(org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor) BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) Query(org.talend.designer.business.model.business.Query) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) TalendItem(org.talend.designer.business.model.business.TalendItem) IFigure(org.eclipse.draw2d.IFigure) TableMetadata(org.talend.designer.business.model.business.TableMetadata) SQLPattern(org.talend.designer.business.model.business.SQLPattern) BusinessItemShapeEditPart(org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart) DiagramEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) BaseBusinessItemRelationShipEditPart(org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart) IEditorPart(org.eclipse.ui.IEditorPart) Routine(org.talend.designer.business.model.business.Routine) RepositoryNode(org.talend.repository.model.RepositoryNode) BaseBusinessItemRelationShipEditPart(org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart) Diagram(org.eclipse.gmf.runtime.notation.Diagram) BusinessItemShapeEditPart(org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart) ZoomManager(org.eclipse.gef.editparts.ZoomManager) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) BusinessItemShapeFigure(org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure) BusinessItem(org.talend.designer.business.model.business.BusinessItem) BusinessProcess(org.talend.designer.business.model.business.BusinessProcess)

Example 3 with ZoomManager

use of org.eclipse.gef.editparts.ZoomManager in project cubrid-manager by CUBRID.

the class MonitorDashboardEditor method configureGraphicalViewer.

/**
	 * @see org.eclipse.gef.ui.parts.GraphicalEditor.configureGraphicalViewer
	 */
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    GraphicalViewer viewer = getGraphicalViewer();
    ScalableFreeformRootEditPart rootEditPart = new ScalableFreeformRootEditPart();
    viewer.setRootEditPart(rootEditPart);
    viewer.setEditPartFactory(new MonitorEditPartFacotry());
    ZoomManager manager = rootEditPart.getZoomManager();
    double[] zoomLevels = new double[] { 1.0, 1.2, 1.4, 1.6, 1.8, 2.0 };
    manager.setZoomLevels(zoomLevels);
    getActionRegistry().registerAction(new ZoomInAction(manager));
    getActionRegistry().registerAction(new ZoomOutAction(manager));
    KeyHandler keyHandler = new GefViewerKeyHandler(viewer);
    keyHandler.put(KeyStroke.getReleased('', 97, SWT.CONTROL), getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId()));
    keyHandler.put(KeyStroke.getPressed('+', SWT.KEYPAD_ADD, 0), getActionRegistry().getAction(GEFActionConstants.ZOOM_IN));
    keyHandler.put(KeyStroke.getPressed('-', SWT.KEYPAD_SUBTRACT, 0), getActionRegistry().getAction(GEFActionConstants.ZOOM_OUT));
    viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.CTRL), MouseWheelZoomHandler.SINGLETON);
    viewer.setKeyHandler(keyHandler);
    //initialize context menu
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(new IMenuListener() {

        /**
			 * get menus to show.
			 * 
			 * @param manager IMenuManager
			 */
        public void menuAboutToShow(IMenuManager manager) {
            IStructuredSelection selection = (IStructuredSelection) getGraphicalViewer().getSelection();
            String[] ids = new String[] {};
            if (null == selection || selection.isEmpty() || selection.getFirstElement() instanceof DashboardPart) {
                manager.add(getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId()));
                ids = new String[] { AddHostMonitorAction.ID, SEPARATOR, DashboardRefreshAction.ID };
            } else if (selection.getFirstElement() instanceof HostMonitorPart) {
                ids = new String[] { MonitorDetailAction.ID, DeleteHostMonitorAction.ID, EditAliasNameAction.ID, SEPARATOR, //HARoleChangeAction.ID, SEPARATOR,
                HostDashboardHistoryAction.ID, AddDatabaseMonitorAction.ID, AddBrokerMonitorAction.ID, SEPARATOR, HideHostAction.ID, MinimizeFigureAction.ID, DashboardRefreshAction.ID };
            } else if (selection.getFirstElement() instanceof DatabaseMonitorPart) {
                ids = new String[] { MonitorDetailAction.ID, DeleteDatabaseMonitorAction.ID, EditAliasNameAction.ID, SEPARATOR, DbDashboardHistoryAction.ID, OpenApplyLogDBLogAction.ID, OpenCopyLogDBLogAction.ID, OpenDatabaseLogAction.ID, SEPARATOR, ShowHostAction.ID, MinimizeFigureAction.ID, DashboardRefreshAction.ID };
            } else if (selection.getFirstElement() instanceof BrokerMonitorPart) {
                ids = new String[] { MonitorDetailAction.ID, DeleteBrokerMonitorAction.ID, EditAliasNameAction.ID, SEPARATOR, ShowBrokerClientAction.ID, ShowBrokerDabaseAction.ID, SEPARATOR, ShowHostAction.ID, MinimizeFigureAction.ID, DashboardRefreshAction.ID };
            } else if (selection.getFirstElement() instanceof ClientMonitorPart) {
                ids = new String[] { EditAliasNameAction.ID };
            } else if (selection.getFirstElement() instanceof BrokerDBListMonitorPart) {
                ids = new String[] { EditAliasNameAction.ID };
            }
            for (String id : ids) {
                if (id.equals(SEPARATOR)) {
                    manager.add(new Separator());
                } else {
                    IAction action = ActionManager.getInstance().getAction(id);
                    ((ISelectionAction) action).setSelectionProvider(getGraphicalViewer());
                    ActionManager.addActionToManager(manager, action);
                }
            }
            manager.update(true);
        }
    });
    viewer.setContextMenu(menuManager);
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) BrokerDBListMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerDBListMonitorPart) IAction(org.eclipse.jface.action.IAction) ZoomOutAction(org.eclipse.gef.ui.actions.ZoomOutAction) BrokerMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerMonitorPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) HostMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart) IMenuListener(org.eclipse.jface.action.IMenuListener) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) ClientMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.ClientMonitorPart) ZoomManager(org.eclipse.gef.editparts.ZoomManager) DashboardPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DashboardPart) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) DatabaseMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart) MonitorEditPartFacotry(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.MonitorEditPartFacotry) KeyHandler(org.eclipse.gef.KeyHandler) ZoomInAction(org.eclipse.gef.ui.actions.ZoomInAction) Separator(org.eclipse.jface.action.Separator)

Example 4 with ZoomManager

use of org.eclipse.gef.editparts.ZoomManager in project knime-core by knime.

the class WorkflowSelectionTool method getTargetRequest.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
protected Request getTargetRequest() {
    Request targetRequest = super.getTargetRequest();
    Point start = new Point(m_xLocation, m_yLocation);
    ZoomManager zm = (ZoomManager) getCurrentViewer().getProperty(ZoomManager.class.toString());
    WorkflowEditor.adaptZoom(zm, start, true);
    targetRequest.getExtendedData().put(DRAG_START_LOCATION, start);
    return targetRequest;
}
Also used : ZoomManager(org.eclipse.gef.editparts.ZoomManager) Request(org.eclipse.gef.Request) Point(org.eclipse.draw2d.geometry.Point)

Example 5 with ZoomManager

use of org.eclipse.gef.editparts.ZoomManager in project knime-core by knime.

the class WorkflowEditor method createGraphicalViewer.

/**
 * Creates the graphical viewer that is hosted in this editor and hooks
 * keyhandler and edit domain.
 *
 * @see org.eclipse.gef.ui.parts.GraphicalEditor
 *      #createGraphicalViewer(org.eclipse.swt.widgets.Composite)
 * @param parent The parent
 */
@Override
protected void createGraphicalViewer(final Composite parent) {
    IEditorSite editorSite = getEditorSite();
    GraphicalViewer viewer = new WorkflowGraphicalViewerCreator(editorSite, this.getActionRegistry()).createViewer(parent);
    // Add a listener to the static node provider
    NodeProvider.INSTANCE.addListener(this);
    // Configure the key handler
    GraphicalViewerKeyHandler keyHandler = new GraphicalViewerKeyHandler(viewer);
    KeyHandler parentKeyHandler = keyHandler.setParent(getCommonKeyHandler());
    viewer.setKeyHandler(parentKeyHandler);
    // hook the viewer into the EditDomain
    getEditDomain().addViewer(viewer);
    // activate the viewer as selection provider for Eclipse
    getSite().setSelectionProvider(viewer);
    // remember this viewer
    m_graphicalViewer = viewer;
    // load properties like grid- or node-connections settings (e.g. width, curved)
    // needs to be called before getGraphicalViewer().setContents(m_manager), since
    // the node connections are repainted on that setContents-call and the properties need
    // to be set by then
    loadProperties();
    // We already have the model - set it into the viewer
    getGraphicalViewer().setContents(m_manager);
    // add Help context
    WorkbenchHelpSystem.getInstance().setHelp(m_graphicalViewer.getControl(), "org.knime.workbench.help.flow_editor_context");
    updateEditorBackgroundColor();
    updateJobManagerDisplay();
    updateTempRemoteWorkflowMessage();
    RootEditPart rep = getGraphicalViewer().getRootEditPart();
    ((WorkflowRootEditPart) rep.getChildren().get(0)).createToolTipHelper(getSite().getShell());
    ZoomManager zm = this.getZoomManager();
    zm.setZoomLevels(ZOOM_LEVELS);
    m_zoomWheelListener = new ZoomWheelListener(zm, (FigureCanvas) getViewer().getControl());
}
Also used : FigureCanvas(org.eclipse.draw2d.FigureCanvas) GraphicalViewer(org.eclipse.gef.GraphicalViewer) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) ZoomManager(org.eclipse.gef.editparts.ZoomManager) GraphicalViewerKeyHandler(org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler) KeyHandler(org.eclipse.gef.KeyHandler) GraphicalViewerKeyHandler(org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler) IEditorSite(org.eclipse.ui.IEditorSite) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) RootEditPart(org.eclipse.gef.RootEditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart)

Aggregations

ZoomManager (org.eclipse.gef.editparts.ZoomManager)46 Point (org.eclipse.draw2d.geometry.Point)14 ArrayList (java.util.ArrayList)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 Dimension (org.eclipse.draw2d.geometry.Dimension)4 ScalableFreeformRootEditPart (org.eclipse.gef.editparts.ScalableFreeformRootEditPart)4 ZoomInAction (org.eclipse.gef.ui.actions.ZoomInAction)4 ZoomOutAction (org.eclipse.gef.ui.actions.ZoomOutAction)4 Iterator (java.util.Iterator)3 Rectangle (org.eclipse.draw2d.geometry.Rectangle)3 GraphicalViewer (org.eclipse.gef.GraphicalViewer)3 IAction (org.eclipse.jface.action.IAction)3 ConnectionContainerEditPart (org.knime.workbench.editor2.editparts.ConnectionContainerEditPart)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 AbsoluteBendpoint (org.eclipse.draw2d.AbsoluteBendpoint)2 Bendpoint (org.eclipse.draw2d.Bendpoint)2 FigureCanvas (org.eclipse.draw2d.FigureCanvas)2 Viewport (org.eclipse.draw2d.Viewport)2 KeyHandler (org.eclipse.gef.KeyHandler)2