|
|
|
Re: Select All + Arrange All [solved] [message #179500 is a reply to message #179468] |
Fri, 28 March 2008 08:36 |
Eclipse User |
|
|
|
Originally posted by: trommas.yahoo.com
I tried your code, but this ArrangeAction class - where does it come
from? Is it a custom class? (also what is ViewHelper?)
Why not use ArrangeRequest?
I do this with:
ArrangeRequest arrangeRequest = new ArrangeRequest(
RequestConstants.REQ_ARRANGE_DEFERRED);
arrangeRequest.setViewAdaptersToArrange(editList);
selectedElement.getDiagramEditDomain().getDiagramCommandStac k().
execute(selectedElement.getCommand(arrangeRequest));
Cheers,
Tomas Zijdemans
Sandip wrote:
> Hi Guys,
> The following code seems to work. Have an initial look. I will refactor
> this a bit and update later
>
> IDiagramGraphicalViewer viewer = ((IDiagramWorkbenchPart)
> ViewHelper.getInstance().getActiveEditorPart().getSite().get Part())
> getDiagramGraphicalViewer();
>
> //Set the focus to the diagram editor
> diagramEditor.setFocus();
>
> //Sets the correct newly added elements as selected components.
> // listEditPart is a list of editParts we want to select and arrange
> if (viewer != null) {
> if (!listEditPart.isEmpty()) {
> viewer.setSelection(new
> StructuredSelection(listEditPart));
> }
> }
>
> //Ensure that the focus shifts back to the DiagramEditor,
> diagramEditor.getDiagramEditPart().setFocus(true);
> diagramEditor.getEditorSite().getPage().activate(diagramEdit or.getSite().getPart());
>
>
> //Arrange The selected components. //Two times running the action give
> better layout
> ArrangeAction arrange =
> ArrangeAction.createArrangeAllAction(diagramEditor.getEditor Site().getPage());
>
>
> arrange.init();
> arrange.setActionDefinitionId(ActionIds.ACTION_ARRANGE_ALL);
> arrange.setup();
>
> arrange.run( new SubProgressMonitor(monitor, 100));
> arrange.run( new SubProgressMonitor(monitor, 100));
>
> //Deselects newly added elements if (viewer != null) {
> viewer.select(diagramEditor.getDiagramEditPart());
> }
>
|
|
|
|
Re: Select All + Arrange All [solved] [message #179678 is a reply to message #179546] |
Fri, 28 March 2008 14:28 |
Eclipse User |
|
|
|
Originally posted by: trommas.yahoo.com
Sandip wrote:
>
> Hi Tomas,
>
> We already tried that piece of code. Didnt seem to solve our purpose
> where we need to rearrange inner components and connections.
> Later we moved to ArrangeAction from
> org.eclipse.gmf.runtime.diagram.ui.actions and it seem to work fine.
Ok.. I don't have that class in my package, so I guess you subclassed:
org.eclipse.gmf.runtime.diagram.ui.actions.DiagramAction.
|
|
|
|
|
|
Re: Select All + Arrange All [message #184611 is a reply to message #178568] |
Mon, 28 April 2008 19:56 |
Eclipse User |
|
|
|
Originally posted by: birar01.ca.com
In case this is helpful to anyone:
I wanted to kick off an arrange all when the editor is started. I added the
following code to the generated DiagramEditor:
protected void initializeGraphicalViewerContents() {
super.initializeGraphicalViewerContents();
ArrangeRequest arrangeRequest = new
ArrangeRequest(ActionIds.ACTION_ARRANGE_ALL);
IGraphicalEditPart rootEP = (IGraphicalEditPart)
getDiagramGraphicalViewer().getRootEditPart().getContents();
List l = new ArrayList();
l.add(rootEP);
arrangeRequest.setPartsToArrange(l);
Command cmd = rootEP.getCommand(arrangeRequest);
getCommandStack().execute(cmd);
}
"Sandip" <sandip.b@in.bosch.com> wrote in message
news:6af76885b722de035e420af80ec3a31f$1@www.eclipse.org...
>
> Hi Team,
>
> I have a situation here. Intention is to fire a command that selects
> editparts in the active editor and perform arrange all.
>
> For select all I am using -
> IDiagramGraphicalViewer viewer = ((IDiagramWorkbenchPart)
> ViewHelper.getInstance().getActiveEditorPart().getSite().get Part()).getDiagramGraphicalViewer();
>
> if (viewer != null) { //listEditPart is the list of editparts (nodes and
> edges) under current diagram
> if (!listEditPart.isEmpty()) {
> viewer.setSelection(new StructuredSelection(listEditPart));
>
> }
> }
> -This works fine.
>
>
>
> For Arrange All I am using -
> ArrangeRequest arrangeRequest = new
> ArangeRequest(ActionIds.ACTION_ARRANGE_ALL);
>
> arrangeRequest.setPartsToArrange(listEditPart);
>
> DiagramDocumentEditor diagramEditor = (DiagramDocumentEditor)
> ViewHelper.getInstance().getActiveEditorPart();
>
>
> CompoundCommand cc1 = new CompoundCommand("Arrange All");
>
> Command command1 =
> diagramEditor.getDiagramEditPart().getCommand(arrangeRequest );
> cc1.add(command1);
>
> diagramEditor.getDiagramEditDomain().getDiagramCommandStack( )
> .execute(cc1, new NullProgressMonitor());
>
> diagramEditor.getDiagramEditPart().refresh();
>
>
> Although It selects correctly, it doesnt perform the arrange all operation
> as we see from the menu action.
> Any idea why?
>
>
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.48797 seconds