Skip to content

Commit

Permalink
Removed reveal button from Graph
Browse files Browse the repository at this point in the history
Created new Zest example for hide-nodes and moved the reveal button from
Graph to example
  • Loading branch information
sebHollersbacher authored and azoitl committed Aug 16, 2023
1 parent 24e1900 commit 2312b49
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 57 deletions.
98 changes: 41 additions & 57 deletions org.eclipse.zest.core/src/org/eclipse/zest/core/widgets/Graph.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public class Graph extends FigureCanvas implements IContainer {
/**
* Constructor for a Graph. This widget represents the root of the graph, and
* can contain graph items such as graph nodes and graph connections.
*
*
* @param parent
* @param style
*/
Expand All @@ -125,7 +125,7 @@ public Graph(Composite parent, int style) {
/**
* Constructor for a Graph. This widget represents the root of the graph, and
* can contain graph items such as graph nodes and graph connections.
*
*
* @param parent
* @param style
* @param enableHideNodes
Expand Down Expand Up @@ -184,21 +184,6 @@ public void dispatchMouseMoved(org.eclipse.swt.events.MouseEvent me) {
this.figure2ItemMap = new HashMap<>();
this.enableHideNodes = enableHideNodes;

if (enableHideNodes) {
Button revealAllButton = new Button("Reveal All");
revealAllButton.setBounds(new Rectangle(new Point(0, 0), revealAllButton.getPreferredSize()));
revealAllButton.addActionListener(event -> {
for (GraphNode node : nodes) {
HideNodeHelper hideNodeHelper = node.getHideNodeHelper();
if (hideNodeHelper != null) {
node.setVisible(true);
hideNodeHelper.resetCounter();
}
}
});
zestRootLayer.add(revealAllButton);
}

revealListeners = new ArrayList<>(1);
this.addPaintListener(event -> {
// Go through the reveal list and let everyone know that the
Expand All @@ -222,7 +207,7 @@ public void dispatchMouseMoved(org.eclipse.swt.events.MouseEvent me) {
/**
* This adds a listener to the set of listeners that will be called when a
* selection event occurs.
*
*
* @param selectionListener
*/
public void addSelectionListener(SelectionListener selectionListener) {
Expand All @@ -241,7 +226,7 @@ public void removeSelectionListener(SelectionListener selectionListener) {
* Gets a list of the GraphModelNode children objects under the root node in
* this diagram. If the root node is null then all the top level nodes are
* returned.
*
*
* @return List of GraphModelNode objects
*/
@Override
Expand All @@ -251,7 +236,7 @@ public List<? extends GraphNode> getNodes() {

/**
* Adds a new constraint adapter to the list of constraint adapters
*
*
* @param constraintAdapter
*/
public void addConstraintAdapter(ConstraintAdapter constraintAdapter) {
Expand All @@ -260,7 +245,7 @@ public void addConstraintAdapter(ConstraintAdapter constraintAdapter) {

/**
* Sets the constraint adapters on this model
*
*
* @param constraintAdapters
*/
public void setConstraintAdapters(List<ConstraintAdapter> constraintAdapters) {
Expand All @@ -269,7 +254,7 @@ public void setConstraintAdapters(List<ConstraintAdapter> constraintAdapters) {

/**
* Gets the root layer for this graph
*
*
* @return
*/
public ScalableFigure getRootLayer() {
Expand All @@ -278,7 +263,7 @@ public ScalableFigure getRootLayer() {

/**
* Sets the default connection style.
*
*
* @param connection style the connection style to set
* @see org.eclipse.mylar.zest.core.widgets.ZestStyles
*/
Expand All @@ -288,7 +273,7 @@ public void setConnectionStyle(int connectionStyle) {

/**
* Gets the default connection style.
*
*
* @return the connection style
* @see org.eclipse.mylar.zest.core.widgets.ZestStyles
*/
Expand All @@ -298,7 +283,7 @@ public int getConnectionStyle() {

/**
* Sets the default node style.
*
*
* @param nodeStyle the node style to set
* @see org.eclipse.mylar.zest.core.widgets.ZestStyles
*/
Expand All @@ -308,7 +293,7 @@ public void setNodeStyle(int nodeStyle) {

/**
* Gets the default node style.
*
*
* @return the node style
* @see org.eclipse.mylar.zest.core.widgets.ZestStyles
*/
Expand All @@ -318,7 +303,7 @@ public int getNodeStyle() {

/**
* Gets the list of GraphModelConnection objects.
*
*
* @return list of GraphModelConnection objects
*/
public List<? extends GraphConnection> getConnections() {
Expand All @@ -327,15 +312,15 @@ public List<? extends GraphConnection> getConnections() {

/**
* Changes the selection to the list of items
*
*
* @param l
*/
public void setSelection(GraphItem[] items) {
clearSelection();
if (items != null) {
for (int i = 0; i < items.length; i++) {
if (items[i] != null) {
select(items[i]);
for (GraphItem item : items) {
if (item != null) {
select(item);
}
}
}
Expand All @@ -347,7 +332,7 @@ public void selectAll() {

/**
* Gets the list of currently selected GraphNodes
*
*
* @return Currently selected graph node
*/
public List<? extends GraphItem> getSelection() {
Expand All @@ -356,7 +341,7 @@ public List<? extends GraphItem> getSelection() {

/*
* (non-Javadoc)
*
*
* @see org.eclipse.swt.widgets.Widget#toString()
*/
@Override
Expand All @@ -366,7 +351,7 @@ public String toString() {

/*
* (non-Javadoc)
*
*
* @see org.eclipse.mylar.zest.core.internal.graphmodel.IGraphItem#getGraphModel
* ()
*/
Expand Down Expand Up @@ -399,7 +384,7 @@ public void applyLayout() {
/**
* Sets the preferred size of the layout area. Size of ( -1, -1) uses the
* current canvas size.
*
*
* @param width
* @param height
*/
Expand All @@ -424,7 +409,7 @@ public LayoutAlgorithm getLayoutAlgorithm() {

/**
* Finds a figure at the location X, Y in the graph
*
*
* This point should be translated to relative before calling findFigureAt
*/
public IFigure getFigureAt(int x, int y) {
Expand Down Expand Up @@ -477,7 +462,7 @@ public boolean getHideNodesEnabled() {
// /////////////////////////////////////////////////////////////////////////////////
class DragSupport implements MouseMotionListener, org.eclipse.draw2d.MouseListener {
/**
*
*
*/
Graph graph = null;
Point lastLocation = null;
Expand Down Expand Up @@ -732,7 +717,7 @@ public void mouseReleased(org.eclipse.draw2d.MouseEvent me) {

/*
* (non-Javadoc)
*
*
* @see org.eclipse.swt.widgets.Widget#notifyListeners(int,
* org.eclipse.swt.widgets.Event)
*/
Expand Down Expand Up @@ -814,7 +799,7 @@ private void setNodeSelected(GraphItem item, boolean selected) {

/**
* Moves the edge to the highlight layer. This moves the edge above the nodes
*
*
* @param connection
*/
void highlightEdge(GraphConnection connection) {
Expand All @@ -826,7 +811,7 @@ void highlightEdge(GraphConnection connection) {

/**
* Moves the edge from the edge feedback layer back to the edge layer
*
*
* @param graphConnection
*/
void unhighlightEdge(GraphConnection connection) {
Expand All @@ -838,7 +823,7 @@ void unhighlightEdge(GraphConnection connection) {

/**
* Moves the node onto the node feedback layer
*
*
* @param node
*/
void highlightNode(GraphNode node) {
Expand All @@ -850,7 +835,7 @@ void highlightNode(GraphNode node) {

/**
* Moves the node onto the node feedback layer
*
*
* @param node
*/
void highlightNode(GraphContainer node) {
Expand All @@ -862,7 +847,7 @@ void highlightNode(GraphContainer node) {

/**
* Moves the node off the node feedback layer
*
*
* @param node
*/
void unhighlightNode(GraphContainer node) {
Expand All @@ -874,7 +859,7 @@ void unhighlightNode(GraphContainer node) {

/**
* Moves the node off the node feedback layer
*
*
* @param node
*/
void unhighlightNode(GraphNode node) {
Expand All @@ -887,13 +872,12 @@ void unhighlightNode(GraphNode node) {
/**
* Converts the list of GraphModelConnection objects into an array and returns
* it.
*
*
* @return GraphModelConnection[]
*/
GraphConnection[] getConnectionsArray() {
GraphConnection[] connsArray = new GraphConnection[connections.size()];
connsArray = connections.toArray(connsArray);
return connsArray;
return connections.toArray(connsArray);
}

LayoutRelationship[] getConnectionsToLayout(List<GraphNode> nodesToLayout) {
Expand Down Expand Up @@ -983,7 +967,7 @@ void addConnection(GraphConnection connection, boolean addToEdgeLayer) {

/*
* public void redraw() {
*
*
* Iterator iterator = this.getConnections().iterator(); while
* (iterator.hasNext()) { GraphConnection connection = (GraphConnection)
* iterator.next(); IFigure figure = connection.getFigure(); if
Expand All @@ -993,9 +977,9 @@ void addConnection(GraphConnection connection, boolean addToEdgeLayer) {
* = (GraphNode) iterator.next(); IFigure figure = graphNode.getFigure(); if
* (!zestRootLayer.getChildren().contains(figure)) {
* zestRootLayer.addNode(graphNode.getFigure()); } }
*
*
* super.redraw();
*
*
* }
*/

Expand Down Expand Up @@ -1033,8 +1017,8 @@ void registerItem(GraphItem item) {
}

/*
*
*
*
*
* /** Changes the figure for a particular node
*/
void changeNodeFigure(IFigure oldValue, IFigure newFigure, GraphNode graphItem) {
Expand All @@ -1048,7 +1032,7 @@ void changeNodeFigure(IFigure oldValue, IFigure newFigure, GraphNode graphItem)

/**
* Invoke all the constraint adapters for this constraints
*
*
* @param object
* @param constraint
*/
Expand Down Expand Up @@ -1122,7 +1106,7 @@ interface MyRunnable extends Runnable {
* Adds a reveal listener to the view. Note: A reveal listener will only every
* be called ONCE!!! even if a view comes and goes. There is no remove reveal
* listener. This is used to defer some events until after the view is revealed.
*
*
* @param revealListener
*/
private void addRevealListener(final RevealListener revealListener) {
Expand Down Expand Up @@ -1172,7 +1156,7 @@ private ScalableFigure createLayers() {
* This removes the fisheye from the graph. It uses an animation to make the
* fisheye shrink, and then it finally clears the fisheye layer. This assumes
* that there is ever only 1 node on the fisheye layer at any time.
*
*
* @param fishEyeFigure The fisheye figure
* @param regularFigure The regular figure (i.e. the non fisheye version)
*/
Expand Down Expand Up @@ -1206,7 +1190,7 @@ void removeFishEye(final IFigure fishEyeFigure, final IFigure regularFigure, boo

/**
* Replaces the old fisheye figure with a new one.
*
*
* @param oldFigure
* @param newFigure
*/
Expand All @@ -1230,7 +1214,7 @@ boolean replaceFishFigure(IFigure oldFigure, IFigure newFigure) {
* Add a fisheye version of the node. This works by animating the change from
* the original node to the fisheyed one, and then placing the fisheye node on
* the fisheye layer.
*
*
* @param startFigure The original node
* @param endFigure The fisheye figure
* @param newBounds The final size of the fisheyed figure
Expand Down
Loading

0 comments on commit 2312b49

Please sign in to comment.