use of org.eclipse.gef.GraphicalViewer in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method selectNode.
/**
* DOC bqian Comment method "selectNode".
*
* @param node
*/
public void selectNode(INode node) {
GraphicalViewer viewer = designerEditor.getViewer();
Object object = viewer.getRootEditPart().getChildren().get(0);
if (object instanceof ProcessPart) {
for (EditPart editPart : (List<EditPart>) ((ProcessPart) object).getChildren()) {
if (editPart instanceof NodePart) {
if (((NodePart) editPart).getModel().equals(node)) {
viewer.select(editPart);
}
}
}
}
}
use of org.eclipse.gef.GraphicalViewer 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());
}
}
}
}
}
use of org.eclipse.gef.GraphicalViewer in project tdi-studio-se by Talend.
the class ProcessLayoutEditPolicy method getConnectionAndEndCommands.
protected Command getConnectionAndEndCommands(CreateConnectionRequest request) {
CompoundCommand cc = new CompoundCommand("CreateNodeCommand");
ProcessPart processPart = (ProcessPart) this.getHost();
final GraphicalViewer graphicalViewer = (GraphicalViewer) processPart.getViewer();
final CommandStack commandStack = processPart.getViewer().getEditDomain().getCommandStack();
final String categoryName = ComponentsFactoryProvider.getInstance().getComponentsHandler().extractComponentsCategory().getName();
final IProcess2 process = (IProcess2) processPart.getModel();
TalendEditorConnectionTargetAssist assist = new TalendEditorConnectionTargetAssist(categoryName, graphicalViewer, commandStack, process);
char start = '*';
assist.showComponentCreationAssist(start);
ConnectionCreateCommand cmd = (ConnectionCreateCommand) request.getStartCommand();
if (assist.getComponentName() == null) {
assist.releaseText();
return cmd;
}
IComponent component = TalendEditorComponentCreationUtil.getComponentsInCategory(categoryName).get(assist.getComponentName());
if (component == null) {
assist.releaseText();
return cmd;
}
assist.releaseText();
Node newNode = new Node(component);
NodeContainer nodeContainer = ((Process) newNode.getProcess()).loadNodeContainer(newNode, false);
CreateNodeContainerCommand command = new CreateNodeContainerCommand((org.talend.designer.core.ui.editor.process.Process) newNode.getProcess(), nodeContainer, request.getLocation());
cc.add(command);
cmd.setTarget(newNode);
cc.add(cmd);
return cc;
}
Aggregations