Search in sources :

Example 1 with RemovePushButtonForExtendedTable

use of org.talend.commons.ui.swt.advanced.dataeditor.button.RemovePushButtonForExtendedTable in project tdi-studio-se by Talend.

the class JSONFileMetadataEmfToolbarEditor 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) {
            linker.getBackgroundRefresher().refreshBackground();
        }
    };
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) RemovePushButtonForExtendedTable(org.talend.commons.ui.swt.advanced.dataeditor.button.RemovePushButtonForExtendedTable) MetadataEmfPasteCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfPasteCommand) Command(org.eclipse.gef.commands.Command) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with RemovePushButtonForExtendedTable

use of org.talend.commons.ui.swt.advanced.dataeditor.button.RemovePushButtonForExtendedTable in project tdi-studio-se by Talend.

the class PropertiesTableToolbarEditorView method createRemovePushButton.

@Override
protected RemovePushButton createRemovePushButton() {
    RemovePushButtonForExtendedTable removePushButton = new RemovePushButtonForExtendedTable(this.toolbar, getExtendedTableViewer()) {

        @Override
        public boolean getEnabledState() {
            if (model != null && !model.getElemParameter().getElement().isReadOnly() && (model.getElemParameter().getName().equals("HADOOP_ADVANCED_PROPERTIES") || model.getElemParameter().getName().equals("SPARK_ADVANCED_PROPERTIES") || model.getElemParameter().getName().equals("HBASE_PARAMETERS"))) {
                if (getExtendedTableViewer().getTable().getSelectionIndex() > -1) {
                    TableItem item = extendedTableViewer.getTable().getSelection()[0];
                    HashMap<String, String> itemMap = (HashMap<String, String>) item.getData();
                    List<HashMap<String, String>> parameterValue = (List<HashMap<String, String>>) model.getElemParameter().getValue();
                    for (HashMap<String, String> parameterValueMap : parameterValue) {
                        if (parameterValueMap != null && itemMap != null && parameterValueMap.get("PROPERTY") != null && itemMap.get("PROPERTY") != null) {
                            if (parameterValueMap.get("PROPERTY").equals(itemMap.get("PROPERTY")) && parameterValueMap.get("VALUE").equals(itemMap.get("VALUE"))) {
                                if (parameterValueMap.get("BUILDIN") != null && parameterValueMap.get("BUILDIN").equals("TRUE")) {
                                    return true;
                                }
                            }
                        }
                    }
                }
            }
            return super.getEnabledState() && (model == null || !model.getElemParameter().isBasedOnSubjobStarts());
        }
    };
    // TDI-6568, after remove, fire change
    removePushButton.addListener(getPropertyChangeListener(), false);
    return removePushButton;
}
Also used : RemovePushButtonForExtendedTable(org.talend.commons.ui.swt.advanced.dataeditor.button.RemovePushButtonForExtendedTable) HashMap(java.util.HashMap) TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with RemovePushButtonForExtendedTable

use of org.talend.commons.ui.swt.advanced.dataeditor.button.RemovePushButtonForExtendedTable 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)

Aggregations

ArrayList (java.util.ArrayList)3 List (java.util.List)3 RemovePushButtonForExtendedTable (org.talend.commons.ui.swt.advanced.dataeditor.button.RemovePushButtonForExtendedTable)3 Command (org.eclipse.gef.commands.Command)2 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)2 MetadataEmfPasteCommand (org.talend.core.ui.metadata.extended.command.MetadataEmfPasteCommand)2 HashMap (java.util.HashMap)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 TableItem (org.eclipse.swt.widgets.TableItem)1 ExtendedTableResetDBTypesCommand (org.talend.core.ui.metadata.extended.command.ExtendedTableResetDBTypesCommand)1 MetadataEmfExportXmlCommand (org.talend.core.ui.metadata.extended.command.MetadataEmfExportXmlCommand)1 MetadataEmfImportXmlCommand (org.talend.core.ui.metadata.extended.command.MetadataEmfImportXmlCommand)1 IModel (org.talend.designer.hl7.model.IModel)1