Search in sources :

Example 61 with TreeObject

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

the class XObjectEditorInput2 method getToolTipText.

@Override
public String getToolTipText() {
    TreeObject xobject = (TreeObject) getModel();
    // $NON-NLS-1$
    String sep = " - ";
    if (xobject.getType() == TreeObject.ROUTING_RULE) {
        return Messages.XObjectEditorInput2_trigger + sep + xobject.getDisplayName();
    } else if (xobject.getType() == TreeObject.TRANSFORMER) {
        return Messages.XObjectEditorInput2_process + sep + xobject.getDisplayName();
    } else {
        return // $NON-NLS-1$
        TreeObject.getTypeName(xobject.getType()) + " - " + xobject.getDisplayName();
    }
}
Also used : TreeObject(com.amalto.workbench.models.TreeObject)

Example 62 with TreeObject

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

the class XSDEditor2 method createPages.

@Override
protected void createPages() {
    super.createPages();
    XSDEditorInput2 editorInput = (XSDEditorInput2) getEditorInput();
    TreeObject treeObject = editorInput.getTreeObject();
    IRepositoryViewEditorInput xobjectEditorinput = new XObjectEditorInput2(editorInput.getViewObject(), treeObject, treeObject.getDisplayName());
    xobjectEditorinput.setReadOnly(editorInput.isReadOnly());
    IFile xsdFile = null;
    try {
        xsdFile = getXSDFile(treeObject);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
    dMainPage = new DataModelMainPage2(treeObject);
    dMainPage.addPropertyListener(this);
    try {
        MODEL_PAGE_INDEX = addPage(dMainPage, xobjectEditorinput);
    } catch (PartInitException e) {
        log.error(e.getMessage(), e);
    }
    // Add ER Editor
    if (isEE()) {
        exAdapter.addPage(xsdFile, editorInput.isReadOnly());
    }
    // add repository view object in selectionprovider
    // ContainerCacheService.get(editorInput.getInputItem().getProperty());
    IRepositoryViewObject repositoryViewObj = editorInput.getViewObject();
    CompositeViewersSelectionProvider selectionProvider = (CompositeViewersSelectionProvider) dMainPage.getSelectionProvider();
    selectionProvider.setRepositoryViewObj(repositoryViewObj);
    // 
    // add XSDSelectionListener
    XSDSelectionListener xsdListener = new XSDSelectionListener(this, dMainPage);
    dMainPage.getTypesViewer().addSelectionChangedListener(xsdListener);
    dMainPage.getElementsViewer().addSelectionChangedListener(xsdListener);
    // 
    setXObject(treeObject);
    // 
    folder = (CTabFolder) dMainPage.getMainControl().getParent();
    // $NON-NLS-1$
    folder.getItem(MODEL_PAGE_INDEX).setText(treeObject.getDisplayName() + " " + Util.getRevision(treeObject));
    folder.getItem(SOURCE_PAGE_INDEX).setText(Messages.XSDEditor2_schemaSource);
    // default use
    activePage(xsdFile);
}
Also used : IFile(org.eclipse.core.resources.IFile) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) XSDSelectionListener(com.amalto.workbench.editors.xsdeditor.XSDSelectionListener) TreeObject(com.amalto.workbench.models.TreeObject) PartInitException(org.eclipse.ui.PartInitException) CompositeViewersSelectionProvider(com.amalto.workbench.utils.CompositeViewersSelectionProvider) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) LoginException(org.talend.commons.exception.LoginException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 63 with TreeObject

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

the class Bean2EObjUtil method wrapEObjWithTreeObject.

public TreeObject wrapEObjWithTreeObject(EObject eobj, Object wsObj) {
    if (eobj instanceof MDMServerObject) {
        MDMServerObject serverObject = (MDMServerObject) eobj;
        TreeObject treeObj = new TreeObject(serverObject.getName(), null, serverObject.getType(), serverObject.getName(), wsObj);
        return treeObj;
    }
    return null;
}
Also used : TreeObject(com.amalto.workbench.models.TreeObject) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)

Example 64 with TreeObject

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

the class TreeObjectCheckTreeViewer method createTreeViewer.

@Override
protected void createTreeViewer(Composite itemComposite) {
    filteredCheckboxTree = new FilteredCheckboxTree(itemComposite, SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.FULL_SELECTION) {

        ContainerCheckedTreeViewer treeViewer;

        @Override
        protected CheckboxTreeViewer doCreateTreeViewer(Composite parent, int style) {
            treeViewer = new ContainerCheckedTreeViewer(parent, style);
            contentProvider = new TreeObjectContentProvider(serverRoot);
            treeViewer.setContentProvider(contentProvider);
            installColumns();
            treeViewer.setInput(serverRoot);
            return treeViewer;
        }

        private void installColumns() {
            treeViewer.getTree().setHeaderVisible(true);
            // 
            TreeViewerColumn nameColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
            nameColumn.getColumn().setWidth(320);
            nameColumn.getColumn().setText(Messages.ConsistencyConflict_name);
            nameColumn.setLabelProvider(new ServerTreeLabelProvider());
            // compare result
            TreeViewerColumn resultColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
            resultColumn.getColumn().setWidth(120);
            resultColumn.getColumn().setText(Messages.ConsistencyConflict_compareResult);
            resultColumn.setLabelProvider(new CompareResultColumnProvider());
            // 
            localTimeColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
            localTimeColumn.getColumn().setText(Messages.ConsistencyConflict_retrievalTimestamp);
            localTimeColumn.setLabelProvider(new TimeStampColumnProvider(true));
            // 
            serverTimeColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
            serverTimeColumn.getColumn().setText(Messages.ConsistencyConflict_serverTimestamp);
            serverTimeColumn.setLabelProvider(new TimeStampColumnProvider(false));
            // 
            showTimeStampColumns(false);
        }

        @Override
        protected boolean isNodeCollectable(TreeItem item) {
            return false;
        }

        @Override
        protected void refreshCompleted() {
            treeViewer.expandToLevel(3);
            restoreCheckedElements();
        }
    };
    filteredCheckboxTree.getViewer().addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            TreeObject node = (TreeObject) element;
            return filterRepositoryNode(node, isOverWrite);
        }
    });
}
Also used : FilteredCheckboxTree(com.amalto.workbench.widgets.FilteredCheckboxTree) Composite(org.eclipse.swt.widgets.Composite) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TreeItem(org.eclipse.swt.widgets.TreeItem) Viewer(org.eclipse.jface.viewers.Viewer) AbstractNodeCheckTreeViewer(org.talend.mdm.repository.ui.widgets.AbstractNodeCheckTreeViewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) TreeObject(com.amalto.workbench.models.TreeObject) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer) TreeObject(com.amalto.workbench.models.TreeObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ServerTreeLabelProvider(com.amalto.workbench.providers.ServerTreeLabelProvider)

Example 65 with TreeObject

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

the class ImportServerObjectWizard method doImport.

public List<String> doImport(Object[] objs, IProgressMonitor monitor) {
    monitor.beginTask(Messages.Import_Objects, objs.length);
    List<String> importedIds = new LinkedList<String>();
    ImportService.setImporting(true);
    List<Integer> types = new ArrayList<Integer>();
    types.add(TreeObject.CUSTOM_FORM);
    types.add(TreeObject.DATA_CLUSTER);
    types.add(TreeObject.DATA_MODEL);
    types.add(TreeObject.TRANSFORMER);
    types.add(TreeObject.ROUTING_RULE);
    types.add(TreeObject.MENU);
    types.add(TreeObject.ROLE);
    types.add(TreeObject.STORED_PROCEDURE);
    types.add(TreeObject.VIEW);
    types.add(TreeObject.WORKFLOW_PROCESS);
    IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    for (Object obj : objs) {
        try {
            TreeObject treeObj = (TreeObject) obj;
            monitor.subTask(treeObj.getDisplayName());
            String treeObjName = treeObj.getName();
            MDMServerObject eobj = handleSpecialTreeObject(treeObj);
            if (treeObj.getType() == TreeObject.WORKFLOW_PROCESS) {
                continue;
            }
            if (eobj == null) {
                if (!types.contains(treeObj.getType()) || treeObj.getWsObject() == null || ("JCAAdapers".equals(treeObj.getName()) && treeObj.getType() == TreeObject.DATA_CLUSTER)) {
                    // $NON-NLS-1$
                    continue;
                }
                eobj = (MDMServerObject) Bean2EObjUtil.getInstance().convertFromBean2EObj(treeObj.getWsObject(), null);
            }
            eobj.setLastServerName(serverDef.getName());
            ERepositoryObjectType type = RepositoryQueryService.getRepositoryObjectType(treeObj.getType());
            String uniqueName = getUniqueName(treeObj, treeObjName);
            MDMServerObjectItem item = RepositoryQueryService.findServerObjectItemByNameWithDeleted(type, uniqueName, true);
            if (item != null) {
                if (!isOverrideAll) {
                    int result = isOveride(treeObj.getName(), TreeObject.getTypeName(treeObj.getType()));
                    if (result == IDialogConstants.CANCEL_ID) {
                        ImportService.setImporting(false);
                        return importedIds;
                    }
                    if (result == IDialogConstants.YES_TO_ALL_ID) {
                        isOverrideAll = true;
                    }
                    if (result == IDialogConstants.NO_ID) {
                        break;
                    }
                }
                if (!RepositoryResourceUtil.isLockedItem(item)) {
                    try {
                        factory.lock(item);
                    } catch (PersistenceException e1) {
                        log.error(e1.getMessage(), e1);
                    } catch (LoginException e1) {
                        log.error(e1.getMessage(), e1);
                    }
                    item.setMDMServerObject(eobj);
                    item.getState().setDeleted(false);
                    // save
                    RepositoryResourceUtil.saveItem(item, false);
                    try {
                        factory.unlock(item);
                    } catch (PersistenceException e) {
                        log.error(e.getMessage(), e);
                    } catch (LoginException e) {
                        log.error(e.getMessage(), e);
                    }
                    importedIds.add(item.getProperty().getId());
                }
                CommandManager.getInstance().removeCommandStack(item.getProperty().getId());
            } else {
                IRepositoryNodeConfiguration config = RepositoryNodeConfigurationManager.getConfiguration(type);
                item = (MDMServerObjectItem) config.getResourceProvider().createNewItem(type);
                item.setMDMServerObject(eobj);
                ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
                itemState.setPath(caculatePath(treeObj));
                handlePath(itemState, type);
                item.setState(itemState);
                String version = getVersion(treeObj);
                if (RepositoryResourceUtil.createItem(item, uniqueName, version, false, false)) {
                    importedIds.add(item.getProperty().getId());
                }
            }
        } catch (IOException e) {
            log.error(e.getMessage(), e);
        }
        monitor.worked(1);
    }
    ImportService.setImporting(false);
    monitor.done();
    return importedIds;
}
Also used : MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) ArrayList(java.util.ArrayList) IOException(java.io.IOException) LinkedList(java.util.LinkedList) ItemState(org.talend.core.model.properties.ItemState) PersistenceException(org.talend.commons.exception.PersistenceException) TreeObject(com.amalto.workbench.models.TreeObject) LoginException(org.talend.commons.exception.LoginException) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TreeObject(com.amalto.workbench.models.TreeObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)

Aggregations

TreeObject (com.amalto.workbench.models.TreeObject)66 TreeParent (com.amalto.workbench.models.TreeParent)21 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)14 ArrayList (java.util.ArrayList)12 MDMServerObject (org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)12 TMDMService (com.amalto.workbench.webservices.TMDMService)6 WSDataModel (com.amalto.workbench.webservices.WSDataModel)5 WSDataModelPK (com.amalto.workbench.webservices.WSDataModelPK)5 WSGetDataModel (com.amalto.workbench.webservices.WSGetDataModel)5 Document (org.dom4j.Document)5 Element (org.dom4j.Element)5 EObject (org.eclipse.emf.ecore.EObject)5 MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)5 WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 IAvailableModel (com.amalto.workbench.availablemodel.IAvailableModel)3 UserInfo (com.amalto.workbench.utils.UserInfo)3 WSDataCluster (com.amalto.workbench.webservices.WSDataCluster)3 WSDigest (com.amalto.workbench.webservices.WSDigest)3 WSDigestKey (com.amalto.workbench.webservices.WSDigestKey)3