Download NetBeans!

20080331 Monday March 31, 2008

OpenOffice.org... has its own Plugin Portal!

The OpenOffice.org developers of the NetBeans plugin for OpenOffice.org are in Prague today. I attended an interesting presentation where they demoed their plugin this morning. One of several things I learned about was their very cool Extensions site:

http://extensions.services.openoffice.org/

Unfortunately, however, you cannot see (currently) from inside OpenOffice.org which extensions are available. On the other hand, this is a feature that NetBeans IDE 6.1 Beta does have support for (at least, on my machine, thanks to a plugin I created) because I integrated their various application-specific extension feeds into the IDE's toolbar:

When I get some time, I will try to create an OpenOffice.org Add-On (using the NetBeans/OpenOffice.org plugin) which will attempt to do the same thing from within OpenOffice.org.

Here's the relevant code in the JPanel, which I added to the toolbar via CallableSystemAction.getToolbarPresenter:

public class OOExtensionsPanel extends javax.swing.JPanel {

    DefaultComboBoxModel model = new DefaultComboBoxModel();

    /** Creates new form OOExtensionsPanel */
    public OOExtensionsPanel() {
        initComponents();
        //appList is the list of OpenOffice.org applications:
        appList.addActionListener(new AppListListener());
        //extList is the list of OpenOffice.org extensions:
        extList.setModel(model);
    }

    private class AppListListener implements ActionListener {

        public void actionPerformed(ActionEvent ev) {

            model.removeAllElements();

            BufferedReader in = null;
            
            try {

                //InputOutput io = IOProvider.getDefault().getIO("OpenOffice Extensions", true);
                JComboBox box = (JComboBox) ev.getSource();
                String selectedApp = box.getSelectedItem().toString();

                URL url = null;
                if (selectedApp.equals("Writer")) {
                    url = new URL("http://extensions.services.openoffice.org/taxonomy/term/2/0/feed");
                } else if (selectedApp.equals("Calc")) {
                    url = new URL("http://extensions.services.openoffice.org/taxonomy/term/1/0/feed");
                } else if (selectedApp.equals("Draw")) {
                    url = new URL("http://extensions.services.openoffice.org/taxonomy/term/4/0/feed");
                } else if (selectedApp.equals("Impress")) {
                    url = new URL("http://extensions.services.openoffice.org/taxonomy/term/3/0/feed");
                } else if (selectedApp.equals("Chart")) {
                    url = new URL("http://extensions.services.openoffice.org/taxonomy/term/21/0/feed");
                }

                in = new BufferedReader(new InputStreamReader(url.openStream()));
                InputSource source = new InputSource(in);
                org.w3c.dom.Document doc = XMLUtil.parse(source, false, false, null, null);
                org.w3c.dom.NodeList list = doc.getElementsByTagName("*");
                int length = list.getLength();
                //io.select();

                for (int i = 0; i < length; i++) {
                    org.w3c.dom.Node mainNode = list.item(i);
                    String nodeName = mainNode.getNodeName();
                    String value = mainNode.getTextContent();
                    if (nodeName.equals("title")) {
                        //io.getOut().println("Extension: " + value);
                        model.addElement(value);
                    }
                }
            //io.getOut().close();

            } catch (SAXException ex) {
                Exceptions.printStackTrace(ex);
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            } finally {
                try {
                    in.close();
                } catch (IOException ex) {
                    Exceptions.printStackTrace(ex);
                }
            }
        }
    }
...
...
...

Today on NetBeans Zone. Overview of NetBeans Java API Samples in Plugin Portal.

Mar 31 2008, 04:49:37 AM PDT Permalink

Trackback URL: http://blogs.sun.com/geertjan/entry/openoffice_has_its_own_plugin
Comments:

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed