Source Code Cross Referenced for UpdatePanel.java in  » IDE-Netbeans » mercurial » org » netbeans » modules » mercurial » ui » update » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » mercurial » org.netbeans.modules.mercurial.ui.update 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:        package org.netbeans.modules.mercurial.ui.update;
042:
043:        import java.io.File;
044:        import java.util.Set;
045:        import java.util.Vector;
046:        import java.util.LinkedHashSet;
047:        import javax.swing.SwingUtilities;
048:        import javax.swing.ComboBoxModel;
049:        import javax.swing.DefaultComboBoxModel;
050:        import org.netbeans.api.progress.ProgressHandleFactory;
051:        import org.netbeans.api.progress.ProgressHandle;
052:        import org.openide.util.RequestProcessor;
053:        import org.openide.util.NbBundle;
054:        import org.netbeans.modules.mercurial.util.HgCommand;
055:
056:        /**
057:         *
058:         * @author  Padraig O'Briain
059:         */
060:        public class UpdatePanel extends javax.swing.JPanel {
061:
062:            private File repository;
063:            private RequestProcessor.Task refreshViewTask;
064:            private static final RequestProcessor rp = new RequestProcessor(
065:                    "MercurialUpdate", 1); // NOI18N
066:            private Thread refreshViewThread;
067:
068:            private static final int HG_REVERT_TARGET_LIMIT = 100;
069:
070:            /** Creates new form ReverModificationsPanel */
071:            public UpdatePanel(File repo) {
072:                repository = repo;
073:                refreshViewTask = rp.create(new RefreshViewTask());
074:                initComponents();
075:                refreshViewTask.schedule(0);
076:            }
077:
078:            public String getSelectedRevision() {
079:                String revStr = (String) revisionsComboBox.getSelectedItem();
080:                if (revStr != null) {
081:                    if (revStr.equals(NbBundle.getMessage(
082:                            RevertModificationsPanel.class,
083:                            "MSG_Revision_Default"))
084:                            || // NOI18N
085:                            revStr.equals(NbBundle.getMessage(
086:                                    RevertModificationsPanel.class,
087:                                    "MSG_Fetching_Revisions"))) { // NOI18N
088:                        revStr = null;
089:                    } else {
090:                        revStr = revStr.substring(0, revStr.indexOf(" ")); // NOI18N
091:                    }
092:                }
093:                return revStr;
094:            }
095:
096:            public boolean isForcedUpdateRequested() {
097:                return forcedUpdateChxBox.isSelected();
098:            }
099:
100:            /** This method is called from within the constructor to
101:             * initialize the form.
102:             * WARNING: Do NOT modify this code. The content of this method is
103:             * always regenerated by the Form Editor.
104:             */
105:            // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
106:            private void initComponents() {
107:
108:                revisionsLabel = new javax.swing.JLabel();
109:                revisionsComboBox = new javax.swing.JComboBox();
110:                jLabel1 = new javax.swing.JLabel();
111:                jLabel2 = new javax.swing.JLabel();
112:                jPanel1 = new javax.swing.JPanel();
113:                forcedUpdateChxBox = new javax.swing.JCheckBox();
114:
115:                revisionsLabel.setLabelFor(revisionsComboBox);
116:                org.openide.awt.Mnemonics.setLocalizedText(revisionsLabel,
117:                        org.openide.util.NbBundle.getMessage(UpdatePanel.class,
118:                                "UpdatePanel.revisionsLabel.text")); // NOI18N
119:
120:                jLabel1.setFont(new java.awt.Font("Dialog", 1, 11));
121:                org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
122:                        org.openide.util.NbBundle.getMessage(UpdatePanel.class,
123:                                "UpdatePanel.infoLabel.text")); // NOI18N
124:
125:                jLabel2.setForeground(new java.awt.Color(153, 153, 153));
126:                org.openide.awt.Mnemonics.setLocalizedText(jLabel2,
127:                        org.openide.util.NbBundle.getMessage(UpdatePanel.class,
128:                                "UpdatePanel.infoLabel2.text")); // NOI18N
129:
130:                jPanel1.setBorder(javax.swing.BorderFactory
131:                        .createTitledBorder(org.openide.util.NbBundle
132:                                .getMessage(UpdatePanel.class,
133:                                        "UpdatePanel.jPanel1.border.title"))); // NOI18N
134:
135:                org.openide.awt.Mnemonics.setLocalizedText(forcedUpdateChxBox,
136:                        org.openide.util.NbBundle.getMessage(UpdatePanel.class,
137:                                "UpdatePanel.forcedUpdateChxBox.text")); // NOI18N
138:
139:                org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(
140:                        jPanel1);
141:                jPanel1.setLayout(jPanel1Layout);
142:                jPanel1Layout.setHorizontalGroup(jPanel1Layout
143:                        .createParallelGroup(
144:                                org.jdesktop.layout.GroupLayout.LEADING).add(
145:                                jPanel1Layout.createSequentialGroup()
146:                                        .addContainerGap().add(
147:                                                forcedUpdateChxBox)
148:                                        .addContainerGap(25, Short.MAX_VALUE)));
149:                jPanel1Layout
150:                        .setVerticalGroup(jPanel1Layout
151:                                .createParallelGroup(
152:                                        org.jdesktop.layout.GroupLayout.LEADING)
153:                                .add(
154:                                        jPanel1Layout
155:                                                .createSequentialGroup()
156:                                                .add(forcedUpdateChxBox)
157:                                                .addContainerGap(
158:                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
159:                                                        Short.MAX_VALUE)));
160:
161:                org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
162:                        this );
163:                this .setLayout(layout);
164:                layout
165:                        .setHorizontalGroup(layout
166:                                .createParallelGroup(
167:                                        org.jdesktop.layout.GroupLayout.LEADING)
168:                                .add(
169:                                        layout
170:                                                .createSequentialGroup()
171:                                                .addContainerGap()
172:                                                .add(
173:                                                        layout
174:                                                                .createParallelGroup(
175:                                                                        org.jdesktop.layout.GroupLayout.LEADING)
176:                                                                .add(
177:                                                                        jPanel1,
178:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
179:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
180:                                                                        Short.MAX_VALUE)
181:                                                                .add(jLabel2)
182:                                                                .add(
183:                                                                        jLabel1,
184:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
185:                                                                        355,
186:                                                                        Short.MAX_VALUE)
187:                                                                .add(
188:                                                                        layout
189:                                                                                .createSequentialGroup()
190:                                                                                .add(
191:                                                                                        36,
192:                                                                                        36,
193:                                                                                        36)
194:                                                                                .add(
195:                                                                                        revisionsLabel)
196:                                                                                .addPreferredGap(
197:                                                                                        org.jdesktop.layout.LayoutStyle.RELATED)
198:                                                                                .add(
199:                                                                                        revisionsComboBox,
200:                                                                                        0,
201:                                                                                        174,
202:                                                                                        Short.MAX_VALUE)))
203:                                                .addContainerGap()));
204:                layout
205:                        .setVerticalGroup(layout
206:                                .createParallelGroup(
207:                                        org.jdesktop.layout.GroupLayout.LEADING)
208:                                .add(
209:                                        layout
210:                                                .createSequentialGroup()
211:                                                .add(
212:                                                        jLabel1,
213:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
214:                                                        25,
215:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
216:                                                .add(4, 4, 4)
217:                                                .add(jLabel2)
218:                                                .add(29, 29, 29)
219:                                                .add(
220:                                                        layout
221:                                                                .createParallelGroup(
222:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
223:                                                                .add(
224:                                                                        revisionsLabel)
225:                                                                .add(
226:                                                                        revisionsComboBox,
227:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
228:                                                                        16,
229:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
230:                                                .addPreferredGap(
231:                                                        org.jdesktop.layout.LayoutStyle.UNRELATED)
232:                                                .add(
233:                                                        jPanel1,
234:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
235:                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
236:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
237:                                                .addContainerGap(15,
238:                                                        Short.MAX_VALUE)));
239:            }// </editor-fold>//GEN-END:initComponents
240:
241:            /**
242:             * Must NOT be run from AWT.
243:             */
244:            private void setupModels() {
245:                // XXX attach Cancelable hook
246:                final ProgressHandle ph = ProgressHandleFactory
247:                        .createHandle(NbBundle.getMessage(
248:                                RevertModificationsPanel.class,
249:                                "MSG_Refreshing_Update_Versions")); // NOI18N
250:                try {
251:                    Set<String> initialRevsSet = new LinkedHashSet<String>();
252:                    initialRevsSet.add(NbBundle.getMessage(
253:                            RevertModificationsPanel.class,
254:                            "MSG_Fetching_Revisions")); // NOI18N
255:                    ComboBoxModel targetsModel = new DefaultComboBoxModel(
256:                            new Vector<String>(initialRevsSet));
257:                    revisionsComboBox.setModel(targetsModel);
258:                    refreshViewThread = Thread.currentThread();
259:                    Thread.interrupted(); // clear interupted status
260:                    ph.start();
261:
262:                    refreshRevisions();
263:                } finally {
264:                    SwingUtilities.invokeLater(new Runnable() {
265:                        public void run() {
266:                            ph.finish();
267:                            refreshViewThread = null;
268:                        }
269:                    });
270:                }
271:            }
272:
273:            private void refreshRevisions() {
274:                java.util.List<String> targetRevsList = HgCommand.getRevisions(
275:                        repository, HG_REVERT_TARGET_LIMIT);
276:
277:                Set<String> targetRevsSet = new LinkedHashSet<String>();
278:
279:                int size;
280:                if (targetRevsList == null) {
281:                    size = 0;
282:                    targetRevsSet.add(NbBundle.getMessage(
283:                            RevertModificationsPanel.class,
284:                            "MSG_Revision_Default")); // NOI18N
285:                } else {
286:                    size = targetRevsList.size();
287:                    int i = 0;
288:                    while (i < size) {
289:                        targetRevsSet.add(targetRevsList.get(i));
290:                        i++;
291:                    }
292:                }
293:                ComboBoxModel targetsModel = new DefaultComboBoxModel(
294:                        new Vector<String>(targetRevsSet));
295:                revisionsComboBox.setModel(targetsModel);
296:
297:                if (targetRevsSet.size() > 0) {
298:                    revisionsComboBox.setSelectedIndex(0);
299:                }
300:            }
301:
302:            private class RefreshViewTask implements  Runnable {
303:                public void run() {
304:                    setupModels();
305:                }
306:            }
307:
308:            // Variables declaration - do not modify//GEN-BEGIN:variables
309:            private javax.swing.JCheckBox forcedUpdateChxBox;
310:            private javax.swing.JLabel jLabel1;
311:            private javax.swing.JLabel jLabel2;
312:            private javax.swing.JPanel jPanel1;
313:            private javax.swing.JComboBox revisionsComboBox;
314:            private javax.swing.JLabel revisionsLabel;
315:            // End of variables declaration//GEN-END:variables
316:
317:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.