The Source for Java Technology Collaboration
User: Password:



Edgar Silva

Edgar Silva's Blog

NetBeans's JSF Palette Part II

Posted by edgars on January 12, 2007 at 10:24 AM | Comments (3)

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 Items

I 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:


Drag and Drop the Component from Palette to the source:
11.JPG
Code Generated:
12.JPG

I hope you can enjoy this examples!


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • This looks greats, and I am looking for the NBM. Do you have it somewhere, or would you like to contribute it in NetBeans contrib area?

    Ludo

    Posted by: ludo on January 13, 2007 at 08:47 AM

  • Hi Ludo, as sooner as I put more components I will do that, I am planning to put on NetBeans Contrib this next week! I hope you and others can enjoy it ...
    Cya

    Edgar

    Posted by: edgars on January 13, 2007 at 01:16 PM

  • I'm so grateful for all that you've done. Thanks again for that nice essay and I would be most grateful if you would send me the latter ones....


    mirc
    mırc
    mirç
    mırç
    mirc indir
    chat yap
    islami sohbet
    dini sohbet
    kelebek
    kelebek sohbet
    kelebek mirc
    kameralı mirc
    kameralı sohbet
    chat yap
    çet
    çet odaları
    sohbet kanalları
    sohbet odaları
    yarışma
    sevgili
    arkadaş
    arkadaş ara
    arkadaşlık

    Posted by: jklmno on June 19, 2008 at 09:12 AM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds