Skip to content

Commit

Permalink
8293364: IGV: Refactor Action in EditorTopComponent and fix minor bugs
Browse files Browse the repository at this point in the history
Reviewed-by: rcastanedalo, chagedorn
  • Loading branch information
tobiasholenstein committed Sep 21, 2022
1 parent 844a95b commit e9401e6
Show file tree
Hide file tree
Showing 37 changed files with 975 additions and 1,047 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
CTL_ImportAction=Open...
CTL_OpenGraphAction=View graph
CTL_DiffGraphAction=Difference to current graph
CTL_RemoveAction=Remove selected graphs and groups
CTL_RemoveAllAction=Remove all graphs and groups
CTL_OutlineAction=Outline
CTL_SaveAsAction=Save selected groups...
CTL_SaveAllAction=Save all groups...
CTL_PropertiesAction=Open Properties Window
CTL_NewFilterAction=New filter...
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -24,6 +24,7 @@
*/
package com.sun.hotspot.igv.util;

import com.sun.hotspot.igv.data.ChangedListener;
import java.awt.EventQueue;
import org.openide.util.*;
import org.openide.util.actions.CallableSystemAction;
Expand All @@ -32,9 +33,10 @@
*
* @author Thomas Wuerthinger
*/
public abstract class ContextAction<T> extends CallableSystemAction implements LookupListener, ContextAwareAction {
public abstract class ContextAction<T> extends CallableSystemAction implements LookupListener, ContextAwareAction, ChangedListener<T> {

private T t;

private Lookup context = null;
private Lookup.Result<T> result = null;

public ContextAction() {
Expand All @@ -46,7 +48,6 @@ public ContextAction(Lookup context) {
}

private void init(Lookup context) {
this.context = context;
result = context.lookupResult(contextClass());
result.addLookupListener(this);
resultChanged(null);
Expand All @@ -66,13 +67,7 @@ public void performAction() {
final T t = result.allInstances().iterator().next();

// Ensure it's AWT event thread
EventQueue.invokeLater(new Runnable() {

@Override
public void run() {
performAction(t);
}
});
EventQueue.invokeLater(() -> performAction(t));
}

public void update(T t) {
Expand All @@ -81,13 +76,39 @@ public void update(T t) {
} else {
setEnabled(isEnabled(t));
}
if (this.t != t) {
if (this.t != null) {
removeContextListener(this.t);
}
this.t = t;
if (this.t != null) {
addContextListener(this.t);
}
}
}

@Override
public void changed(T t) {
update(t);
}

@Override
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}

public boolean isEnabled(T context) {
return true;
@Override
protected boolean asynchronous() {
return false;
}

public abstract boolean isEnabled(T context);

public abstract Class<T> contextClass();

public abstract void performAction(T context);
public abstract void performAction(T t);

public abstract void addContextListener(T t);

public abstract void removeContextListener(T t);
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void evaluate(SearchRequest request, SearchResponse response) {
final EditorTopComponent comp = EditorTopComponent.getActive();
assert(comp != null);
if (theGraph != null) {
comp.getDiagramModel().selectGraph(theGraph);
comp.getModel().selectGraph(theGraph);
}
comp.setSelectedNodes(b);
comp.requestActive();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,25 @@
*/
package com.sun.hotspot.igv.view;

import com.sun.hotspot.igv.data.ChangedListener;
import com.sun.hotspot.igv.data.ControllableChangedListener;
import com.sun.hotspot.igv.data.InputBlock;
import com.sun.hotspot.igv.data.InputNode;
import com.sun.hotspot.igv.data.Pair;
import com.sun.hotspot.igv.data.Properties;
import com.sun.hotspot.igv.data.services.Scheduler;
import com.sun.hotspot.igv.data.*;
import com.sun.hotspot.igv.graph.*;
import com.sun.hotspot.igv.hierarchicallayout.HierarchicalClusterLayoutManager;
import com.sun.hotspot.igv.hierarchicallayout.HierarchicalCFGLayoutManager;
import com.sun.hotspot.igv.hierarchicallayout.LinearLayoutManager;
import com.sun.hotspot.igv.hierarchicallayout.HierarchicalClusterLayoutManager;
import com.sun.hotspot.igv.hierarchicallayout.HierarchicalLayoutManager;
import com.sun.hotspot.igv.hierarchicallayout.LinearLayoutManager;
import com.sun.hotspot.igv.layout.LayoutGraph;
import com.sun.hotspot.igv.layout.Link;
import com.sun.hotspot.igv.selectioncoordinator.SelectionCoordinator;
import com.sun.hotspot.igv.util.ColorIcon;
import com.sun.hotspot.igv.util.CustomSelectAction;
import com.sun.hotspot.igv.util.DoubleClickAction;
import com.sun.hotspot.igv.util.PropertiesSheet;
import com.sun.hotspot.igv.view.actions.CustomSelectAction;
import com.sun.hotspot.igv.view.actions.CustomizablePanAction;
import com.sun.hotspot.igv.view.EditorTopComponent;
import com.sun.hotspot.igv.view.widgets.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.util.List;
import java.util.*;
import javax.swing.*;
Expand All @@ -65,9 +60,9 @@
import org.openide.nodes.Children;
import org.openide.nodes.Sheet;
import org.openide.util.Lookup;
import org.openide.util.Utilities;
import org.openide.util.lookup.AbstractLookup;
import org.openide.util.lookup.InstanceContent;
import org.openide.util.Utilities;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,7 @@ public void setShowEmptyBlocks(boolean b) {
viewPropertiesChangedEvent.fire();
}

public boolean getHideDuplicates() {
return hideDuplicates;
}

public void setHideDuplicates(boolean b) {
System.err.println("setHideDuplicates: " + b);
hideDuplicates = b;
public void setHideDuplicates(boolean hideDuplicates) {
InputGraph currentGraph = getFirstGraph();
if (hideDuplicates) {
// Back up to the unhidden equivalent graph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ enum InteractionMode {
PANNING,
}

DiagramViewModel getModel();

public void paint(Graphics2D generator);

public Lookup getLookup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public EditorInputGraphProvider(EditorTopComponent editor) {
@Override
public InputGraph getGraph() {
if (editor != null && editor.isOpened()) {
return editor.getDiagramModel().getGraphToView();
return editor.getModel().getGraphToView();
} else {
return null;
}
Expand All @@ -66,7 +66,7 @@ public void setSelectedNodes(Set<InputNode> nodes) {
@Override
public Iterable<InputGraph> searchBackward() {
if (editor != null && editor.isOpened()) {
return editor.getDiagramModel().getGraphsBackward();
return editor.getModel().getGraphsBackward();
} else {
return null;
}
Expand All @@ -75,7 +75,7 @@ public Iterable<InputGraph> searchBackward() {
@Override
public Iterable<InputGraph> searchForward() {
if (editor != null && editor.isOpened()) {
return editor.getDiagramModel().getGraphsForward();
return editor.getModel().getGraphsForward();
} else {
return null;
}
Expand Down

1 comment on commit e9401e6

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.