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: package org.netbeans.modules.visualweb.propertyeditors.css;
042:
043: import java.awt.BorderLayout;
044: import java.awt.event.ActionEvent;
045: import java.awt.event.ActionListener;
046: import java.beans.PropertyChangeEvent;
047: import java.beans.PropertyChangeListener;
048: import javax.swing.JDialog;
049: import javax.swing.JPanel;
050: import javax.swing.UIManager;
051: import org.openide.DialogDescriptor;
052: import org.openide.DialogDisplayer;
053:
054: /**
055: * Main Style Builder Dialog
056: * @author Winston Prakash
057: */
058: public class StyleBuilderDialog extends JPanel implements
059: PropertyChangeListener {
060: DialogDescriptor dlg = null;
061: JDialog dialog = null;
062:
063: /** Creates new form StyleBuilder */
064: public StyleBuilderDialog() {
065: initComponents();
066: String cssStyleString = "font-family:'Arial', 'Times New Roman', 'sans-serif'";
067: StyleBuilderPanel styleBuilderPanel = new StyleBuilderPanel(
068: cssStyleString);
069: styleBuilderPanel.addCssPropertyChangeListener(this );
070: add(styleBuilderPanel, BorderLayout.CENTER);
071: }
072:
073: public void propertyChange(PropertyChangeEvent evt) {
074: System.out.println(evt.getNewValue());
075: }
076:
077: public void showDialog() {
078: // Add a listener to the dialog's buttons
079: ActionListener listener = new ActionListener() {
080: public void actionPerformed(ActionEvent evt) {
081: Object o = evt.getSource();
082:
083: Object[] option = dlg.getOptions();
084:
085: if (o == option[1]) {
086: System.exit(0);
087: } else if (o == option[0]) {
088: System.out.println("Dialog closed"); //NOI18N
089: System.exit(0);
090: }
091: }
092: };
093: dlg = new DialogDescriptor(this , "Style Builder", true,
094: listener); //NOI18N
095: dlg.setOptions(new Object[] { "Ok", "Cancel" }); //NOI18N
096: dlg.setClosingOptions(new Object[] { "Cancel" }); //NOI18N
097: dlg.setValid(false);
098: // when help is written, correct the helpID here...
099: // dlg.setHelpCtx(new HelpCtx("projrave_ui_elements_project_nav_data_source_ref")); // NOI18N
100:
101: dialog = (JDialog) DialogDisplayer.getDefault().createDialog(
102: dlg);
103: //dialog.setResizable(false);
104: dialog.addWindowListener(new java.awt.event.WindowAdapter() {
105: public void windowClosed(java.awt.event.WindowEvent evt) {
106: System.exit(0);
107: }
108: });
109: dialog.pack();
110: dialog.show();
111: }
112:
113: private void initComponents() {//GEN-BEGIN:initComponents
114:
115: setLayout(new java.awt.BorderLayout());
116:
117: }//GEN-END:initComponents
118:
119: /**
120: * @param args the command line arguments
121: */
122: public static void main(String args[]) {
123: java.awt.EventQueue.invokeLater(new Runnable() {
124: public void run() {
125: try {
126: UIManager
127: .setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); //NOI18N
128: } catch (Exception e) {
129: }
130: new StyleBuilderDialog().showDialog();
131: }
132: });
133: }
134:
135: // Variables declaration - do not modify//GEN-BEGIN:variables
136: // End of variables declaration//GEN-END:variables
137:
138: }
|