001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.welcome.ui;
043:
044: import java.awt.BorderLayout;
045: import java.awt.GridBagConstraints;
046: import java.awt.GridBagLayout;
047: import java.awt.Insets;
048: import java.awt.event.ActionEvent;
049: import javax.swing.AbstractAction;
050: import javax.swing.BorderFactory;
051: import javax.swing.JLabel;
052: import javax.swing.JPanel;
053: import org.netbeans.modules.welcome.content.ActionButton;
054: import org.netbeans.modules.welcome.content.BundleSupport;
055: import org.openide.util.Exceptions;
056: import org.openide.util.Lookup;
057: import org.openide.util.actions.CallableSystemAction;
058:
059: /**
060: *
061: * @author S. Aubrecht
062: */
063: class PluginsPanel extends JPanel {
064:
065: public PluginsPanel() {
066: super (new BorderLayout());
067: setOpaque(false);
068: JPanel center = new JPanel(new GridBagLayout());
069: center.setOpaque(false);
070: JLabel lbl = new JLabel("<html>"
071: + BundleSupport.getLabel("PluginsContent")); //NOI18N
072: lbl.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
073:
074: center.add(lbl, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
075: GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
076: new Insets(0, 0, 15, 0), 0, 0));
077: center.add(new JLabel(), new GridBagConstraints(0, 1, 1, 1,
078: 1.0, 1.0, GridBagConstraints.CENTER,
079: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
080:
081: add(center, BorderLayout.CENTER);
082: JPanel bottom = new JPanel(new GridBagLayout());
083: bottom.setOpaque(false);
084:
085: bottom.add(new ActionButton(new ShowPluginManagerAction(),
086: false, null), new GridBagConstraints(1, 0, 1, 1, 0.0,
087: 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
088: new Insets(0, 0, 0, 0), 0, 0));
089:
090: bottom.add(new JLabel(), new GridBagConstraints(0, 0, 1, 1,
091: 1.0, 0.0, GridBagConstraints.WEST,
092: GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0),
093: 0, 0));
094:
095: // bottom.add( new JLabel(), new GridBagConstraints(2,0,1,1,1.0,0.0,GridBagConstraints.EAST,
096: // GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0) );
097: add(bottom, BorderLayout.SOUTH);
098: }
099:
100: private static class ShowPluginManagerAction extends AbstractAction {
101: public ShowPluginManagerAction() {
102: super (BundleSupport.getLabel("AddPlugins"));
103: }
104:
105: public void actionPerformed(ActionEvent e) {
106: try {
107: ClassLoader cl = Lookup.getDefault().lookup(
108: ClassLoader.class);
109: Class<CallableSystemAction> clz = (Class<CallableSystemAction>) cl
110: .loadClass("org.netbeans.modules.autoupdate.ui.actions.PluginManagerAction");
111: CallableSystemAction a = CallableSystemAction
112: .findObject(clz, true);
113: a.performAction();
114: } catch (Exception ex) {
115: Exceptions.printStackTrace(ex);
116: }
117: }
118:
119: }
120: }
|