* Xerox/PARC initial implementation
* ******************************************************************/
-
package org.aspectj.ajde.ui;
-import java.util.*;
+import java.util.Iterator;
+import java.util.List;
-import org.aspectj.asm.*;
+import org.aspectj.ajde.Ajde;
+import org.aspectj.asm.AsmManager;
+import org.aspectj.asm.IProgramElement;
+import org.aspectj.asm.IRelationship;
+import org.aspectj.asm.IRelationshipMap;
/**
* @author Mik Kersten
- */
+ */
public abstract class StructureViewNodeFactory {
- private AbstractIconRegistry iconRegistry;
+ private final AbstractIconRegistry iconRegistry;
public StructureViewNodeFactory(AbstractIconRegistry iconRegistry) {
- this.iconRegistry = iconRegistry;
+ this.iconRegistry = iconRegistry;
}
public IStructureViewNode createNode(IProgramElement node) {
- return createNode(node, null);
+ return createNode(node, null);
}
public IStructureViewNode createNode(IProgramElement node, List children) {
IStructureViewNode svNode = createDeclaration(node, icon, children);
String nodeHandle = node.getHandleIdentifier();
- // Don't put relationships on fields as they can then appear twice when building the outline -
+ // Don't put relationships on fields as they can then appear twice when building the outline -
// once under clinit field-set nodes and once under the field declaration.
- if (nodeHandle != null && !node.getKind().equals(IProgramElement.Kind.FIELD)) {
- AsmManager manager = AsmManager.getDefault();
- IRelationshipMap relMap = (manager==null?null:manager.getRelationshipMap());
- List relationships = (relMap==null?null:relMap.get(nodeHandle));
+ if (nodeHandle != null && !node.getKind().equals(IProgramElement.Kind.FIELD)) {
+ AsmManager manager = Ajde.getDefault().getModel();
+ IRelationshipMap relMap = (manager == null ? null : manager.getRelationshipMap());
+ List relationships = (relMap == null ? null : relMap.get(nodeHandle));
if (relationships != null) {
- for (Iterator it = relationships.iterator(); it.hasNext(); ) {
- IRelationship rel = (IRelationship)it.next();
+ for (Iterator it = relationships.iterator(); it.hasNext();) {
+ IRelationship rel = (IRelationship) it.next();
if (rel != null && rel.getTargets().size() > 0) {
- IStructureViewNode relNode = createRelationship(
- rel,
- iconRegistry.getIcon(rel.getKind())
- );
+ IStructureViewNode relNode = createRelationship(rel, iconRegistry.getIcon(rel.getKind()));
if (relNode != null) {
- svNode.add(relNode, 0);
- for (Iterator it2 = rel.getTargets().iterator(); it2.hasNext(); ) {
- String handle = (String)it2.next();
- IProgramElement link = AsmManager.getDefault().getHierarchy().findElementForHandle(handle);
+ svNode.add(relNode, 0);
+ for (Iterator it2 = rel.getTargets().iterator(); it2.hasNext();) {
+ String handle = (String) it2.next();
+ IProgramElement link = Ajde.getDefault().getModel().getHierarchy().findElementForHandle(handle);
if (link != null) {
- IStructureViewNode linkNode = createLink(
- link,
- iconRegistry.getStructureIcon(link.getKind(), link.getAccessibility())
- );
+ IStructureViewNode linkNode = createLink(link, iconRegistry.getStructureIcon(link.getKind(),
+ link.getAccessibility()));
relNode.add(linkNode);
}
}
/**
* Implementors must override this method in order to create link new nodes.
- */
+ */
protected abstract IStructureViewNode createLink(IProgramElement node, AbstractIcon icon);
-
+
/**
* Implementors must override this method in order to create new relationship nodes.
*
* If returned node is null it will not be added to the tree.
- */
+ */
protected abstract IStructureViewNode createRelationship(IRelationship relationship, AbstractIcon icon);
/**
* Implementors must override this method in order to create new nodes.
- */
+ */
protected abstract IStructureViewNode createDeclaration(IProgramElement node, AbstractIcon icon, List children);
/**
* Don't show code elements under types since they show under the corresponding initializers.
*/
public static boolean acceptNode(IProgramElement parent, IProgramElement child) {
- if (parent.getKind() == IProgramElement.Kind.CLASS
- && child.getKind() == IProgramElement.Kind.CODE) {
+ if (parent.getKind() == IProgramElement.Kind.CLASS && child.getKind() == IProgramElement.Kind.CODE) {
return false;
} else {
return true;
* Helen Hawkins Converted to new interface (bug 148190)
* ******************************************************************/
-
package org.aspectj.ajde.ui.swing;
import java.awt.BorderLayout;
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.ui.StructureView;
import org.aspectj.ajde.ui.StructureViewProperties;
-import org.aspectj.asm.AsmManager;
import org.aspectj.asm.IHierarchy;
import org.aspectj.asm.IHierarchyListener;
import org.aspectj.asm.IProgramElement;
public class SimpleStructureViewToolPanel extends JPanel {
private static final long serialVersionUID = -7573973278642540506L;
- private StructureView currentView;
- private JButton separator_button = new JButton();
+ private final StructureView currentView;
+ private final JButton separator_button = new JButton();
private boolean hideNonAJEnabled = false;
private boolean hideAssociationsEnabled = false;
private boolean sortEnabled = false;
- Border border1;
- Border border2;
- JButton structureView_button = new JButton();
- JPanel label_panel = new JPanel();
- JLabel currConfig_field = new JLabel();
- JPanel spacer_panel = new JPanel();
- JPanel jPanel2 = new JPanel();
- JButton forward_button = new JButton();
- JPanel navigation_panel = new JPanel();
- JButton back_button = new JButton();
- BorderLayout borderLayout1 = new BorderLayout();
- JPanel buttons_panel = new JPanel();
- BorderLayout borderLayout2 = new BorderLayout();
- BorderLayout borderLayout3 = new BorderLayout();
- BorderLayout borderLayout4 = new BorderLayout();
-
- public final IHierarchyListener MODEL_LISTENER = new IHierarchyListener() {
- public void elementsUpdated(IHierarchy model) {
+ Border border1;
+ Border border2;
+ JButton structureView_button = new JButton();
+ JPanel label_panel = new JPanel();
+ JLabel currConfig_field = new JLabel();
+ JPanel spacer_panel = new JPanel();
+ JPanel jPanel2 = new JPanel();
+ JButton forward_button = new JButton();
+ JPanel navigation_panel = new JPanel();
+ JButton back_button = new JButton();
+ BorderLayout borderLayout1 = new BorderLayout();
+ JPanel buttons_panel = new JPanel();
+ BorderLayout borderLayout2 = new BorderLayout();
+ BorderLayout borderLayout3 = new BorderLayout();
+ BorderLayout borderLayout4 = new BorderLayout();
+
+ public final IHierarchyListener MODEL_LISTENER = new IHierarchyListener() {
+ public void elementsUpdated(IHierarchy model) {
String path = Ajde.getDefault().getBuildConfigManager().getActiveConfigFile();
- String fileName = "<no active config>";
- if (path != null) fileName = new File(path).getName();
+ String fileName = "<no active config>";
+ if (path != null)
+ fileName = new File(path).getName();
updateCurrConfigLabel(fileName);
- }
- };
-
- JButton hideNonAJ_button = new JButton();
- JPanel navigation_panel1 = new JPanel();
- JButton hideAssociations_button = new JButton();
- BorderLayout borderLayout5 = new BorderLayout();
- JButton sort_button = new JButton();
+ }
+ };
+
+ JButton hideNonAJ_button = new JButton();
+ JPanel navigation_panel1 = new JPanel();
+ JButton hideAssociations_button = new JButton();
+ BorderLayout borderLayout5 = new BorderLayout();
+ JButton sort_button = new JButton();
public SimpleStructureViewToolPanel(StructureView currentView) {
this.currentView = currentView;
- AsmManager.getDefault().addListener(MODEL_LISTENER);
+ Ajde.getDefault().getModel().addListener(MODEL_LISTENER);
try {
jbInit();
} catch (Exception e) {
- Message msg = new Message("Could not initialize GUI.",IMessage.ERROR,e,null);
- Ajde.getDefault().getMessageHandler().handleMessage(msg);
+ Message msg = new Message("Could not initialize GUI.", IMessage.ERROR, e, null);
+ Ajde.getDefault().getMessageHandler().handleMessage(msg);
}
updateCurrConfigLabel("<no active config>");
}
-
- private void updateCurrConfigLabel(String text) {
- currConfig_field.setText(" File View (" + text + ")");
- }
-
- private void jbInit() throws Exception {
- border1 = BorderFactory.createBevelBorder(BevelBorder.LOWERED,Color.white,Color.white,new Color(156, 156, 158),new Color(109, 109, 110));
- border2 = BorderFactory.createEmptyBorder(0,1,0,0);
-
-
-
- separator_button.setPreferredSize(new Dimension(2, 16));
- separator_button.setMinimumSize(new Dimension(2, 16));
- separator_button.setEnabled(false);
- separator_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
- separator_button.setMaximumSize(new Dimension(2, 16));
-
- structureView_button.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- structureView_button_actionPerformed(e);
- }
- });
- structureView_button.setIcon(Ajde.getDefault().getIconRegistry().getStructureViewIcon());
- structureView_button.setBorder(border2);
- structureView_button.setToolTipText("Navigate back");
- structureView_button.setPreferredSize(new Dimension(20, 20));
- structureView_button.setMinimumSize(new Dimension(20, 20));
- structureView_button.setMaximumSize(new Dimension(24, 20));
- currConfig_field.setBackground(SystemColor.control);
- currConfig_field.setFont(new java.awt.Font("SansSerif", 0, 11));
- currConfig_field.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
- //currConfig_field.setEditable(false);
- currConfig_field.setText(" ");
-
- forward_button.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- forward_button_actionPerformed(e);
- }
- });
- forward_button.setIcon(Ajde.getDefault().getIconRegistry().getForwardIcon());
- forward_button.setToolTipText("Navigate forward");
- forward_button.setPreferredSize(new Dimension(20, 20));
- forward_button.setMinimumSize(new Dimension(20, 20));
- forward_button.setMaximumSize(new Dimension(24, 20));
- forward_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
- navigation_panel.setLayout(borderLayout1);
- back_button.setMaximumSize(new Dimension(24, 20));
- back_button.setMinimumSize(new Dimension(20, 20));
- back_button.setPreferredSize(new Dimension(20, 20));
- back_button.setToolTipText("Navigate back");
- back_button.setIcon(Ajde.getDefault().getIconRegistry().getBackIcon());
- back_button.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- back_button_actionPerformed(e);
- }
- });
- back_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
- this.setLayout(borderLayout2);
- buttons_panel.setLayout(borderLayout3);
- label_panel.setLayout(borderLayout4);
- hideNonAJ_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
- hideNonAJ_button.setMaximumSize(new Dimension(24, 20));
- hideNonAJ_button.setMinimumSize(new Dimension(20, 20));
- hideNonAJ_button.setPreferredSize(new Dimension(20, 20));
- hideNonAJ_button.setToolTipText("Hide non-AspectJ members");
- hideNonAJ_button.setIcon(Ajde.getDefault().getIconRegistry().getHideNonAJIcon());
- hideNonAJ_button.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- hideNonAJ_button_actionPerformed(e);
- }
- });
- navigation_panel1.setLayout(borderLayout5);
- hideAssociations_button.setMaximumSize(new Dimension(24, 20));
- hideAssociations_button.setMinimumSize(new Dimension(20, 20));
- hideAssociations_button.setPreferredSize(new Dimension(20, 20));
- hideAssociations_button.setToolTipText("Hide associations");
- hideAssociations_button.setIcon(Ajde.getDefault().getIconRegistry().getHideAssociationsIcon());
- hideAssociations_button.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- hideAssociations_button_actionPerformed(e);
- }
- });
- hideAssociations_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
- sort_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
- sort_button.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- sort_button_actionPerformed(e);
- }
- });
- sort_button.setIcon(Ajde.getDefault().getIconRegistry().getOrderIcon());
- sort_button.setToolTipText("Sort member");
- sort_button.setPreferredSize(new Dimension(20, 20));
- sort_button.setMinimumSize(new Dimension(20, 20));
- sort_button.setMaximumSize(new Dimension(24, 20));
- label_panel.add(currConfig_field, BorderLayout.CENTER);
- //label_panel.add(structureView_button, BorderLayout.WEST);
- this.add(spacer_panel, BorderLayout.CENTER);
- this.add(buttons_panel, BorderLayout.EAST);
- buttons_panel.add(navigation_panel, BorderLayout.CENTER);
- navigation_panel.add(back_button, BorderLayout.CENTER);
- navigation_panel.add(forward_button, BorderLayout.EAST);
- navigation_panel.add(jPanel2, BorderLayout.WEST);
- buttons_panel.add(navigation_panel1, BorderLayout.WEST);
- navigation_panel1.add(hideAssociations_button, BorderLayout.EAST);
- navigation_panel1.add(hideNonAJ_button, BorderLayout.CENTER);
- navigation_panel1.add(sort_button, BorderLayout.WEST);
- this.add(label_panel, BorderLayout.WEST);
+ private void updateCurrConfigLabel(String text) {
+ currConfig_field.setText(" File View (" + text + ")");
+ }
+ private void jbInit() throws Exception {
+ border1 = BorderFactory.createBevelBorder(BevelBorder.LOWERED, Color.white, Color.white, new Color(156, 156, 158),
+ new Color(109, 109, 110));
+ border2 = BorderFactory.createEmptyBorder(0, 1, 0, 0);
+
+ separator_button.setPreferredSize(new Dimension(2, 16));
+ separator_button.setMinimumSize(new Dimension(2, 16));
+ separator_button.setEnabled(false);
+ separator_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
+ separator_button.setMaximumSize(new Dimension(2, 16));
+
+ structureView_button.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ structureView_button_actionPerformed(e);
+ }
+ });
+ structureView_button.setIcon(Ajde.getDefault().getIconRegistry().getStructureViewIcon());
+ structureView_button.setBorder(border2);
+ structureView_button.setToolTipText("Navigate back");
+ structureView_button.setPreferredSize(new Dimension(20, 20));
+ structureView_button.setMinimumSize(new Dimension(20, 20));
+ structureView_button.setMaximumSize(new Dimension(24, 20));
+ currConfig_field.setBackground(SystemColor.control);
+ currConfig_field.setFont(new java.awt.Font("SansSerif", 0, 11));
+ currConfig_field.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
+ // currConfig_field.setEditable(false);
+ currConfig_field.setText(" ");
+
+ forward_button.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ forward_button_actionPerformed(e);
+ }
+ });
+ forward_button.setIcon(Ajde.getDefault().getIconRegistry().getForwardIcon());
+ forward_button.setToolTipText("Navigate forward");
+ forward_button.setPreferredSize(new Dimension(20, 20));
+ forward_button.setMinimumSize(new Dimension(20, 20));
+ forward_button.setMaximumSize(new Dimension(24, 20));
+ forward_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
+ navigation_panel.setLayout(borderLayout1);
+ back_button.setMaximumSize(new Dimension(24, 20));
+ back_button.setMinimumSize(new Dimension(20, 20));
+ back_button.setPreferredSize(new Dimension(20, 20));
+ back_button.setToolTipText("Navigate back");
+ back_button.setIcon(Ajde.getDefault().getIconRegistry().getBackIcon());
+ back_button.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ back_button_actionPerformed(e);
+ }
+ });
+ back_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
+ this.setLayout(borderLayout2);
+ buttons_panel.setLayout(borderLayout3);
+ label_panel.setLayout(borderLayout4);
+ hideNonAJ_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
+ hideNonAJ_button.setMaximumSize(new Dimension(24, 20));
+ hideNonAJ_button.setMinimumSize(new Dimension(20, 20));
+ hideNonAJ_button.setPreferredSize(new Dimension(20, 20));
+ hideNonAJ_button.setToolTipText("Hide non-AspectJ members");
+ hideNonAJ_button.setIcon(Ajde.getDefault().getIconRegistry().getHideNonAJIcon());
+ hideNonAJ_button.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ hideNonAJ_button_actionPerformed(e);
+ }
+ });
+ navigation_panel1.setLayout(borderLayout5);
+ hideAssociations_button.setMaximumSize(new Dimension(24, 20));
+ hideAssociations_button.setMinimumSize(new Dimension(20, 20));
+ hideAssociations_button.setPreferredSize(new Dimension(20, 20));
+ hideAssociations_button.setToolTipText("Hide associations");
+ hideAssociations_button.setIcon(Ajde.getDefault().getIconRegistry().getHideAssociationsIcon());
+ hideAssociations_button.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ hideAssociations_button_actionPerformed(e);
+ }
+ });
+ hideAssociations_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
+ sort_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
+ sort_button.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ sort_button_actionPerformed(e);
+ }
+ });
+ sort_button.setIcon(Ajde.getDefault().getIconRegistry().getOrderIcon());
+ sort_button.setToolTipText("Sort member");
+ sort_button.setPreferredSize(new Dimension(20, 20));
+ sort_button.setMinimumSize(new Dimension(20, 20));
+ sort_button.setMaximumSize(new Dimension(24, 20));
+ label_panel.add(currConfig_field, BorderLayout.CENTER);
+ // label_panel.add(structureView_button, BorderLayout.WEST);
+ this.add(spacer_panel, BorderLayout.CENTER);
+ this.add(buttons_panel, BorderLayout.EAST);
+ buttons_panel.add(navigation_panel, BorderLayout.CENTER);
+ navigation_panel.add(back_button, BorderLayout.CENTER);
+ navigation_panel.add(forward_button, BorderLayout.EAST);
+ navigation_panel.add(jPanel2, BorderLayout.WEST);
+ buttons_panel.add(navigation_panel1, BorderLayout.WEST);
+ navigation_panel1.add(hideAssociations_button, BorderLayout.EAST);
+ navigation_panel1.add(hideNonAJ_button, BorderLayout.CENTER);
+ navigation_panel1.add(sort_button, BorderLayout.WEST);
+ this.add(label_panel, BorderLayout.WEST);
}
- private void forward_button_actionPerformed(ActionEvent e) {
- Ajde.getDefault().getStructureViewManager().fireNavigateForwardAction(currentView);
- }
+ private void forward_button_actionPerformed(ActionEvent e) {
+ Ajde.getDefault().getStructureViewManager().fireNavigateForwardAction(currentView);
+ }
- private void back_button_actionPerformed(ActionEvent e) {
- Ajde.getDefault().getStructureViewManager().fireNavigateBackAction(currentView);
- }
+ private void back_button_actionPerformed(ActionEvent e) {
+ Ajde.getDefault().getStructureViewManager().fireNavigateBackAction(currentView);
+ }
- void structureView_button_actionPerformed(ActionEvent e) {
+ void structureView_button_actionPerformed(ActionEvent e) {
- }
+ }
- private void hideNonAJ_button_actionPerformed(ActionEvent e) {
+ private void hideNonAJ_button_actionPerformed(ActionEvent e) {
if (hideNonAJEnabled) {
hideNonAJ_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
hideNonAJEnabled = false;
} else {
hideNonAJ_button.setBorder(AjdeWidgetStyles.LOWERED_BEVEL_BORDER);
hideNonAJEnabled = true;
- currentView.getViewProperties().setFilteredMemberKinds(
- IProgramElement.Kind.getNonAJMemberKinds()
- );
+ currentView.getViewProperties().setFilteredMemberKinds(IProgramElement.Kind.getNonAJMemberKinds());
}
Ajde.getDefault().getStructureViewManager().refreshView(currentView);
- }
+ }
- private void hideAssociations_button_actionPerformed(ActionEvent e) {
+ private void hideAssociations_button_actionPerformed(ActionEvent e) {
if (hideAssociationsEnabled) {
hideAssociations_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
hideAssociationsEnabled = false;
- currentView.getViewProperties().setRelations(
- Ajde.getDefault().getStructureViewManager().getAvailableRelations()
- );
+ currentView.getViewProperties().setRelations(Ajde.getDefault().getStructureViewManager().getAvailableRelations());
} else {
hideAssociations_button.setBorder(AjdeWidgetStyles.LOWERED_BEVEL_BORDER);
hideAssociationsEnabled = true;
currentView.getViewProperties().setRelations(new ArrayList());
}
Ajde.getDefault().getStructureViewManager().refreshView(currentView);
- }
+ }
- private void sort_button_actionPerformed(ActionEvent e) {
+ private void sort_button_actionPerformed(ActionEvent e) {
if (sortEnabled) {
sort_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
sortEnabled = false;
- currentView.getViewProperties().setSorting(
- StructureViewProperties.Sorting.DECLARATIONAL
- );
+ currentView.getViewProperties().setSorting(StructureViewProperties.Sorting.DECLARATIONAL);
} else {
sort_button.setBorder(AjdeWidgetStyles.LOWERED_BEVEL_BORDER);
sortEnabled = true;
- currentView.getViewProperties().setSorting(
- StructureViewProperties.Sorting.ALPHABETICAL
- );
+ currentView.getViewProperties().setSorting(StructureViewProperties.Sorting.ALPHABETICAL);
}
Ajde.getDefault().getStructureViewManager().refreshView(currentView);
- }
+ }
}