private Command createCommand(final List objects, final RGB rgb) { if (objects.isEmpty()) { return null; } if (!(objects.get(0) instanceof GraphicalEditPart)) { return null; } final CompoundCommand command = new CompoundCommand(); for (int i = 0; i < objects.size(); i++) { final GraphicalEditPart part = (GraphicalEditPart) objects.get(i); final Object modelObject = part.getModel(); if (modelObject instanceof ViewableModel) { command.add(new ChangeBackgroundColorCommand((ViewableModel) modelObject, rgb.red, rgb.green, rgb.blue)); } else if (modelObject instanceof ConnectionElement) { command.add(new ChangeConnectionColorCommand((ConnectionElement) modelObject, rgb.red, rgb.green, rgb.blue)); } } return command; }
private Command createAlignmentCommand() { final AlignmentRequest request = new AlignmentRequest(RequestConstants.REQ_ALIGN); request.setAlignmentRectangle(calculateAlignmentRectangle(request)); request.setAlignment(alignment); final List editparts = getOperationSet(request); if (editparts.size() < 2) return null; final CompoundCommand command = new CompoundCommand(); command.setDebugLabel(getText()); for (int i = 0; i < editparts.size(); i++) { final EditPart editpart = (EditPart) editparts.get(i); command.add(editpart.getCommand(request)); } return command; }
protected void execute(final Event event) { final GraphicalViewer viewer = getGraphicalViewer(); final List<Command> commandList = new ArrayList<Command>(); for (final Object object : viewer.getSelectedEditParts()) { final List<Command> subCommandList = getCommand((EditPart) object, event); commandList.addAll(subCommandList); } if (!commandList.isEmpty()) { final CompoundCommand compoundCommand = new CompoundCommand(); for (final Command command : commandList) { compoundCommand.add(command); } this.execute(compoundCommand); } }
/** * {@inheritDoc} */ @Override public void performRequest(final Request request) { final View view = (View) getModel(); final ERDiagram diagram = (ERDiagram) getRoot().getContents().getModel(); if (request.getType().equals(RequestConstants.REQ_OPEN)) { final View copyView = view.copyData(); final ViewDialog dialog = new ViewDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), getViewer(), copyView); if (dialog.open() == IDialogConstants.OK_ID) { final CompoundCommand command = ViewEditPart.createChangeViewPropertyCommand(diagram, view, copyView); execute(command.unwrap()); } } super.performRequest(request); }
/** * {@inheritDoc} */ @Override public void performRequest(final Request request) { final ERTable table = (ERTable) getModel(); final ERDiagram diagram = (ERDiagram) getRoot().getContents().getModel(); if (request.getType().equals(RequestConstants.REQ_OPEN)) { final ERTable copyTable = table.copyData(); final TableDialog dialog = new TableDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), getViewer(), copyTable); if (dialog.open() == IDialogConstants.OK_ID) { final CompoundCommand command = ERTableEditPart.createChangeTablePropertyCommand(diagram, table, copyTable); execute(command.unwrap()); } } super.performRequest(request); }
/** * {@inheritDoc} */ @Override public void performRequestOpen() { final View view = (View) getModel(); final ERDiagram diagram = getDiagram(); final View copyView = view.copyData(); final ViewDialog dialog = new ViewDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), getViewer(), copyView); if (dialog.open() == IDialogConstants.OK_ID) { final CompoundCommand command = createChangeViewPropertyCommand(diagram, view, copyView); executeCommand(command.unwrap()); } }
/** * {@inheritDoc} */ @Override public void performRequestOpen() { final ERTable table = (ERTable) getModel(); final ERDiagram diagram = getDiagram(); final ERTable copyTable = table.copyData(); final TableDialog dialog = new TableDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), getViewer(), copyTable); if (dialog.open() == IDialogConstants.OK_ID) { final CompoundCommand command = createChangeTablePropertyCommand(diagram, table, copyTable); executeCommand(command.unwrap()); } }
/** * {@inheritDoc} */ @Override protected Command getDirectEditCommand(final DirectEditRequest request) { final CompoundCommand command = new CompoundCommand(); final String text = (String) request.getCellEditor().getValue(); final Note note = (Note) getHost().getModel(); final NoteEditCommand noteEditCommand = new NoteEditCommand(note, text); command.add(noteEditCommand); final MoveElementCommand autoResizeCommand = new MoveElementCommand((ERDiagram) getHost().getRoot().getContents().getModel(), getHostFigure().getBounds(), note.getX(), note.getY(), -1, -1, note); command.add(autoResizeCommand); return command.unwrap(); }
private Command alignToStart(int start, List<NodeElementEditPart> list) { CompoundCommand command = new CompoundCommand(); Category currentCategory = getDiagram().getCurrentCategory(); for (NodeElementEditPart editPart : list) { NodeElement nodeElement = (NodeElement) editPart.getModel(); MoveElementCommand moveCommand = new MoveElementCommand(this .getDiagram(), editPart.getFigure().getBounds(), nodeElement.getX(currentCategory), start, nodeElement.getWidth(currentCategory), nodeElement.getHeight(currentCategory), nodeElement); command.add(moveCommand); } return command.unwrap(); }
private Command alignToStart(int start, List<NodeElementEditPart> list) { CompoundCommand command = new CompoundCommand(); ERDiagram diagram = this.getDiagram(); for (AbstractModelEditPart editPart : list) { NodeElement nodeElement = (NodeElement) editPart.getModel(); Category currentCategory = diagram.getCurrentCategory(); MoveElementCommand moveCommand = new MoveElementCommand(diagram, editPart.getFigure().getBounds(), start, nodeElement.getY(currentCategory), nodeElement.getWidth(currentCategory), nodeElement.getHeight(currentCategory), nodeElement); command.add(moveCommand); } return command.unwrap(); }
private Command createAlignmentCommand() { AlignmentRequest request = new AlignmentRequest( RequestConstants.REQ_ALIGN); request.setAlignmentRectangle(calculateAlignmentRectangle(request)); request.setAlignment(alignment); List editparts = getOperationSet(request); if (editparts.size() < 2) return null; CompoundCommand command = new CompoundCommand(); command.setDebugLabel(getText()); for (int i = 0; i < editparts.size(); i++) { EditPart editpart = (EditPart) editparts.get(i); command.add(editpart.getCommand(request)); } return command; }
protected void execute(Event event) { GraphicalViewer viewer = this.getGraphicalViewer(); List<Command> commandList = new ArrayList<Command>(); for (Object object : viewer.getSelectedEditParts()) { List<Command> subCommandList = this.getCommand((EditPart) object, event); commandList.addAll(subCommandList); } if (!commandList.isEmpty()) { CompoundCommand compoundCommand = new CompoundCommand(); for (Command command : commandList) { compoundCommand.add(command); } this.execute(compoundCommand); } }
/** * {@inheritDoc} */ @Override public void performRequest(Request request) { View view = (View) this.getModel(); ERDiagram diagram = (ERDiagram) this.getRoot().getContents().getModel(); if (request.getType().equals(RequestConstants.REQ_OPEN)) { View copyView = view.copyData(); ViewDialog dialog = new ViewDialog(PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getShell(), this.getViewer(), copyView); if (dialog.open() == IDialogConstants.OK_ID) { CompoundCommand command = ViewEditPart .createChangeViewPropertyCommand(diagram, view, copyView); this.execute(command.unwrap()); } } super.performRequest(request); }
/** * {@inheritDoc} */ @Override public void performRequest(Request request) { ERTable table = (ERTable) this.getModel(); ERDiagram diagram = (ERDiagram) this.getRoot().getContents().getModel(); if (request.getType().equals(RequestConstants.REQ_OPEN)) { ERTable copyTable = table.copyData(); TableDialog dialog = new TableDialog(PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getShell(), this.getViewer(), copyTable); if (dialog.open() == IDialogConstants.OK_ID) { CompoundCommand command = ERTableEditPart .createChangeTablePropertyCommand(diagram, table, copyTable); this.execute(command.unwrap()); } } super.performRequest(request); }
/** * {@inheritDoc} */ @Override public void performRequestOpen() { View view = (View) this.getModel(); ERDiagram diagram = this.getDiagram(); View copyView = view.copyData(); ViewDialog dialog = new ViewDialog(PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getShell(), this.getViewer(), copyView); if (dialog.open() == IDialogConstants.OK_ID) { CompoundCommand command = createChangeViewPropertyCommand(diagram, view, copyView); this.executeCommand(command.unwrap()); } }
/** * {@inheritDoc} */ @Override public void performRequestOpen() { ERTable table = (ERTable) this.getModel(); ERDiagram diagram = this.getDiagram(); ERTable copyTable = table.copyData(); TableDialog dialog = new TableDialog(PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getShell(), this.getViewer(), copyTable); if (dialog.open() == IDialogConstants.OK_ID) { CompoundCommand command = createChangeTablePropertyCommand(diagram, table, copyTable); this.executeCommand(command.unwrap()); } }
/** * {@inheritDoc} */ @Override protected Command getDirectEditCommand(DirectEditRequest request) { CompoundCommand command = new CompoundCommand(); String text = (String) request.getCellEditor().getValue(); Note note = (Note) getHost().getModel(); NoteEditCommand noteEditCommand = new NoteEditCommand(note, text); command.add(noteEditCommand); ERDiagram diagram = (ERDiagram) this.getHost().getRoot().getContents().getModel(); Category currentCategory = diagram.getCurrentCategory(); MoveElementCommand autoResizeCommand = new MoveElementCommand( diagram, this.getHostFigure().getBounds(), note.getX(currentCategory), note.getY(currentCategory), -1, -1, note); command.add(autoResizeCommand); return command.unwrap(); }
protected Command getAddCommand(ChangeBoundsRequest request) { CompoundCommand command = new CompoundCommand(); List editparts = request.getEditParts(); int index = findIndexOfTreeItemAt(request.getLocation()); for (int i = 0; i < editparts.size(); i++) { EditPart child = (EditPart) editparts.get(i); if (GUIEditorPlugin.getComponentValidator().isAncestor((Element)child.getModel(),(Element)getHost().getModel())) command.add(UnexecutableCommand.INSTANCE); else { TitaniumUIBoundedElement childModel = (TitaniumUIBoundedElement) child.getModel(); command.add(createCreateCommand(childModel, new Rectangle(new org.eclipse.draw2d.geometry.Point(), new Dimension(-1, -1)), index, "Reparent LogicSubpart"));//$NON-NLS-1$ } } return command; }
protected Command getMoveChildrenCommand(ChangeBoundsRequest request) { CompoundCommand command = new CompoundCommand(); List editparts = request.getEditParts(); List children = getHost().getChildren(); int newIndex = findIndexOfTreeItemAt(request.getLocation()); for (int i = 0; i < editparts.size(); i++) { EditPart child = (EditPart) editparts.get(i); int tempIndex = newIndex; int oldIndex = children.indexOf(child); if (tempIndex == -1 || oldIndex == tempIndex || oldIndex + 1 == tempIndex) { command.add(UnexecutableCommand.INSTANCE); return command; } else if (oldIndex <= tempIndex) { tempIndex--; } command.add(new MoveChildCommand((Element) child.getModel(),tempIndex)); } return command; }
/** * @see org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#getCommand(org.eclipse.gef.Request) */ public Command getCommand(Request request) { try { if (!(getHost() instanceof AbstractDiagramEditPart)) { if (REQ_RESIZE.equals(request.getType())) { if (request instanceof ChangeBoundsRequest) { CompoundCommand resize = new CompoundCommand(); List<EditPart> children = ((ChangeBoundsRequest) request).getEditParts(); for (EditPart child : children) { resize.add(createChangeConstraintCommand(child, ((ChangeBoundsRequest) request).getResizeDirection(), ((ChangeBoundsRequest) request).getSizeDelta().preciseHeight())); } return resize; } } else { return new EmptyCommand(); } } return super.getCommand(request); } catch (Exception e) { e.printStackTrace(); } return null; }
/** * UmlElement drop 처리 * * @param next * @param count * void */ protected void dropCommandForNode(AbstractNode node, CompoundCommand commpoundCommand) { Command command = null; command = new DropNotationCommand("Add drop"); ((DropNotationCommand) command).setDiagram(this.diagramEditor.getDiagram()); ((DropNotationCommand) command).setChild(node); commpoundCommand.add(command); // viewModelListInDiagram.addAll(this.diagramEditor.getDiagram().getNodeList()); // if (!viewModelListInDiagram.contains(node)) { // viewModelListInDiagram.add(node); // } getNotationNodeWithRelation(commpoundCommand, node); // this.getNotationNodeAsAssociation(commpoundCommand, node); // this.getNotationNodeAsSource(commpoundCommand, node); // this.getNotationNodeAsTarget(commpoundCommand, node); }
/** * clearLifeline * * @param _package void */ private void clearLifeline(org.eclipse.uml2.uml.Package _package) { EObject obj; List<AbstractView> viewModel; Property property; int i = 0; CompoundCommand command = new CompoundCommand(); Command deleteCommand; for (TreeIterator<EObject> iter = _package.eAllContents(); iter.hasNext();) { obj = iter.next(); if (obj instanceof Lifeline) { viewModel = UMLManager.getRelatedViewModel((Element) obj); if (0 == viewModel.size()) { Log.error(((Lifeline) obj).getInteraction().getQualifiedName() + UICoreConstant.PROJECT_CONSTANTS__TRIPLE_COLON + UMLManager.getRelatedElement((Element) obj)); } } } }
/** * @see nexcore.tool.uml.ui.core.diagram.editor.DiagramDropTargetListener#dropCommandForNode(org.eclipse.swt.dnd.DropTargetEvent, * org.eclipse.gef.commands.CompoundCommand, * nexcore.tool.uml.ui.core.project.ITreeNode, int) */ @Override protected void dropCommandForNode(DropTargetEvent event, CompoundCommand commpoundCommand, ITreeNode next, int count) { Element treeElement = (Element) next.getEObject(); int horizontalScrollPoint = 0; int verticalScrollPoint = 0; Point eventPoint = null; Command command = null; org.eclipse.draw2d.geometry.Point where = null; horizontalScrollPoint = ((FigureCanvas) diagramEditor.getDiagramGraphicalViewer().getControl()).getHorizontalBar() .getSelection(); verticalScrollPoint = ((FigureCanvas) diagramEditor.getDiagramGraphicalViewer().getControl()).getVerticalBar() .getSelection(); eventPoint = diagramEditor.getDiagramGraphicalViewer().getControl().toControl(event.x + horizontalScrollPoint, event.y + verticalScrollPoint); // y좌표에 +100은 여러개를 Dorp했을때 대각선 아래로 위치하도록 한다. where = new org.eclipse.draw2d.geometry.Point(eventPoint.x + (count * 160), eventPoint.y);//20); command = new DropLifeLineNotationCommand(UMLMessage.LABEL_ADD_DROP, diagramEditor, treeElement, where); ((DropLifeLineNotationCommand) command).setDiagram(this.diagramEditor.getDiagram()); commpoundCommand.add(command); }
@Override public Command createDeleteCommand(@SuppressWarnings("rawtypes") List objects) { final Command command = super.createDeleteCommand(objects); if (command == null) { return null; } if (command instanceof CompoundCommand) { final CompoundCommand compoundCommand = (CompoundCommand) command; if (compoundCommand.getCommands().isEmpty()) { return null; } } final EditPart editPart = part.getGraphicalViewer().getContents(); final ERDiagram diagram = ERModelUtil.getDiagram(editPart); return new WithoutUpdateCommandWrapper(command, diagram); }
private Command alignToStart(int start, List<DiagramWalkerEditPart> list) { final CompoundCommand command = new CompoundCommand(); final ERDiagram diagram = getDiagram(); for (final AbstractModelEditPart editPart : list) { final DiagramWalker nodeElement = (DiagramWalker) editPart.getModel(); final MoveElementCommand moveCommand = new MoveElementCommand(diagram, editPart.getFigure().getBounds(), start, nodeElement.getY(), nodeElement.getWidth(), nodeElement.getHeight(), nodeElement); command.add(moveCommand); } return command.unwrap(); }
private Command createAlignmentCommand() { final AlignmentRequest request = new AlignmentRequest(RequestConstants.REQ_ALIGN); request.setAlignmentRectangle(calculateAlignmentRectangle(request)); request.setAlignment(alignment); final List<?> editparts = getOperationSet(request); if (editparts.size() < 2) return null; final CompoundCommand command = new CompoundCommand(); command.setDebugLabel(getText()); for (int i = 0; i < editparts.size(); i++) { final EditPart editpart = (EditPart) editparts.get(i); command.add(editpart.getCommand(request)); } return command; }
protected void execute(Event event) { final GraphicalViewer viewer = getGraphicalViewer(); final List<Command> commandList = new ArrayList<>(); for (final Object object : viewer.getSelectedEditParts()) { final List<Command> subCommandList = getCommand((EditPart) object, event); commandList.addAll(subCommandList); } if (!commandList.isEmpty()) { final CompoundCommand compoundCommand = new CompoundCommand(); for (final Command command : commandList) { compoundCommand.add(command); } execute(compoundCommand); } }
@Override public void performRequest(Request request) { final ERView view = (ERView) getModel(); final ERDiagram diagram = getDiagram(); if (request.getType().equals(RequestConstants.REQ_OPEN)) { final ERView copyView = view.copyData(); final ViewDialog dialog = new ViewDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), getViewer(), copyView, diagram .getDiagramContents().getColumnGroupSet()); if (dialog.open() == IDialogConstants.OK_ID) { final CompoundCommand command = ViewEditPart.createChangeViewPropertyCommand(diagram, view, copyView); execute(command.unwrap()); } } super.performRequest(request); }
@Override public void performRequest(Request request) { final ERTable table = getModel(); final ERDiagram diagram = getDiagram(); if (request.getType().equals(RequestConstants.REQ_OPEN)) { final ERTable copyTable = table.copyData(); final TableDialog dialog = new TableDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), getViewer(), copyTable, diagram .getDiagramContents().getColumnGroupSet()); if (dialog.open() == IDialogConstants.OK_ID) { final CompoundCommand command = ERTableEditPart.createChangeTablePropertyCommand(diagram, table, copyTable); execute(command.unwrap()); } } super.performRequest(request); }
public static Command createMoveColumnGroupCommand(DirectEditRequest editRequest, TableView newTableView, int index) { final ColumnGroup columnGroup = (ColumnGroup) ((Map<?, ?>) editRequest.getDirectEditFeature()) .get(ERDiagramTransferDragSourceListener.MOVE_COLUMN_GROUP_PARAM_GROUP); final TableView oldTableView = (TableView) ((Map<?, ?>) editRequest.getDirectEditFeature()) .get(ERDiagramTransferDragSourceListener.MOVE_COLUMN_GROUP_PARAM_PARENT); if (newTableView == oldTableView) { return new ChangeColumnOrderCommand(newTableView, columnGroup, index); } final CompoundCommand command = new CompoundCommand(); final TableView copyOldTableView = oldTableView.copyData(); for (final ERColumn column : copyOldTableView.getColumns()) { if (column == columnGroup) { copyOldTableView.removeColumn(column); break; } } final ChangeTableViewPropertyCommand sourceTableCommand = new ChangeTableViewPropertyCommand(oldTableView, copyOldTableView); command.add(sourceTableCommand); if (!newTableView.getColumns().contains(columnGroup)) { command.add(new AddColumnGroupCommand(newTableView, columnGroup, index)); } return command.unwrap(); }
private Command alignToStart(int start, List<NodeElementEditPart> list) { CompoundCommand command = new CompoundCommand(); for (NodeElementEditPart editPart : list) { NodeElement nodeElement = (NodeElement) editPart.getModel(); MoveElementCommand moveCommand = new MoveElementCommand(this .getDiagram(), editPart.getFigure().getBounds(), nodeElement.getX(), start, nodeElement.getWidth(), nodeElement.getHeight(), nodeElement); command.add(moveCommand); } return command.unwrap(); }
/** * {@inheritDoc} */ @Override protected Command getDirectEditCommand(DirectEditRequest request) { CompoundCommand command = new CompoundCommand(); String text = (String) request.getCellEditor().getValue(); Note note = (Note) getHost().getModel(); NoteEditCommand noteEditCommand = new NoteEditCommand(note, text); command.add(noteEditCommand); MoveElementCommand autoResizeCommand = new MoveElementCommand( (ERDiagram) this.getHost().getRoot().getContents().getModel(), this .getHostFigure().getBounds(), note.getX(), note.getY(), -1, -1, note); command.add(autoResizeCommand); return command.unwrap(); }
/** * Overrides <code>getAddCommand()</code> to generate the proper constraint * for each child being added. Once the constraint is calculated, * {@link #createAddCommand(EditPart,Object)} is called. Subclasses must * implement this method. * * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#getAddCommand(Request) */ protected Command getAddCommand(Request generic) { ChangeBoundsRequest request = (ChangeBoundsRequest) generic; List editParts = request.getEditParts(); CompoundCommand command = new CompoundCommand(); command.setDebugLabel("Add in ConstrainedLayoutEditPolicy");//$NON-NLS-1$ GraphicalEditPart child; for (int i = 0; i < editParts.size(); i++) { child = (GraphicalEditPart) editParts.get(i); command.add(createAddCommand( request, child, translateToModelConstraint(getConstraintFor(request, child)))); } return command.unwrap(); }
/** * Returns the <code>Command</code> for changing bounds for a group of * children. * * @param request * the ChangeBoundsRequest * @return the Command * * @since 3.7 */ protected Command getChangeConstraintCommand(ChangeBoundsRequest request) { CompoundCommand resize = new CompoundCommand(); Command c; GraphicalEditPart child; List children = request.getEditParts(); for (int i = 0; i < children.size(); i++) { child = (GraphicalEditPart) children.get(i); c = createChangeConstraintCommand( request, child, translateToModelConstraint(getConstraintFor(request, child))); resize.add(c); } return resize.unwrap(); }