PlusLibraryTutorial 

HOME INDEX SEARCH GO  

 <<O>>  Difference Topic PlusLibraryTutorial (r1.5 - 27 Oct 2004 - AlexeyEfimov)
Changed:
<
<

PLUS library jar distributed with PLUS plugin. You can get it throught Plugin Manager in IDEA (Aurora, Pallada).

>
>

PLUS library jar distributed with PLUS plugin. You can get it throught Plugin Manager in IDEA (Pallada).

Changed:
<
<

PLUS plugin have follow directory structure:

>
>

PLUS library archive have follow directory structure:

Changed:
<
<

$IDEA_PLUGINS_HOME/plus lib redist plus_rt.jar src.zip

>
>

+ lib + src src_plus_jdk1.5.zip plus.jar forms_rt.jar CHANGES.txt

Changed:
<
<

  • plus_rt.jar - it PLUS runtime API.
  • src.zip - is API sources.

To setup plugin project with using PLUS API, you can get Wizard plugin, and setup it by "Plugin" wizard. Or copy and setup manualy plus_rt.jar to your plugin lib, and attach it to project as library (with src.zip as sources).

>
>

  • plus.jar - it PLUS API jar, requered to user library.
  • src_plus_jdk1.5.zip - is a sources for PLUS library writen in JDK 1.5
Changed:
<
<

PluginManager pluginManager = PluginManager.getInstance(); PluginDescriptor? descriptor = pluginManager.getDescriptor();

>
>

PluginDescriptorManager? descriptorManager = PluginDescriptorManager?.getInstance(); PluginDescriptor? descriptor = descriptorManager.getDescriptor();

Deleted:
<
<

Creation default "About Splash" for your plugin

For show quick "About Splash" of your plugin, you can use PLUS api, to generate automatical splash, like IDEA splash.

  AboutManager aboutManager = AboutManager.getInstance();
  JComponent component = aboutManager.getAboutComponent();
  // ...

  // Or just get AnAction to attach in toolbar
  AnAction action = aboutManager.getAboutAction();
Changed:
<
<

  • Plugin utility class.
>
>

  • Plugin utility.
Changed:
<
<

public class Plugin {

>
>

public interface Plugin {

Changed:
<
<

public static final Localizer localizer = LocalizerManager?.getInstance().getLocalizer("org.intellij.yourPlugin.resources.strings");

>
>

Localizer localizer = LocalizerManager?.getInstance().getLocalizer("org.intellij.yourPlugin.resources.strings");

Changed:
<
<

public static PluginDescriptor? descriptor = PluginManager.getInstance().getDescriptor();

>
>

PluginDescriptor? descriptor = PluginDescriptorManager?.getInstance().getDescriptor();

Changed:
<
<

public static final Logger logger = Logger.getInstance(descriptor.getPluginName());

>
>

Logger logger = Logger.getInstance(descriptor.getPluginName());

Changed:
<
<

Then you may just call to static fields of Plugin class. Such as:

>
>

Then you may just call to static fields of Plugin interface. Such as:

Changed:
<
<

-- AlexeyEfimov - 29 Mar 2004

>
>

-- AlexeyEfimov - 27 Oct 2004


 <<O>>  Difference Topic PlusLibraryTutorial (r1.4 - 08 Aug 2004 - AlexeyEfimov)
Changed:
<
<

%META:TOPICPARENT{name="PlusPlugin"}%

Tutorial of extending PlusPlugin?

>
>

%META:TOPICPARENT{name="PlusLibrary"}%

Tutorial of extending PlusLibrary

Added:
>
>

%META:TOPICMOVED{by="AlexeyEfimov" date="1091948679" from="Main.PlusPluginTutorial" to="Main.PlusLibraryTutorial"}%


 <<O>>  Difference Topic PlusLibraryTutorial (r1.3 - 29 Mar 2004 - AlexeyEfimov)
Added:
>
>

Custom FileType registration

Then you design your ouw FileEditor you maybe need for file type registration for your editor. Then you may use PLUS API, FileTypeDescriptorManager class for it.

    FileTypeDescriptor ftd = new FileTypeDescriptor();
    ftd.setName("MyFileType");
    ftd.setDescription("My test FileType");
    ftd.setDefaultExtension("myext");
    ftd.setIconPath("/org/intellij/myEditor/resources/ext.png");
    FileTypeDescriptorManager ftdManager = FileTypeDescriptorManager.getInstance();
    ftdManager.registerFileType(ftd);
Changed:
<
<

-- AlexeyEfimov - 28 Mar 2004

>
>

-- AlexeyEfimov - 29 Mar 2004


 <<O>>  Difference Topic PlusLibraryTutorial (r1.2 - 27 Mar 2004 - AlexeyEfimov)
Changed:
<
<

Writing PLUS services

>
>

Getting PLUS API

Changed:
<
<

PLUS have API to register and unregister services. But, better if you not write separate plugin with new services, and notify PLUS author to include services into it. So use services API only for testing and creating testing suite to post it to PLUS author. Services must be fully documented, must be light, must be minimal API and must be realy needed.

>
>

PLUS library jar distributed with PLUS plugin. You can get it throught Plugin Manager in IDEA (Aurora, Pallada).

Changed:
<
<

Defining your Service

>
>

PLUS plugin have follow directory structure:

$IDEA_PLUGINS_HOME/plus
  lib
  redist
    plus_rt.jar
  src.zip

  • plus_rt.jar - it PLUS runtime API.
  • src.zip - is API sources.

To setup plugin project with using PLUS API, you can get Wizard plugin, and setup it by "Plugin" wizard. Or copy and setup manualy plus_rt.jar to your plugin lib, and attach it to project as library (with src.zip as sources).

Changed:
<
<

You must extend Service interface and define all methods of your service:

>
>

Using PLUS API

Reading plugin info from plugin.xml descriptor

Then you need to get info from plugin.xml descriptor of your plugin, you may use follow PLUS API:

Changed:
<
<

public interface PluginDescriptorService? extends Service { public PluginDescriptor? getDescriptor(Class type) throws IOException, JDOMException;

>
>

PluginManager pluginManager = PluginManager.getInstance(); PluginDescriptor? descriptor = pluginManager.getDescriptor();

Changed:
<
<

public void logInit(Class type);

>
>

String pluginName = descriptor.getPluginName(); String authorName = descriptor.getAuthorName();

Changed:
<
<

public void logDispose(Class type); }

>
>

VirtualFile? pluginHome = descriptor.getPluginDirectory();

// ... etc

Changed:
<
<

Follow implement it by local package class and extending from AbstractService:

>
>

Reading options of other components in $IDEA_CONFIG_HOME/options/*.xml files

Then you need to get info from other components settings in IDEA config directory, such as "Browser Path" from IDE settings, you can use Options api:

Changed:
<
<

class PluginDescriptorServiceImpl? extends AbstractService? implements PluginDescriptorService? { private static final String SERVICE_NAME = "PluginDescriptor";

>
>

OptionsManager? opm = OptionsManager?.getInstance(); OptionsDescriptor? options = opm.getOptions(OptionsManager?.IDE_GENERAL);

Changed:
<
<

public String getServiceName() { return SERVICE_NAME; }

>
>

// Read path to HTML browser String browserPath = options.getComponentOption("GeneralSettings", "browserPath");

// Get whole XML element for component "GeneralSettings" Element element = options.getComponentElement("GeneralSettings");

// ... etc

Creation default "About Splash" for your plugin

Changed:
<
<

public PluginDescriptor? getDescriptor(Class type) throws IOException, JDOMException {

>
>

For show quick "About Splash" of your plugin, you can use PLUS api, to generate automatical splash, like IDEA splash.

  AboutManager aboutManager = AboutManager.getInstance();
  JComponent component = aboutManager.getAboutComponent();
<nop>
Deleted:
<
<

}

Changed:
<
<

public void logInit(Class type) { // .. }

>
>

// Or just get AnAction? to attach in toolbar AnAction? action = aboutManager.getAboutAction();

Changed:
<
<

public void logDispose(Class type) { // .. }

>
>

Localization of your plugin

Changed:
<
<

}

>
>

If you like to support different languages, you need for localization. PLUS API support universal localizer, that concatenate two classes - ResourceBundle and MessageFormat:

  LocalizerManager lm = LocalizerManager.getInstance();
  Localizer localizer = lm.getLocalizer("my.bundle.name");
 
  String myValue = localizer.getString("myKey");
  String myFormatedValue = localizer.format("myFormatKey", new Object[] {"Hello!", new Date()});
<nop>
Changed:
<
<

Thats all, now just define it in plugins.xml as ApplicationComponent:

>
>

Real using in your plugin

How you can use PLUS API for real. There are very simple way - just create follow utility class for every your plugin:

Changed:
<
<

org.intellij.plus.services.PluginDescriptorService org.intellij.plus.services.impl.PluginDescriptorServiceImpl

>
>

/**

  • Plugin utility class. */ public class Plugin { /** * Localizer */ public static final Localizer localizer = LocalizerManager?.getInstance().getLocalizer("org.intellij.yourPlugin.resources.strings");

/** * Descriptor */ public static PluginDescriptor? descriptor = PluginManager.getInstance().getDescriptor();

/** * Default logger */ public static final Logger logger = Logger.getInstance(descriptor.getPluginName());

}

Changed:
<
<

>
>

Then you may just call to static fields of Plugin class. Such as:

  // ...
  setTitle(Plugin.localizer.getString("wizard.panel.title"));
  // ...
<nop>
Changed:
<
<

-- AlexeyEfimov - 10 Mar 2004

>
>

-- AlexeyEfimov - 28 Mar 2004


 <<O>>  Difference Topic PlusLibraryTutorial (r1.1 - 10 Mar 2004 - AlexeyEfimov)
Added:
>
>

%META:TOPICINFO{author="AlexeyEfimov" date="1078877880" format="1.0" version="1.1"}% %META:TOPICPARENT{name="PlusPlugin"}%

Tutorial of extending PlusPlugin?


Writing PLUS services

PLUS have API to register and unregister services. But, better if you not write separate plugin with new services, and notify PLUS author to include services into it. So use services API only for testing and creating testing suite to post it to PLUS author. Services must be fully documented, must be light, must be minimal API and must be realy needed.

Defining your Service

You must extend Service interface and define all methods of your service:

public interface PluginDescriptorService extends Service {
  public PluginDescriptor getDescriptor(Class type) throws IOException, JDOMException;

  public void logInit(Class type);

  public void logDispose(Class type);
}

Follow implement it by local package class and extending from AbstractService:

class PluginDescriptorServiceImpl extends AbstractService implements PluginDescriptorService {
  private static final String SERVICE_NAME = "PluginDescriptor";

  public String getServiceName() {
    return SERVICE_NAME;
  }

  public PluginDescriptor getDescriptor(Class type) throws IOException, JDOMException {
    // ...
  }

  public void logInit(Class type) {
    // ..
  }

  public void logDispose(Class type) {
    // ..
  }

}

Thats all, now just define it in plugins.xml as ApplicationComponent:

  <!-- Application components of the plugin -->
  <application-components>
    <!-- PluginDescriptor service  -->
    <component>
      <interface-class>org.intellij.plus.services.PluginDescriptorService</interface-class>
      <implementation-class>org.intellij.plus.services.impl.PluginDescriptorServiceImpl</implementation-class>
    </component>
    
    <!-- ... -->
  </application-components>

-- AlexeyEfimov - 10 Mar 2004


View | Diffs | r1.5 | > | r1.4 | > | r1.3 | More

e d i t a t t a c h r e f - b y d i f f s
Ideas,requests,problems regarding this site? Send feedback.
Copyright @ 2000-2003 by the contribution authors. All material on this collaboration tool is the property of the contributing authors.

Revision r1.1 - 10 Mar 2004 - 00:18 GMT - AlexeyEfimov
Revision r1.5 - 27 Oct 2004 - 13:13 GMT - AlexeyEfimov
Copyright © 2001 by the contributing authors. All material on this collaboration tool is the property of the contributing authors.
Ideas, requests, problems regarding this site? Send feedback.