-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1892 from uqbar-project/dynamic-diagram-revamp
Dynamic Diagram Revamp
- Loading branch information
Showing
78 changed files
with
1,127 additions
and
761 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
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 | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,6 @@ abstract class XDebugValue implements Serializable { | |
} | ||
|
||
def String getTypeName() | ||
|
||
def boolean isWKO() { false } | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+793 Bytes
org.uqbar.project.wollok.ui.diagrams/icons/object_diagram_icon3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+494 Bytes
org.uqbar.project.wollok.ui.diagrams/icons/show-variables-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
257 changes: 257 additions & 0 deletions
257
...ect.wollok.ui.diagrams/src/org/uqbar/project/wollok/ui/diagrams/AbstractDiagramView.xtend
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,257 @@ | ||
package org.uqbar.project.wollok.ui.diagrams | ||
|
||
import java.util.List | ||
import org.eclipse.core.runtime.Platform | ||
import org.eclipse.draw2d.ColorConstants | ||
import org.eclipse.gef.ContextMenuProvider | ||
import org.eclipse.gef.DefaultEditDomain | ||
import org.eclipse.gef.EditPartFactory | ||
import org.eclipse.gef.GraphicalViewer | ||
import org.eclipse.gef.commands.CommandStack | ||
import org.eclipse.gef.editparts.ScalableFreeformRootEditPart | ||
import org.eclipse.gef.editparts.ZoomManager | ||
import org.eclipse.gef.ui.actions.ActionRegistry | ||
import org.eclipse.gef.ui.actions.ZoomInAction | ||
import org.eclipse.gef.ui.actions.ZoomOutAction | ||
import org.eclipse.gef.ui.palette.FlyoutPaletteComposite | ||
import org.eclipse.gef.ui.palette.PaletteViewerProvider | ||
import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler | ||
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer | ||
import org.eclipse.gef.ui.parts.SelectionSynchronizer | ||
import org.eclipse.jface.action.IAction | ||
import org.eclipse.jface.commands.ActionHandler | ||
import org.eclipse.jface.text.source.ISourceViewer | ||
import org.eclipse.jface.viewers.ISelection | ||
import org.eclipse.jface.viewers.ISelectionChangedListener | ||
import org.eclipse.jface.viewers.ISelectionProvider | ||
import org.eclipse.jface.viewers.SelectionChangedEvent | ||
import org.eclipse.swt.SWT | ||
import org.eclipse.swt.widgets.Composite | ||
import org.eclipse.swt.widgets.Display | ||
import org.eclipse.ui.IPartListener | ||
import org.eclipse.ui.ISelectionListener | ||
import org.eclipse.ui.IViewSite | ||
import org.eclipse.ui.IWorkbenchPart | ||
import org.eclipse.ui.PartInitException | ||
import org.eclipse.ui.handlers.IHandlerService | ||
import org.eclipse.ui.part.ViewPart | ||
import org.eclipse.xtend.lib.annotations.Accessors | ||
import org.eclipse.xtext.ui.editor.ISourceViewerAware | ||
import org.uqbar.project.wollok.ui.diagrams.classes.model.StaticDiagram | ||
import org.uqbar.project.wollok.ui.diagrams.classes.palette.CustomPalettePage | ||
import org.uqbar.project.wollok.ui.diagrams.dynamic.WollokFlyoutPreferences | ||
|
||
abstract class AbstractDiagramView extends ViewPart implements ISelectionListener, ISourceViewerAware, IPartListener, ISelectionProvider, ISelectionChangedListener { | ||
|
||
@Accessors DefaultEditDomain editDomain | ||
@Accessors(PUBLIC_GETTER) GraphicalViewer graphicalViewer | ||
@Accessors(PUBLIC_GETTER) SelectionSynchronizer synchronizer | ||
@Accessors(PUBLIC_GETTER) ActionRegistry actionRegistry | ||
|
||
@Accessors StaticDiagram diagram | ||
@Accessors(PUBLIC_GETTER) IViewSite site | ||
|
||
@Accessors(PUBLIC_GETTER) IAction zoomIn | ||
@Accessors(PUBLIC_GETTER) IAction zoomOut | ||
|
||
// splitter and palette | ||
@Accessors(PUBLIC_GETTER) FlyoutPaletteComposite splitter | ||
@Accessors CustomPalettePage page | ||
@Accessors PaletteViewerProvider provider | ||
|
||
// selection provider | ||
val List<ISelectionChangedListener> listeners = newArrayList | ||
var ISelection selection = null | ||
|
||
override init(IViewSite site) throws PartInitException { | ||
super.init(site) | ||
this.site = site | ||
// listen for selection | ||
site.workbenchWindow.selectionService.addSelectionListener(this) | ||
site.workbenchWindow.activePage.addPartListener(this) | ||
} | ||
|
||
def getAction(String actionId) { | ||
actionRegistry.getAction(actionId) | ||
} | ||
|
||
override createPartControl(Composite parent) { | ||
splitter = new FlyoutPaletteComposite(parent, SWT.NONE, site.page, paletteViewerProvider, palettePreferences) | ||
createViewer(splitter) | ||
|
||
splitter.graphicalControl = graphicalViewer.control | ||
if (page !== null) { | ||
splitter.externalViewer = page.getPaletteViewer | ||
page = null | ||
} | ||
|
||
// Create toolbar | ||
configureToolbar | ||
|
||
// set initial content based on active editor (if any) | ||
partBroughtToTop(site.page.activeEditor) | ||
|
||
// we provide selection | ||
site.selectionProvider = this | ||
} | ||
|
||
abstract def void configureToolbar() | ||
|
||
def createViewer(Composite parent) { | ||
val viewer = new ScrollingGraphicalViewer | ||
viewer.createControl(parent) | ||
|
||
setGraphicalViewer(viewer) | ||
|
||
configureGraphicalViewer | ||
hookGraphicalViewer | ||
initializeGraphicalViewer | ||
|
||
// provides selection | ||
site.selectionProvider = graphicalViewer | ||
} | ||
|
||
def configureGraphicalViewer() { | ||
graphicalViewer => [ | ||
control.background = ColorConstants.listBackground | ||
editPartFactory = createEditPartFactory | ||
rootEditPart = new ScalableFreeformRootEditPart | ||
keyHandler = new GraphicalViewerKeyHandler(it) | ||
|
||
val cmProvider = getContextMenuProvider(it, getActionRegistry) | ||
contextMenu = cmProvider | ||
if (shouldRegisterContextMenu) { | ||
site.registerContextMenu(cmProvider, it) | ||
} | ||
] | ||
} | ||
|
||
def getSelectionSynchronizer() { | ||
if (synchronizer === null) | ||
synchronizer = new SelectionSynchronizer | ||
synchronizer | ||
} | ||
|
||
def hookGraphicalViewer() { | ||
selectionSynchronizer.addViewer(graphicalViewer) | ||
site.selectionProvider = graphicalViewer | ||
} | ||
|
||
def initializeGraphicalViewer() { | ||
if (model !== null) { | ||
graphicalViewer.contents = model | ||
layout | ||
} | ||
} | ||
|
||
def EditPartFactory createEditPartFactory() | ||
|
||
abstract def void layout() | ||
|
||
def getActionRegistry() { | ||
if (actionRegistry === null) { | ||
actionRegistry = new ActionRegistry => [ | ||
doGetActionRegistry | ||
|
||
// Adding zoom capabilities | ||
val zoomManager = (graphicalViewer.rootEditPart as ScalableFreeformRootEditPart).zoomManager | ||
zoomManager.setZoomLevelContributions(#[ | ||
ZoomManager.FIT_ALL, | ||
ZoomManager.FIT_WIDTH, | ||
ZoomManager.FIT_HEIGHT | ||
]) | ||
zoomIn = new ZoomInAction(zoomManager) | ||
zoomOut = new ZoomOutAction(zoomManager) | ||
registerAction(zoomIn) | ||
registerAction(zoomOut) | ||
|
||
val service = site.getService(IHandlerService) | ||
service.activateHandler(zoomIn.getActionDefinitionId(), new ActionHandler(zoomIn)) | ||
service.activateHandler(zoomOut.getActionDefinitionId(), new ActionHandler(zoomOut)) | ||
] | ||
} | ||
actionRegistry | ||
} | ||
|
||
abstract def void doGetActionRegistry(ActionRegistry actionRegistry) | ||
|
||
abstract def ContextMenuProvider getContextMenuProvider(GraphicalViewer graphicalViewer, | ||
ActionRegistry actionRegistry) | ||
|
||
def shouldRegisterContextMenu() { false } | ||
|
||
override setFocus() { | ||
graphicalViewer.control.setFocus | ||
} | ||
|
||
def setGraphicalViewer(GraphicalViewer viewer) { | ||
editDomain.addViewer(viewer) | ||
graphicalViewer = viewer | ||
graphicalViewer => [ | ||
addSelectionChangedListener(this) | ||
] | ||
} | ||
|
||
def getModel() { | ||
diagram | ||
} | ||
|
||
def CommandStack getCommandStack() { | ||
editDomain.commandStack | ||
} | ||
|
||
// **************************** | ||
// ** Palette | ||
// **************************** | ||
def getPalettePreferences() { | ||
val preferencesService = Platform.getPreferencesService() // as PreferenceServices | ||
new WollokFlyoutPreferences(preferencesService.rootNode) | ||
} | ||
|
||
def getPaletteViewerProvider() { | ||
if (provider === null) { | ||
provider = createPaletteViewerProvider | ||
} | ||
provider | ||
} | ||
|
||
def createPaletteViewerProvider() { new PaletteViewerProvider(editDomain) } | ||
|
||
// **************************** | ||
// ** Part listener (listen for open editor) | ||
// **************************** | ||
override partActivated(IWorkbenchPart part) {} | ||
|
||
override partBroughtToTop(IWorkbenchPart part) {} | ||
|
||
override partClosed(IWorkbenchPart part) {} | ||
|
||
override partDeactivated(IWorkbenchPart part) {} | ||
|
||
override partOpened(IWorkbenchPart part) {} | ||
|
||
override selectionChanged(IWorkbenchPart part, ISelection selection) {} | ||
|
||
override setSourceViewer(ISourceViewer sourceViewer) {} | ||
|
||
override addSelectionChangedListener(ISelectionChangedListener listener) { listeners += listener } | ||
|
||
override getSelection() { selection } | ||
|
||
override setSelection(ISelection selection) {} | ||
|
||
override removeSelectionChangedListener(ISelectionChangedListener listener) { listeners -= listener } | ||
|
||
override selectionChanged(SelectionChangedEvent event) {} | ||
|
||
def List<ISelectionChangedListener> getCurrentListeners() { listeners } | ||
|
||
override dispose() { | ||
site.workbenchWindow.selectionService.removeSelectionListener(this) | ||
editDomain.activeTool = null | ||
if(actionRegistry !== null) actionRegistry.dispose | ||
|
||
if (Display.current !== null) super.dispose | ||
} | ||
|
||
} |
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.