Search in sources :

Example 26 with RepositoryObject

use of org.talend.core.model.repository.RepositoryObject in project tdi-studio-se by Talend.

the class FixUnevenItemContextParametersMigrationTaskTest method testAfter.

@After
public void testAfter() throws PersistenceException, BusinessException {
    RepositoryObject objToDelete = new RepositoryObject(testItem.getProperty());
    ProxyRepositoryFactory.getInstance().deleteObjectPhysical(objToDelete);
    testItem = null;
}
Also used : RepositoryObject(org.talend.core.model.repository.RepositoryObject) After(org.junit.After)

Example 27 with RepositoryObject

use of org.talend.core.model.repository.RepositoryObject in project tdi-studio-se by Talend.

the class StatusManagerSettingPage method processItems.

private void processItems(List<RepositoryObject> objects, IRepositoryNode node) {
    if (node == null) {
        return;
    }
    // if the root node of type is not init, force init.
    IProjectRepositoryNode root = node.getRoot();
    if (root instanceof ProjectRepositoryNode) {
        ((ProjectRepositoryNode) root).initNode(node);
    }
    if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
        if (node.getObject() != null) {
            Property property = node.getObject().getProperty();
            Item item = property.getItem();
            if (item != null && filterRepositoryNode((RepositoryNode) node)) {
                // must be item
                RepositoryObject object = new RepositoryObject(node.getObject().getProperty());
                object.setRepositoryNode(node);
                // ItemVersionObject object = new ItemVersionObject(node, property.getVersion());
                objects.add(object);
            }
        }
    } else {
        IContentProvider contentProvider = treeViewer.getContentProvider();
        if (contentProvider instanceof NavigatorContentServiceContentProvider) {
            NavigatorContentServiceContentProvider navigatorProvider = (NavigatorContentServiceContentProvider) contentProvider;
            Object[] children = navigatorProvider.getChildren(node);
            for (Object child : children) {
                if (child instanceof RepositoryNode) {
                    processItems(objects, (RepositoryNode) child);
                }
            }
        } else {
            for (IRepositoryNode child : node.getChildren()) {
                processItems(objects, child);
            }
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) TableItem(org.eclipse.swt.widgets.TableItem) RepositoryObject(org.talend.core.model.repository.RepositoryObject) IContentProvider(org.eclipse.jface.viewers.IContentProvider) IRepositoryNode(org.talend.repository.model.IRepositoryNode) NavigatorContentServiceContentProvider(org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) RepositoryObject(org.talend.core.model.repository.RepositoryObject) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Property(org.talend.core.model.properties.Property) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode)

Example 28 with RepositoryObject

use of org.talend.core.model.repository.RepositoryObject in project tdi-studio-se by Talend.

the class StatusManagerSettingPage method addItemElements.

private void addItemElements(List<RepositoryObject> elements) {
    if (elements == null || elements.isEmpty()) {
        return;
    }
    final Color redColor = Display.getDefault().getSystemColor(SWT.COLOR_RED);
    for (final RepositoryObject object : elements) {
        if (object.isDeleted()) {
            continue;
        }
        TableItem tableItem = null;
        // for bug 17692
        ERepositoryObjectType objectType = object.getRepositoryNode().getObjectType();
        ERepositoryObjectType type = object.getRepositoryNode().getContentType();
        if (!objectType.equals(ERepositoryObjectType.JOB_DOC) && !objectType.equals(ERepositoryObjectType.JOBLET_DOC)) {
            if (isTechinalStatus()) {
                // obj.equals(constant) that will cause NPE.
                if (!type.equals(ERepositoryObjectType.DOCUMENTATION) && !type.equals(ERepositoryObjectType.BUSINESS_PROCESS) && !type.equals(ERepositoryObjectType.JOBLET_DOC)) {
                    // if (!type.equals(ERepositoryObjectType.DOCUMENTATION) &&
                    // !type.equals(ERepositoryObjectType.BUSINESS_PROCESS)
                    // && !type.equals(ERepositoryObjectType.JOBLETS)) {
                    itemTable.setRedraw(false);
                    tableItem = new TableItem(itemTable, SWT.NONE);
                }
            } else if (isDocumentStatus()) {
                if (type.equals(ERepositoryObjectType.DOCUMENTATION) || type.equals(ERepositoryObjectType.BUSINESS_PROCESS)) {
                    itemTable.setRedraw(false);
                    tableItem = new TableItem(itemTable, SWT.NONE);
                }
            } else // bug 20078
            {
                itemTable.setRedraw(false);
                tableItem = new TableItem(itemTable, SWT.NONE);
            }
        } else {
            if (isDocumentStatus()) {
                if (type.equals(ERepositoryObjectType.JOB_DOC) || type.equals(ERepositoryObjectType.JOBLET_DOC)) {
                    itemTable.setRedraw(false);
                    tableItem = new TableItem(itemTable, SWT.NONE);
                }
            }
        }
        if (tableItem != null) {
            tableItem.setData(object);
            try {
                statusHelper.getStatusList(object.getProperty());
            } catch (PersistenceException e1) {
            // TODO Auto-generated catch block
            }
            object.getProperty().setOldStatusCode(statusHelper.getStatusCode(object.getStatusCode()));
            Image itemsImage = null;
            IBaseLabelProvider labelProvider = treeViewer.getLabelProvider();
            if (labelProvider instanceof NavigatorDecoratingLabelProvider) {
                NavigatorDecoratingLabelProvider navigatorProvider = (NavigatorDecoratingLabelProvider) labelProvider;
                itemsImage = navigatorProvider.getImage(object.getRepositoryNode());
            } else {
                ERepositoryObjectType itemType = object.getRepositoryObjectType();
                itemsImage = getItemsImage(CoreImageProvider.getIcon(itemType));
            }
            tableItem.setImage(itemsImage);
            tableItem.setText(object.getLabel());
            // old version
            tableItem.setText(1, statusHelper.getStatusLabel(object.getStatusCode()));
            TableEditor versionEditor = null;
            if (isFixedstatus()) {
                String version = statusCombo.getText();
                tableItem.setText(2, version);
                if (!object.getProperty().getOldStatusCode().equals(statusHelper.getStatusCode(version))) {
                    tableItem.setForeground(2, redColor);
                } else {
                    tableItem.setForeground(2, Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
                }
            } else {
                // new version
                versionEditor = new TableEditor(itemTable);
                Composite versionComposit = new Composite(itemTable, SWT.NONE);
                GridLayout layout = new GridLayout(3, false);
                layout.horizontalSpacing = 1;
                layout.verticalSpacing = 0;
                layout.marginHeight = 0;
                layout.marginWidth = 0;
                versionComposit.setLayout(layout);
                final CCombo statusItemCombo = new CCombo(versionComposit, SWT.BORDER | SWT.READ_ONLY);
                GridData data = new GridData(GridData.FILL_HORIZONTAL);
                statusItemCombo.setLayoutData(data);
                statusItemCombo.setEditable(false);
                if (!type.equals(ERepositoryObjectType.DOCUMENTATION) && !type.equals(ERepositoryObjectType.BUSINESS_PROCESS)) {
                    statusItemCombo.setItems(toArray(technicalStatusList));
                    statusItemCombo.select(0);
                    if (!object.getProperty().getOldStatusCode().equals("DEV")) {
                        statusItemCombo.setForeground(redColor);
                    } else {
                        statusItemCombo.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
                    }
                } else {
                    statusItemCombo.setItems(toArray(documentStatusList));
                    statusItemCombo.select(0);
                    if (!object.getProperty().getOldStatusCode().equals("UCK")) {
                        statusItemCombo.setForeground(redColor);
                    } else {
                        statusItemCombo.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
                    }
                }
                statusItemCombo.addSelectionListener(new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        String version = statusItemCombo.getText();
                        String status = statusHelper.getStatusCode(version);
                        if (!status.equals(object.getProperty().getOldStatusCode())) {
                            statusItemCombo.setForeground(redColor);
                        }
                        object.getProperty().setStatusCode(statusHelper.getStatusCode(version));
                    }
                });
                versionEditor.minimumWidth = itemTable.getColumn(2).getWidth();
                versionEditor.setEditor(versionComposit, tableItem, 2);
            }
            TableEditor delEditor = new TableEditor(itemTable);
            Label delLabel = new Label(itemTable, SWT.CENTER);
            delLabel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
            delLabel.setImage(ImageProvider.getImage(EImage.DELETE_ICON));
            //$NON-NLS-1$
            delLabel.setToolTipText(Messages.getString("VersionManagementDialog.DeletedTip"));
            delLabel.pack();
            addLabelMouseListener(delLabel, object, tableItem);
            delEditor.minimumWidth = 25;
            delEditor.horizontalAlignment = SWT.CENTER;
            delEditor.setEditor(delLabel, tableItem, 3);
            if (isFixedstatus()) {
                tableItem.setData(ITEM_EDITOR_KEY, new TableEditor[] { delEditor });
            } else if (versionEditor != null) {
                tableItem.setData(ITEM_EDITOR_KEY, new TableEditor[] { versionEditor, delEditor });
            }
            itemTable.setRedraw(true);
        }
    }
}
Also used : RepositoryObject(org.talend.core.model.repository.RepositoryObject) Composite(org.eclipse.swt.widgets.Composite) NavigatorDecoratingLabelProvider(org.eclipse.ui.internal.navigator.NavigatorDecoratingLabelProvider) Color(org.eclipse.swt.graphics.Color) TableItem(org.eclipse.swt.widgets.TableItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) IImage(org.talend.commons.ui.runtime.image.IImage) Image(org.eclipse.swt.graphics.Image) EImage(org.talend.commons.ui.runtime.image.EImage) TableEditor(org.eclipse.swt.custom.TableEditor) GridLayout(org.eclipse.swt.layout.GridLayout) CCombo(org.eclipse.swt.custom.CCombo) PersistenceException(org.talend.commons.exception.PersistenceException) IBaseLabelProvider(org.eclipse.jface.viewers.IBaseLabelProvider) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 29 with RepositoryObject

use of org.talend.core.model.repository.RepositoryObject in project tdi-studio-se by Talend.

the class StatusManagerSettingPage method addRepositoryTreeViewer.

/**
     * repository tree viewer.
     */
private void addRepositoryTreeViewer(Composite leftComposite) {
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.widthHint = 210;
    gridData.heightHint = 400;
    leftComposite.setLayoutData(gridData);
    RepoCommonViewerProvider provider = RepoCommonViewerProvider.CHECKBOX;
    treeViewer = (CheckboxRepositoryTreeViewer) provider.createViewer(leftComposite);
    // filter
    treeViewer.addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            RepositoryNode node = (RepositoryNode) element;
            return filterRepositoryNode(node);
        }
    });
    // event
    treeViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            RepositoryNode node = (RepositoryNode) event.getElement();
            List<RepositoryObject> objects = new ArrayList<RepositoryObject>();
            processItems(objects, node);
            if (!objects.isEmpty()) {
                if (event.getChecked()) {
                    checkedObjects.addAll(objects);
                } else {
                    checkedObjects.removeAll(objects);
                    removeItemElements(objects);
                }
                // researchMaxVersion();
                refreshTableItems();
            }
        }
    });
    treeViewer.addTreeListener(new ITreeViewerListener() {

        @Override
        public void treeCollapsed(TreeExpansionEvent event) {
        //
        }

        @Override
        public void treeExpanded(TreeExpansionEvent event) {
        // refreshCheckedTreeView();
        }
    });
    expandSomeNodes(provider.getProjectRepositoryNode());
}
Also used : ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) RepositoryObject(org.talend.core.model.repository.RepositoryObject) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ITreeViewerListener(org.eclipse.jface.viewers.ITreeViewerListener) CheckboxRepositoryTreeViewer(org.talend.repository.viewer.ui.viewer.CheckboxRepositoryTreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepoCommonViewerProvider(org.talend.repository.viewer.ui.provider.RepoCommonViewerProvider) GridData(org.eclipse.swt.layout.GridData) RepositoryObject(org.talend.core.model.repository.RepositoryObject) List(java.util.List) ArrayList(java.util.ArrayList) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent)

Example 30 with RepositoryObject

use of org.talend.core.model.repository.RepositoryObject in project tbd-studio-se by Talend.

the class HDFSModelUtilTest method tearDown.

@After
public void tearDown() throws PersistenceException {
    factory.deleteObjectPhysical(new RepositoryObject(contextItem.getProperty()));
    factory.deleteObjectPhysical(new RepositoryObject(hcConnectionItem.getProperty()));
}
Also used : RepositoryObject(org.talend.core.model.repository.RepositoryObject) After(org.junit.After)

Aggregations

RepositoryObject (org.talend.core.model.repository.RepositoryObject)32 RepositoryNode (org.talend.repository.model.RepositoryNode)11 Property (org.talend.core.model.properties.Property)10 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)9 IRepositoryNode (org.talend.repository.model.IRepositoryNode)9 TableItem (org.eclipse.swt.widgets.TableItem)5 PersistenceException (org.talend.commons.exception.PersistenceException)5 Item (org.talend.core.model.properties.Item)5 ArrayList (java.util.ArrayList)4 IPath (org.eclipse.core.runtime.IPath)4 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)4 IEditorPart (org.eclipse.ui.IEditorPart)4 IRepositoryObject (org.talend.core.model.repository.IRepositoryObject)4 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)4 IProjectRepositoryNode (org.talend.repository.model.nodes.IProjectRepositoryNode)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 ISelection (org.eclipse.jface.viewers.ISelection)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 WizardDialog (org.eclipse.jface.wizard.WizardDialog)3