Search in sources :

Example 26 with Property

use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.

the class ShowRoutineItemsLabelProvider method getElements.

public Object[] getElements(Object inputElement) {
    Set<Project> projects = allRoutineItems.keySet();
    List<Object> objects = new ArrayList<Object>();
    Project currentProject = ProjectManager.getInstance().getCurrentProject();
    for (Project p : projects) {
        if (p.equals(currentProject)) {
            List<Property> items = allRoutineItems.get(p);
            if (items != null) {
                objects.addAll(items);
            }
        } else {
            objects.add(p);
        }
    }
    return objects.toArray();
}
Also used : Project(org.talend.core.model.general.Project) ArrayList(java.util.ArrayList) Property(org.talend.core.model.properties.Property)

Example 27 with Property

use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.

the class StatsAndLogsHelper method changeRepositoryConnection.

static void changeRepositoryConnection(Element process, StatsAndLogsComposite statsComposite) {
    String propertyType = (String) ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName());
    String id = (String) (ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName()));
    Connection repositoryConnection = null;
    /* 16969 */
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    Item item = null;
    try {
        IRepositoryViewObject repobj = factory.getLastVersion(id);
        if (repobj != null) {
            Property tmpproperty = repobj.getProperty();
            if (tmpproperty != null) {
                item = tmpproperty.getItem();
            }
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    if (item != null && item instanceof ConnectionItem) {
        repositoryConnection = ((ConnectionItem) item).getConnection();
    } else {
        repositoryConnection = null;
    }
    ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
    propertyType);
    ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
    id);
    AbstractMultiPageTalendEditor part = (AbstractMultiPageTalendEditor) ((IProcess2) process).getEditor();
    if (part instanceof AbstractMultiPageTalendEditor) {
        Object adapter = (part).getTalendEditor().getAdapter(CommandStack.class);
        if (adapter != null) {
            CommandStack commandStack = ((CommandStack) adapter);
            commandStack.execute(cmd1);
            commandStack.execute(cmd2);
        }
    }
}
Also used : ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) CommandStack(org.eclipse.gef.commands.CommandStack) ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) ConnectionItem(org.talend.core.model.properties.ConnectionItem) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) Connection(org.talend.core.model.metadata.builder.connection.Connection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 28 with Property

use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.

the class ProjectSettingManager method changeImplicitContextRepositoryItem.

static void changeImplicitContextRepositoryItem(Element process, ExtraComposite extraComposite) {
    // change repository item
    String propertyType = (String) ElementParameter2ParameterType.getParameterValue(process, JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()));
    String id = (String) (ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName()));
    Connection repositoryConnection = null;
    /* 16969 */
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    Item item = null;
    try {
        IRepositoryViewObject repobj = factory.getLastVersion(id);
        if (repobj != null) {
            Property tmpproperty = repobj.getProperty();
            if (tmpproperty != null) {
                item = tmpproperty.getItem();
            }
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    if (item != null && item instanceof ConnectionItem) {
        repositoryConnection = ((ConnectionItem) item).getConnection();
    } else {
        repositoryConnection = null;
    }
    ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
    propertyType);
    ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
    id);
    AbstractMultiPageTalendEditor part = (AbstractMultiPageTalendEditor) ((IProcess2) process).getEditor();
    if (part instanceof AbstractMultiPageTalendEditor) {
        Object adapter = (part).getTalendEditor().getAdapter(CommandStack.class);
        if (adapter != null) {
            CommandStack commandStack = ((CommandStack) adapter);
            commandStack.execute(cmd1);
            commandStack.execute(cmd2);
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) ConnectionItem(org.talend.core.model.properties.ConnectionItem) CommandStack(org.eclipse.gef.commands.CommandStack) ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) ConnectionItem(org.talend.core.model.properties.ConnectionItem) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) Connection(org.talend.core.model.metadata.builder.connection.Connection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 29 with Property

use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.

the class SetupProcessDependenciesRoutinesDialog method createButtonField.

private void createButtonField(Composite parent) {
    Composite btnComposite = new Composite(parent, SWT.NONE);
    btnComposite.setLayout(new GridLayout());
    GridData layoutData = new GridData(GridData.FILL_VERTICAL);
    layoutData.verticalAlignment = SWT.CENTER;
    btnComposite.setLayoutData(layoutData);
    addBtn = new Button(btnComposite, SWT.PUSH);
    addBtn.setImage(ImageProvider.getImage(EImage.ADD_ICON));
    addBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ListViewer currentViewer = getCurrentViewer();
            if (currentViewer == null) {
                return;
            }
            boolean system = (currentViewer == systemViewer);
            List<RoutineItemRecord> currentRecords = getCurrentRecords();
            ShowRoutineItemsDialog dialog = new ShowRoutineItemsDialog(getShell(), allRoutineItems, currentRecords, system);
            if (dialog.open() == Window.OK) {
                Property[] selectedItems = dialog.getSelectedItems();
                List<Property> needAddedItems = new ArrayList<Property>();
                // filter
                for (Property p : selectedItems) {
                    boolean found = false;
                    for (RoutineItemRecord record : currentRecords) {
                        if (system) {
                            found = p.getLabel().equals(record.getLabel());
                        } else {
                            found = p.getId().equals(record.getId());
                        }
                    }
                    if (!found) {
                        needAddedItems.add(p);
                    }
                }
                // create
                for (Property p : needAddedItems) {
                    RoutineItemRecord newOne = new RoutineItemRecord();
                    newOne.setId(p.getId());
                    newOne.setLabel(p.getLabel());
                    newOne.setName(p.getLabel());
                    newOne.setVersion(p.getVersion());
                    currentRecords.add(newOne);
                }
                //
                currentViewer.setInput(currentRecords);
                currentViewer.refresh();
                updateButtons();
            }
        }
    });
    delBtn = new Button(btnComposite, SWT.PUSH);
    delBtn.setImage(ImageProvider.getImage(EImage.DELETE_ICON));
    delBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ListViewer currentViewer = getCurrentViewer();
            List<RoutineItemRecord> currentRecords = getCurrentRecords();
            if (currentViewer != null && !((IStructuredSelection) currentViewer.getSelection()).isEmpty()) {
                Iterator iterator = ((IStructuredSelection) currentViewer.getSelection()).iterator();
                int index = 0;
                while (iterator.hasNext()) {
                    Object selectedRecord = iterator.next();
                    if (currentRecords != null && selectedRecord != null) {
                        index = currentRecords.indexOf(selectedRecord);
                        currentRecords.remove(selectedRecord);
                        if (index > currentRecords.size() - 1) {
                            index = currentRecords.size() - 1;
                        } else if (index < 0) {
                            index = 0;
                        }
                    }
                }
                currentViewer.setInput(currentRecords);
                currentViewer.getList().select(index);
                currentViewer.refresh();
            }
            updateButtons();
        }
    });
    upBtn = new Button(btnComposite, SWT.PUSH);
    upBtn.setImage(ImageProvider.getImage(EImage.UP_ICON));
    upBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveDatas(true);
        }
    });
    downBtn = new Button(btnComposite, SWT.PUSH);
    downBtn.setImage(ImageProvider.getImage(EImage.DOWN_ICON));
    downBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveDatas(false);
        }
    });
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property)

Example 30 with Property

use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.

the class JavaProcessorUtilities method getNeededModulesForProcess.

public static Set<ModuleNeeded> getNeededModulesForProcess(IProcess process) {
    Set<ModuleNeeded> neededLibraries = new TreeSet<ModuleNeeded>(new Comparator<ModuleNeeded>() {

        @Override
        public int compare(ModuleNeeded m1, ModuleNeeded m2) {
            return m1.toString().compareTo(m2.toString());
        }
    });
    Set<ModuleNeeded> neededModules = LastGenerationInfo.getInstance().getModulesNeededWithSubjobPerJob(process.getId(), process.getVersion());
    neededLibraries.addAll(neededModules);
    if (process == null || !(process instanceof IProcess2)) {
        if (neededLibraries.isEmpty() && process != null) {
            neededLibraries = process.getNeededModules(true);
            if (neededLibraries == null) {
                neededLibraries = new HashSet<ModuleNeeded>();
            // for (ModuleNeeded moduleNeeded : ModulesNeededProvider.getModulesNeeded()) {
            // neededLibraries.add(moduleNeeded.getModuleName());
            // }
            }
        } else {
            for (ModuleNeeded moduleNeeded : ModulesNeededProvider.getRunningModules()) {
                neededLibraries.add(moduleNeeded);
            }
        }
        return neededLibraries;
    }
    Property property = ((IProcess2) process).getProperty();
    if (neededLibraries.isEmpty()) {
        neededLibraries = process.getNeededModules(true);
        if (neededLibraries == null) {
            neededLibraries = new HashSet<ModuleNeeded>();
            for (ModuleNeeded moduleNeeded : ModulesNeededProvider.getModulesNeeded()) {
                neededLibraries.add(moduleNeeded);
            }
        }
    } else {
        if (property != null && property.getItem() instanceof ProcessItem) {
            neededLibraries.addAll(ModulesNeededProvider.getModulesNeededForProcess((ProcessItem) property.getItem(), process));
        } else {
            for (ModuleNeeded moduleNeeded : ModulesNeededProvider.getRunningModules()) {
                neededLibraries.add(moduleNeeded);
            }
        }
    }
    if (property != null && GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
        ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
        if (camelService.isInstanceofCamel(property.getItem())) {
            // http://jira.talendforge.org/browse/TESB-5887 LiXiaopeng 2012-6-19
            // Synchronize Route resources
            camelService.synchronizeRouteResource((ProcessItem) property.getItem());
            try {
                for (IRepositoryViewObject object : CoreRuntimePlugin.getInstance().getProxyRepositoryFactory().getAll(camelService.getBeansType())) {
                    Item item = object.getProperty().getItem();
                    if (item instanceof RoutineItem) {
                        RoutineItem routine = (RoutineItem) item;
                        for (Object o : routine.getImports()) {
                            IMPORTType type = (IMPORTType) o;
                            ModuleNeeded neededModule = new ModuleNeeded("camel bean dependencies", type.getMODULE(), "camel bean dependencies", true);
                            neededLibraries.add(neededModule);
                        }
                    }
                }
            } catch (PersistenceException e) {
                ExceptionHandler.process(e);
            }
        }
    }
    return neededLibraries;
}
Also used : ICamelDesignerCoreService(org.talend.designer.core.ICamelDesignerCoreService) RoutineItem(org.talend.core.model.properties.RoutineItem) Item(org.talend.core.model.properties.Item) RoutineItem(org.talend.core.model.properties.RoutineItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) TreeSet(java.util.TreeSet) IProcess2(org.talend.core.model.process.IProcess2) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IMPORTType(org.talend.designer.core.model.utils.emf.component.IMPORTType) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ModuleNeeded(org.talend.core.model.general.ModuleNeeded) Property(org.talend.core.model.properties.Property)

Aggregations

Property (org.talend.core.model.properties.Property)147 PersistenceException (org.talend.commons.exception.PersistenceException)56 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)48 Item (org.talend.core.model.properties.Item)46 ProcessItem (org.talend.core.model.properties.ProcessItem)39 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)36 Node (org.talend.designer.core.ui.editor.nodes.Node)28 Process (org.talend.designer.core.ui.editor.process.Process)23 RepositoryNode (org.talend.repository.model.RepositoryNode)22 IElementParameter (org.talend.core.model.process.IElementParameter)21 ConnectionItem (org.talend.core.model.properties.ConnectionItem)21 IDynamicProperty (org.talend.core.ui.properties.tab.IDynamicProperty)21 ArrayList (java.util.ArrayList)20 Test (org.junit.Test)19 INode (org.talend.core.model.process.INode)19 IComponent (org.talend.core.model.components.IComponent)15 Connection (org.talend.core.model.metadata.builder.connection.Connection)14 IProcess2 (org.talend.core.model.process.IProcess2)14 List (java.util.List)12 IFile (org.eclipse.core.resources.IFile)12