Search in sources :

Example 16 with Element

use of org.talend.core.model.process.Element in project tdi-studio-se by Talend.

the class AbstractJobSettingsPage method updateProjectSetting.

public void updateProjectSetting() {
    String[] split = getRepositoryPropertyName().split(":");
    String parentParamName = split[0];
    Element elementParams = elem;
    IElementParameter elementParameter = elementParams.getElementParameter(parentParamName);
    if (elementParameter != null && elementParameter.isShow(elem.getElementParameters()) && elementParameter.getChildParameters() != null) {
        if (elementParameter.getChildParameters().get("PROPERTY_TYPE") != null && !EmfComponent.BUILTIN.equals(elementParameter.getChildParameters().get("PROPERTY_TYPE").getValue())) {
            DatabaseConnection connection = null;
            String id = (String) elementParameter.getChildParameters().get("REPOSITORY_PROPERTY_TYPE").getValue();
            IRepositoryViewObject lastVersion = UpdateRepositoryUtils.getRepositoryObjectById(id);
            if (lastVersion != null && lastVersion.getProperty() != null) {
                Item item = lastVersion.getProperty().getItem();
                if (item instanceof DatabaseConnectionItem) {
                    DatabaseConnectionItem dbItem = (DatabaseConnectionItem) item;
                    connection = (DatabaseConnection) dbItem.getConnection();
                }
            }
            if (connection != null) {
                boolean sameValues = true;
                for (IElementParameter param : elementParams.getElementParameters()) {
                    String repositoryValue = param.getRepositoryValue();
                    if (param.isShow(elementParams.getElementParameters()) && repositoryValue != null && !param.getName().equals("PROPERTY_TYPE")) {
                        Object repValue = RepositoryToComponentProperty.getValue(connection, repositoryValue, null);
                        if (repValue == null) {
                            continue;
                        }
                        if (repositoryValue.equals(UpdatesConstants.TYPE)) {
                            // datebase type
                            boolean found = false;
                            String[] list = param.getListRepositoryItems();
                            for (int i = 0; (i < list.length) && (!found); i++) {
                                if (repValue.equals(list[i])) {
                                    found = true;
                                }
                            }
                            if (!found) {
                                sameValues = false;
                                break;
                            }
                        } else {
                            // check the value
                            if (!param.getValue().equals(repValue)) {
                                sameValues = false;
                                break;
                            }
                        }
                    }
                }
                if (!sameValues) {
                    boolean ok = MessageDialog.openQuestion(getShell(), getDisplayName(), "Connection has been changed , do you want to change value from repository ?");
                    if (ok) {
                        ChangeValuesFromRepository changeValuesFromRepository = new ChangeValuesFromRepository(elem, connection, getRepositoryPropertyName(), id);
                        changeValuesFromRepository.execute();
                        isConnectionChanged = true;
                    }
                }
            } else {
                MessageDialog.openInformation(getShell(), getDisplayName(), "Connection has been deleted ,change to build in automaticlly");
                ChangeValuesFromRepository changeValuesFromRepository1 = new ChangeValuesFromRepository(elem, null, getPropertyTypeName(), EmfComponent.BUILTIN);
                changeValuesFromRepository1.execute();
                isConnectionChanged = true;
            }
        }
    }
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) Element(org.talend.core.model.process.Element) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IElementParameter(org.talend.core.model.process.IElementParameter) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Example 17 with Element

use of org.talend.core.model.process.Element in project tdi-studio-se by Talend.

the class CodeGeneratorService method refreshTemplates.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.codegen.ICodeGeneratorService#refreshTemplates()
     */
@Override
public Job refreshTemplates() {
    Element oldComponent = null;
    IComponentSettingsView viewer = null;
    if (!CommonUIPlugin.isFullyHeadless()) {
        // TDI-25866:In case select a component and sctrl+shift+f3,need clean its componentSetting view
        IWorkbenchWindow wwindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (wwindow != null && wwindow.getActivePage() != null) {
            viewer = (IComponentSettingsView) wwindow.getActivePage().findView(IComponentSettingsView.ID);
            if (viewer != null) {
                oldComponent = viewer.getElement();
                viewer.cleanDisplay();
            }
        }
    }
    ComponentCompilations.deleteMarkers();
    ComponentsFactoryProvider.getInstance().resetCache();
    ILibraryManagerService librairesManagerService = (ILibraryManagerService) GlobalServiceRegister.getDefault().getService(ILibraryManagerService.class);
    librairesManagerService.clearCache();
    CorePlugin.getDefault().getLibrariesService().syncLibraries();
    Job job = CodeGeneratorEmittersPoolFactory.initialize();
    // achen modify to record ctrl+shift+f3 is pressed to fix bug 0006107
    IDesignerCoreService designerCoreService = (IDesignerCoreService) GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
    designerCoreService.getLastGeneratedJobsDateMap().clear();
    if (oldComponent != null && viewer != null) {
        viewer.setElement(oldComponent);
    }
    if (!CommonUIPlugin.isFullyHeadless()) {
        CorePlugin.getDefault().getDesignerCoreService().synchronizeDesignerUI(new PropertyChangeEvent(this, IComponentConstants.NORMAL, null, null));
    }
    return job;
}
Also used : IComponentSettingsView(org.talend.core.views.IComponentSettingsView) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) PropertyChangeEvent(java.beans.PropertyChangeEvent) ILibraryManagerService(org.talend.core.ILibraryManagerService) Element(org.talend.core.model.process.Element) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) Job(org.eclipse.core.runtime.jobs.Job)

Example 18 with Element

use of org.talend.core.model.process.Element in project tesb-studio-se by Talend.

the class CheckCXFNodesService method checkNode.

/*
	 * (non-Javadoc)
	 *
	 * @see
	 * org.talend.designer.core.ICheckNodesService#checkNode(org.talend.designer
	 * .core.ui.editor.nodes.Node)
	 */
public void checkNode(Node node) {
    if (!node.getComponent().getName().equals("cSOAP")) {
        // $NON-NLS-1$
        return;
    }
    // $NON-NLS-1$
    final IElementParameter serviceParam = node.getElementParameter("SERVICE_TYPE");
    // Select WSDL
    if (serviceParam != null && "wsdlURL".equals(serviceParam.getValue())) {
        // $NON-NLS-1$
        // $NON-NLS-1$
        final IElementParameter wsdlFileParam = node.getElementParameter("WSDL_FILE");
        // $NON-NLS-1$
        final IElementParameter wsdlTypeParam = node.getElementParameter("WSDL_TYPE");
        // Select File
        if (wsdlTypeParam != null && "file".equals(wsdlTypeParam.getValue())) {
            // WSDL file is empty
            if (wsdlFileParam == null || wsdlFileParam.getValue() == null || wsdlFileParam.getValue().toString().isEmpty() || wsdlFileParam.getValue().toString().equals("\"\"")) {
                // $NON-NLS-1$
                String errorMessage = // $NON-NLS-1$
                MessageFormat.format(// $NON-NLS-1$
                CamelDesignerMessages.getString("CheckCXFNodesService_emptyError"), wsdlFileParam == null ? "" : wsdlFileParam.getDisplayName());
                Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage);
            }
        } else // Select Repository
        if (wsdlTypeParam != null && "repo".equals(wsdlTypeParam.getValue())) {
            // $NON-NLS-1$
            final IElementParameter resourceParam = node.getElementParameterFromField(EParameterFieldType.ROUTE_RESOURCE_TYPE);
            // WSDL file is empty
            // $NON-NLS-1$
            String errorMessage = "";
            if (resourceParam == null || resourceParam.getValue() == null || resourceParam.getValue().toString().isEmpty()) {
                errorMessage = // $NON-NLS-1$
                MessageFormat.format(// $NON-NLS-1$
                CamelDesignerMessages.getString("CheckCXFNodesService_emptyError"), wsdlFileParam.getDisplayName());
                Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage);
            } else {
                String id = (String) resourceParam.getValue();
                try {
                    IRepositoryViewObject lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion(id);
                    if (lastVersion == null) {
                        errorMessage = // $NON-NLS-1$
                        MessageFormat.format(// $NON-NLS-1$
                        CamelDesignerMessages.getString("CheckCXFNodesService_nonexistError"), wsdlFileParam.getDisplayName());
                        Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage);
                    } else if (lastVersion.isDeleted()) {
                        errorMessage = // $NON-NLS-1$
                        MessageFormat.format(// $NON-NLS-1$
                        CamelDesignerMessages.getString("CheckCXFNodesService_removedError"), resourceParam.getDisplayName());
                        Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage);
                    }
                } catch (PersistenceException e) {
                    errorMessage = // $NON-NLS-1$
                    MessageFormat.format(// $NON-NLS-1$
                    CamelDesignerMessages.getString("CheckCXFNodesService_emptyError"), wsdlFileParam.getDisplayName());
                    Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage);
                }
            }
        }
    } else // Select Service class
    if (serviceParam != null && "serviceClass".equals(serviceParam.getValue())) {
        // $NON-NLS-1$
        // $NON-NLS-1$
        final IElementParameter clazzParam = node.getElementParameter("SERVICE_CLASS");
        // Service class is empty
        if (clazzParam == null || clazzParam.getValue() == null || clazzParam.getValue().toString().isEmpty()) {
            String errorMessage = // $NON-NLS-1$
            MessageFormat.format(// $NON-NLS-1$
            CamelDesignerMessages.getString("CheckCXFNodesService_emptyError"), clazzParam.getDisplayName());
            Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage);
        }
    }
}
Also used : Element(org.talend.core.model.process.Element) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter)

Example 19 with Element

use of org.talend.core.model.process.Element in project tesb-studio-se by Talend.

the class CheckMultiRestRequestNodes method checkNode.

@Override
public void checkNode(Node node) {
    String name = node.getComponent().getName();
    if (!RESTREQUEST_COMPONENT.equals(name)) {
        return;
    }
    IProcess process = node.getProcess();
    if (process.getNodesOfType(RESTREQUEST_COMPONENT).size() > 1) {
        Problems.add(ProblemStatus.ERROR, (Element) node, "Only one " + RESTREQUEST_COMPONENT + " component is allowed in a Job!");
    } else if (process.getNodesOfType(ESBPROVIDER_COMPONENT).size() > 0) {
        Problems.add(ProblemStatus.ERROR, (Element) node, RESTREQUEST_COMPONENT + " and " + ESBPROVIDER_COMPONENT + " can't present in a same Job!");
    }
}
Also used : Element(org.talend.core.model.process.Element) IProcess(org.talend.core.model.process.IProcess)

Example 20 with Element

use of org.talend.core.model.process.Element in project tdi-studio-se by Talend.

the class SubjobBasicComposite method refresh.

@Override
public void refresh() {
    super.refresh();
    Element element = getElement();
    if (element != null && element instanceof SubjobContainer) {
        SubjobContainer process = (SubjobContainer) element;
        if (reloadBtn != null && !reloadBtn.isDisposed()) {
            reloadBtn.setEnabled(!process.isReadOnly());
        }
        if (saveBtn != null && !saveBtn.isDisposed()) {
            saveBtn.setEnabled(!process.isReadOnly());
        }
    }
}
Also used : SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) Element(org.talend.core.model.process.Element)

Aggregations

Element (org.talend.core.model.process.Element)37 IProcess (org.talend.core.model.process.IProcess)11 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)11 IElementParameter (org.talend.core.model.process.IElementParameter)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 IElement (org.talend.core.model.process.IElement)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 TalendPropertyTabDescriptor (org.talend.core.ui.properties.tab.TalendPropertyTabDescriptor)4 FakeElement (org.talend.designer.core.model.FakeElement)4 Process (org.talend.designer.core.ui.editor.process.Process)4 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)3 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)3 Control (org.eclipse.swt.widgets.Control)3 IEditorPart (org.eclipse.ui.IEditorPart)3 Test (org.junit.Test)3 IProcess2 (org.talend.core.model.process.IProcess2)3 EmptyRepositoryObject (org.talend.core.model.repository.EmptyRepositoryObject)3 Form (org.talend.daikon.properties.presentation.Form)3 ChangeValuesFromRepository (org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository)3