Search in sources :

Example 46 with IRepositoryNode

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

the class EditProcess method getSelectedObject.

private IRepositoryNode getSelectedObject() {
    if (params == null) {
        ISelection selection = getSelection();
        if (selection != null) {
            return (IRepositoryNode) ((IStructuredSelection) selection).getFirstElement();
        }
    } else {
        IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (null == workbenchWindow) {
            return null;
        }
        IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
        if (null == workbenchPage) {
            return null;
        }
        IPerspectiveDescriptor currentPerspective = workbenchPage.getPerspective();
        if (!getPerspectiveId().equals(currentPerspective.getId())) {
            // show di perspective
            try {
                workbenchWindow.getWorkbench().showPerspective(getPerspectiveId(), workbenchWindow);
                workbenchPage = workbenchWindow.getActivePage();
            } catch (WorkbenchException e) {
                ExceptionHandler.process(e);
                return null;
            }
        }
        IRepositoryNode repositoryNode = RepositorySeekerManager.getInstance().searchRepoViewNode(params.getProperty("nodeId"), false);
        IRepositoryView viewPart = getViewPart();
        if (repositoryNode != null && viewPart != null) {
            RepositoryNodeUtilities.expandParentNode(viewPart, repositoryNode);
            return repositoryNode;
        }
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ISelection(org.eclipse.jface.viewers.ISelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) WorkbenchException(org.eclipse.ui.WorkbenchException) IRepositoryView(org.talend.repository.ui.views.IRepositoryView)

Example 47 with IRepositoryNode

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

the class SaveAsProcessAction method run.

@Override
public void run() {
    SaveAsProcessWizard processWizard = new SaveAsProcessWizard(editorPart);
    WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), processWizard);
    if (dlg.open() == Window.OK) {
        try {
            // Set readonly to false since created job will always be editable.
            JobEditorInput newJobEditorInput = new ProcessEditorInput(processWizard.getProcess(), true, true, false);
            IWorkbenchPage page = getActivePage();
            IRepositoryNode repositoryNode = RepositoryNodeUtilities.getRepositoryNode(newJobEditorInput.getItem().getProperty().getId(), false);
            newJobEditorInput.setRepositoryNode(repositoryNode);
            // close the old editor
            page.closeEditor(((AbstractTalendEditor) this.editorPart).getParent(), false);
            // open the new editor, because at the same time, there will update the jobSetting/componentSetting view
            page.openEditor(newJobEditorInput, MultiPageTalendEditor.ID, true);
        } catch (Exception e) {
            MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", "Job could not be saved" + " : " + e.getMessage());
            ExceptionHandler.process(e);
        }
    }
}
Also used : JobEditorInput(org.talend.core.ui.editor.JobEditorInput) IRepositoryNode(org.talend.repository.model.IRepositoryNode) SaveAsProcessWizard(org.talend.designer.core.ui.wizards.SaveAsProcessWizard) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) WizardDialog(org.eclipse.jface.wizard.WizardDialog) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput)

Example 48 with IRepositoryNode

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

the class ComponentChooseDialog method getChangeMetadataCommand.

/**
     * DOC bqian Comment method "getChangeMetadataCommand".
     *
     * @param selectedNode
     * @param node
     * @param list
     * @param connectionItem
     */
private void getChangeMetadataCommand(CompoundCommand cc, RepositoryNode selectedNode, Node node, ConnectionItem connectionItem) {
    if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_COLUMN) {
        RepositoryNode columnParentNode = selectedNode.getParent().getParent();
        if (columnParentNode != null) {
            selectedNode = columnParentNode;
        }
    }
    if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_TABLE || selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SAP_FUNCTION || selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SALESFORCE_MODULE) {
        String etlSchema = null;
        if (connectionItem.getConnection() instanceof DatabaseConnection) {
            DatabaseConnection connection = (DatabaseConnection) connectionItem.getConnection();
            if (connection instanceof DatabaseConnection) {
                etlSchema = connection.getUiSchema();
            }
            if (!"".equals(etlSchema)) {
                //$NON-NLS-1$
                //$NON-NLS-1$
                IElementParameter e = node.getElementParameter("ELT_SCHEMA_NAME");
                if (e != null) {
                    if (connection.isContextMode() && ContextParameterUtils.isContainContextParam(etlSchema)) {
                        e.setValue(etlSchema);
                    } else {
                        e.setValue(TalendTextUtils.addQuotes(etlSchema));
                    }
                }
            // node.getElementParameter("ELT_SCHEMA_NAME").setValue("\"" + etlSchema + "\"");
            }
        }
        IRepositoryViewObject object = selectedNode.getObject();
        MetadataTable table = null;
        if (object instanceof MetadataTableRepositoryObject) {
            table = ((MetadataTableRepositoryObject) object).getTable();
        } else if (object instanceof SalesforceModuleRepositoryObject) {
            table = ((SalesforceModuleRepositoryObject) object).getDefaultTable();
            IRepositoryViewObject obj = null;
            if (selectedNode.getChildren() != null) {
                for (IRepositoryNode repositoryNode : selectedNode.getChildren()) {
                    obj = repositoryNode.getObject();
                    if (obj instanceof MetadataTableRepositoryObject) {
                        table = ((MetadataTableRepositoryObject) obj).getTable();
                        break;
                    }
                }
            }
        }
        // for SAP
        if (PluginChecker.isSAPWizardPluginLoaded() && connectionItem instanceof SAPConnectionItem) {
            getSAPCommand(cc, object, connectionItem, table, node);
            return;
        }
        if (table != null) {
            //$NON-NLS-1$
            String value = connectionItem.getProperty().getId() + " - " + table.getLabel();
            IElementParameter schemaParam = node.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
            if (schemaParam == null) {
                schemaParam = node.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE);
            }
            IElementParameter queryParam = node.getElementParameterFromField(EParameterFieldType.QUERYSTORE_TYPE);
            if (queryParam != null) {
                queryParam = queryParam.getChildParameters().get(EParameterName.QUERYSTORE_TYPE.getName());
                if (queryParam != null) {
                    queryParam.setValue(EmfComponent.BUILTIN);
                }
            }
            // }
            if (PluginChecker.isHL7PluginLoaded() && connectionItem instanceof HL7ConnectionItem) {
                Command hl7Cmd = new RepositoryChangeMetadataForHL7Command(node, IEbcdicConstant.TABLE_SCHEMAS, table.getLabel(), ConvertionHelper.convert(table));
                cc.add(hl7Cmd);
                return;
            }
            if (schemaParam == null) {
                return;
            }
            if (node.isELTComponent()) {
                //$NON-NLS-1$
                node.setPropertyValue(EParameterName.LABEL.getName(), "__ELT_TABLE_NAME__");
            }
            schemaParam.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
            RepositoryChangeMetadataCommand command2 = new RepositoryChangeMetadataCommand(node, //$NON-NLS-1$
            schemaParam.getName() + ":" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(), value, ConvertionHelper.convert(table), null, connectionItem.getConnection());
            cc.add(command2);
            return;
        }
    }
}
Also used : RepositoryChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeMetadataCommand) IRepositoryNode(org.talend.repository.model.IRepositoryNode) SalesforceModuleRepositoryObject(org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) ConnectionCreateCommand(org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand) RepositoryChangeMetadataForSAPCommand(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForSAPCommand) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) RepositoryChangeQueryCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeQueryCommand) ConnectionReconnectCommand(org.talend.designer.core.ui.editor.cmd.ConnectionReconnectCommand) RepositoryChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeMetadataCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) RepositoryChangeMetadataForEBCDICCommand(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForEBCDICCommand) QueryGuessCommand(org.talend.designer.core.ui.editor.cmd.QueryGuessCommand) RepositoryChangeMetadataForHL7Command(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForHL7Command) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) RepositoryChangeMetadataForHL7Command(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForHL7Command) IElementParameter(org.talend.core.model.process.IElementParameter) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection)

Example 49 with IRepositoryNode

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

the class ComponentChooseDialog method handleDrop.

// private void checkRequiredModules() {
// Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
// if (newObject instanceof Node) {
// IComponent component = ((Node) newObject).getComponent();
// Shell shell = Display.getCurrent().getActiveShell();
// ModulesInstallerUtil.installModules(new Shell(shell), component);
// }
// }
/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.dnd.TemplateTransferDropTargetListener#handleDrop()
     */
@Override
protected void handleDrop() {
    updateTargetRequest();
    updateTargetEditPart();
    // checkRequiredModules();
    if (fromPalette && getTargetRequest() instanceof CreateRequest) {
        if (selectedConnectionPart != null) {
            CreateRequest req = ((CreateRequest) getTargetRequest());
            Object o = req.getNewObject();
            Point location = req.getLocation();
            if (o instanceof Node) {
                createComponentOnLink((Node) o, location);
            }
            // checkRequiredModules();
            return;
        } else if (getTargetEditPart() instanceof ProcessPart) {
            // for palette dnd, feature 6457
            Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
            if (newObject != null) {
                Command command = getCommand();
                if (command != null) {
                    execCommandStack(command);
                }
            }
            // checkRequiredModules();
            return;
        } else if (getTargetEditPart() instanceof SubjobContainerPart) {
            // TDI-24985:for palette dnd.
            Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
            if (newObject != null) {
                Command command = getCommand();
                if (command != null) {
                    execCommandStack(command);
                }
            }
            return;
        } else if (getTargetEditPart() instanceof JobletContainerPart) {
            JobletContainerPart jobletPart = (JobletContainerPart) getTargetEditPart();
            if (isLock(jobletPart)) {
                Shell shell = Display.getCurrent().getActiveShell();
                ChooseJobletDialog dialog = new ChooseJobletDialog(new Shell(shell), getDropLocation());
                if (dialog.open() == dialog.OK) {
                    EditPart part = getTargetEditPart();
                    if (dialog.addToJoblet()) {
                        AbstractMultiPageTalendEditor openEditor = getJobletPart((JobletContainerPart) part);
                        part = openEditor.getDesignerEditor().getProcessPart();
                        // editor = openEditor.getTalendEditor();
                        setTargetEditPart(part);
                        Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
                        if (newObject != null) {
                            Command command = getCommand();
                            if (command != null) {
                                CommandStack commandStack = (CommandStack) openEditor.getAdapter(CommandStack.class);
                                if (commandStack != null) {
                                    commandStack.execute(command);
                                } else {
                                    command.execute();
                                }
                            }
                        }
                        // checkRequiredModules();
                        return;
                    } else {
                        part = getParentPart(part);
                        setTargetEditPart(part);
                        Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
                        if (newObject != null) {
                            Command command = getCommand();
                            if (command != null) {
                                execCommandStack(command);
                            }
                        }
                        // checkRequiredModules();
                        return;
                    }
                }
            }
        }
    }
    List<Object> sources = getSelectSource();
    if (containsContextSource(sources)) {
        createContext(sources);
    } else {
        if (!(getTargetEditPart() instanceof NodeContainerPart)) {
            try {
                createNewComponent(getCurrentEvent());
            } catch (OperationCanceledException e) {
                return;
            }
        } else {
            if (containsSQLPatternSource(sources)) {
                createSQLPattern(sources);
            } else {
                Object obj = getSelection().getFirstElement();
                createSchema(obj, getTargetEditPart());
                createQuery(obj, getTargetEditPart());
                createProperty(obj, getTargetEditPart());
                createChildJob(obj, getTargetEditPart());
                createValidationRule(obj, getTargetEditPart());
                if (obj instanceof IRepositoryNode) {
                    propaHadoopCfgChanges((IRepositoryNode) obj);
                }
                for (IExtendedNodeHandler hander : ExtendedNodeManager.getExtendedNodeHandler()) {
                    boolean updated = hander.updateComponent(obj, getTargetEditPart(), editor.getCommandStack());
                    if (updated) {
                        break;
                    }
                }
            }
        }
    }
    // in case after drag/drop the editor is dirty but can not get focus
    if (editor.isDirty()) {
        editor.setFocus();
    }
    this.eraseTargetFeedback();
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) IRepositoryNode(org.talend.repository.model.IRepositoryNode) CreateRequest(org.eclipse.gef.requests.CreateRequest) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) HL7FileNode(org.talend.core.model.metadata.builder.connection.HL7FileNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) XMLFileNode(org.talend.core.model.metadata.builder.connection.XMLFileNode) MapperExternalNode(org.talend.core.model.process.node.MapperExternalNode) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) RootEditPart(org.eclipse.gef.RootEditPart) EditPart(org.eclipse.gef.EditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) PaletteEditPart(org.eclipse.gef.ui.palette.editparts.PaletteEditPart) JobletContainerPart(org.talend.designer.core.ui.editor.jobletcontainer.JobletContainerPart) Point(org.eclipse.draw2d.geometry.Point) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) ChooseJobletDialog(org.talend.designer.core.ui.dialog.mergeorder.ChooseJobletDialog) IExtendedNodeHandler(org.talend.designer.core.IExtendedNodeHandler) Shell(org.eclipse.swt.widgets.Shell) ConnectionCreateCommand(org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand) RepositoryChangeMetadataForSAPCommand(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForSAPCommand) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) RepositoryChangeQueryCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeQueryCommand) ConnectionReconnectCommand(org.talend.designer.core.ui.editor.cmd.ConnectionReconnectCommand) RepositoryChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeMetadataCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) RepositoryChangeMetadataForEBCDICCommand(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForEBCDICCommand) QueryGuessCommand(org.talend.designer.core.ui.editor.cmd.QueryGuessCommand) RepositoryChangeMetadataForHL7Command(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForHL7Command) SAPFunctionRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) QueryRepositoryObject(org.talend.core.repository.model.repositoryObject.QueryRepositoryObject) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) SalesforceModuleRepositoryObject(org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) SAPIDocRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPIDocRepositoryObject)

Example 50 with IRepositoryNode

use of org.talend.repository.model.IRepositoryNode 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)

Aggregations

IRepositoryNode (org.talend.repository.model.IRepositoryNode)73 RepositoryNode (org.talend.repository.model.RepositoryNode)24 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)21 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)13 PersistenceException (org.talend.commons.exception.PersistenceException)13 ArrayList (java.util.ArrayList)12 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)12 WizardDialog (org.eclipse.jface.wizard.WizardDialog)10 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)8 IEditorPart (org.eclipse.ui.IEditorPart)8 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)8 ISelection (org.eclipse.jface.viewers.ISelection)6 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)6 ProcessItem (org.talend.core.model.properties.ProcessItem)6 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)6 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)6 IRepositoryView (org.talend.repository.ui.views.IRepositoryView)6 IPath (org.eclipse.core.runtime.IPath)5 PartInitException (org.eclipse.ui.PartInitException)5 Item (org.talend.core.model.properties.Item)5