Search in sources :

Example 6 with DummyComponent

use of org.talend.designer.core.model.components.DummyComponent in project tdi-studio-se by Talend.

the class NodePart method setSelected.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#setSelected(int)
     */
@Override
@SuppressWarnings("unchecked")
public void setSelected(final int value) {
    if (value == SELECTED) {
        super.setSelected(SELECTED_PRIMARY);
    } else {
        super.setSelected(value);
    }
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    if (value == SELECTED_NONE) {
        ComponentSettingsView viewer = (ComponentSettingsView) page.findView(ComponentSettingsView.ID);
        if (viewer == null) {
            return;
        }
        ComponentSettingsView compSettings = viewer;
        compSettings.cleanDisplay();
        return;
    }
    IEditorPart activeEditor = page.getActiveEditor();
    if (activeEditor instanceof AbstractMultiPageTalendEditor) {
        GraphicalViewer designerViewer = ((AbstractMultiPageTalendEditor) activeEditor).getTalendEditor().getViewer();
        Control ctrl = designerViewer.getControl();
        String helpLink = (String) ((Node) getModel()).getPropertyValue(EParameterName.HELP.getName());
        String requiredHelpLink = ((Process) ((Node) getModel()).getProcess()).getBaseHelpLink() + ((Node) getModel()).getComponent().getName();
        if (helpLink == null || "".equals(helpLink) || !requiredHelpLink.equals(helpLink)) {
            //$NON-NLS-1$
            helpLink = ((Process) ((Node) getModel()).getProcess()).getBaseHelpLink() + ((Node) getModel()).getComponent().getName();
        }
        if (ctrl != null) {
            PlatformUI.getWorkbench().getHelpSystem().setHelp(ctrl, helpLink);
        }
        // This code was to update automatically the help view, to set the documentation of the selected component
        // remove for TDI-24396
        //            IViewPart view = page.findView("org.eclipse.help.ui.HelpView"); //$NON-NLS-1$
        // if (view != null) {
        // PlatformUI.getWorkbench().getHelpSystem().displayHelp(helpLink);
        // }
        TalendSelectionManager selectionManager = (TalendSelectionManager) designerViewer.getSelectionManager();
        if (value == SELECTED || value == SELECTED_PRIMARY) {
            ComponentSettingsView viewer = (ComponentSettingsView) page.findView(ComponentSettingsView.ID);
            if (viewer == null) {
                return;
            }
            if (selectionManager.getSelectionType() == ETalendSelectionType.SINGLE) {
                ComponentSettingsView compSettings = viewer;
                compSettings.setElement((Node) getModel());
                if (((Node) getModel()).getComponent() instanceof DummyComponent) {
                    MessageDialog.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), //$NON-NLS-1$
                    Messages.getString("NodePart_warning"), //$NON-NLS-1$
                    Messages.getString("NodePart_componentNotLoaded"));
                    return;
                }
                CodeView.refreshCodeView((Node) getModel());
            } else if (!viewer.isCleaned() && selectionManager.getSelectionType() == ETalendSelectionType.MULTIPLE) {
                ComponentSettingsView compSettings = viewer;
                compSettings.cleanDisplay();
            } else if (isDrop()) {
                if (value == SELECTED || value == SELECTED_PRIMARY) {
                    ComponentSettingsView compSettings = viewer;
                    compSettings.setElement((Node) getModel());
                    if (((Node) getModel()).getComponent() instanceof DummyComponent) {
                        MessageDialog.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), //$NON-NLS-1$
                        Messages.getString("NodePart_warning"), //$NON-NLS-1$
                        Messages.getString("NodePart_componentNotLoaded"));
                        return;
                    }
                    CodeView.refreshCodeView((Node) getModel());
                }
            }
        }
    }
}
Also used : Control(org.eclipse.swt.widgets.Control) GraphicalViewer(org.eclipse.gef.GraphicalViewer) DummyComponent(org.talend.designer.core.model.components.DummyComponent) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) Process(org.talend.designer.core.ui.editor.process.Process) IEditorPart(org.eclipse.ui.IEditorPart) ComponentSettingsView(org.talend.designer.core.ui.views.properties.ComponentSettingsView) TalendSelectionManager(org.talend.designer.core.ui.editor.TalendSelectionManager)

Example 7 with DummyComponent

use of org.talend.designer.core.model.components.DummyComponent in project tdi-studio-se by Talend.

the class NodeUtilTest method testIsBigDataFrameworkNode.

@Test
public void testIsBigDataFrameworkNode() {
    DummyComponent comp = Mockito.mock(DummyComponent.class);
    Mockito.when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_CAMEL.getName());
    //$NON-NLS-1$
    INode node = new DataNode(comp, "");
    assertFalse(NodeUtil.isBigDataFrameworkNode(node));
    Mockito.when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_DI.getName());
    //$NON-NLS-1$
    node = new DataNode(comp, "");
    assertFalse(NodeUtil.isBigDataFrameworkNode(node));
    Mockito.when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_MAPREDUCE.getName());
    //$NON-NLS-1$
    node = new DataNode(comp, "");
    assertTrue(NodeUtil.isBigDataFrameworkNode(node));
    Mockito.when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_SPARK.getName());
    //$NON-NLS-1$
    node = new DataNode(comp, "");
    assertTrue(NodeUtil.isBigDataFrameworkNode(node));
    Mockito.when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_SPARKSTREAMING.getName());
    //$NON-NLS-1$
    node = new DataNode(comp, "");
    assertTrue(NodeUtil.isBigDataFrameworkNode(node));
    Mockito.when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_STORM.getName());
    //$NON-NLS-1$
    node = new DataNode(comp, "");
    assertTrue(NodeUtil.isBigDataFrameworkNode(node));
}
Also used : INode(org.talend.core.model.process.INode) DummyComponent(org.talend.designer.core.model.components.DummyComponent) DataNode(org.talend.designer.core.model.process.DataNode) Test(org.junit.Test)

Aggregations

DummyComponent (org.talend.designer.core.model.components.DummyComponent)7 INode (org.talend.core.model.process.INode)5 Test (org.junit.Test)3 IComponent (org.talend.core.model.components.IComponent)3 DataNode (org.talend.designer.core.model.process.DataNode)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 IElementParameter (org.talend.core.model.process.IElementParameter)2 IExternalNode (org.talend.core.model.process.IExternalNode)2 IGraphicalNode (org.talend.core.ui.process.IGraphicalNode)2 ElementParameter (org.talend.designer.core.model.components.ElementParameter)2 Process (org.talend.designer.core.ui.editor.process.Process)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Point (org.eclipse.draw2d.geometry.Point)1 GraphicalViewer (org.eclipse.gef.GraphicalViewer)1 PaletteEntry (org.eclipse.gef.palette.PaletteEntry)1 CreationFactory (org.eclipse.gef.requests.CreationFactory)1