use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class AbstractTalendEditor method getCommonKeyHandler.
/**
* DOC qzhang Comment method "getCommonKeyHandler".
*
* @return
*/
public KeyHandler getCommonKeyHandler() {
if (sharedKeyHandler == null) {
sharedKeyHandler = new KeyHandler();
sharedKeyHandler.put(KeyStroke.getPressed(SWT.F1, 0), new Action() {
@Override
public void run() {
ISelection selection = getGraphicalViewer().getSelection();
if (selection != null) {
if (selection instanceof IStructuredSelection) {
Object input = ((IStructuredSelection) selection).getFirstElement();
Node node = null;
if (input instanceof NodeTreeEditPart) {
NodeTreeEditPart nTreePart = (NodeTreeEditPart) input;
node = (Node) nTreePart.getModel();
} else {
if (input instanceof NodePart) {
EditPart editPart = (EditPart) input;
node = (Node) editPart.getModel();
}
}
if (node != null) {
String helpLink = (String) node.getPropertyValue(EParameterName.HELP.getName());
String requiredHelpLink = ((Process) node.getProcess()).getBaseHelpLink() + node.getComponent().getName();
if (helpLink == null || "".equals(helpLink) || !requiredHelpLink.equals(helpLink)) {
helpLink = ((Process) node.getProcess()).getBaseHelpLink() + node.getComponent().getName();
}
PlatformUI.getWorkbench().getHelpSystem().displayHelp(helpLink);
}
}
}
}
});
sharedKeyHandler.put(KeyStroke.getPressed(SWT.DEL, 0), getActionRegistry().getAction(ActionFactory.DELETE.getId()));
// deactivate the F2 shortcut as it's not used anymore
// sharedKeyHandler.put(KeyStroke.getPressed(SWT.F2, 0),
// getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT));
}
return sharedKeyHandler;
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class AbstractTalendEditor method selectPaletteEntry.
private boolean selectPaletteEntry(String componentName, PaletteViewer paletteViewer, List entries) {
for (Object entry : entries) {
if (entry instanceof PaletteContainer) {
PaletteContainer container = (PaletteContainer) entry;
if (selectPaletteEntry(componentName, paletteViewer, container.getChildren())) {
return true;
}
} else if (entry instanceof TalendPaletteDrawer) {
TalendPaletteDrawer drawer = (TalendPaletteDrawer) entry;
if (selectPaletteEntry(componentName, paletteViewer, drawer.getChildren())) {
return true;
}
} else if (entry instanceof ToolEntry) {
ToolEntry paletteEntry = (ToolEntry) entry;
if (paletteEntry.getLabel().equals(componentName)) {
EditPart part = getToolEntryEditPart(paletteViewer, paletteEntry);
expandPaletteDrawer(paletteViewer, paletteEntry);
// paletteViewer.setSelection(new StructuredSelection(part));
// paletteViewer.setFocus(part);
paletteViewer.select(part);
paletteViewer.reveal(part);
paletteViewer.setActiveTool(paletteEntry);
return true;
}
}
}
return false;
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class ShowComponentSettingViewerAction method canPerformAction.
/**
* Test if the selected item is a node.
*
* @return true / false
*/
private boolean canPerformAction() {
if (getSelectedObjects().isEmpty()) {
return false;
}
List parts = getSelectedObjects();
if (parts.size() == 1) {
Object o = parts.get(0);
if (!(o instanceof NodePart)) {
return false;
}
NodePart part = (NodePart) o;
if (!(part.getModel() instanceof INode)) {
return false;
}
node = (Node) part.getModel();
EditPart parentPart = part.getParent();
while (!(parentPart instanceof ProcessPart)) {
parentPart = parentPart.getParent();
}
if (!(parentPart instanceof ProcessPart)) {
return false;
}
process = (IProcess) ((ProcessPart) parentPart).getModel();
//$NON-NLS-1$
setText(Messages.getString("PropertiesContextAction.Properties"));
}
return true;
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class TalendConnectionCreationTool method selectAddedObject.
protected void selectAddedObject(EditPartViewer viewer, Collection objects) {
final List editparts = new ArrayList();
final EditPart[] primaryEP = new EditPart[1];
for (Iterator i = objects.iterator(); i.hasNext(); ) {
Object object = i.next();
if (object instanceof IAdaptable) {
Object editPart = viewer.getEditPartRegistry().get(((IAdaptable) object).getAdapter(View.class));
if (editPart instanceof GraphicalEditPart) {
editparts.add(editPart);
}
}
}
if (!editparts.isEmpty()) {
viewer.setSelection(new StructuredSelection(editparts));
// automatically put the first shape into edit-mode
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
if (primaryEP[0] == null) {
primaryEP[0] = (EditPart) editparts.get(0);
}
// code is being executed. (see RATLC00527114)
if (primaryEP[0].isActive()) {
primaryEP[0].performRequest(new Request("direct edit"));
}
}
});
}
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class TalendCreateConnectionTool method handleButtonUp.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.tools.AbstractConnectionCreationTool#handleButtonUp(int)
*/
@Override
protected boolean handleButtonUp(int button) {
if (button == 1 && stateTransition(STATE_CONNECTION_STARTED, STATE_TERMINAL)) {
if (getTargetEditPart() == null) {
EditPart processPart = getProcessPart(this.sourcePart);
if (processPart != null) {
this.setTargetEditPart(getProcessPart(this.sourcePart));
this.getTargetRequest().setType(RequestConstants.REQ_CONNECTION_END);
}
}
return handleConnection();
}
super.handleButtonDown(button);
if (isInState(STATE_CONNECTION_STARTED)) {
// Fake a drag to cause feedback to be displayed immediately on
// mouse down.
handleDrag();
}
return true;
}
Aggregations