automatocally Grid in Background [message #804419] |
Wed, 22 February 2012 10:53  |
Eclipse User |
|
|
|
Hello everyone
I programming a small editor and have little problem.
I found out to show the grid layout in the background of my editor by this overlays my figures. I searched for a solution in the internet but cant find a good one. To get the grid automatically in the background i wrote my own custum preferences class but theres no option to set gridInFront to false.
I hope someone can help me finding a good solution.
THX Sascha
|
|
|
Re: automatocally Grid in Background [message #804516 is a reply to message #804419] |
Wed, 22 February 2012 13:16   |
Eclipse User |
|
|
|
Hello,
I have added the followng code into the TaiPan sample, TaiPanDiagramEditor#configureGraphicalViewer():
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
DiagramEditorContextMenuProvider provider = new DiagramEditorContextMenuProvider(this, getDiagramGraphicalViewer());
getDiagramGraphicalViewer().setContextMenu(provider);
getSite().registerContextMenu(ActionIds.DIAGRAM_EDITOR_CONTEXT_MENU, provider, getDiagramGraphicalViewer());
//ADDED START
DiagramRootEditPart root = (DiagramRootEditPart) getDiagramGraphicalViewer().getRootEditPart();
Layer printableLayers = (Layer)root.getLayer(LayerConstants.PRINTABLE_LAYERS);
Layer gridLayer = (Layer)root.getLayer(LayerConstants.GRID_LAYER);
if (printableLayers != null && gridLayer != null){
LayeredPane paneForPrintable = (LayeredPane)printableLayers.getParent();
LayeredPane paneForGrid = (LayeredPane)gridLayer.getParent();
if (paneForGrid == paneForPrintable) {
paneForGrid.removeLayer(LayerConstants.GRID_LAYER);
paneForGrid.addLayerBefore(gridLayer, LayerConstants.GRID_LAYER, LayerConstants.PRINTABLE_LAYERS);
}
}
//ADDED END
}
Looks hackish, so any better solution would be appreciated, but at least to first look it works -- see attached screenshot

|
|
|
|
Powered by
FUDForum. Page generated in 0.08461 seconds