Search in sources :

Example 11 with KeyValue

use of com.amalto.workbench.models.KeyValue in project tmdm-studio-se by Talend.

the class UserSecurityCellModifier method modify.

public void modify(Object element, String property, Object value) {
    if (value instanceof Integer) {
        if (Integer.valueOf(value.toString()) == -1) {
            return;
        }
    }
    Line line = null;
    if (element instanceof TableItem) {
        TableItem item = (TableItem) element;
        line = (Line) item.getData();
    } else {
        line = (Line) element;
    }
    int columnIndex = Arrays.asList(viewer.getColumnProperties()).indexOf(property);
    if (columnIndex >= 0 && columnIndex < viewer.getColumnProperties().length) {
        if (isAColumnWithCombo(columnIndex)) {
            String[] attrs = conditionColumns[columnIndex].getComboValues();
            value = attrs[Integer.parseInt(value.toString())];
        }
        KeyValue kv = line.keyValues.get(columnIndex);
        boolean noChange = kv.value.equals(value.toString());
        kv.value = value.toString();
        viewer.refresh();
        if (!noChange && page != null) {
            page.markDirty();
        }
    }
}
Also used : Line(com.amalto.workbench.models.Line) KeyValue(com.amalto.workbench.models.KeyValue) TableItem(org.eclipse.swt.widgets.TableItem)

Example 12 with KeyValue

use of com.amalto.workbench.models.KeyValue in project tmdm-studio-se by Talend.

the class AddBrowseItemsWizardR method modifyRolesWithAttachedBrowseItem.

@Override
protected void modifyRolesWithAttachedBrowseItem(String browseItem, List<Line> roles) {
    for (Line line : roles) {
        List<KeyValue> keyValues = line.keyValues;
        String roleName = keyValues.get(0).value;
        MDMServerObjectItem roleItem = RepositoryQueryService.findServerObjectItemByName(IServerObjectRepositoryType.TYPE_ROLE, roleName);
        if (roleItem != null) {
            CommandManager.getInstance().pushCommand(ICommand.CMD_MODIFY, roleItem.getProperty().getId(), roleItem.getMDMServerObject().getName());
        }
        if (roleItem != null) {
            IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
            if (factory.isEditableAndLockIfPossible(roleItem)) {
                WSRoleE role = ((WSRoleItem) roleItem).getWsRole();
                for (WSRoleSpecificationE spec : role.getSpecification()) {
                    if (spec.getObjectType().equals("View")) {
                        // $NON-NLS-1$
                        EList<WSRoleSpecificationInstanceE> specInstance = spec.getInstance();
                        // 
                        WSRoleSpecificationInstanceE newInstance = MdmserverobjectFactory.eINSTANCE.createWSRoleSpecificationInstanceE();
                        newInstance.setInstanceName(browseItem);
                        // $NON-NLS-1$
                        newInstance.setWritable(keyValues.get(1).value.equals("Read Only") ? false : true);
                        // 
                        specInstance.add(newInstance);
                        // 
                        break;
                    }
                }
                RepositoryResourceUtil.saveItem(roleItem);
            }
            try {
                factory.unlock(roleItem);
            } catch (PersistenceException e) {
                log.error(e.getMessage(), e);
            } catch (LoginException e) {
                log.error(e.getMessage(), e);
            }
        }
    }
}
Also used : KeyValue(com.amalto.workbench.models.KeyValue) WSRoleE(org.talend.mdm.repository.model.mdmserverobject.WSRoleE) WSRoleSpecificationInstanceE(org.talend.mdm.repository.model.mdmserverobject.WSRoleSpecificationInstanceE) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) WSRoleSpecificationE(org.talend.mdm.repository.model.mdmserverobject.WSRoleSpecificationE) Line(com.amalto.workbench.models.Line) WSRoleItem(org.talend.mdm.repository.model.mdmproperties.WSRoleItem) PersistenceException(org.talend.commons.exception.PersistenceException) LoginException(org.talend.commons.exception.LoginException) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Aggregations

KeyValue (com.amalto.workbench.models.KeyValue)12 Line (com.amalto.workbench.models.Line)10 ArrayList (java.util.ArrayList)9 SelectionListener (org.eclipse.swt.events.SelectionListener)4 GridData (org.eclipse.swt.layout.GridData)4 Composite (org.eclipse.swt.widgets.Composite)4 List (java.util.List)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 TableItem (org.eclipse.swt.widgets.TableItem)3 EImage (com.amalto.workbench.image.EImage)2 XPathFunc (com.amalto.workbench.models.XPathFunc)2 ListenerList (org.eclipse.core.runtime.ListenerList)2 CellEditor (org.eclipse.jface.viewers.CellEditor)2 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)2 ICellModifier (org.eclipse.jface.viewers.ICellModifier)2 ILabelProviderListener (org.eclipse.jface.viewers.ILabelProviderListener)2 IStructuredContentProvider (org.eclipse.jface.viewers.IStructuredContentProvider)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 ITableLabelProvider (org.eclipse.jface.viewers.ITableLabelProvider)2 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)2