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-2006 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: /*
043: * CyclicDepenedcyWarningPanel.java
044: *
045: * Created on 20. kveten 2004, 11:48
046: */
047: package org.netbeans.modules.mobility.project.ui;
048:
049: import java.awt.Dialog;
050: import java.awt.event.WindowAdapter;
051: import java.awt.event.WindowEvent;
052: import javax.swing.DefaultListModel;
053: import javax.swing.JPanel;
054: import javax.swing.SwingUtilities;
055: import org.openide.DialogDescriptor;
056: import org.openide.DialogDisplayer;
057: import org.openide.NotifyDescriptor;
058: import org.openide.util.HelpCtx;
059: import org.openide.util.NbBundle;
060:
061: /**
062: *
063: * @author Adam
064: */
065: public class CyclicDependencyWarningPanel extends JPanel implements
066: Runnable {
067:
068: private static CyclicDependencyWarningPanel panel;
069: private final DefaultListModel model;
070:
071: protected Dialog d = null;
072: protected final CloseListener listener;
073: protected static boolean dontShow = false;
074:
075: public static void showWarning(final String projectName) {
076: synchronized (CyclicDependencyWarningPanel.class) {
077: if (dontShow)
078: return;
079: if (panel == null)
080: panel = new CyclicDependencyWarningPanel();
081: if (!panel.model.contains(projectName))
082: panel.model.addElement(projectName);
083: SwingUtilities.invokeLater(panel);
084: }
085: }
086:
087: /** Creates new form CyclicDepenedcyWarningPanel */
088: private CyclicDependencyWarningPanel() {
089: model = new DefaultListModel();
090: listener = new CloseListener();
091: initComponents();
092: initAccessibility();
093: jList1.setModel(model);
094: }
095:
096: public void run() {
097: synchronized (CyclicDependencyWarningPanel.class) {
098: if (d == null) {
099: d = DialogDisplayer
100: .getDefault()
101: .createDialog(
102: new DialogDescriptor(
103: this ,
104: NbBundle
105: .getMessage(
106: CyclicDependencyWarningPanel.class,
107: "Title_CycDep"),
108: false, //NOI18N
109: new Object[] { NotifyDescriptor.OK_OPTION },
110: NotifyDescriptor.OK_OPTION,
111: DialogDescriptor.DEFAULT_ALIGN,
112: new HelpCtx(
113: CyclicDependencyWarningPanel.class),
114: null));
115: d.addWindowListener(listener);
116: }
117: d.setVisible(true);
118: }
119: }
120:
121: /** This method is called from within the constructor to
122: * initialize the form.
123: * WARNING: Do NOT modify this code. The content of this method is
124: * always regenerated by the Form Editor.
125: */
126: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
127: private void initComponents() {
128: java.awt.GridBagConstraints gridBagConstraints;
129:
130: jLabel2 = new javax.swing.JLabel();
131: jLabel1 = new javax.swing.JLabel();
132: jScrollPane1 = new javax.swing.JScrollPane();
133: jList1 = new javax.swing.JList();
134: jCheckBox1 = new javax.swing.JCheckBox();
135:
136: setLayout(new java.awt.GridBagLayout());
137:
138: org.openide.awt.Mnemonics.setLocalizedText(jLabel2, NbBundle
139: .getMessage(CyclicDependencyWarningPanel.class,
140: "LBL_CyclicDependencies")); // NOI18N
141: gridBagConstraints = new java.awt.GridBagConstraints();
142: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
143: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
144: gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12);
145: add(jLabel2, gridBagConstraints);
146:
147: jLabel1.setLabelFor(jList1);
148: org.openide.awt.Mnemonics.setLocalizedText(jLabel1, NbBundle
149: .getMessage(CyclicDependencyWarningPanel.class,
150: "LBL_CycDeps_Projects")); // NOI18N
151: gridBagConstraints = new java.awt.GridBagConstraints();
152: gridBagConstraints.gridx = 0;
153: gridBagConstraints.gridy = 1;
154: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
155: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
156: gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12);
157: add(jLabel1, gridBagConstraints);
158:
159: jList1.setBackground(javax.swing.UIManager.getDefaults()
160: .getColor("Panel.background"));
161: jScrollPane1.setViewportView(jList1);
162:
163: gridBagConstraints = new java.awt.GridBagConstraints();
164: gridBagConstraints.gridx = 0;
165: gridBagConstraints.gridy = 2;
166: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
167: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
168: gridBagConstraints.weightx = 1.0;
169: gridBagConstraints.weighty = 1.0;
170: gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 12);
171: add(jScrollPane1, gridBagConstraints);
172:
173: org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1, NbBundle
174: .getMessage(CyclicDependencyWarningPanel.class,
175: "LBL_CycDeps_DoNotAgain")); // NOI18N
176: gridBagConstraints = new java.awt.GridBagConstraints();
177: gridBagConstraints.gridx = 0;
178: gridBagConstraints.gridy = 3;
179: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
180: gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
181: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
182: gridBagConstraints.insets = new java.awt.Insets(12, 12, 12, 12);
183: add(jCheckBox1, gridBagConstraints);
184: }// </editor-fold>//GEN-END:initComponents
185:
186: private void initAccessibility() {
187: getAccessibleContext().setAccessibleName(
188: (NbBundle.getMessage(
189: CyclicDependencyWarningPanel.class,
190: "ACSN_CycDep")));
191: getAccessibleContext().setAccessibleDescription(
192: (NbBundle.getMessage(
193: CyclicDependencyWarningPanel.class,
194: "ACSD_CycDep")));
195: }
196:
197: // Variables declaration - do not modify//GEN-BEGIN:variables
198: private javax.swing.JCheckBox jCheckBox1;
199: private javax.swing.JLabel jLabel1;
200: private javax.swing.JLabel jLabel2;
201: private javax.swing.JList jList1;
202: private javax.swing.JScrollPane jScrollPane1;
203:
204: // End of variables declaration//GEN-END:variables
205:
206: private class CloseListener extends WindowAdapter {
207: private CloseListener() {
208: //Just to avoid creation of accessor class
209: }
210:
211: @SuppressWarnings("synthetic-access")
212: public void windowClosed(@SuppressWarnings("unused")
213: final WindowEvent e) {
214: synchronized (CyclicDependencyWarningPanel.class) {
215: dontShow = jCheckBox1.isSelected();
216: d.removeWindowListener(listener);
217: d = null;
218: }
219: }
220: }
221: }
|