Search in sources :

Example 26 with EditPart

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

the class XmlMapOutputZoneToolBar method addTable.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.newabstractmap.figures.treetools.zone.OutputZoneToolBar#addTable()
     */
@Override
protected void addTable() {
    final OutputXmlTree createOutputXmlTree = XmlmapFactory.eINSTANCE.createOutputXmlTree();
    CommandStack commandStack = externalPart.getViewer().getEditDomain().getCommandStack();
    commandStack.execute(new Command() {

        @Override
        public void execute() {
            if (externalPart.getViewer() instanceof XmlMapGraphicViewer) {
                XmlMapGraphicViewer viewer = (XmlMapGraphicViewer) externalPart.getViewer();
                MapperManager manager = viewer.getMapperManager();
                String outputName = manager.getMapperUI().openNewOutputCreationDialog();
                if (outputName == null) {
                    return;
                }
                createOutputXmlTree.setName(outputName);
                externalData.getOutputTrees().add(createOutputXmlTree);
                MetadataTable metadataTable = new MetadataTable();
                metadataTable.setLabel(outputName);
                metadataTable.setTableName(outputName);
                mapperComponent.getMetadataList().add(metadataTable);
                mapperComponent.getProcess().addUniqueConnectionName(outputName);
                int indexOf = externalPart.getModelChildren().indexOf(createOutputXmlTree);
                if (indexOf != -1) {
                    externalPart.getViewer().select((EditPart) externalPart.getChildren().get(indexOf));
                }
                if (!min_size.isEnabled()) {
                    min_size.setEnabled(true);
                }
                // check problem for created output incase input main is multiloop
                mapperManger.getProblemsAnalyser().checkProblems(createOutputXmlTree);
                mapperManger.getMapperUI().updateStatusBar();
            }
        }
    });
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) MapperManager(org.talend.designer.xmlmap.ui.tabs.MapperManager) Command(org.eclipse.gef.commands.Command) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) OutputXmlTreeEditPart(org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart) XmlMapDataEditPart(org.talend.designer.xmlmap.parts.XmlMapDataEditPart) EditPart(org.eclipse.gef.EditPart) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) XmlMapGraphicViewer(org.talend.designer.xmlmap.editor.XmlMapGraphicViewer)

Example 27 with EditPart

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

the class XmlMapOutputZoneToolBar method removeTable.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.newabstractmap.figures.treetools.zone.OutputZoneToolBar#removeTable()
     */
@Override
protected void removeTable() {
    CommandStack commandStack = graphicViewer.getEditDomain().getCommandStack();
    commandStack.execute(new Command() {

        @Override
        public void execute() {
            OutputXmlTreeEditPart currentSelectedOutputXmlTree = graphicViewer.getFiguresManager().getCurrentSelectedOutputTable();
            if (currentSelectedOutputXmlTree != null) {
                OutputXmlTree outputTree = (OutputXmlTree) currentSelectedOutputXmlTree.getModel();
                int indexOf = externalPart.getModelChildren().indexOf(outputTree);
                mapperComponent.getProcess().removeUniqueConnectionName(outputTree.getName());
                removeMetadataTableByName(outputTree.getName());
                for (OutputTreeNode treeNode : outputTree.getNodes()) {
                    XmlMapUtil.detachConnectionsSouce(treeNode, externalData);
                }
                externalData.getOutputTrees().remove(outputTree);
                XmlMapUtil.detachFilterSource(outputTree, externalData);
                indexOf = indexOf - 1;
                if (indexOf > -1 && (EditPart) externalPart.getChildren().get(indexOf) instanceof OutputXmlTreeEditPart) {
                    graphicViewer.select((EditPart) externalPart.getChildren().get(indexOf));
                } else if (indexOf > -1 && indexOf + 1 < externalPart.getChildren().size() && (EditPart) externalPart.getChildren().get(indexOf + 1) instanceof OutputXmlTreeEditPart) {
                    graphicViewer.select((EditPart) externalPart.getChildren().get(indexOf + 1));
                } else {
                    mapperManger.getMapperUI().getTabFolderEditors().getOutputMetaEditorView().setMetadataTableEditor(null);
                }
                mapperManger.getProblemsAnalyser().clearProblemsForTree(outputTree);
                mapperManger.getMapperUI().updateStatusBar();
            }
            if (externalData.getOutputTrees().isEmpty() && min_size.isEnabled()) {
                min_size.setEnabled(false);
            }
        }
    });
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) Command(org.eclipse.gef.commands.Command) OutputXmlTreeEditPart(org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart) XmlMapDataEditPart(org.talend.designer.xmlmap.parts.XmlMapDataEditPart) EditPart(org.eclipse.gef.EditPart) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) OutputXmlTreeEditPart(org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart)

Example 28 with EditPart

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

the class TalendTabbedPropertySheetPage method selectionChanged.

@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
    ISelection newSelection;
    if (part instanceof AbstractMultiPageTalendEditor) {
        AbstractMultiPageTalendEditor mpte = (AbstractMultiPageTalendEditor) part;
        newSelection = mpte.getTalendEditor().getViewer().getSelection();
        if (selection instanceof StructuredSelection) {
            StructuredSelection structSel = (StructuredSelection) newSelection;
            if (structSel.size() != 1) {
                return;
            }
            if (structSel.getFirstElement() instanceof EditPart) {
                if (structSel.equals(oldSelection)) {
                // if (getCurrentTab() != null) {
                // getCurrentTab().setInput(part, selection);
                // }
                } else {
                    super.selectionChanged(part, selection);
                }
                oldSelection = structSel;
            }
        }
    } else if (part instanceof ContentOutline) {
        ContentOutline outline = (ContentOutline) part;
        newSelection = outline.getSelection();
        if (selection instanceof StructuredSelection) {
            StructuredSelection structSel = (StructuredSelection) newSelection;
            if (structSel.size() != 1) {
                return;
            }
            if (structSel.getFirstElement() instanceof NodeTreeEditPart) {
                if (structSel.equals(oldSelection)) {
                // this.getCurrentTab().setInput(part, selection);
                } else {
                    super.selectionChanged(part, selection);
                }
                oldSelection = structSel;
            }
        }
    }
}
Also used : NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) EditPart(org.eclipse.gef.EditPart) ContentOutline(org.eclipse.ui.views.contentoutline.ContentOutline)

Example 29 with EditPart

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

the class TalendSelectionManager method appendSelection.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.SelectionManager#appendSelection(org.eclipse.gef.EditPart)
     */
@Override
public void appendSelection(EditPart arg0) {
    // judge whether the refresh operation is executed.
    // see bug 3315.
    boolean needRefresh = false;
    if (getSelection() instanceof StructuredSelection) {
        StructuredSelection selection = (StructuredSelection) getSelection();
        Object selected = null;
        for (Object element : selection.toArray()) {
            selected = element;
        }
        if (getSelection().isEmpty() || (selected instanceof ProcessPart)) {
            this.selectionType = ETalendSelectionType.SINGLE;
            needRefresh = true;
        }
        if (!(arg0 instanceof NodeLabelEditPart) && !(arg0 instanceof ConnLabelEditPart) && !(arg0 instanceof ConnectionPart)) {
            // removes old selections of labels by calling setSelection
            for (Object element : selection.toArray()) {
                if (element instanceof NodeLabelEditPart) {
                    this.deselect(((AbstractGraphicalEditPart) element));
                } else if (element instanceof ConnLabelEditPart) {
                    this.deselect(((AbstractGraphicalEditPart) element));
                } else if (element instanceof ConnectionPart) {
                    this.deselect(((AbstractConnectionEditPart) element));
                }
            }
            needRefresh = true;
        }
        if (arg0 instanceof ConnectionPerformanceEditPart && getSelectPoint() != null) {
            if (needRefresh) {
                EditPart transferPart = transferFocus((ConnectionPerformanceEditPart) arg0);
                if (transferPart == null) {
                    needRefresh = false;
                    setSelectPoint(null);
                    return;
                }
                super.appendSelection(transferPart);
                needRefresh = false;
                return;
            }
        }
        if (needRefresh) {
            super.appendSelection(arg0);
            needRefresh = false;
            setSelectPoint(null);
        }
    }
}
Also used : AbstractConnectionEditPart(org.eclipse.gef.editparts.AbstractConnectionEditPart) ConnectionPerformanceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionPerformanceEditPart) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) EditPart(org.eclipse.gef.EditPart) AbstractConnectionEditPart(org.eclipse.gef.editparts.AbstractConnectionEditPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) ConnectionPerformanceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionPerformanceEditPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 30 with EditPart

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

the class TalendDrawerEditPart method createFigure.

@Override
@SuppressWarnings("restriction")
public IFigure createFigure() {
    EditPart module = getParent();
    if (module instanceof TalendDrawerEditPart) {
        TalendDrawerEditPart parent = (TalendDrawerEditPart) getParent();
        childLevel = parent.childLevel + 1;
    } else {
        childLevel = 0;
    }
    //$NON-NLS-1$
    getViewer().getControl().setData("ANIMATE", Boolean.FALSE);
    TalendDrawerFigure fig = new TalendDrawerFigure(getViewer().getControl(), childLevel, cssStyleSetting) {

        @Override
        IFigure buildTooltip() {
            return createToolTip();
        }
    };
    //$NON-NLS-1$
    getViewer().getControl().setData("ANIMATE", Boolean.TRUE);
    fig.setExpanded(getDrawer().isInitiallyOpen());
    fig.setPinned(getDrawer().isInitiallyPinned());
    fig.getCollapseToggle().addFocusListener(new FocusListener.Stub() {

        @Override
        public void focusGained(FocusEvent fe) {
            getViewer().select(TalendDrawerEditPart.this);
        }
    });
    return fig;
}
Also used : EditPart(org.eclipse.gef.EditPart) DrawerEditPart(org.eclipse.gef.internal.ui.palette.editparts.DrawerEditPart) FocusListener(org.eclipse.draw2d.FocusListener) FocusEvent(org.eclipse.draw2d.FocusEvent)

Aggregations

EditPart (org.eclipse.gef.EditPart)291 List (java.util.List)58 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)55 ArrayList (java.util.ArrayList)51 Command (org.eclipse.gef.commands.Command)32 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)27 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)27 Point (org.eclipse.draw2d.geometry.Point)26 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)26 Test (org.junit.Test)26 EmptyEditPart (com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart)21 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)21 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)20 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)19 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)19 Iterator (java.util.Iterator)18 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)18 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)16 ConnectionContainerEditPart (org.knime.workbench.editor2.editparts.ConnectionContainerEditPart)14 DiagramConnectionEditPart (com.archimatetool.editor.diagram.editparts.DiagramConnectionEditPart)13