Saturday, November 18, 2006

Netbeans Module Development

Netbeans Module Development - 1

Date: 18 Nov' 2006

This example adds "Export Sources" menu item to File Menu in the IDE. Onclicking it displays a message box and creates an output tab and writes into in.

Requires:

Dialogs API, I/O API, Utilities API


package org.deb.exportmodule;

import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.actions.CallableSystemAction;
import org.openide.windows.IOProvider;
import org.openide.windows.InputOutput;
import org.openide.windows.OutputWriter;

public final class ExportFiles extends CallableSystemAction
{

public void performAction()
{
InputOutput io = IOProvider.getDefault().getIO("Hello", true);
NotifyDescriptor d = new NotifyDescriptor.Message("I am plugged in!", NotifyDescriptor.INFORMATION_MESSAGE);
DialogDisplayer.getDefault().notify(d);
io.getOut().println("Hello from standard out");
io.getErr().println("Hello from standard err"); //this text should appear in red
io.getOut().close();
io.getErr().close();
}

public String getName()
{
return NbBundle.getMessage(ExportFiles.class, "CTL_ExportFiles");
}

protected void initialize()
{
super.initialize();
// see org.openide.util.actions.SystemAction.iconResource() javadoc for more details
putValue("noIconInMenu", Boolean.TRUE);
}

public HelpCtx getHelpCtx()
{
return HelpCtx.DEFAULT_HELP;
}

protected boolean asynchronous()
{
return true;
}

}















No comments: