Search in sources :

Example 81 with Command

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

the class HL7MetadataEmfToolbarEditor method createRemovePushButton.

@Override
protected RemovePushButton createRemovePushButton() {
    return new RemovePushButtonForExtendedTable(toolbar, extendedTableViewer) {

        @Override
        protected void beforeCommandExecution() {
            List beanList = this.getExtendedTableViewer().getExtendedTableModel().getBeansList();
            for (int index : this.getExtendedTableViewer().getTable().getSelectionIndices()) {
                MetadataColumn column = (MetadataColumn) beanList.get(index);
                needUpdateInRelationMap.add(column);
            }
        }

        @Override
        protected void afterCommandExecution(Command executedCommand) {
            //$NON-NLS-N$
            String key = "";
            IStructuredSelection selection = (IStructuredSelection) linker.getMainui().getMetaTableViewer().getSelection();
            if (selection.getFirstElement() != null && selection.getFirstElement() instanceof IModel) {
                key = ((IModel) selection.getFirstElement()).getDisplayName();
            }
            if (!needUpdateInRelationMap.isEmpty()) {
                for (MetadataColumn col : needUpdateInRelationMap) {
                    linker.getManager().updateRelationMapping(key, col, false);
                }
            }
            linker.getMainui().redrawLinkers();
            linker.getBackgroundRefresher().refreshBackground();
        }

        @Override
        public boolean getEnabledState() {
            // 13749
            return super.getEnabledState() && !isRepository;
        }
    };
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) IModel(org.talend.designer.hl7.model.IModel) RemovePushButtonForExtendedTable(org.talend.commons.ui.swt.advanced.dataeditor.button.RemovePushButtonForExtendedTable) MetadataEmfExportXmlCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfExportXmlCommand) MetadataEmfPasteCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfPasteCommand) ExtendedTableResetDBTypesCommand(org.talend.core.ui.metadata.extended.command.ExtendedTableResetDBTypesCommand) MetadataEmfImportXmlCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfImportXmlCommand) Command(org.eclipse.gef.commands.Command) ArrayList(java.util.ArrayList) List(java.util.List) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 82 with Command

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

the class HL7MetadataEmfToolbarEditor method createMoveUpPushButton.

@Override
protected MoveUpPushButton createMoveUpPushButton() {
    return new MoveUpPushButtonForExtendedTable(toolbar, extendedTableViewer) {

        @Override
        protected void afterCommandExecution(Command executedCommand) {
            MetadataEmfTableEditor tableEditorModel = (MetadataEmfTableEditor) getExtendedTableViewer().getExtendedControlModel();
            IStructuredSelection selection = (IStructuredSelection) ((HL7MultiSchemaUI) linker.getMainui()).getMetaTableViewer().getSelection();
            Object selectedObj = selection.getFirstElement();
            if (selectedObj != null) {
                String key = ((IModel) selectedObj).getDisplayName();
                List<MetadataColumn> metadataColumnList = tableEditorModel.getMetadataColumnList();
                Map<String, List<MetadataColumn>> schemaRelationMap = linker.getManager().getSchemaRelationMap();
                if (schemaRelationMap != null) {
                    List<MetadataColumn> schemas = new ArrayList<MetadataColumn>();
                    schemas.addAll(metadataColumnList);
                    schemaRelationMap.put(key, schemas);
                }
            }
            linker.getMainui().redrawLinkers();
            linker.getBackgroundRefresher().refreshBackground();
        }

        @Override
        public boolean getEnabledState() {
            // 13749
            return super.getEnabledState() && !isRepository;
        }
    };
}
Also used : IModel(org.talend.designer.hl7.model.IModel) MoveUpPushButtonForExtendedTable(org.talend.commons.ui.swt.advanced.dataeditor.button.MoveUpPushButtonForExtendedTable) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) MetadataEmfExportXmlCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfExportXmlCommand) MetadataEmfPasteCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfPasteCommand) ExtendedTableResetDBTypesCommand(org.talend.core.ui.metadata.extended.command.ExtendedTableResetDBTypesCommand) MetadataEmfImportXmlCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfImportXmlCommand) Command(org.eclipse.gef.commands.Command) MetadataEmfTableEditor(org.talend.core.ui.metadata.editor.MetadataEmfTableEditor) HL7MultiSchemaUI(org.talend.designer.hl7.ui.HL7MultiSchemaUI) ArrayList(java.util.ArrayList) List(java.util.List)

Example 83 with Command

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

the class HL7MetadataEmfToolbarEditor method createPastePushButton.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.ui.extended.ExtendedToolbarView#createPastButton()
     */
@Override
public PastePushButton createPastePushButton() {
    return new PastePushButtonForExtendedTable(toolbar, extendedTableViewer) {

        @Override
        protected Command getCommandToExecute(ExtendedTableModel extendedTableModel, Integer indexWhereInsert) {
            return new MetadataEmfPasteCommand(extendedTableModel, indexWhereInsert);
        }

        @Override
        public boolean getEnabledState() {
            // 13749
            return super.getEnabledState() && !isRepository;
        }

        @Override
        protected void afterCommandExecution(Command executedCommand) {
            MetadataEmfTableEditor tableEditorModel = (MetadataEmfTableEditor) getExtendedTableViewer().getExtendedControlModel();
            IStructuredSelection selection = (IStructuredSelection) ((HL7MultiSchemaUI) linker.getMainui()).getMetaTableViewer().getSelection();
            Object selectedObj = selection.getFirstElement();
            if (selectedObj != null) {
                String key = ((IModel) selectedObj).getDisplayName();
                List<MetadataColumn> metadataColumnList = tableEditorModel.getMetadataColumnList();
                Map<String, List<MetadataColumn>> schemaRelationMap = linker.getManager().getSchemaRelationMap();
                if (schemaRelationMap != null) {
                    List<MetadataColumn> schemas = new ArrayList<MetadataColumn>();
                    schemas.addAll(metadataColumnList);
                    schemaRelationMap.put(key, schemas);
                }
            }
        }
    };
}
Also used : IModel(org.talend.designer.hl7.model.IModel) ArrayList(java.util.ArrayList) PastePushButtonForExtendedTable(org.talend.commons.ui.swt.advanced.dataeditor.button.PastePushButtonForExtendedTable) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) MetadataEmfPasteCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfPasteCommand) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) MetadataEmfExportXmlCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfExportXmlCommand) MetadataEmfPasteCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfPasteCommand) ExtendedTableResetDBTypesCommand(org.talend.core.ui.metadata.extended.command.ExtendedTableResetDBTypesCommand) MetadataEmfImportXmlCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfImportXmlCommand) Command(org.eclipse.gef.commands.Command) MetadataEmfTableEditor(org.talend.core.ui.metadata.editor.MetadataEmfTableEditor) HL7MultiSchemaUI(org.talend.designer.hl7.ui.HL7MultiSchemaUI) ArrayList(java.util.ArrayList) List(java.util.List) ExtendedTableModel(org.talend.commons.ui.swt.extended.table.ExtendedTableModel)

Example 84 with Command

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

the class HL7MetadataEmfToolbarEditor method createImportPushButton.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.ui.extended.ExtendedToolbarView#createPastButton()
     */
@Override
public ImportPushButton createImportPushButton() {
    return new ImportPushButtonForExtendedTable(toolbar, extendedTableViewer) {

        @Override
        protected Command getCommandToExecute(ExtendedTableModel extendedTableModel, File file) {
            return new MetadataEmfImportXmlCommand(extendedTableModel, file);
        }

        @Override
        public boolean getEnabledState() {
            // 13749
            return super.getEnabledState() && !isRepository;
        }

        @Override
        protected void beforeCommandExecution() {
            IStructuredSelection selection = (IStructuredSelection) ((HL7MultiSchemaUI) linker.getMainui()).getMetaTableViewer().getSelection();
            Object selectedObj = selection.getFirstElement();
            if (selectedObj != null) {
                super.beforeCommandExecution();
            } else {
                MessageDialog.openError(HL7MetadataEmfToolbarEditor.this.getParentComposite().getShell(), "Can't import xml file", "Need to init a schema by choosing a file at first");
            }
        }

        protected void afterCommandExecution(Command executedCommand) {
            MetadataEmfTableEditor tableEditorModel = (MetadataEmfTableEditor) getExtendedTableViewer().getExtendedControlModel();
            IStructuredSelection selection = (IStructuredSelection) ((HL7MultiSchemaUI) linker.getMainui()).getMetaTableViewer().getSelection();
            Object selectedObj = selection.getFirstElement();
            if (selectedObj != null) {
                String key = ((IModel) selectedObj).getDisplayName();
                for (MetadataColumn col : tableEditorModel.getMetadataColumnList()) {
                    linker.getManager().updateRelationMapping(key, col, true);
                }
            }
            linker.getMainui().redrawLinkers();
            linker.getBackgroundRefresher().refreshBackground();
        }
    };
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) ImportPushButtonForExtendedTable(org.talend.commons.ui.swt.advanced.dataeditor.button.ImportPushButtonForExtendedTable) IModel(org.talend.designer.hl7.model.IModel) MetadataEmfExportXmlCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfExportXmlCommand) MetadataEmfPasteCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfPasteCommand) ExtendedTableResetDBTypesCommand(org.talend.core.ui.metadata.extended.command.ExtendedTableResetDBTypesCommand) MetadataEmfImportXmlCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfImportXmlCommand) Command(org.eclipse.gef.commands.Command) MetadataEmfTableEditor(org.talend.core.ui.metadata.editor.MetadataEmfTableEditor) HL7MultiSchemaUI(org.talend.designer.hl7.ui.HL7MultiSchemaUI) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ExtendedTableModel(org.talend.commons.ui.swt.extended.table.ExtendedTableModel) File(java.io.File) MetadataEmfImportXmlCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfImportXmlCommand)

Example 85 with Command

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

the class HL7MetadataEmfToolbarEditor method createMoveDownPushButton.

@Override
protected MoveDownPushButton createMoveDownPushButton() {
    return new MoveDownPushButtonForExtendedTable(toolbar, extendedTableViewer) {

        @Override
        protected void afterCommandExecution(Command executedCommand) {
            MetadataEmfTableEditor tableEditorModel = (MetadataEmfTableEditor) getExtendedTableViewer().getExtendedControlModel();
            IStructuredSelection selection = (IStructuredSelection) ((HL7MultiSchemaUI) linker.getMainui()).getMetaTableViewer().getSelection();
            Object selectedObj = selection.getFirstElement();
            if (selectedObj != null) {
                String key = ((IModel) selectedObj).getDisplayName();
                List<MetadataColumn> metadataColumnList = tableEditorModel.getMetadataColumnList();
                Map<String, List<MetadataColumn>> schemaRelationMap = linker.getManager().getSchemaRelationMap();
                if (schemaRelationMap != null) {
                    List<MetadataColumn> schemas = new ArrayList<MetadataColumn>();
                    schemas.addAll(metadataColumnList);
                    schemaRelationMap.put(key, schemas);
                }
            }
            linker.getMainui().redrawLinkers();
            linker.getBackgroundRefresher().refreshBackground();
        }

        @Override
        public boolean getEnabledState() {
            // 13749
            return super.getEnabledState() && !isRepository;
        }
    };
}
Also used : IModel(org.talend.designer.hl7.model.IModel) MoveDownPushButtonForExtendedTable(org.talend.commons.ui.swt.advanced.dataeditor.button.MoveDownPushButtonForExtendedTable) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) MetadataEmfExportXmlCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfExportXmlCommand) MetadataEmfPasteCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfPasteCommand) ExtendedTableResetDBTypesCommand(org.talend.core.ui.metadata.extended.command.ExtendedTableResetDBTypesCommand) MetadataEmfImportXmlCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfImportXmlCommand) Command(org.eclipse.gef.commands.Command) MetadataEmfTableEditor(org.talend.core.ui.metadata.editor.MetadataEmfTableEditor) HL7MultiSchemaUI(org.talend.designer.hl7.ui.HL7MultiSchemaUI) ArrayList(java.util.ArrayList) List(java.util.List)

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