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.xml.schema.abe.wizard;
043:
044: import org.openide.*;
045: import org.openide.util.*;
046: import org.openide.windows.*;
047: import java.awt.*;
048: import java.awt.Dialog;
049:
050: /**
051: *
052: * @author Ayub Khan
053: */
054: public class SchemaTransformProgressPanel extends javax.swing.JPanel {
055: private static final long serialVersionUID = -483941387931729295L;
056: // Variables declaration - do not modify
057: private javax.swing.JLabel jLabel1;
058: private javax.swing.JProgressBar progressBar;
059:
060: private Dialog dialog;
061:
062: /**
063: *
064: *
065: */
066: public SchemaTransformProgressPanel() {
067: super ();
068: initComponents();
069: }
070:
071: /**
072: *
073: *
074: */
075: public DialogDescriptor createDialog(String message) {
076: SchemaTransformProgressPanel panel = new SchemaTransformProgressPanel();
077: DialogDescriptor descriptor = new DialogDescriptor(panel,
078: NbBundle.getMessage(SchemaTransformProgressPanel.class,
079: "MSG_SchemaTransform_ProgressPanel",
080: new Object[] { message })); // NOI18N
081:
082: final Object[] OPTIONS = new Object[0];
083: descriptor.setOptions(OPTIONS);
084: descriptor.setClosingOptions(OPTIONS);
085: descriptor.setModal(true);
086: descriptor.setOptionsAlign(DialogDescriptor.BOTTOM_ALIGN);
087:
088: dialog = DialogDisplayer.getDefault().createDialog(descriptor);
089:
090: Frame mainWindow = WindowManager.getDefault().getMainWindow();
091: int windowX = mainWindow.getX();
092: int windowY = mainWindow.getY();
093: int windowWidth = mainWindow.getWidth();
094: int windowHeight = mainWindow.getHeight();
095: int dialogWidth = dialog.getWidth();
096: int dialogHeight = dialog.getHeight();
097: int dialogX = (int) (windowWidth / 2.0)
098: - (int) (dialogWidth / 2.0);
099: int dialogY = (int) (windowHeight / 2.0)
100: - (int) (dialogHeight / 2.0);
101:
102: dialog.setLocation(dialogX, dialogY);
103:
104: return descriptor;
105: }
106:
107: /**
108: *
109: *
110: */
111: public void showDialog(String message) {
112: assert dialog != null : "invoke createDialog, then call this method";
113: dialog.setVisible(true);
114: }
115:
116: /**
117: *
118: *
119: */
120: public void hideDialog() {
121: if (dialog != null) {
122: dialog.setVisible(false);
123: dialog.dispose();
124: dialog = null;
125: }
126: }
127:
128: /** This method is called from within the constructor to
129: * initialize the form.
130: * WARNING: Do NOT modify this code. The content of this method is
131: * always regenerated by the Form Editor.
132: */
133: private void initComponents() {//GEN-BEGIN:initComponents
134:
135: java.awt.GridBagConstraints gridBagConstraints;
136:
137: jLabel1 = new javax.swing.JLabel();
138: progressBar = new javax.swing.JProgressBar();
139:
140: setLayout(new java.awt.GridBagLayout());
141:
142: setBorder(new javax.swing.border.EmptyBorder(
143: new java.awt.Insets(10, 10, 15, 10)));
144: setMinimumSize(new java.awt.Dimension(100, 38));
145: setPreferredSize(new java.awt.Dimension(250, 55));
146: jLabel1.setText(java.util.ResourceBundle.getBundle(
147: "org/netbeans/modules/xml/schema/abe/wizard/Bundle")
148: .getString("MSG_SchemaTransform_ProgressPanelMessage"));
149: gridBagConstraints = new java.awt.GridBagConstraints();
150: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
151: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
152: add(jLabel1, gridBagConstraints);
153:
154: progressBar.setIndeterminate(true);
155: gridBagConstraints = new java.awt.GridBagConstraints();
156: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
157: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
158: gridBagConstraints.weightx = 1.0;
159: gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0);
160: add(progressBar, gridBagConstraints);
161: }//GEN-END:initComponents
162:
163: }
|