Search in sources :

Example 96 with Command

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

the class WhereConnectionCreationTool method performConnectionStartWith.

public void performConnectionStartWith(EditPart sourcePart) {
    setConnectionSource(sourcePart);
    updateTargetRequest();
    Command cmd = ((ColumnPart) sourcePart).getCommand(getTargetRequest());
    setCurrentCommand(cmd);
    setState(STATE_CONNECTION_STARTED);
}
Also used : Command(org.eclipse.gef.commands.Command) ColumnPart(org.talend.sqlbuilder.erdiagram.ui.parts.ColumnPart)

Example 97 with Command

use of org.eclipse.gef.commands.Command 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 98 with Command

use of org.eclipse.gef.commands.Command 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)

Example 99 with Command

use of org.eclipse.gef.commands.Command in project tesb-studio-se by Talend.

the class ESBService method checkRepository.

private void checkRepository(final Node node, Item item, CommandStack stack) {
    final String updataComponentParamName = EParameterName.UPDATE_COMPONENTS.getName();
    final List<IElementParameter> repositoryParam = new ArrayList<IElementParameter>();
    for (IElementParameter param : node.getElementParameters()) {
        if (param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE)) {
            String value = (String) param.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).getValue();
            if (value.equals(EmfComponent.REPOSITORY)) {
                IElementParameter schema = param.getChildParameters().get(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
                if (schema != null && schema.getValue() != null) {
                    //$NON-NLS-1$
                    String[] names = ((String) schema.getValue()).split(" - ");
                    if (names.length > 0 && names[0].equals(item.getProperty().getId())) {
                        repositoryParam.add(schema);
                    }
                }
            }
        } else if (param.getFieldType().equals(EParameterFieldType.PROPERTY_TYPE)) {
            Object value = param.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).getValue();
            if (value.equals(EmfComponent.REPOSITORY)) {
                IElementParameter property = param.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
                if (property != null && property.getValue() != null) {
                    String proValue = (String) property.getValue();
                    if (proValue != null && proValue.contains(" - ")) {
                        proValue = proValue.split(" - ")[0];
                    }
                    if (proValue.equals(item.getProperty().getId())) {
                        repositoryParam.add(property);
                    }
                }
            }
        }
    }
    if (repositoryParam.isEmpty()) {
        return;
    }
    stack.execute(new Command() {

        @Override
        public void execute() {
            node.setPropertyValue(updataComponentParamName, Boolean.TRUE);
            for (IElementParameter param : repositoryParam) {
                // force to reload label
                param.setListItemsDisplayName(new String[0]);
                param.setListItemsValue(new String[0]);
            }
        }
    });
}
Also used : Command(org.eclipse.gef.commands.Command) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter) PortRepositoryObject(org.talend.repository.services.utils.PortRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) OperationRepositoryObject(org.talend.repository.services.utils.OperationRepositoryObject)

Example 100 with Command

use of org.eclipse.gef.commands.Command in project tesb-studio-se by Talend.

the class CamelDependenciesEditor method dependencesChanged.

@Override
public void dependencesChanged(Composite source) {
    //		setDirty(true);
    final Command cmd;
    if (source == manageRouteResourcePanel) {
        cmd = new Command() {

            @Override
            public void execute() {
                RouteResourceUtil.saveResourceDependency(getJobEditorInput().getLoadedProcess().getAdditionalProperties(), manageRouteResourcePanel.getInput());
                RelationshipItemBuilder.getInstance().addOrUpdateItem(getJobEditorInput().getItem());
            }
        };
    } else {
        cmd = new Command() {

            @Override
            public void execute() {
                //save all datas
                DependenciesCoreUtil.saveToMap(getJobEditorInput().getLoadedProcess().getAdditionalProperties(), (Collection<BundleClasspath>) bundleClasspathViewer.getInput(), (Collection<ImportPackage>) importPackageViewer.getInput(), (Collection<RequireBundle>) requireBundleViewer.getInput(), (Collection<ExportPackage>) exportPackageViewer.getInput());
            }
        };
    }
    commandStack.execute(cmd);
//		doSave(new NullProgressMonitor());
}
Also used : Command(org.eclipse.gef.commands.Command) Collection(java.util.Collection)

Aggregations

Command (org.eclipse.gef.commands.Command)100 ArrayList (java.util.ArrayList)38 List (java.util.List)35 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)35 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)28 IElementParameter (org.talend.core.model.process.IElementParameter)22 Node (org.talend.designer.core.ui.editor.nodes.Node)20 INode (org.talend.core.model.process.INode)17 EditPart (org.eclipse.gef.EditPart)15 CommandStack (org.eclipse.gef.commands.CommandStack)15 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)15 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)14 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)14 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)13 RepositoryNode (org.talend.repository.model.RepositoryNode)13 RepositoryChangeMetadataCommand (org.talend.designer.core.ui.editor.cmd.RepositoryChangeMetadataCommand)12 Request (org.eclipse.gef.Request)11 NonResizableEditPolicy (org.eclipse.gef.editpolicies.NonResizableEditPolicy)11 DirectEditRequest (org.eclipse.gef.requests.DirectEditRequest)11 LabelDirectEditPolicy (org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy)11