Skip to content

Commit

Permalink
Fixes for Static diagram (#1967)
Browse files Browse the repository at this point in the history
* Adding width - trying to fix object serialization

* Fix Xpect repo

* Fixing locations, sizes & remembering those attributes while persisting .wsdi

* Fix #1948 - stack overflow for cyclic hierarchy in static diagram

* Fix #1940 Static Diagram in a workspace with spaces

* Back to original version

Co-authored-by: Nahuel Palumbo <nahuel.palumbo@gmail.com>
  • Loading branch information
fdodino and PalumboN committed Nov 19, 2020
1 parent 2960687 commit 8ae9ea8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import java.io.InvalidClassException
import java.io.ObjectInputStream
import java.io.ObjectOutputStream
import java.io.Serializable
import java.net.URLDecoder
import java.util.List
import java.util.Map
import java.util.Observable
Expand All @@ -30,20 +31,16 @@ import static extension org.uqbar.project.wollok.model.WollokModelExtensions.*
import static extension org.uqbar.project.wollok.utils.StringUtils.*

@Accessors
abstract class AbstractDiagramConfiguration extends Observable {
abstract class AbstractDiagramConfiguration extends Observable implements Serializable {

/** Notification Events */
public static String CONFIGURATION_CHANGED = "configuration"

/** Internal state */
boolean rememberLocationsAndSizes = true
Map<String, Point> locations
Map<String, Dimension> sizes
protected Map<String, Point> locations = newHashMap
protected Map<String, Dimension> sizes = newHashMap

new() {
init
}

/**
******************************************************
* STATE INITIALIZATION
Expand Down Expand Up @@ -118,7 +115,7 @@ abstract class AbstractDiagramConfiguration extends Observable {
*
*/
@Accessors
class StaticDiagramConfiguration extends AbstractDiagramConfiguration implements Serializable {
class StaticDiagramConfiguration extends AbstractDiagramConfiguration {

/** Internal state */
boolean showVariables = false
Expand Down Expand Up @@ -369,7 +366,7 @@ class StaticDiagramConfiguration extends AbstractDiagramConfiguration implements
}


/**
/**
******************************************************
* CONFIGURATION LOAD & SAVE TO EXTERNAL FILE
*******************************************************
Expand All @@ -395,11 +392,13 @@ class StaticDiagramConfiguration extends AbstractDiagramConfiguration implements
val file = new FileOutputStream(staticDiagramFile)
val oos = new ObjectOutputStream(file)
oos.writeObject(this)
oos.close
file.close
}
}

def getStaticDiagramFile() {
new File(fullPath, staticDiagramFileName)
new File(URLDecoder.decode(fullPath, "UTF-8"), staticDiagramFileName)
}

def getStaticDiagramFileName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import org.eclipse.gef.editparts.AbstractGraphicalEditPart
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.ZoomComboContributionItem
import org.eclipse.gef.ui.properties.UndoablePropertySheetPage
import org.eclipse.gef.ui.views.palette.PalettePage
import org.eclipse.jface.action.Separator
Expand Down Expand Up @@ -398,7 +397,7 @@ class StaticDiagramView extends AbstractDiagramView implements IDocumentListener
val clazz = model.getComponent
if (clazz !== null) {
this.selection = new StructuredSelection(clazz)
val selectionChangedEvent = new SelectionChangedEvent(this, this.selection)
val selectionChangedEvent = new SelectionChangedEvent(this, selection)
currentListeners.forEach [ listener |
listener.selectionChanged(selectionChangedEvent)
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ abstract class AbstractModel extends Shape {

protected val static TOP_POSITION = 10
protected val static DEFAULT_WIDTH = 120
protected val static ELEMENT_WIDTH = 50
protected val static MAX_ELEMENT_WIDTH = 230
protected val static ELEMENT_WIDTH = 150
protected val static MAX_ELEMENT_WIDTH = 400
protected val static MAX_ELEMENT_HEIGHT = 300
protected val static ELEMENT_HEIGHT = 55
protected val static WIDTH_SEPARATION_BETWEEN_ELEMENTS = 20
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ class WMethodContainerExtensions extends WollokModelExtensions {
}

def static void superClassesIncludingYourselfTopDownDo(WClass cl, (WClass)=>void action) {
if (cl.equals(cl.parent)) return; // avoid stack overflow
if (cl.hasCyclicHierarchy) return;
if (cl.parent !== null) cl.parent.superClassesIncludingYourselfTopDownDo(action)
action.apply(cl)
}
Expand Down

0 comments on commit 8ae9ea8

Please sign in to comment.