This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create a collapsible tool group per dictionary
support reorder of metablocks and form inputs support drop of metablocks into forms in specific positions try adding back compartment insets to get rid of scrollbars
- Loading branch information
Showing
25 changed files
with
813 additions
and
432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
crosswalk-gmf.diagram/src/crosswalk/diagram/custom/CompartmentChildCreateCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,34 @@ | |||
package crosswalk.diagram.custom; | |||
|
|||
import org.eclipse.core.commands.ExecutionException; | |||
import org.eclipse.core.runtime.IAdaptable; | |||
import org.eclipse.core.runtime.IProgressMonitor; | |||
import org.eclipse.emf.transaction.TransactionalEditingDomain; | |||
import org.eclipse.gmf.runtime.common.core.command.CommandResult; | |||
import org.eclipse.gmf.runtime.diagram.core.services.ViewService; | |||
import org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand; | |||
import org.eclipse.gmf.runtime.notation.View; | |||
import org.eclipse.jface.util.Assert; | |||
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor; | |||
|
|||
public class CompartmentChildCreateCommand extends CreateCommand { | |||
int index; | |||
|
|||
public CompartmentChildCreateCommand(TransactionalEditingDomain editingDomain, ViewDescriptor viewDescriptor, | |||
View containerView, int index) { | |||
super(editingDomain, viewDescriptor, containerView); | |||
this.index = index; | |||
} | |||
|
|||
@Override | |||
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { | |||
|
|||
View view = ViewService.getInstance().createView(viewDescriptor.getViewKind(), | |||
viewDescriptor.getElementAdapter(), containerView, viewDescriptor.getSemanticHint(), index, | |||
viewDescriptor.isPersisted(), viewDescriptor.getPreferencesHint()); | |||
Assert.isNotNull(view, "failed to create a view"); //$NON-NLS-1$ | |||
viewDescriptor.setView(view); | |||
|
|||
return CommandResult.newOKCommandResult(viewDescriptor); | |||
} | |||
} |
112 changes: 112 additions & 0 deletions
112
crosswalk-gmf.diagram/src/crosswalk/diagram/custom/CompartmentChildCreationEditPolicy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,112 @@ | |||
package crosswalk.diagram.custom; | |||
|
|||
import java.util.Iterator; | |||
import java.util.List; | |||
|
|||
import org.eclipse.draw2d.FlowLayout; | |||
import org.eclipse.draw2d.IFigure; | |||
import org.eclipse.draw2d.geometry.Point; | |||
import org.eclipse.draw2d.geometry.Rectangle; | |||
import org.eclipse.draw2d.geometry.Transposer; | |||
import org.eclipse.emf.transaction.TransactionalEditingDomain; | |||
import org.eclipse.gef.EditPart; | |||
import org.eclipse.gef.GraphicalEditPart; | |||
import org.eclipse.gef.Request; | |||
import org.eclipse.gef.commands.Command; | |||
import org.eclipse.gef.requests.DropRequest; | |||
import org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand; | |||
import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; | |||
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; | |||
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy; | |||
import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages; | |||
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest; | |||
import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand; | |||
import org.eclipse.gmf.runtime.notation.View; | |||
|
|||
public class CompartmentChildCreationEditPolicy extends CreationEditPolicy { | |||
@Override | |||
protected Command getCreateCommand(CreateViewRequest request) { | |||
TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); | |||
CompositeTransactionalCommand cc = new CompositeTransactionalCommand(editingDomain, | |||
DiagramUIMessages.AddCommand_Label); | |||
|
|||
Iterator descriptors = request.getViewDescriptors().iterator(); | |||
|
|||
while (descriptors.hasNext()) { | |||
CreateViewRequest.ViewDescriptor descriptor = (CreateViewRequest.ViewDescriptor) descriptors.next(); | |||
|
|||
CreateCommand createCommand = new CompartmentChildCreateCommand(editingDomain, descriptor, | |||
(View) (getHost().getModel()), getFeedbackIndexFor(request)); | |||
|
|||
cc.compose(createCommand); | |||
} | |||
return new ICommandProxy(cc.reduce()); | |||
} | |||
|
|||
protected int getFeedbackIndexFor(Request request) { | |||
List children = getHost().getChildren(); | |||
if (children.isEmpty()) | |||
return -1; | |||
|
|||
Transposer transposer = new Transposer(); | |||
transposer.setEnabled(!isHorizontal()); | |||
|
|||
Point p = transposer.t(getLocationFromRequest(request)); | |||
|
|||
// Current row bottom, initialize to above the top. | |||
int rowBottom = Integer.MIN_VALUE; | |||
int candidate = -1; | |||
for (int i = 0; i < children.size(); i++) { | |||
EditPart child = (EditPart) children.get(i); | |||
Rectangle rect = transposer.t(getAbsoluteBounds(((GraphicalEditPart) child))); | |||
if (rect.y > rowBottom) { | |||
/* | |||
* We are in a new row, so if we don't have a candidate but yet are within the previous row, then the | |||
* current entry becomes the candidate. This is because we know we must be to the right of center of the | |||
* last Figure in the previous row, so this Figure (which is at the start of a new row) is the candidate. | |||
*/ | |||
if (p.y <= rowBottom) { | |||
if (candidate == -1) | |||
candidate = i; | |||
break; | |||
} else | |||
candidate = -1; // Mouse's Y is outside the row, so reset the candidate | |||
} | |||
rowBottom = Math.max(rowBottom, rect.bottom()); | |||
if (candidate == -1) { | |||
/* | |||
* See if we have a possible candidate. It is a candidate if the cursor is left of the center of this | |||
* candidate. | |||
*/ | |||
if (p.x <= rect.x + (rect.width / 2)) | |||
candidate = i; | |||
} | |||
if (candidate != -1) { | |||
// We have a candidate, see if the rowBottom has grown to include the mouse Y. | |||
if (p.y <= rowBottom) { | |||
/* | |||
* Now we have determined that the cursor.Y is above the bottom of the current row of figures. Stop now, | |||
* to prevent the next row from being searched | |||
*/ | |||
break; | |||
} | |||
} | |||
} | |||
return candidate; | |||
} | |||
|
|||
protected boolean isHorizontal() { | |||
IFigure figure = ((GraphicalEditPart) getHost()).getContentPane(); | |||
return ((FlowLayout) figure.getLayoutManager()).isHorizontal(); | |||
} | |||
|
|||
private Point getLocationFromRequest(Request request) { | |||
return ((DropRequest) request).getLocation(); | |||
} | |||
|
|||
private Rectangle getAbsoluteBounds(GraphicalEditPart ep) { | |||
Rectangle bounds = ep.getFigure().getBounds().getCopy(); | |||
ep.getFigure().translateToAbsolute(bounds); | |||
return bounds; | |||
} | |||
} |
39 changes: 39 additions & 0 deletions
39
crosswalk-gmf.diagram/src/crosswalk/diagram/custom/CompartmentRepositionEObjectCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,39 @@ | |||
package crosswalk.diagram.custom; | |||
|
|||
import org.eclipse.core.commands.ExecutionException; | |||
import org.eclipse.core.runtime.IAdaptable; | |||
import org.eclipse.core.runtime.IProgressMonitor; | |||
import org.eclipse.emf.common.util.EList; | |||
import org.eclipse.emf.ecore.EObject; | |||
import org.eclipse.emf.transaction.TransactionalEditingDomain; | |||
import org.eclipse.gef.EditPart; | |||
import org.eclipse.gmf.runtime.common.core.command.CommandResult; | |||
import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; | |||
import org.eclipse.gmf.runtime.emf.commands.core.commands.RepositionEObjectCommand; | |||
import org.eclipse.gmf.runtime.notation.View; | |||
|
|||
public class CompartmentRepositionEObjectCommand extends RepositionEObjectCommand { | |||
EditPart childToMove = null; | |||
int newIndex = 0; | |||
|
|||
public CompartmentRepositionEObjectCommand(TransactionalEditingDomain editingDomain, String label, EList elements, | |||
EObject element, int displacement) { | |||
super(editingDomain, label, elements, element, displacement); | |||
} | |||
|
|||
public CompartmentRepositionEObjectCommand(EditPart childToMove, TransactionalEditingDomain editingDomain, | |||
String label, EList elements, EObject element, int displacement, int newIndex) { | |||
super(editingDomain, label, elements, element, displacement); | |||
this.childToMove = childToMove; | |||
this.newIndex = newIndex; | |||
} | |||
|
|||
public CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) | |||
throws ExecutionException { | |||
CommandResult rs = super.doExecuteWithResult(progressMonitor, info); | |||
EditPart compartment = childToMove.getParent(); | |||
ViewUtil.repositionChildAt((View) compartment.getModel(), (View) childToMove.getModel(), newIndex); | |||
compartment.refresh(); | |||
return rs; | |||
} | |||
} |
96 changes: 96 additions & 0 deletions
96
crosswalk-gmf.diagram/src/crosswalk/diagram/custom/ReorderCompartmentEditPolicy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,96 @@ | |||
package crosswalk.diagram.custom; | |||
|
|||
import org.eclipse.draw2d.PositionConstants; | |||
import org.eclipse.emf.common.util.EList; | |||
import org.eclipse.emf.ecore.EStructuralFeature; | |||
import org.eclipse.emf.transaction.TransactionalEditingDomain; | |||
import org.eclipse.gef.EditPart; | |||
import org.eclipse.gef.EditPolicy; | |||
import org.eclipse.gef.Request; | |||
import org.eclipse.gef.commands.Command; | |||
import org.eclipse.gef.requests.CreateRequest; | |||
import org.eclipse.gmf.runtime.diagram.core.commands.AddCommand; | |||
import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; | |||
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; | |||
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.FlowLayoutEditPolicy; | |||
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableEditPolicyEx; | |||
import org.eclipse.gmf.runtime.emf.commands.core.commands.RepositionEObjectCommand; | |||
import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; | |||
import org.eclipse.gmf.runtime.notation.View; | |||
|
|||
public class ReorderCompartmentEditPolicy extends FlowLayoutEditPolicy { | |||
private EStructuralFeature feature = null; | |||
|
|||
public ReorderCompartmentEditPolicy(EStructuralFeature feature) { | |||
super(); | |||
this.feature = feature; | |||
} | |||
|
|||
@Override | |||
protected Command createAddCommand(EditPart child, EditPart after) { | |||
int index = getHost().getChildren().indexOf(after); | |||
TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); | |||
AddCommand command = new AddCommand(editingDomain, new EObjectAdapter((View)getHost().getModel()), | |||
new EObjectAdapter((View)child.getModel()), index); | |||
return new ICommandProxy(command); | |||
} | |||
|
|||
@Override | |||
protected Command createMoveChildCommand(EditPart child, EditPart after) { | |||
|
|||
int newIndex; | |||
int displacement; | |||
|
|||
int childIndex = getHost().getChildren().indexOf(child); | |||
int afterIndex = getHost().getChildren().indexOf(after); | |||
|
|||
if(afterIndex == -1) { | |||
newIndex = getHost().getChildren().size()-1; | |||
displacement = newIndex - childIndex; | |||
} else { | |||
newIndex = afterIndex; | |||
displacement = afterIndex - childIndex; | |||
if (childIndex <= afterIndex) { | |||
newIndex--; | |||
displacement--; | |||
} | |||
} | |||
|
|||
|
|||
TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); | |||
|
|||
RepositionEObjectCommand command = new CompartmentRepositionEObjectCommand(child, editingDomain, "", | |||
(EList)((View)child.getParent().getModel()).getElement().eGet(feature), | |||
((View)child.getModel()).getElement(), | |||
displacement, newIndex); | |||
|
|||
//TODO ev. reintroduce target feedback (actual problem: line is not deleted after dropping) | |||
eraseLayoutTargetFeedback(null); | |||
|
|||
return new ICommandProxy(command); | |||
} | |||
|
|||
@Override | |||
protected EditPolicy createChildEditPolicy(EditPart child) { | |||
ResizableEditPolicyEx policy = new ResizableEditPolicyEx(); | |||
//policy.setResizeDirections(PositionConstants.EAST_WEST); | |||
policy.setResizeDirections(0); | |||
return policy; | |||
} | |||
|
|||
@Override | |||
protected Command getCreateCommand(CreateRequest request) { | |||
return null; | |||
} | |||
|
|||
@Override | |||
protected Command getDeleteDependantCommand(Request request) { | |||
return null; | |||
} | |||
|
|||
@Override | |||
protected Command getOrphanChildrenCommand(Request request) { | |||
return null; | |||
} | |||
|
|||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.