use of org.eclipse.gef.EditPartViewer in project tdi-studio-se by Talend.
the class TalendConnectionCreationTool method handleConnection.
protected boolean handleConnection() {
setAvoidDeactivation(true);
EditPartViewer viewer = getCurrentViewer();
Command endCommand = getCommand();
if (endCommand == null) {
if (isInState(STATE_TERMINAL)) {
// Fake a drag to cause feedback to be displayed immediately on mouse down.
setState(STATE_CONNECTION_STARTED);
handleDrag();
}
return true;
}
sourcePart.getViewer().getSelectionManager().deselect(sourcePart);
setCurrentCommand(endCommand);
executeCurrentCommand();
selectAddedObject(viewer, getReturnValues(endCommand));
setAvoidDeactivation(false);
getSourceRequest().setType(RequestConstants.REQ_CONNECTION_END);
eraseSourceFeedback();
deactivate();
return true;
}
use of org.eclipse.gef.EditPartViewer in project tdi-studio-se by Talend.
the class MapperSelectEditPartTracker method performSelection.
@Override
protected void performSelection() {
if (hasSelectionOccurred()) {
return;
}
setFlag(FLAG_SELECTION_PERFORMED, true);
EditPartViewer viewer = getCurrentViewer();
List selectedObjects = viewer.getSelectedEditParts();
if (getCurrentInput().isModKeyDown(SWT.MOD1)) {
lastSelectedShiftPart = null;
if (selectedObjects.contains(getSourceEditPart())) {
viewer.deselect(getSourceEditPart());
} else if (canAppend()) {
viewer.appendSelection(getSourceEditPart());
} else {
viewer.select(getSourceEditPart());
}
} else if (getCurrentInput().isShiftKeyDown()) {
if (lastSelectedShiftPart == null) {
if (!selectedObjects.isEmpty()) {
Object object = selectedObjects.get(selectedObjects.size() - 1);
if (object instanceof TableEntityPart) {
lastSelectedShiftPart = (EditPart) object;
}
} else {
lastSelectedShiftPart = getSourceEditPart();
}
}
if (canAppend()) {
List<EditPart> toselect = new ArrayList<EditPart>();
List<EditPart> deSelect = new ArrayList<EditPart>();
getShiftAffactedEditPart(toselect, deSelect);
for (EditPart part : deSelect) {
viewer.deselect(part);
}
for (EditPart part : toselect) {
if (!viewer.getSelectedEditParts().contains(part)) {
viewer.appendSelection(part);
}
}
} else {
viewer.select(getSourceEditPart());
}
} else {
lastSelectedShiftPart = null;
viewer.select(getSourceEditPart());
}
}
use of org.eclipse.gef.EditPartViewer in project cubrid-manager by CUBRID.
the class SchemaContextMenuProvider method buildContextMenu.
@Override
public void buildContextMenu(IMenuManager menu) {
if (!(menu instanceof SchemaContextMenuProvider)) {
return;
}
SchemaContextMenuProvider menuProvider = (SchemaContextMenuProvider) menu;
EditPartViewer viewer = menuProvider.getViewer();
if (viewer == null) {
return;
}
buildPublicMenuItems(menu);
List selectParts = viewer.getSelectedEditParts();
// blank right-click
if (selectParts == null || selectParts.size() == 0) {
return;
}
// multi-objects right-click
if (selectParts.size() > 1) {
buildMultiFiguresMenuItems(menu);
return;
}
// one object right-click
Object object = selectParts.get(0);
if (object instanceof TablePart) {
buildTableMenuItems(menu);
} else if (object instanceof ColumnPart) {
buildColumnMenuItems(menu);
} else if (object instanceof RelationshipPart) {
buildRelationshipLineMenuItems(menu);
}
}
use of org.eclipse.gef.EditPartViewer in project cubrid-manager by CUBRID.
the class SchemaDiagramPart method getEditor.
public ERSchemaEditor getEditor() {
EditPart parentP = getParent();
if (parentP instanceof ScalableFreeformRootEditPart) {
ScalableFreeformRootEditPart parentEditor = (ScalableFreeformRootEditPart) parentP;
EditPartViewer viewer = parentEditor.getViewer();
if (viewer instanceof ValidationGraphicalViewer) {
ValidationGraphicalViewer gViewer = (ValidationGraphicalViewer) viewer;
EditDomain domain = gViewer.getEditDomain();
if (domain instanceof ERSchemaEditDomain) {
ERSchemaEditDomain erEditorDomain = (ERSchemaEditDomain) domain;
return (ERSchemaEditor) erEditorDomain.getEditorPart();
}
}
}
return null;
}
use of org.eclipse.gef.EditPartViewer in project tdi-studio-se by Talend.
the class XmlDropTargetListener method selectAddedObject.
private void selectAddedObject() {
boolean added = false;
List newObjects = getCreateRequest().getNewObjects();
for (int i = 0; i < newObjects.size(); i++) {
Object model = newObjects.get(i);
EditPartViewer viewer = getViewer();
viewer.getControl().forceFocus();
Object editpart = viewer.getEditPartRegistry().get(model);
if (editpart instanceof EditPart) {
if (!added) {
// Force a layout first.
getViewer().flush();
viewer.select((EditPart) editpart);
added = true;
} else {
viewer.appendSelection((EditPart) editpart);
}
}
}
}
Aggregations