Back to OneInstance
To implement custom listener you must implements ListenerComponent and extends AbstractListenerConfiguration. You can use subpackage win32 for examples how to make simple listener.
You can also add type into class Plugins in style like existing types.
Finaly you must describe your component in plugin.xml. Look Win32Listener description in plugin.xml for example to describe.
To stop/start plugin use IDE Options and find in left list item
IntelliJListener. This may help in debug.
- I think so. It would be nice to use IDEA as the external editor for other tools (Rose, Together, Dreamweaver)..
-- JoeParks - 21 Nov 2002
Back to top
package org.phantom.intellij.ide.oneInstance.win32;
import org.phantom.intellij.ide.oneInstance.*;
/**
* Win 32 Native Listener
* @author <a href="mailto:aefimov@spklabs.com>Alexey Efimov</a>
*/
public class Win32Listener implements ListenerComponent {
/** Configuration panel */
private AbstractListenerConfiguration configurationPanel;
/** Listener status */
private ListenerStatus status;
public AbstractListenerConfiguration getConfigurable() {
if (configurationPanel == null) {
configurationPanel = new Win32ListenerConfigurationPanel();
}
return configurationPanel;
}
public void initListener() {
// Not supported yet;
status = ListenerStatus.STARTED;
}
public void disposeListener() {
// Not supported yet;
status = ListenerStatus.STOPED;
}
public ListenerStatus getListenerStatus() {
return status;
}
public void initComponent() {
}
public void disposeComponent() {
// Kill listener
disposeListener();
}
public String getComponentName() {
return getClass().getName();
}
}
Back to top
package org.phantom.intellij.ide.oneInstance.win32;
import org.phantom.intellij.ide.oneInstance.AbstractListenerConfiguration;
import org.phantom.intellij.ide.oneInstance.ListenerType;
import org.phantom.lang.Resource;
import javax.swing.*;
/**
* Configuration Panel
* @author <a href="mailto:aefimov@spklabs.com>Alexey Efimov</a>
*/
public class Win32ListenerConfigurationPanel extends AbstractListenerConfiguration {
private final static String NAME = "Windows";
private final static Icon ICON = Resource.getIcon("/org/phantom/intellij/ide/oneInstance/win32/windows.gif");
public ListenerType getListenerType() {
return ListenerType.WINDOWS;
}
public String getDisplayName() {
return NAME;
}
public Icon getIcon() {
return ICON;
}
protected void buildUI() {
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
// TODO: I don't know how make word wrapping :(( By now just \n
String description =
"Under construction. Use RMI instead.\n\n" +
"Windows native listener provide a invocation already running instance of IntelliJ by Win 32 Event. Make file \n" +
"types assotiations with idea.exe from plugin distributive manualy. Put this file to %IDEA_HOME%/bin directory \n" +
"and use as program assotiation with file type.\n\n" +
"Windows native listener not allow execute more that one IntelliJ instance. If you want execute another one\n" +
"instance, then templorary shutdown the listener.\n\n" +
"Note: By now IntelliJ deny access to open files in editor, and this plugin work now only for denied run more\n" +
"that one instance of IntelliJ. Please wait for build #630. If you try use idea.exe you get message pane with\n" +
"list of requesting files, but IntelliJ does not open them.";
JTextPane jtpDescription = new JTextPane();
JLabel jlDummy = new JLabel();
jtpDescription.setText(description);
jtpDescription.setBackground(jlDummy.getBackground());
jtpDescription.setFont(jlDummy.getFont());
jtpDescription.setForeground(jlDummy.getForeground());
jtpDescription.setEditable(false);
panel.add(jtpDescription);
}
}
Back to top
package org.phantom.intellij.ide.oneInstance;
import org.phantom.lang.ScalarType;
import java.text.ParseException;
/**
* Scalar Type for Listener Type (RMI, Windows etc)
* @author <a href="mailto:aefimov@spklabs.com>Alexey Efimov</a>
*/
public class ListenerType extends ScalarType {
private static final int RMI_VALUE = 0;
private static final int WINDOWS_VALUE = 1;
private static final int SOLARIS_VALUE = 2;
/** RMI */
public static final ListenerType RMI = new ListenerType(RMI_VALUE);
/** Windows */
public static final ListenerType WINDOWS = new ListenerType(WINDOWS_VALUE);
/** Solaris */
public static final ListenerType SOLARIS = new ListenerType(SOLARIS_VALUE);
public ListenerType(String s) throws ParseException {
super(s);
}
private ListenerType(int i) {
super(i);
}
/**
* Check type is RMI
*/
public boolean isRMI() {
return value == RMI_VALUE;
}
/**
* Check type is Windows
*/
public boolean isWindows() {
return value == WINDOWS_VALUE;
}
/**
* Check type is Solaris
*/
public boolean isSolaris() {
return value == SOLARIS_VALUE;
}
}
Back to top
<idea-plugin>
<name>PhantomPlugin</name>
<description></description>
<version>1.0</version>
<vendor>Alexey Efimov</vendor>
<idea-version min="3.0" max="3.1"/>
<application-components>
<!-- Listener's realization -->
<component>
<implementation-class>org.phantom.intellij.ide.oneInstance.ListenerConfiguration</implementation-class>
<option name="workspace" value="true" />
</component>
<component>
<implementation-class>org.phantom.intellij.ide.oneInstance.ListenerConfigurationPanel</implementation-class>
</component>
<component>
<implementation-class>org.phantom.intellij.ide.oneInstance.rmi.RMIListenerComponent</implementation-class>
</component>
<component>
<implementation-class>org.phantom.intellij.ide.oneInstance.win32.Win32Listener</implementation-class>
</component>
<component>
<implementation-class>org.phantom.intellij.ide.oneInstance.solaris.SunListener</implementation-class>
</component>
</application-components>
</idea-plugin>
Back to top
-- AlexeyEfimov - 24 Jul 2002