Skip to content

Commit

Permalink
Merge pull request #1892 from uqbar-project/dynamic-diagram-revamp
Browse files Browse the repository at this point in the history
Dynamic Diagram Revamp
  • Loading branch information
fdodino committed Jun 8, 2020
2 parents 05a1100 + c05704f commit 8dc8bc4
Show file tree
Hide file tree
Showing 78 changed files with 1,127 additions and 761 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import static org.uqbar.project.wollok.sdk.WollokSDK.*
* A variable within a stack execution.
*
* @author jfernandes
* @author dodain Refactored in order to avoid cyclic references
*/
@Accessors
class XDebugStackFrameVariable implements Serializable {
Expand Down Expand Up @@ -76,6 +77,15 @@ class XDebugStackFrameVariable implements Serializable {
}

def isCustom() {
!this.variable.name.startsWith("wollok.")
!this.variable.name.startsWith("wollok.")
}

def getIdentifier() {
this.variable.id.toString
}

def getName() {
this.variable.name
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ abstract class XDebugValue implements Serializable {
}

def String getTypeName()

def boolean isWKO() { false }
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract class XWollokCollectionDebugValue extends XDebugValue {
val result = newArrayList
val elements = collection.getElements(concreteNativeType)
elements.forEach [ element, i |
result.add(new XDebugStackFrameVariable(new WVariable(i.getVariableName(collection, concreteNativeType), System.identityHashCode(element), false), element))
result.add(new XDebugStackFrameVariable(new WVariable(i.getVariableName(collection, concreteNativeType), System.identityHashCode(element), false, false), element))
]
variables = newArrayList(result)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ import static org.uqbar.project.wollok.WollokConstants.*
class XWollokObjectDebugValue extends XDebugValue {
@Accessors(PUBLIC_GETTER) String typeName
@Accessors(PUBLIC_GETTER) String varName
@Accessors(PUBLIC_GETTER) boolean isNamedObject

new(String varName, WollokObject obj) {
super(obj.description, System.identityHashCode(obj))
this.isNamedObject = obj.behavior.wellKnownObject
this.typeName = obj.behavior.fqn
this.varName = varName
if (!obj.isBasicType)
if (!obj.isBasicType && !obj.shouldUseShortDescriptionForDynamicDiagram)
variables = obj.debugVariables
}

Expand All @@ -33,10 +35,12 @@ class XWollokObjectDebugValue extends XDebugValue {
obj.asString(TO_STRING_PRINTABLE)
}
else {
if (obj.hasShortDescription)
if (obj.shouldUseShortDescriptionForDynamicDiagram)
obj.asString(TO_STRING_SHORT)
else obj.shortLabel
}
}


override isWKO() { this.isNamedObject }

}
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 org.uqbar.project.wollok.ui.diagrams/icons/eye.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.
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.
2 changes: 1 addition & 1 deletion org.uqbar.project.wollok.ui.diagrams/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<view
category="org.uqbar.project.wollok.ui.diagrams.category"
class="org.uqbar.project.wollok.ui.diagrams.classes.WollokDslExecutableExtensionFactory:org.uqbar.project.wollok.ui.diagrams.dynamic.DynamicDiagramView"
icon="icons/object_diagram_icon.png"
icon="icons/object_diagram_icon3.png"
id="org.uqbar.project.wollok.ui.diagrams.object"
name="%dynamicDiagramView"
restorable="true">
Expand Down
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
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ public class Messages extends NLS {
public static String StaticDiagram_DeleteAllOutsiderClasses_Description;

// Dynamic Diagram - Toolbar actions
public static String DynamicDiagram_Clean_Description;
public static String DynamicDiagram_ShowHiddenObjects_Description;
public static String DynamicDiagram_FilteredObjects_Description;
public static String DynamicDiagram_ColorBlind_Description;
public static String DynamicDiagram_EffectTransition_Description;
public static String DynamicDiagram_RememberObjectPosition_Description;

// Tool entries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ class StaticDiagramConfiguration extends AbstractDiagramConfiguration implements
def resourceIsForStaticDiagram() {
originalFileName.endsWith(WollokConstants.WOLLOK_DEFINITION_EXTENSION)
}

}

@Data
Expand Down
Loading

0 comments on commit 8dc8bc4

Please sign in to comment.