Search in sources :

Example 86 with EditPart

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

the class XmlDropTargetListener method selectAddedObject.

private void selectAddedObject() {
    boolean added = false;
    List newObjects = getCreateRequest().getNewObjects();
    for (int i = 0; i < newObjects.size(); i++) {
        Object model = newObjects.get(i);
        EditPartViewer viewer = getViewer();
        viewer.getControl().forceFocus();
        Object editpart = viewer.getEditPartRegistry().get(model);
        if (editpart instanceof EditPart) {
            if (!added) {
                // Force a layout first.
                getViewer().flush();
                viewer.select((EditPart) editpart);
                added = true;
            } else {
                viewer.appendSelection((EditPart) editpart);
            }
        }
    }
}
Also used : AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) VarNodeEditPart(org.talend.designer.xmlmap.parts.VarNodeEditPart) EditPart(org.eclipse.gef.EditPart) EditPartViewer(org.eclipse.gef.EditPartViewer) List(java.util.List) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) Point(org.eclipse.draw2d.geometry.Point)

Example 87 with EditPart

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

the class XmlMapInputZoneToolBar method changProperty.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.newabstractmap.figures.treetools.zone.InputZoneTooBar#changProperty()
     */
@Override
public void changProperty() {
    boolean dieOnError = mapperManger.isDieOnError();
    PropertySetDialog propertySet = new PropertySetDialog(null, dieOnError);
    if (propertySet.open() == Window.OK) {
        if (graphicViewer != null && propertySet.isValueChanged()) {
            final boolean newValue = !dieOnError;
            CommandStack commandStack = graphicViewer.getEditDomain().getCommandStack();
            commandStack.execute(new Command() {

                @Override
                public void execute() {
                    mapperManger.setDieOnError(newValue);
                    if (newValue) {
                        if (!externalData.getOutputTrees().isEmpty()) {
                            OutputXmlTree outputTree = externalData.getOutputTrees().get(0);
                            if (outputTree.isErrorReject()) {
                                // mapperComponent.getMetadataList().add(metadataTable);
                                externalData.getOutputTrees().remove(0);
                                mapperComponent.getProcess().removeUniqueConnectionName(outputTree.getName());
                                removeMetadataTableByName(outputTree.getName());
                                if (!externalData.getOutputTrees().isEmpty()) {
                                    int indexOf = externalPart.getModelChildren().indexOf(externalData.getOutputTrees().get(0));
                                    if (indexOf != -1) {
                                        graphicViewer.select((EditPart) externalPart.getChildren().get(indexOf));
                                    }
                                }
                            }
                        }
                    } else {
                        boolean hasRejectTable = false;
                        if (!externalData.getOutputTrees().isEmpty()) {
                            OutputXmlTree outputTree = externalData.getOutputTrees().get(0);
                            if (outputTree.isErrorReject()) {
                                hasRejectTable = true;
                            }
                        }
                        if (!hasRejectTable) {
                            String baseName = MapperManager.ERROR_REJECT;
                            IProcess process = mapperComponent.getProcess();
                            String tableName = baseName;
                            if (!process.checkValidConnectionName(baseName) && process instanceof IProcess2) {
                                final String uniqueName = ((IProcess2) process).generateUniqueConnectionName("row", baseName);
                                tableName = uniqueName;
                                ((IProcess2) process).addUniqueConnectionName(uniqueName);
                            } else if (process instanceof IProcess2) {
                                tableName = baseName;
                                ((IProcess2) process).addUniqueConnectionName(baseName);
                            }
                            OutputXmlTree outputXmlTree = XmlmapFactory.eINSTANCE.createOutputXmlTree();
                            outputXmlTree.setErrorReject(true);
                            outputXmlTree.setName(tableName);
                            externalData.getOutputTrees().add(0, outputXmlTree);
                            MetadataTable metadataTable = new MetadataTable();
                            metadataTable.setLabel(tableName);
                            metadataTable.setTableName(tableName);
                            MetadataColumn errorMessageCol = new MetadataColumn();
                            errorMessageCol.setLabel(MapperManager.ERROR_REJECT_MESSAGE);
                            errorMessageCol.setTalendType(DesignerPlugin.getDefault().getPreferenceStore().getString(MetadataTypeLengthConstants.FIELD_DEFAULT_TYPE));
                            errorMessageCol.setNullable(true);
                            errorMessageCol.setOriginalDbColumnName(MapperManager.ERROR_REJECT_MESSAGE);
                            errorMessageCol.setReadOnly(true);
                            errorMessageCol.setCustom(true);
                            metadataTable.getListColumns().add(errorMessageCol);
                            MetadataColumn errorStackTrace = new MetadataColumn();
                            errorStackTrace.setLabel(MapperManager.ERROR_REJECT_STACK_TRACE);
                            errorStackTrace.setTalendType(DesignerPlugin.getDefault().getPreferenceStore().getString(MetadataTypeLengthConstants.FIELD_DEFAULT_TYPE));
                            errorStackTrace.setNullable(true);
                            errorStackTrace.setOriginalDbColumnName(MapperManager.ERROR_REJECT_STACK_TRACE);
                            errorStackTrace.setReadOnly(true);
                            errorStackTrace.setCustom(true);
                            metadataTable.getListColumns().add(errorStackTrace);
                            mapperComponent.getMetadataList().add(metadataTable);
                            OutputTreeNode errorMessageNode = XmlmapFactory.eINSTANCE.createOutputTreeNode();
                            errorMessageNode.setName(MapperManager.ERROR_REJECT_MESSAGE);
                            errorMessageNode.setType(errorMessageCol.getTalendType());
                            errorMessageNode.setNullable(true);
                            outputXmlTree.getNodes().add(errorMessageNode);
                            OutputTreeNode errorStackTraceNode = XmlmapFactory.eINSTANCE.createOutputTreeNode();
                            errorStackTraceNode.setName(MapperManager.ERROR_REJECT_STACK_TRACE);
                            errorStackTraceNode.setType(errorStackTrace.getTalendType());
                            errorStackTraceNode.setNullable(true);
                            outputXmlTree.getNodes().add(errorStackTraceNode);
                            int indexOf = externalPart.getModelChildren().indexOf(outputXmlTree);
                            if (indexOf != -1) {
                                graphicViewer.select((EditPart) externalPart.getChildren().get(indexOf));
                            }
                        }
                    }
                }
            });
        }
    }
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) PropertySetDialog(org.talend.designer.xmlmap.ui.dialog.PropertySetDialog) XmlMapDataEditPart(org.talend.designer.xmlmap.parts.XmlMapDataEditPart) InputXmlTreeEditPart(org.talend.designer.xmlmap.parts.InputXmlTreeEditPart) EditPart(org.eclipse.gef.EditPart) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) Command(org.eclipse.gef.commands.Command) IProcess2(org.talend.core.model.process.IProcess2) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) IProcess(org.talend.core.model.process.IProcess)

Example 88 with EditPart

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

the class ErDiagramPartFactory method createEditPart.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.EditPartFactory#createEditPart(org.eclipse.gef.EditPart, java.lang.Object)
     */
public EditPart createEditPart(EditPart context, Object model) {
    EditPart part = null;
    if (model instanceof ErDiagram) {
        part = new ErDiagramPart();
    } else if (model instanceof Column) {
        part = new ColumnPart();
    } else if (model instanceof Table) {
        part = new TablePart();
    } else if (model instanceof Relation) {
        part = new RelationPart();
    } else {
        return null;
    }
    // tell the newly created part about the model object
    part.setModel(model);
    return part;
}
Also used : RelationPart(org.talend.sqlbuilder.erdiagram.ui.parts.RelationPart) Relation(org.talend.sqlbuilder.erdiagram.ui.nodes.Relation) Table(org.talend.sqlbuilder.erdiagram.ui.nodes.Table) ErDiagram(org.talend.sqlbuilder.erdiagram.ui.nodes.ErDiagram) Column(org.talend.sqlbuilder.erdiagram.ui.nodes.Column) EditPart(org.eclipse.gef.EditPart) TablePart(org.talend.sqlbuilder.erdiagram.ui.parts.TablePart) ColumnPart(org.talend.sqlbuilder.erdiagram.ui.parts.ColumnPart) ErDiagramPart(org.talend.sqlbuilder.erdiagram.ui.parts.ErDiagramPart)

Example 89 with EditPart

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

the class VarToolBarFigure method removeVar.

@Override
protected void removeVar() {
    CommandStack commandStack = getTableManager().getGraphicalViewer().getEditDomain().getCommandStack();
    commandStack.execute(new Command() {

        @Override
        public void execute() {
            List selectedEditParts = getTableManager().getGraphicalViewer().getSelectedEditParts();
            final List<VarNode> toRemove = new ArrayList<VarNode>();
            int minIndex = parentTable.getNodes().size() - 1;
            for (Object obj : selectedEditParts) {
                if (obj instanceof VarNodeEditPart) {
                    VarNode model = (VarNode) ((VarNodeEditPart) obj).getModel();
                    toRemove.add(model);
                    XmlMapUtil.detachNodeConnections(model, (XmlMapData) parentTable.eContainer(), true);
                    int index = parentTable.getNodes().indexOf(model);
                    if (index < minIndex) {
                        minIndex = index;
                    }
                }
            }
            parentTable.getNodes().removeAll(toRemove);
            if (!tablePart.getChildren().isEmpty()) {
                if (minIndex > tablePart.getChildren().size() - 1) {
                    minIndex = tablePart.getChildren().size() - 1;
                }
                tablePart.getViewer().select((EditPart) tablePart.getChildren().get(minIndex));
            } else {
                remove.setEnabled(false);
            }
        }
    });
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) CommandStack(org.eclipse.gef.commands.CommandStack) VarNodeEditPart(org.talend.designer.xmlmap.parts.VarNodeEditPart) Command(org.eclipse.gef.commands.Command) VarNodeEditPart(org.talend.designer.xmlmap.parts.VarNodeEditPart) EditPart(org.eclipse.gef.EditPart) EList(org.eclipse.emf.common.util.EList) ArrayList(java.util.ArrayList) List(java.util.List) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Example 90 with EditPart

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

the class VarToolBarFigure method addVar.

@Override
protected void addVar() {
    CommandStack commandStack = getTableManager().getGraphicalViewer().getEditDomain().getCommandStack();
    commandStack.execute(new Command() {

        @Override
        public void execute() {
            VarNode newNode = XmlmapFactory.eINSTANCE.createVarNode();
            newNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
            newNode.setName(XmlMapUtil.findUniqueVarColumnName("Var", parentTable));
            parentTable.getNodes().add(newNode);
            parentTable.setMinimized(false);
            EditPart toSelect = null;
            int index = parentTable.getNodes().indexOf(newNode);
            if (index < tablePart.getChildren().size()) {
                toSelect = (EditPart) tablePart.getChildren().get(index);
                tablePart.getViewer().select(toSelect);
            }
            if (!remove.isEnabled()) {
                remove.setEnabled(true);
            }
        }
    });
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) CommandStack(org.eclipse.gef.commands.CommandStack) Command(org.eclipse.gef.commands.Command) VarNodeEditPart(org.talend.designer.xmlmap.parts.VarNodeEditPart) EditPart(org.eclipse.gef.EditPart)

Aggregations

EditPart (org.eclipse.gef.EditPart)90 List (java.util.List)43 ArrayList (java.util.ArrayList)32 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)19 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)19 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)18 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)17 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)16 Command (org.eclipse.gef.commands.Command)15 Node (org.talend.designer.core.ui.editor.nodes.Node)13 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)12 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)11 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)11 INode (org.talend.core.model.process.INode)10 NoteEditPart (org.talend.designer.core.ui.editor.notes.NoteEditPart)10 Iterator (java.util.Iterator)9 CommandStack (org.eclipse.gef.commands.CommandStack)9 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)9 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)9 GraphicalViewer (org.eclipse.gef.GraphicalViewer)8