Search |
||
NetBeans's JSF Palette Part IIPosted by edgars on January 12, 2007 at 10:24 AM PST
NetBeans platform is really cool, I´ve been creating some new items for JSP Palette, and maybe I publish this plugin in some place, even I know that NetBeans Team can do it much better than I. Although my newest palette items are working pretty well. And I can show you some additional tricks.
Some additional Tips to do New ItemsI created an abstract class called, AbstractPaletteComponent , and then it is the base class for any new Tag. This following souce listing shows you how this works:
import javax.swing.text.BadLocationException;
import javax.swing.text.JTextComponent;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.text.ActiveEditorDrop;
/**
* @author Edgar Silva
*/
abstract public class AbstractPaletteComponent implements ActiveEditorDrop {
final protected IdAndValueDialog tag = new IdAndValueDialog();
private String tagValue;
/** Creates a new instance of SelectOne */
public AbstractPaletteComponent() {
}
private String createBody() {
setTagValue(getPropsForTag());
String tag;
tag = getTagValue();
return tag;
}
public boolean handleTransfer(JTextComponent targetComponent) {
String body = createBody();
try {
FacesPaletteUtilities.insert(body, targetComponent);
} catch (BadLocationException ble) {
return false;
}
return true;
}
protected abstract String getPropsForTag();
public String getTagValue() {
return tagValue;
}
public void setTagValue(String tagValue) {
this.tagValue = tagValue;
}
public void showErrorMessage(String text) {
NotifyDescriptor.Message msg = new NotifyDescriptor.Message(text);
msg.setMessageType(NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notify(msg);
}
}
And now, create new items into palette is a really simple task. I created a new Item do generate the source of SelectItem, and this tags could be a lot of items, that´s why I created a new JPanel with JTable where I can to handle and manage the items. Look in the following images this new Component in action:
I hope you can enjoy this examples! »
Related Topics >>
Netbeans Comments
Comments are listed in date ascending order (oldest first)
|
||
|
|