Search in sources :

Example 1 with TalendSelectionManager

use of org.talend.designer.core.ui.editor.TalendSelectionManager 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)

Aggregations

GraphicalViewer (org.eclipse.gef.GraphicalViewer)1 Control (org.eclipse.swt.widgets.Control)1 IEditorPart (org.eclipse.ui.IEditorPart)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IExternalNode (org.talend.core.model.process.IExternalNode)1 INode (org.talend.core.model.process.INode)1 IGraphicalNode (org.talend.core.ui.process.IGraphicalNode)1 DummyComponent (org.talend.designer.core.model.components.DummyComponent)1 AbstractMultiPageTalendEditor (org.talend.designer.core.ui.AbstractMultiPageTalendEditor)1 TalendSelectionManager (org.talend.designer.core.ui.editor.TalendSelectionManager)1 Process (org.talend.designer.core.ui.editor.process.Process)1 ComponentSettingsView (org.talend.designer.core.ui.views.properties.ComponentSettingsView)1