KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > refactoring > impl > UndoRedoProgress


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * UndoRedoProgress.java
22  *
23  * Created on June 16, 2006, 5:10 PM
24  *
25  * To change this template, choose Tools | Template Manager
26  * and open the template in the editor.
27  */

28
29 package org.netbeans.modules.xml.refactoring.impl;
30
31 import java.awt.BorderLayout JavaDoc;
32 import java.awt.Dialog JavaDoc;
33 import javax.swing.JComponent JavaDoc;
34 import javax.swing.JDialog JavaDoc;
35 import javax.swing.JLabel JavaDoc;
36 import javax.swing.JPanel JavaDoc;
37 import javax.swing.SwingUtilities JavaDoc;
38 import javax.swing.WindowConstants JavaDoc;
39 import javax.swing.border.EmptyBorder JavaDoc;
40 import org.netbeans.api.progress.ProgressHandle;
41 import org.netbeans.api.progress.ProgressHandleFactory;
42 import org.openide.DialogDescriptor;
43 import org.openide.DialogDisplayer;
44 import org.openide.util.NbBundle;
45
46 /**
47  *
48  * @author Jeri Lockhart
49  */

50 public class UndoRedoProgress {
51     private ProgressHandle handle;
52     private Dialog JavaDoc d;
53     
54     /** Creates a new instance of UndoRedoProgress */
55     public UndoRedoProgress() {
56     }
57     
58     public void start() {
59         SwingUtilities.invokeLater(new Runnable JavaDoc() {
60             public void run() {
61                 final String JavaDoc lab = NbBundle.getMessage(UndoRedoProgress.class, "LBL_RefactorProgressLabel");
62                 handle = ProgressHandleFactory.createHandle(lab);
63                 JComponent JavaDoc progress = ProgressHandleFactory.createProgressComponent(handle);
64                 JPanel JavaDoc component = new JPanel JavaDoc();
65                 component.setLayout(new BorderLayout JavaDoc());
66                 component.setBorder(new EmptyBorder JavaDoc(12,12,11,11));
67                 JLabel JavaDoc label = new JLabel JavaDoc(lab);
68                 label.setBorder(new EmptyBorder JavaDoc(0, 0, 6, 0));
69                 component.add(label, BorderLayout.NORTH);
70                 component.add(progress, BorderLayout.CENTER);
71                 DialogDescriptor desc = new DialogDescriptor(component, NbBundle.getMessage(UndoRedoProgress.class, "LBL_RefactoringInProgress"), true, new Object JavaDoc[]{}, null, 0, null, null);
72                 desc.setLeaf(true);
73                 d = DialogDisplayer.getDefault().createDialog(desc);
74                 ((JDialog JavaDoc) d).setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
75                 
76                 
77                 handle.start();
78                 handle.switchToIndeterminate();
79                 
80                 d.setVisible(true);
81             }
82         });
83     }
84    
85     
86     public void stop() {
87         SwingUtilities.invokeLater(new Runnable JavaDoc() {
88             public void run() {
89                 handle.finish();
90                 d.setVisible(false);
91             }
92         });
93     }
94     
95 }
96
Popular Tags