[Jarspy-commits] CVS: JarSpy/src/com/ociweb/jarspy/gui/classdetails AbstractClassDetailTab.java,NONE
Status: Beta
Brought to you by:
brown_j
|
From: Jeff B. <br...@us...> - 2002-07-21 02:03:51
|
Update of /cvsroot/jarspy/JarSpy/src/com/ociweb/jarspy/gui/classdetails
In directory usw-pr-cvs1:/tmp/cvs-serv24046/src/com/ociweb/jarspy/gui/classdetails
Added Files:
AbstractClassDetailTab.java ClassDetailTab.java
ClassDetailTabbedPane.java ClassDetailsPanel.java
ConstantPoolTab.java DependencyTab.java FieldsTab.java
GeneralTab.java MethodsTab.java NoClassSelectedPanel.java
Log Message:
initial set of code for new details panel
--- NEW FILE: AbstractClassDetailTab.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.jarspy.gui.classdetails;
import com.ociweb.jarspy.ClassInfo;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
/**
* An abstract implementation of ClassDetail tab for components to extend
*
* @version $Id: AbstractClassDetailTab.java,v 1.1 2002/07/21 02:03:47 brown_j Exp $
*/
public abstract class AbstractClassDetailTab extends JPanel
implements ClassDetailTab {
private String tabName;
public AbstractClassDetailTab(String tabName) {
this.tabName = tabName;
setBorder(BorderFactory.createRaisedBevelBorder());
}
public void setClassInfo(ClassInfo classInfo) {
}
public String getName() {
return tabName;
}
}
--- NEW FILE: ClassDetailTab.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.jarspy.gui.classdetails;
import com.ociweb.jarspy.ClassInfo;
/**
* Any component to be displayed in a ClassDetailTabbedPane must implement
* this interface
*
* @version $Id: ClassDetailTab.java,v 1.1 2002/07/21 02:03:47 brown_j Exp $
*/
public interface ClassDetailTab {
public void setClassInfo(ClassInfo classInfo);
/**
* Used by JTabbedPane to retrieve the tab name to be used in the UI
*
* @return the label for this tab
*/
public String getName();
}
--- NEW FILE: ClassDetailTabbedPane.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.jarspy.gui.classdetails;
import com.ociweb.jarspy.ClassInfo;
import javax.swing.JTabbedPane;
import javax.swing.SwingUtilities;
/**
* Tabbed pane to display class details
*
* @version $Id: ClassDetailTabbedPane.java,v 1.1 2002/07/21 02:03:47 brown_j Exp $
*/
public class ClassDetailTabbedPane extends JTabbedPane {
private AbstractClassDetailTab[] tabs = {
new GeneralTab(),
new FieldsTab(),
new MethodsTab(),
new ConstantPoolTab(),
new DependencyTab()
};
public ClassDetailTabbedPane() {
for (int i = 0; i < tabs.length; i++) {
AbstractClassDetailTab tab = tabs[i];
add(tab);
}
}
public void setClassInfo(final ClassInfo classInfo) {
// update all of the tabs
// use the event thread since these componenets will
// be changing their on screen state
SwingUtilities.invokeLater(new Runnable() {
public void run() {
for (int i = 0; i < tabs.length; i++) {
AbstractClassDetailTab tab = tabs[i];
try {
tab.setClassInfo(classInfo);
} catch (Exception e) {
}
}
}
});
}
}
--- NEW FILE: ClassDetailsPanel.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.jarspy.gui.classdetails;
import com.ociweb.jarspy.ClassInfo;
import com.ociweb.jarspy.gui.ClassSelectionListener;
import com.ociweb.jarspy.gui.JarFileSelectionListener;
import com.ociweb.jarspy.gui.JarSpyGUI;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import java.awt.CardLayout;
import java.io.File;
/**
* A Panel to display details about a class
*
* @version $Id: ClassDetailsPanel.java,v 1.1 2002/07/21 02:03:47 brown_j Exp $
*/
public class ClassDetailsPanel extends JPanel
implements ClassSelectionListener, JarFileSelectionListener {
private CardLayout cardLayout = new CardLayout();
private static final String NO_CLASS_SELECTED = "NO_CLASS_SELECTED";
private static final String CLASS_DETAIL_PANEL = "CLASS_DETAIL_PANEL";
private ClassDetailTabbedPane tabbedPane = new ClassDetailTabbedPane();
public ClassDetailsPanel(JarSpyGUI gui) {
gui.addClassSelectionListener(this);
gui.addJarFileSelectionListener(this);
setLayout(cardLayout);
add(new JScrollPane(new NoClassSelectedPanel()), NO_CLASS_SELECTED);
add(new JScrollPane(tabbedPane), CLASS_DETAIL_PANEL);
cardLayout.show(this, NO_CLASS_SELECTED);
}
public void classSelected(ClassInfo classInfo) {
if (classInfo == null) {
cardLayout.show(this, NO_CLASS_SELECTED);
} else {
tabbedPane.setClassInfo(classInfo);
cardLayout.show(this, CLASS_DETAIL_PANEL);
}
}
public void jarFileSelectionChanged(File jarFile) {
if (jarFile == null) {
cardLayout.show(this, NO_CLASS_SELECTED);
}
}
}
--- NEW FILE: ConstantPoolTab.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.jarspy.gui.classdetails;
import com.ociweb.jarspy.ClassInfo;
/**
* Panel to diplay the constant pool in a class
*
* @version $Id: ConstantPoolTab.java,v 1.1 2002/07/21 02:03:47 brown_j Exp $
*/
public class ConstantPoolTab extends AbstractClassDetailTab {
public ConstantPoolTab() {
super("Constant Pool");
}
public void setClassInfo(ClassInfo classInfo) {
}
}
--- NEW FILE: DependencyTab.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.jarspy.gui.classdetails;
import com.ociweb.jarspy.ClassInfo;
/**
* A Panel to display dependency information about a class
*
* @version $Id: DependencyTab.java,v 1.1 2002/07/21 02:03:47 brown_j Exp $
*/
public class DependencyTab extends AbstractClassDetailTab {
public DependencyTab() {
super("Dependencies");
}
public void setClassInfo(ClassInfo classInfo) {
}
}
--- NEW FILE: FieldsTab.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.jarspy.gui.classdetails;
import com.ociweb.jarspy.ClassInfo;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import java.awt.BorderLayout;
/**
* Panel to display a list of fields in a class
*
* @version $Id: FieldsTab.java,v 1.1 2002/07/21 02:03:47 brown_j Exp $
*/
public class FieldsTab extends AbstractClassDetailTab {
private JList fieldsList = new JList();
public FieldsTab() {
super("Fields");
setLayout(new BorderLayout());
add(fieldsList);
}
public void setClassInfo(ClassInfo classInfo) {
Object[] fields = classInfo.getFields();
DefaultListModel model = new DefaultListModel();
if (fields.length == 0) {
model.addElement("<none>");
} else {
for (int i = 0; i < fields.length; i++) {
model.addElement(fields[i]);
}
}
fieldsList.setModel(model);
}
}
--- NEW FILE: GeneralTab.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.jarspy.gui.classdetails;
import com.ociweb.jarspy.ClassInfo;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
/**
* Panel to display general details about a class
*
* @version $Id: GeneralTab.java,v 1.1 2002/07/21 02:03:47 brown_j Exp $
*/
public class GeneralTab extends AbstractClassDetailTab {
private JLabel className = new JLabel("");
private JLabel classMajorVersion = new JLabel("");
private JLabel classMinorVersion = new JLabel("");
private JLabel type = new JLabel("");
private JLabel isFinal = new JLabel("");
private JLabel isAbstract = new JLabel("");
public GeneralTab() {
super("General");
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = gbc.RELATIVE;
gbc.gridy = 0;
gbc.insets.top =
gbc.insets.bottom =
gbc.insets.left =
gbc.insets.right = 5;
JLabel[][] labelPairs = {
{new JLabel("Name:"), className},
{new JLabel("Type:"), type},
{new JLabel("Abstract:"), isAbstract},
{new JLabel("Major Version Number:"), classMajorVersion},
{new JLabel("Minor Version Number:"), classMinorVersion},
{new JLabel("Final?:"), isFinal}
};
for (int i = 0; i < labelPairs.length; i++) {
JLabel[] labelPair = labelPairs[i];
gbc.gridy++;
gbc.anchor = gbc.NORTHEAST;
gbc.weightx = 0;
Font font = labelPair[0].getFont();
labelPair[0].setFont(font.deriveFont(Font.BOLD));
add(labelPair[0], gbc);
gbc.anchor = gbc.NORTHWEST;
gbc.weightx = 1;
add(labelPair[1], gbc);
}
gbc.weighty = 1;
gbc.weightx = 0;
add(new JPanel(), gbc);
}
public void setClassInfo(ClassInfo classInfo) {
className.setText(classInfo.getClassName());
classMajorVersion.setText(String.valueOf(classInfo.getMajorVersion()));
classMinorVersion.setText(String.valueOf(classInfo.getMinorVersion()));
type.setText(classInfo.isAnInterface() ? "Interface" : "Class");
isFinal.setText(classInfo.isFinal() ? "Yes" : "No");
isAbstract.setText(classInfo.isAbstract() ? "Yes" : "No");
}
}
--- NEW FILE: MethodsTab.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.jarspy.gui.classdetails;
import com.ociweb.jarspy.ClassInfo;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import java.awt.BorderLayout;
/**
* Panel to display a list of methods
*
* @version $Id: MethodsTab.java,v 1.1 2002/07/21 02:03:47 brown_j Exp $
*/
public class MethodsTab extends AbstractClassDetailTab {
private JList methodsList = new JList();
public MethodsTab() {
super("Methods");
setLayout(new BorderLayout());
add(methodsList);
}
public void setClassInfo(ClassInfo classInfo) {
Object[] methods = classInfo.getMethods();
DefaultListModel model = new DefaultListModel();
for (int i = 0; i < methods.length; i++) {
model.addElement(methods[i]);
}
methodsList.setModel(model);
}
}
--- NEW FILE: NoClassSelectedPanel.java ---
// JarSpy
// Copyright (c) 2001, 2002 Jeff S. Brown
// This file is part of JarSpy.
//
// JarSpy is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// JarSpy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JarSpy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.ociweb.jarspy.gui.classdetails;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
/**
* Panel to display when no class is selected
*
* @version $Id: NoClassSelectedPanel.java,v 1.1 2002/07/21 02:03:47 brown_j Exp $
*/
public class NoClassSelectedPanel extends JPanel {
private JLabel label = new JLabel("Select A Class", SwingConstants.CENTER);
public NoClassSelectedPanel() {
super(new BorderLayout());
add(BorderLayout.CENTER, label);
}
}
|