Skip to content
This repository has been archived by the owner on Apr 10, 2021. It is now read-only.

Plugin Development

Andre Greeff edited this page Jul 27, 2015 · 2 revisions

Plugin Development Notes

The snippets provided below should give some indication of how this plugin functions internally. If you notice any difference in code vs documentation in this regard, please open a new issue to report the inconsistency.

Read file attributes

import org.openide.filesystems.FileObject;

...

FileObject fo ...
Object value = fo.getAttribute("myKey");

if (value != null) {
  ...
}

Handle file locks

  DataObject dataObject = ...;
  FileObject fo = dataObject.getPrimaryFile();

  FileLock lock = FileLock.NONE;

  try {
    if (!fo.isLocked()) {
      BufferedOutputStream os = new BufferedOutputStream(fo.getOutputStream(lock));
      os.write("Hello World".getBytes("ASCII"));
      os.flush();
      os.close();
    }
  } catch (IOException ex) {
    Exceptions.printStackTrace(ex);
    return false;
  } finally {
    lock.releaseLock();
  }

Reformat code

Reformat reformat = Reformat.get(document);
reformat.lock();
reformat.reformat(0, document.getLength());
reformat.unlock();

Change preferences in Editor

Preferences codeStyle = CodeStylePreferences.get(file, file.getMIMEType()).getPreferences();
codeStyle.putInt(SimpleValueNames.INDENT_SHIFT_WIDTH, 2);
codeStyle.flush();

Plugin Release Procedure

Note: Private details such as the certificate file and keystore alias/password will not be provided publicly. The instructions related to plugin releases are intended only for official plugin developer reference.

  1. mvn release:cleanup
  2. mvn release:prepare -Dnbm.signing.keystore=<PATH_TO_CERT> -Dnbm.signing.keystorealias=<ALIAS> -Dnbm.signing.keystorepassword=<PASSWORD>
  3. mvn release:perform -Dnbm.signing.keystore=<PATH_TO_CERT> -Dnbm.signing.keystorealias=<ALIAS> -Dnbm.signing.keystorepassword=<PASSWORD>

If anything goes wrong: mvn release:rollback