Fix for 94695 and also consolidation of palette class. This adds two palette's to the tools menu to stay consistent with HTML and JSF palette. I have created a before tag for visualweb/jsfsupport and visualweb/designer called "designer_palette_mod" so we can do a quick revert if this becomes controversial. I will also create a "designer_palette_mod2" after this commit. designer_palette_mod2
authorJoelleLam
Tue, 07 Aug 2007 03:35:00 +0000
changeset 12358eeb8a4b7b09
parent 1234 cb677743833a
child 1236 f417da519540
Fix for 94695 and also consolidation of palette class. This adds two palette's to the tools menu to stay consistent with HTML and JSF palette. I have created a before tag for visualweb/jsfsupport and visualweb/designer called "designer_palette_mod" so we can do a quick revert if this becomes controversial. I will also create a "designer_palette_mod2" after this commit.
visualweb.designer.jsf/src/org/netbeans/modules/visualweb/designer/jsf/JsfForm.java
visualweb.designer.jsf/src/org/netbeans/modules/visualweb/designer/jsf/palette/Bundle.properties
visualweb.designer.jsf/src/org/netbeans/modules/visualweb/designer/jsf/palette/CreatorPaletteInsertAction.java
visualweb.designer.jsf/src/org/netbeans/modules/visualweb/designer/jsf/palette/JSF1_1PaletteCustomizerAction.java
visualweb.designer.jsf/src/org/netbeans/modules/visualweb/designer/jsf/palette/JSF1_2PaletteCustomizerAction.java
visualweb.designer.jsf/src/org/netbeans/modules/visualweb/designer/jsf/palette/JsfPaletteActions.java
visualweb.designer.jsf/src/org/netbeans/modules/visualweb/designer/jsf/palette/MergedPaletteActions.java
visualweb.designer.jsf/src/org/netbeans/modules/visualweb/designer/jsf/palette/PaletteControllerFactory.java
visualweb.jsfsupport.designtime_1_1/src/org/netbeans/modules/visualweb/jsfsupport/designtime_1_1/layer.xml
visualweb.jsfsupport.designtime_1_2/src/org/netbeans/modules/visualweb/jsfsupport/designtime_1_2/layer.xml
     1.1 --- a/visualweb.designer.jsf/src/org/netbeans/modules/visualweb/designer/jsf/JsfForm.java	Tue Aug 07 01:16:53 2007 +0000
     1.2 +++ b/visualweb.designer.jsf/src/org/netbeans/modules/visualweb/designer/jsf/JsfForm.java	Tue Aug 07 03:35:00 2007 +0000
     1.3 @@ -20,6 +20,7 @@
     1.4  package org.netbeans.modules.visualweb.designer.jsf;
     1.5  
     1.6  
     1.7 +import org.netbeans.modules.visualweb.designer.jsf.palette.PaletteControllerFactory;
     1.8  import org.netbeans.modules.visualweb.api.designer.Designer;
     1.9  import org.netbeans.modules.visualweb.api.designer.DesignerFactory;
    1.10  import org.netbeans.modules.visualweb.api.designer.DomProvider;
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/visualweb.designer.jsf/src/org/netbeans/modules/visualweb/designer/jsf/palette/Bundle.properties	Tue Aug 07 03:35:00 2007 +0000
     2.3 @@ -0,0 +1,2 @@
     2.4 +ACT_OpenJSF1_1Customizer=Visual Web JSF 1.&1 Components
     2.5 +ACT_OpenJSF1_2Customizer=Visual Web JSF 1.&2 Components
     2.6 \ No newline at end of file
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/visualweb.designer.jsf/src/org/netbeans/modules/visualweb/designer/jsf/palette/CreatorPaletteInsertAction.java	Tue Aug 07 03:35:00 2007 +0000
     3.3 @@ -0,0 +1,63 @@
     3.4 +/*
     3.5 + * The contents of this file are subject to the terms of the Common Development
     3.6 + * and Distribution License (the License). You may not use this file except in
     3.7 + * compliance with the License.
     3.8 + *
     3.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
    3.10 + * or http://www.netbeans.org/cddl.txt.
    3.11 + *
    3.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
    3.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
    3.14 + * If applicable, add the following below the CDDL Header, with the fields
    3.15 + * enclosed by brackets [] replaced by your own identifying information:
    3.16 + * "Portions Copyrighted [year] [name of copyright owner]"
    3.17 + *
    3.18 + * Portions Copyrighted 2007 Sun Microsystems, Inc.
    3.19 + */
    3.20 +package org.netbeans.modules.visualweb.designer.jsf.palette;
    3.21 +
    3.22 +import java.awt.datatransfer.DataFlavor;
    3.23 +import java.awt.datatransfer.Transferable;
    3.24 +import java.awt.event.ActionEvent;
    3.25 +import java.io.IOException;
    3.26 +import javax.swing.AbstractAction;
    3.27 +import org.netbeans.modules.visualweb.designer.jsf.DesignerServiceHackImpl;
    3.28 +import org.openide.nodes.Node;
    3.29 +import org.openide.util.Lookup;
    3.30 +
    3.31 +class CreatorPaletteInsertAction extends AbstractAction {
    3.32 +    
    3.33 +    private Lookup item;
    3.34 +    private Transferable itemTransfer;
    3.35 +    
    3.36 +    CreatorPaletteInsertAction(Lookup item) {
    3.37 +        this.item = item;
    3.38 +    }
    3.39 +    
    3.40 +    public void actionPerformed(ActionEvent e) {
    3.41 +        Node itemNode = item.lookup(Node.class);
    3.42 +        try {
    3.43 +            itemTransfer = itemNode.clipboardCopy();
    3.44 +        } catch (IOException ex) {
    3.45 +            ex.printStackTrace();
    3.46 +            return;
    3.47 +        }
    3.48 +        
    3.49 +        if (canDrop(itemTransfer)) {
    3.50 +            //                    DesignerServiceHackProviderImpl.drop(itemTransfer);
    3.51 +            DesignerServiceHackImpl.getDefault().drop(itemTransfer);
    3.52 +        }
    3.53 +    }
    3.54 +    
    3.55 +    private boolean canDrop( Transferable itemTransfer ){
    3.56 +        DataFlavor[] flavors = itemTransfer.getTransferDataFlavors();
    3.57 +        for (DataFlavor flavor : flavors){
    3.58 +            //                    if ( DesignerServiceHackProviderImpl.canDrop(flavors[i])){
    3.59 +            if (DesignerServiceHackImpl.getDefault().canDrop(flavor)) {
    3.60 +                return true;
    3.61 +            }
    3.62 +        }
    3.63 +        return false;
    3.64 +    }
    3.65 +}
    3.66 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/visualweb.designer.jsf/src/org/netbeans/modules/visualweb/designer/jsf/palette/JSF1_1PaletteCustomizerAction.java	Tue Aug 07 03:35:00 2007 +0000
     4.3 @@ -0,0 +1,62 @@
     4.4 +/*
     4.5 + * HTMLPaletteCustomizerAction.java
     4.6 + *
     4.7 + * Created on October 27, 2005, 10:49 AM
     4.8 + *
     4.9 + * To change this template, choose Tools | Options and locate the template under
    4.10 + * the Source Creation and Management node. Right-click the template and choose
    4.11 + * Open. You can then make changes to the template in the Source Editor.
    4.12 + */
    4.13 +
    4.14 +package org.netbeans.modules.visualweb.designer.jsf.palette;
    4.15 +
    4.16 +import java.io.IOException;
    4.17 +import java.util.logging.Level;
    4.18 +import java.util.logging.Logger;
    4.19 +import org.openide.util.HelpCtx;
    4.20 +import org.openide.util.NbBundle;
    4.21 +import org.openide.util.actions.CallableSystemAction;
    4.22 +
    4.23 +/**
    4.24 + *
    4.25 + * @author lk155162
    4.26 + */
    4.27 +public class JSF1_1PaletteCustomizerAction extends CallableSystemAction {
    4.28 +
    4.29 +    private static String name;
    4.30 +    
    4.31 +    public JSF1_1PaletteCustomizerAction () {
    4.32 +        putValue("noIconInMenu", Boolean.TRUE); // NOI18N
    4.33 +    }
    4.34 +
    4.35 +    protected boolean asynchronous() {
    4.36 +        return false;
    4.37 +    }
    4.38 +
    4.39 +    /** Human presentable name of the action. This should be
    4.40 +     * presented as an item in a menu.
    4.41 +     * @return the name of the action
    4.42 +     */
    4.43 +    public String getName() {
    4.44 +        if (name == null)
    4.45 +            name = NbBundle.getBundle(JSF1_1PaletteCustomizerAction.class).getString("ACT_OpenJSF1_1Customizer"); // NOI18N
    4.46 +        
    4.47 +        return name;
    4.48 +    }
    4.49 +
    4.50 +    /** Help context where to find more about the action.
    4.51 +     * @return the help context for this action
    4.52 +     */
    4.53 +    public HelpCtx getHelpCtx() {
    4.54 +        return null;
    4.55 +    }
    4.56 +
    4.57 +    /** This method is called by one of the "invokers" as a result of
    4.58 +     * some user's action that should lead to actual "performing" of the action.
    4.59 +     */
    4.60 +    public void performAction() {
    4.61 +            PaletteControllerFactory.getJsfPaletteController_1_4().showCustomizer();
    4.62 +
    4.63 +    }
    4.64 +
    4.65 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/visualweb.designer.jsf/src/org/netbeans/modules/visualweb/designer/jsf/palette/JSF1_2PaletteCustomizerAction.java	Tue Aug 07 03:35:00 2007 +0000
     5.3 @@ -0,0 +1,62 @@
     5.4 +/*
     5.5 + * HTMLPaletteCustomizerAction.java
     5.6 + *
     5.7 + * Created on October 27, 2005, 10:49 AM
     5.8 + *
     5.9 + * To change this template, choose Tools | Options and locate the template under
    5.10 + * the Source Creation and Management node. Right-click the template and choose
    5.11 + * Open. You can then make changes to the template in the Source Editor.
    5.12 + */
    5.13 +
    5.14 +package org.netbeans.modules.visualweb.designer.jsf.palette;
    5.15 +
    5.16 +import java.io.IOException;
    5.17 +import java.util.logging.Level;
    5.18 +import java.util.logging.Logger;
    5.19 +import org.openide.util.HelpCtx;
    5.20 +import org.openide.util.NbBundle;
    5.21 +import org.openide.util.actions.CallableSystemAction;
    5.22 +
    5.23 +/**
    5.24 + *
    5.25 + * @author lk155162
    5.26 + */
    5.27 +public class JSF1_2PaletteCustomizerAction extends CallableSystemAction {
    5.28 +
    5.29 +    private static String name;
    5.30 +    
    5.31 +    public JSF1_2PaletteCustomizerAction () {
    5.32 +        putValue("noIconInMenu", Boolean.TRUE); // NOI18N
    5.33 +    }
    5.34 +
    5.35 +    protected boolean asynchronous() {
    5.36 +        return false;
    5.37 +    }
    5.38 +
    5.39 +    /** Human presentable name of the action. This should be
    5.40 +     * presented as an item in a menu.
    5.41 +     * @return the name of the action
    5.42 +     */
    5.43 +    public String getName() {
    5.44 +        if (name == null)
    5.45 +            name = NbBundle.getBundle(JSF1_2PaletteCustomizerAction.class).getString("ACT_OpenJSF1_2Customizer"); // NOI18N
    5.46 +        
    5.47 +        return name;
    5.48 +    }
    5.49 +
    5.50 +    /** Help context where to find more about the action.
    5.51 +     * @return the help context for this action
    5.52 +     */
    5.53 +    public HelpCtx getHelpCtx() {
    5.54 +        return null;
    5.55 +    }
    5.56 +
    5.57 +    /** This method is called by one of the "invokers" as a result of
    5.58 +     * some user's action that should lead to actual "performing" of the action.
    5.59 +     */
    5.60 +    public void performAction() {
    5.61 +            PaletteControllerFactory.getJsfPaletteController_5().showCustomizer();
    5.62 +
    5.63 +    }
    5.64 +
    5.65 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/visualweb.designer.jsf/src/org/netbeans/modules/visualweb/designer/jsf/palette/JsfPaletteActions.java	Tue Aug 07 03:35:00 2007 +0000
     6.3 @@ -0,0 +1,63 @@
     6.4 +/*
     6.5 + * The contents of this file are subject to the terms of the Common Development
     6.6 + * and Distribution License (the License). You may not use this file except in
     6.7 + * compliance with the License.
     6.8 + *
     6.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
    6.10 + * or http://www.netbeans.org/cddl.txt.
    6.11 + *
    6.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
    6.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
    6.14 + * If applicable, add the following below the CDDL Header, with the fields
    6.15 + * enclosed by brackets [] replaced by your own identifying information:
    6.16 + * "Portions Copyrighted [year] [name of copyright owner]"
    6.17 + *
    6.18 + * Portions Copyrighted 2007 Sun Microsystems, Inc.
    6.19 + */
    6.20 +package org.netbeans.modules.visualweb.designer.jsf.palette;
    6.21 +
    6.22 +import javax.swing.Action;
    6.23 +import org.netbeans.spi.palette.PaletteActions;
    6.24 +import org.openide.util.Lookup;
    6.25 +
    6.26 +/**
    6.27 + *
    6.28 + * @author joelle
    6.29 + */
    6.30 +
    6.31 +// XXX Moved from designer/DesignerPaletteActions.
    6.32 +/**
    6.33 + * <code>PaletteActions</code> used by jsf palette controller.
    6.34 + *
    6.35 + * @author Joelle Lam
    6.36 + */
    6.37 +public class JsfPaletteActions extends PaletteActions {
    6.38 +
    6.39 +    String paletteFolderName;
    6.40 +
    6.41 +    /** Creates a new instance of FormPaletteProvider */
    6.42 +    public JsfPaletteActions(String paletteFolderName) {
    6.43 +        this.paletteFolderName = paletteFolderName;
    6.44 +    }
    6.45 +
    6.46 +    public Action[] getImportActions() {
    6.47 +        return new Action[]{};
    6.48 +    }
    6.49 +
    6.50 +    public Action[] getCustomCategoryActions(Lookup category) {
    6.51 +        return new Action[0]; //TODO implement this
    6.52 +    }
    6.53 +
    6.54 +    public Action[] getCustomItemActions(Lookup item) {
    6.55 +        return new Action[0]; //TODO implement this
    6.56 +    }
    6.57 +
    6.58 +    public Action[] getCustomPaletteActions() {
    6.59 +        return new Action[0]; //TODO implement this
    6.60 +    }
    6.61 +
    6.62 +    public Action getPreferredAction(Lookup item) {
    6.63 +        //This is the double click action.
    6.64 +        return new CreatorPaletteInsertAction(item);
    6.65 +    }
    6.66 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/visualweb.designer.jsf/src/org/netbeans/modules/visualweb/designer/jsf/palette/MergedPaletteActions.java	Tue Aug 07 03:35:00 2007 +0000
     7.3 @@ -0,0 +1,84 @@
     7.4 +/*
     7.5 + * The contents of this file are subject to the terms of the Common Development
     7.6 + * and Distribution License (the License). You may not use this file except in
     7.7 + * compliance with the License.
     7.8 + * 
     7.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
    7.10 + * or http://www.netbeans.org/cddl.txt.
    7.11 + * 
    7.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
    7.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
    7.14 + * If applicable, add the following below the CDDL Header, with the fields
    7.15 + * enclosed by brackets [] replaced by your own identifying information:
    7.16 + * "Portions Copyrighted [year] [name of copyright owner]"
    7.17 + * 
    7.18 + * Portions Copyrighted 2007 Sun Microsystems, Inc.
    7.19 + */
    7.20 +package org.netbeans.modules.visualweb.designer.jsf.palette;
    7.21 +
    7.22 +import javax.swing.Action;
    7.23 +import org.netbeans.spi.palette.PaletteActions;
    7.24 +import org.openide.util.Lookup;
    7.25 +
    7.26 +public class MergedPaletteActions extends PaletteActions {
    7.27 +
    7.28 +        private PaletteActions palActions1;
    7.29 +
    7.30 +        private PaletteActions palActions2;
    7.31 +
    7.32 +        public MergedPaletteActions(PaletteActions palActions1,
    7.33 +                PaletteActions palActions2) {
    7.34 +            this.palActions1 = palActions1;
    7.35 +            this.palActions2 = palActions2;
    7.36 +        }
    7.37 +
    7.38 +        @Override
    7.39 +        public Action[] getCustomCategoryActions(Lookup category) {
    7.40 +            Action[] actions1 = palActions1.getCustomCategoryActions(category);
    7.41 +            Action[] actions2 = palActions2.getCustomCategoryActions(category);
    7.42 +            return mergeActions(actions1, actions2);
    7.43 +        }
    7.44 +
    7.45 +        @Override
    7.46 +        public Action[] getCustomItemActions(Lookup item) {
    7.47 +            Action[] actions1 = palActions1.getCustomItemActions(item);
    7.48 +            Action[] actions2 = palActions2.getCustomItemActions(item);
    7.49 +            return mergeActions(actions1, actions2);
    7.50 +        }
    7.51 +
    7.52 +        @Override
    7.53 +        public Action[] getCustomPaletteActions() {
    7.54 +            Action[] actions1 = palActions1.getCustomPaletteActions();
    7.55 +            Action[] actions2 = palActions2.getCustomPaletteActions();
    7.56 +            return mergeActions(actions1, actions2);
    7.57 +        }
    7.58 +
    7.59 +        @Override
    7.60 +        public Action[] getImportActions() {
    7.61 +            Action[] actions1 = palActions1.getImportActions();
    7.62 +            Action[] actions2 = palActions2.getImportActions();
    7.63 +            return mergeActions(actions1, actions2);
    7.64 +        }
    7.65 +
    7.66 +        @Override
    7.67 +        public Action getPreferredAction(Lookup item) {
    7.68 +            // Choose the preferred action from the first PaletteActions
    7.69 +            return palActions1.getPreferredAction(item);
    7.70 +        }
    7.71 +
    7.72 +        private static Action[] mergeActions(Action[] actions1,
    7.73 +            Action[] actions2) {
    7.74 +            if (actions2 == null) {
    7.75 +                return actions1;
    7.76 +            }
    7.77 +            if (actions1 == null) {
    7.78 +                return actions2;
    7.79 +            }
    7.80 +
    7.81 +            Action[] allActions = new Action[actions1.length + actions2.length];
    7.82 +            System.arraycopy(actions1, 0, allActions, 0, actions1.length);
    7.83 +            System.arraycopy(actions2, 0, allActions, actions1.length,
    7.84 +                    actions2.length);
    7.85 +            return allActions;
    7.86 +        }
    7.87 +    }
    7.88 \ No newline at end of file
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/visualweb.designer.jsf/src/org/netbeans/modules/visualweb/designer/jsf/palette/PaletteControllerFactory.java	Tue Aug 07 03:35:00 2007 +0000
     8.3 @@ -0,0 +1,205 @@
     8.4 +/*
     8.5 + * The contents of this file are subject to the terms of the Common Development
     8.6 + * and Distribution License (the License). You may not use this file except in
     8.7 + * compliance with the License.
     8.8 + *
     8.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
    8.10 + * or http://www.netbeans.org/cddl.txt.
    8.11 + *
    8.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
    8.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
    8.14 + * If applicable, add the following below the CDDL Header, with the fields
    8.15 + * enclosed by brackets [] replaced by your own identifying information:
    8.16 + * "Portions Copyrighted [year] [name of copyright owner]"
    8.17 + *
    8.18 + * The Original Software is NetBeans. The Initial Developer of the Original
    8.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
    8.20 + * Microsystems, Inc. All Rights Reserved.
    8.21 + */
    8.22 +
    8.23 +package org.netbeans.modules.visualweb.designer.jsf.palette;
    8.24 +
    8.25 +import org.netbeans.modules.visualweb.api.complib.ComplibEvent;
    8.26 +import org.netbeans.modules.visualweb.api.complib.ComplibListener;
    8.27 +import org.netbeans.modules.visualweb.api.complib.ComplibService;
    8.28 +import org.netbeans.modules.visualweb.project.jsf.api.JsfProjectUtils;
    8.29 +import java.io.IOException;
    8.30 +import java.lang.ref.WeakReference;
    8.31 +import org.netbeans.api.project.Project;
    8.32 +import org.netbeans.modules.visualweb.designer.jsf.palette.JsfPaletteActions;
    8.33 +import org.netbeans.modules.visualweb.designer.jsf.palette.MergedPaletteActions;
    8.34 +import org.netbeans.spi.palette.PaletteActions;
    8.35 +import org.netbeans.spi.palette.PaletteController;
    8.36 +import org.netbeans.spi.palette.PaletteFactory;
    8.37 +import org.netbeans.spi.palette.PaletteFilter;
    8.38 +import org.openide.ErrorManager;
    8.39 +import org.openide.util.Exceptions;
    8.40 +import org.openide.util.Lookup;
    8.41 +
    8.42 +/**
    8.43 + * Factory for creating JSF <code>PaletteController</code>.
    8.44 + *
    8.45 + * @author Peter Zavadsky
    8.46 + */
    8.47 +public final class PaletteControllerFactory {
    8.48 +
    8.49 +
    8.50 +    private static final String PALETTE_DIRECTORY_1_4 = "CreatorDesignerPalette"; // NOI18N
    8.51 +
    8.52 +    private static final String PALETTE_DIRECTORY_5   = "CreatorDesignerPalette5"; // NOI18N
    8.53 +
    8.54 +    private static final PaletteControllerFactory INSTANCE = new PaletteControllerFactory();
    8.55 +
    8.56 +
    8.57 +    /** Creates a new instance of JsfPaletteControllerFactory */
    8.58 +    private PaletteControllerFactory() {
    8.59 +    }
    8.60 +
    8.61 +
    8.62 +    public static PaletteControllerFactory getDefault() {
    8.63 +        return INSTANCE;
    8.64 +    }
    8.65 +    
    8.66 +    /**
    8.67 +     * The sole purpose of this method is to grab the controller 
    8.68 +     * for to get the palette customizer (palette manager) for 
    8.69 +     * J2EE 5 projects. 
    8.70 +     **/
    8.71 +    public static PaletteController getJsfPaletteController_5(){
    8.72 +        return getJsfPaletteController(PALETTE_DIRECTORY_5);
    8.73 +    }
    8.74 +    
    8.75 +    /**
    8.76 +     * The sole purpose of this method is to grab the controller 
    8.77 +     * for to get the palette customizer (palette manager) for 
    8.78 +     * J2EE 1.4 projects. 
    8.79 +     **/
    8.80 +    public static PaletteController getJsfPaletteController_1_4(){
    8.81 +        return getJsfPaletteController(PALETTE_DIRECTORY_1_4);
    8.82 +    }
    8.83 +    
    8.84 +    
    8.85 +    /**
    8.86 +     * Only to be used by "getJsfPaletteController_1_4()" and "getJsfPaletteController_5()"
    8.87 +     * @param paletteDirectory can either be "CreatorDesignerPalette" or "CreatorDesignerPalette5"
    8.88 +     **/
    8.89 +    private static PaletteController getJsfPaletteController(String paletteDirectory ){
    8.90 +        try {
    8.91 +            PaletteActions paletteActions = new JsfPaletteActions(paletteDirectory);
    8.92 +            PaletteController controller = PaletteFactory.createPalette(paletteDirectory, paletteActions, null, null);
    8.93 +            return controller;
    8.94 +        } catch (IOException ex) {
    8.95 +            Exceptions.printStackTrace(ex);
    8.96 +            return null;
    8.97 +        }
    8.98 +
    8.99 +    }
   8.100 +
   8.101 +    public PaletteController createJsfPaletteController(Project project) {
   8.102 +        if (project == null) {
   8.103 +            // XXX
   8.104 +            return null;
   8.105 +        }
   8.106 +
   8.107 +        String paletteDirectory;
   8.108 +        if (JsfProjectUtils.JAVA_EE_5.equals(JsfProjectUtils.getJ2eePlatformVersion(project))) {
   8.109 +            paletteDirectory = PALETTE_DIRECTORY_5;
   8.110 +        } else {
   8.111 +            //Later to be renamed with a 1.4
   8.112 +            paletteDirectory = PALETTE_DIRECTORY_1_4;
   8.113 +        }
   8.114 +
   8.115 +        // XXX PaletteController
   8.116 +        PaletteController controller;
   8.117 +        try {
   8.118 +            ComplibService complibService = getComplibService();
   8.119 +            PaletteFilter complibPaletteFilter;
   8.120 +            PaletteActions allPaletteActions;
   8.121 +            if (complibService == null) {
   8.122 +                ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL,
   8.123 +                        new NullPointerException("There is no ComplibService available!")); // NOI18N
   8.124 +                complibPaletteFilter = null;
   8.125 +                allPaletteActions = null;
   8.126 +            } else {
   8.127 +                complibPaletteFilter = complibService.createComplibPaletteFilter(project);
   8.128 +
   8.129 +                // Merge in complib PaletteActions
   8.130 +                PaletteActions jsfPaletteActions = new JsfPaletteActions(paletteDirectory);
   8.131 +                PaletteActions complibPaletteActions = complibService.createComplibPaletteActions();
   8.132 +                if (complibPaletteActions != null) {
   8.133 +                    allPaletteActions = new MergedPaletteActions(jsfPaletteActions, complibPaletteActions);
   8.134 +                } else {
   8.135 +                    allPaletteActions = jsfPaletteActions;
   8.136 +                }
   8.137 +            }
   8.138 +
   8.139 +            controller = PaletteFactory.createPalette(paletteDirectory,
   8.140 +                    allPaletteActions, complibPaletteFilter, null);
   8.141 +
   8.142 +            // XXX #6466711 Listening to changes of complib to refresh the palette.
   8.143 +            JsfComplibListener.getDefault().install();
   8.144 +            JsfComplibListener.getDefault().setPaletteController(controller);
   8.145 +
   8.146 +            return controller;
   8.147 +        } catch (IOException ex) {
   8.148 +            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
   8.149 +            controller = null;
   8.150 +        }
   8.151 +
   8.152 +        return controller;
   8.153 +    }
   8.154 +
   8.155 +    private static ComplibService getComplibService() {
   8.156 +        return Lookup.getDefault().lookup(ComplibService.class);
   8.157 +    }
   8.158 +
   8.159 +
   8.160 +    private static class JsfComplibListener implements ComplibListener {
   8.161 +        private static JsfComplibListener INSTANCE = new JsfComplibListener();
   8.162 +
   8.163 +        private WeakReference<PaletteController> paletteControllerWRef = new WeakReference<PaletteController>(null);
   8.164 +        
   8.165 +        private boolean installed;
   8.166 +        
   8.167 +        public static JsfComplibListener getDefault() {
   8.168 +            return INSTANCE;
   8.169 +        }
   8.170 +        
   8.171 +        public void install() {
   8.172 +            if (installed) {
   8.173 +                return;
   8.174 +            }
   8.175 +            ComplibService complibService = getComplibService();
   8.176 +            if (complibService == null) {
   8.177 +                return;
   8.178 +            }
   8.179 +            complibService.addComplibListener(this);
   8.180 +            installed = true;
   8.181 +        }
   8.182 +        
   8.183 +        public void uninstall() {
   8.184 +            ComplibService complibService = getComplibService();
   8.185 +            if (complibService == null) {
   8.186 +                return;
   8.187 +            }
   8.188 +            complibService.removeComplibListener(this);
   8.189 +            installed = false;
   8.190 +        }
   8.191 +        
   8.192 +        public void setPaletteController(PaletteController paletteController) {
   8.193 +            paletteControllerWRef = new WeakReference<PaletteController>(paletteController);
   8.194 +        }
   8.195 +        
   8.196 +        public void paletteChanged(ComplibEvent evt) {
   8.197 +            PaletteController paletteController = paletteControllerWRef.get();
   8.198 +            if (paletteController == null) {
   8.199 +                return;
   8.200 +            }
   8.201 +            paletteController.refresh();
   8.202 +        }
   8.203 +    } // End of JsfComplibListener        
   8.204 +        
   8.205 +
   8.206 +
   8.207 +
   8.208 +}
     9.1 --- a/visualweb.jsfsupport.designtime_1_1/src/org/netbeans/modules/visualweb/jsfsupport/designtime_1_1/layer.xml	Tue Aug 07 01:16:53 2007 +0000
     9.2 +++ b/visualweb.jsfsupport.designtime_1_1/src/org/netbeans/modules/visualweb/jsfsupport/designtime_1_1/layer.xml	Tue Aug 07 03:35:00 2007 +0000
     9.3 @@ -102,4 +102,12 @@
     9.4              </file>
     9.5          </folder>
     9.6      </folder>
     9.7 +    
     9.8 +    <folder name="Menu">
     9.9 +        <folder name="Tools">
    9.10 +            <folder name="PaletteManager">
    9.11 +                <file name="org-netbeans-modules-visualweb-designer-jsf-palette-JSF1_1PaletteCustomizerAction.instance"/>
    9.12 +            </folder>
    9.13 +        </folder>
    9.14 +    </folder>
    9.15  </filesystem>
    10.1 --- a/visualweb.jsfsupport.designtime_1_2/src/org/netbeans/modules/visualweb/jsfsupport/designtime_1_2/layer.xml	Tue Aug 07 01:16:53 2007 +0000
    10.2 +++ b/visualweb.jsfsupport.designtime_1_2/src/org/netbeans/modules/visualweb/jsfsupport/designtime_1_2/layer.xml	Tue Aug 07 03:35:00 2007 +0000
    10.3 @@ -92,4 +92,11 @@
    10.4          </folder>
    10.5      </folder>
    10.6      
    10.7 +    <folder name="Menu">
    10.8 +        <folder name="Tools">
    10.9 +            <folder name="PaletteManager">
   10.10 +                <file name="org-netbeans-modules-visualweb-designer-jsf-palette-JSF1_2PaletteCustomizerAction.instance"/>
   10.11 +            </folder>
   10.12 +        </folder>
   10.13 +    </folder>
   10.14  </filesystem>