[Jarspy-commits] CVS: JarSpy/src/com/ociweb/jarspy/intellij/plugin ConfigComponent.java,NONE,1.1 Jar
Status: Beta
Brought to you by:
brown_j
|
From: Jeff B. <br...@us...> - 2003-01-25 03:44:56
|
Update of /cvsroot/jarspy/JarSpy/src/com/ociweb/jarspy/intellij/plugin
In directory sc8-pr-cvs1:/tmp/cvs-serv17677/src/com/ociweb/jarspy/intellij/plugin
Added Files:
ConfigComponent.java JarSpyIntelliJPlugin.java
JarSpyIntelliJPluginAction.java
Log Message:
initial stab at IntelliJ IDEA plugin
--- NEW FILE: ConfigComponent.java ---
package com.ociweb.jarspy.intellij.plugin;
import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.ociweb.jarspy.gui.JarSpyInfoPanel;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
public class ConfigComponent implements Configurable, ApplicationComponent {
private JComponent component = null;
public String getDisplayName() {
return "JarSpy";
}
public Icon getIcon() {
return new ImageIcon(getClass().getResource("/com/ociweb/jarspy/gui/images/jaricon32.gif"));
}
public String getHelpTopic() {
return "help";
}
public synchronized JComponent createComponent() {
if (component == null) component = new JarSpyInfoPanel();
return component;
}
public boolean isModified() {
return false;
}
public void apply() throws ConfigurationException {
}
public void reset() {
}
public synchronized void disposeUIResources() {
component = null;
}
public String getComponentName() {
return "JarSpy";
}
public void initComponent() {
}
public void disposeComponent() {
}
}
--- NEW FILE: JarSpyIntelliJPlugin.java ---
package com.ociweb.jarspy.intellij.plugin;
import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.openapi.wm.ToolWindowAnchor;
import com.ociweb.jarspy.JarInspector;
import com.ociweb.jarspy.gui.ClassesViewer;
import java.io.File;
import java.io.IOException;
public class JarSpyIntelliJPlugin implements ProjectComponent {
private Project myProject = null;
private Logger logger;
private JarInspector jarInspector = new JarInspector();
public JarSpyIntelliJPlugin(Project project) {
myProject = project;
logger = Logger.getInstance(getClass().getName());
}
public void projectOpened() {
ToolWindowManager twm = ToolWindowManager.getInstance(myProject);
ClassesViewer cv = new ClassesViewer(jarInspector);
twm.registerToolWindow("JarSpy", cv, ToolWindowAnchor.BOTTOM);
}
public void projectClosed() {
ToolWindowManager twm = ToolWindowManager.getInstance(myProject);
twm.unregisterToolWindow("JarSpy");
}
public String getComponentName() {
return "ToolWindow.JarSpy";
}
public void initComponent() {
}
public void disposeComponent() {
}
public void updateFile(String pathToFile) {
try {
jarInspector.setFile(new File(pathToFile));
} catch (IOException e) {
logger.error(e);
}
}
}
--- NEW FILE: JarSpyIntelliJPluginAction.java ---
package com.ociweb.jarspy.intellij.plugin;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowManager;
public class JarSpyIntelliJPluginAction extends AnAction {
public void update(AnActionEvent e) {
VirtualFile file
= (VirtualFile) e.getDataContext().getData("virtualFile");
Presentation presentation = e.getPresentation();
if (file == null || file.getExtension() == null)
presentation.setVisible(false);
else if (file.getExtension().equalsIgnoreCase("jar")
|| file.getExtension().equalsIgnoreCase("zip")
|| file.getExtension().equalsIgnoreCase("ear")
|| file.getExtension().equalsIgnoreCase("war"))
presentation.setVisible(true);
else
presentation.setVisible(false);
}
public void actionPerformed(AnActionEvent e) {
final VirtualFile file
= (VirtualFile) e.getDataContext().getData("virtualFile");
Project p = (Project) e.getDataContext().getData("project");
ToolWindow tw = ToolWindowManager.getInstance(p).getToolWindow("JarSpy");
if (tw != null) {
tw.activate(null);
JarSpyIntelliJPlugin jsip =
(JarSpyIntelliJPlugin) p.getComponent(JarSpyIntelliJPlugin.class);
jsip.updateFile(file.getPath());
}
}
}
|