/*
This library 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.
*/
package org.gjt.jclasslib.browser;
import org.gjt.jclasslib.browser.config.BrowserConfig;
import org.gjt.jclasslib.browser.config.classpath.*;
import org.gjt.jclasslib.browser.config.window.WindowState;
import org.gjt.jclasslib.mdi.*;
import org.gjt.jclasslib.structures.ClassFile;
import org.gjt.jclasslib.structures.InvalidByteCodeException;
import org.gjt.jclasslib.util.GUIHelper;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.beans.*;
import java.io.*;
import java.net.URL;
import java.util.prefs.Preferences;
/**
* MDI Frame and entry point for the class file browser application.
*
* @author <a href="mailto:jclasslib@ej-technologies.com">Ingo Kegel</a>
* @version $Revision: 1.10 $ $Date: 2005/01/14 15:01:03 $
*/
public class BrowserMDIFrame extends BasicMDIFrame {
static final ImageIcon ICON_APPLICATION = loadIcon("jclasslib.gif");
private static final String SETTINGS_WORKSPACE_CHOOSER_PATH = "workspaceChooserPath";
private static final String SETTINGS_CLASSES_CHOOSER_PATH = "classesChooserPath";
private static final ImageIcon ICON_OPEN_CLASS_FILE = loadIcon("open_small.png");
private static final ImageIcon ICON_OPEN_CLASS_FILE_LARGE = loadIcon("open_large.png");
private static final ImageIcon ICON_OPEN_WORKSPACE = loadIcon("open_ws_small.png");
private static final ImageIcon ICON_OPEN_WORKSPACE_LARGE = loadIcon("open_ws_large.png");
private static final ImageIcon ICON_SAVE_WORKSPACE = loadIcon("save_ws_small.png");
private static final ImageIcon ICON_SAVE_WORKSPACE_LARGE = loadIcon("save_ws_large.png");
private static final ImageIcon ICON_BACKWARD = loadIcon("browser_backward_small.png");
private static final ImageIcon ICON_BACKWARD_LARGE = loadIcon("browser_backward_large.png");
private static final ImageIcon ICON_FORWARD = loadIcon("browser_forward_small.png");
private static final ImageIcon ICON_FORWARD_LARGE = loadIcon("browser_forward_large.png");
private static final ImageIcon ICON_RELOAD = loadIcon("reload_small.png");
private static final ImageIcon ICON_RELOAD_LARGE = loadIcon("reload_large.png");
private static final ImageIcon ICON_WEB = loadIcon("web_small.png");
private static final ImageIcon ICON_WEB_LARGE = loadIcon("web_large.png");
private static final ImageIcon ICON_BROWSE_CLASSPATH = loadIcon("tree_small.png");
private static final ImageIcon ICON_BROWSE_CLASSPATH_LARGE = loadIcon("tree_large.png");
private static final ImageIcon ICON_HELP = loadIcon("help.png");
/**
* Load an icon from the <tt>images</tt> directory.
*
* @param fileName the file name for the icon
* @return the icon
*/
public static ImageIcon loadIcon(String fileName) {
URL imageURL = BrowserMDIFrame.class.getResource("images/" + fileName);
return new ImageIcon(imageURL);
}
private Action actionOpenClassFile;
private Action actionBrowseClasspath;
private Action actionSetupClasspath;
private Action actionNewWorkspace;
private Action actionOpenWorkspace;
private Action actionSaveWorkspace;
private Action actionSaveWorkspaceAs;
private Action actionQuit;
private Action actionShowHomepage;
private Action actionShowEJT;
private Action actionBackward;
private Action actionForward;
private Action actionReload;
private Action actionShowHelp;
private Action actionAbout;
private File workspaceFile;
private String workspaceChooserPath = "";
private String classesChooserPath = "";
private BrowserConfig config;
// Visual Components
private JFileChooser workspaceFileChooser;
private JFileChooser classesFileChooser;
private RecentMenu recentMenu;
private ClasspathSetupDialog classpathSetupDialog;
private ClasspathBrowser classpathBrowser;
private ClasspathBrowser jarBrowser;
/**
* Constructor.
*/
public BrowserMDIFrame() {
doNewWorkspace();
recentMenu = new RecentMenu(this);
loadSettings();
setupActions();
setupMenu();
setupFrame();
}
/**
* Get the current browser config.
*
* @return the browser config
*/
public BrowserConfig getConfig() {
return config;
}
public void setVisible(boolean visible) {
super.setVisible(visible);
if (visible) {
desktopManager.showAll();
}
}
/**
* Get the action for displaying the classpath setup dialog.
*
* @return the action
*/
public Action getActionSetupClasspath() {
return actionSetupClasspath;
}
/**
* Get the action for going backward in the navigation history.
*
* @return the action
*/
public Action getActionBackward() {
return actionBackward;
}
/**
* Get the action for going forward in the navigation history.
*
* @return the action
*/
public Action getActionForward() {
return actionForward;
}
/**
* Get the action for reloading the current frame.
*
* @return the action
*/
public Action getActionReload() {
return actionReload;
}
/**
* Get the last path for the classes file chooser.
*
* @return the path
*/
public String getClassesChooserPath() {
return classesChooserPath;
}
/**
* Set the last path for the classes file chooser.
*
* @param classesChooserPath the path
*/
public void setClassesChooserPath(String classesChooserPath) {
this.classesChooserPath = classesChooserPath;
}
/**
* Open a workspace file.
*
* @param file the file.
*/
public void openWorkspace(File file) {
repaintNow();
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
closeAllFrames();
try {
FileInputStream fos = new FileInputStream(file);
XMLDecoder decoder = new XMLDecoder(fos);
config = (BrowserConfig)decoder.readObject();
readMDIConfig(config.getMDIConfig());
decoder.close();
recentMenu.addRecentWorkspace(file);
if (classpathBrowser != null) {
classpathBrowser.setClasspathComponent(config);
}
} catch (FileNotFoundException e) {
GUIHelper.showMessage(this, "An error occured while reading " + file.getPath(), JOptionPane.ERROR_MESSAGE);
} finally {
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
workspaceFile = file;
updateTitle();
actionSaveWorkspaceAs.setEnabled(true);
}
/**
* Open an internal frame for a given file.
*
* @param file the file
* @return the created internal frame
*/
public BrowserInternalFrame openClassFromFile(File file) {
BrowserInternalFrame frame = new BrowserInternalFrame(desktopManager, new WindowState(file.getPath()));
ClassFile classFile = frame.getClassFile();
if (classFile != null) {
try {
String className = classFile.getThisClassName();
String[] pathComponents = className.split("/");
File currentDirectory = file.getParentFile();
boolean validClasspathEntry = true;
for (int i = pathComponents.length - 2; i >= 0; i--) {
String pathComponent = pathComponents[i];
if (!currentDirectory.getName().equals(pathComponent)) {
validClasspathEntry = false;
break;
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
查看class jclasslib (500个子文件)
i4jparams.conf 93B
doc.css 781B
doc.css 781B
unicows.dll 240KB
i4jinst.dll 102KB
_shfoldr.dll 22KB
jclasslib.exe 136KB
i4jdel.exe 5KB
firstrun 10B
structures.gif 27KB
structures_attributes.gif 24KB
bytecode.gif 22KB
structures_constants.gif 22KB
io.gif 11KB
nbmodule.gif 6KB
ej-technologies.gif 3KB
jclasslib.gif 901B
nbmodule.gif 888B
inherit.gif 57B
index-all.html 611KB
constant-values.html 172KB
Opcodes.html 139KB
RecentMenu.html 121KB
serialized-form.html 117KB
BrowserInternalFrame.html 112KB
ExtendedJLabel.html 102KB
ClassFileViewer.html 102KB
BasicInternalFrame.html 99KB
ByteCodeDisplay.html 99KB
ExtendedTableCellRenderer.html 98KB
AbstractAttributeListDetailPane.html 96KB
BrowserMDIFrame.html 96KB
AbstractDetailPane.html 96KB
FixedListDetailPane.html 94KB
ListDetailPane.html 92KB
ClasspathCellRenderer.html 92KB
BasicMDIFrame.html 91KB
LocalVariableCommonAttributeDetailPane.html 91KB
LocalVariableTableAttributeDetailPane.html 91KB
LocalVariableTypeTableAttributeDetailPane.html 91KB
InnerClassesAttributeDetailPane.html 91KB
ConstantReferenceDetailPane.html 90KB
ConstantClassInfoDetailPane.html 90KB
ExceptionTableDetailPane.html 90KB
LineNumberTableAttributeDetailPane.html 90KB
ExceptionsAttributeDetailPane.html 90KB
ConstantNameAndTypeInfoDetailPane.html 89KB
ConstantIntegerInfoDetailPane.html 89KB
ConstantDoubleInfoDetailPane.html 89KB
ConstantStringInfoDetailPane.html 89KB
ConstantFloatInfoDetailPane.html 89KB
ConstantLongInfoDetailPane.html 89KB
ConstantUtf8InfoDetailPane.html 89KB
ClassMemberDetailPane.html 89KB
AbstractConstantInfoDetailPane.html 88KB
CodeAttributeDetailPane.html 87KB
RuntimeAnnotationsAttributeDetailPane.html 87KB
EnclosingMethodAttributeDetailPane.html 87KB
ConstantValueAttributeDetailPane.html 87KB
AnnotationDefaultAttributeDetailPane.html 87KB
ConstElementValueEntryDetailPane.html 87KB
SignatureAttributeDetailPane.html 87KB
GenericAttributeDetailPane.html 87KB
EnumElementValueEntryDetailPane.html 87KB
MiscDetailPane.html 87KB
GenericElementValueDetailPane.html 87KB
SourceFileAttributeDetailPane.html 87KB
ClassElementValueEntryDetailPane.html 87KB
GeneralDetailPane.html 87KB
ArrayElementValueDetailPane.html 86KB
ElementValuePairDetailPane.html 86KB
InterfaceDetailPane.html 86KB
AttributeDetailPane.html 86KB
AnnotationDetailPane.html 86KB
BrowserComponent.html 86KB
ByteCodeDetailPane.html 86KB
ConstantPoolDetailPane.html 85KB
ElementValueDetailPane.html 85KB
BrowserTreePane.html 83KB
ClasspathBrowser.html 83KB
BrowserDetailPane.html 82KB
CounterDisplay.html 81KB
ProgressDialog.html 78KB
ClasspathSetupDialog.html 78KB
BrowserAboutDialog.html 73KB
overview-tree.html 65KB
ClassFile.html 64KB
ElementValue.html 46KB
BasicDesktopManager.html 46KB
TableSwitchInstruction.html 44KB
ImmediateByteInstruction.html 43KB
CPInfo.html 43KB
LookupSwitchInstruction.html 43KB
IncrementInstruction.html 43KB
AccessFlags.html 42KB
BrowserTreeNode.html 42KB
InvokeInterfaceInstruction.html 41KB
ImmediateShortInstruction.html 41KB
MultianewarrayInstruction.html 40KB
ImmediateIntInstruction.html 40KB
共 500 条
- 1
- 2
- 3
- 4
- 5
资源评论
yuhua3272004
- 粉丝: 57
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功