KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > subversion > ui > status > VersioningPanel


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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.subversion.ui.status;
21
22 import org.netbeans.modules.subversion.client.*;
23 import org.netbeans.modules.subversion.ui.commit.*;
24 import org.netbeans.modules.subversion.ui.diff.*;
25 import org.netbeans.modules.versioning.util.VersioningListener;
26 import org.netbeans.modules.versioning.util.VersioningEvent;
27 import org.netbeans.modules.versioning.util.NoContentPanel;
28 import org.netbeans.modules.subversion.*;
29 import org.netbeans.modules.subversion.SvnModuleConfig;
30 import org.netbeans.modules.subversion.util.Context;
31 import org.netbeans.modules.subversion.util.SvnUtils;
32 import org.netbeans.api.progress.ProgressHandle;
33 import org.netbeans.api.progress.ProgressHandleFactory;
34 import org.openide.explorer.ExplorerManager;
35 import org.openide.nodes.*;
36 import org.openide.windows.TopComponent;
37 import org.openide.util.RequestProcessor;
38 import org.openide.util.NbBundle;
39 import org.openide.LifecycleManager;
40
41 import javax.swing.*;
42 import javax.swing.border.CompoundBorder JavaDoc;
43 import java.awt.*;
44 import java.awt.image.BufferedImage JavaDoc;
45 import java.awt.event.*;
46 import java.util.*;
47 import java.beans.PropertyChangeListener JavaDoc;
48 import java.beans.PropertyChangeEvent JavaDoc;
49 import java.io.File JavaDoc;
50 import java.util.prefs.PreferenceChangeEvent JavaDoc;
51 import java.util.prefs.PreferenceChangeListener JavaDoc;
52 import org.netbeans.modules.subversion.ui.update.UpdateAction;
53 import org.tigris.subversion.svnclientadapter.*;
54
55 /**
56  * The main class of the Synchronize view, shows and acts on set of file roots.
57  *
58  * @author Maros Sandor
59  */

60 class VersioningPanel extends JPanel implements ExplorerManager.Provider, PreferenceChangeListener JavaDoc, PropertyChangeListener JavaDoc, VersioningListener, ActionListener {
61     
62     private ExplorerManager explorerManager;
63     private final SvnVersioningTopComponent parentTopComponent;
64     private final Subversion subversion;
65     private Context context;
66     private int displayStatuses;
67     
68     private SyncTable syncTable;
69     private RequestProcessor.Task refreshViewTask;
70     private Thread JavaDoc refreshViewThread;
71
72     private SvnProgressSupport svnProgressSupport;
73     private static final RequestProcessor rp = new RequestProcessor("SubversionView", 1); // NOI18N
74

75     private final NoContentPanel noContentComponent = new NoContentPanel();
76
77     /**
78      * Creates a new Synchronize Panel managed by the given versioning system.
79      *
80      * @param parent enclosing top component
81      */

82     public VersioningPanel(SvnVersioningTopComponent parent) {
83         this.parentTopComponent = parent;
84         this.subversion = Subversion.getInstance();
85         refreshViewTask = rp.create(new RefreshViewTask());
86         explorerManager = new ExplorerManager ();
87         displayStatuses = FileInformation.STATUS_REMOTE_CHANGE | FileInformation.STATUS_LOCAL_CHANGE;
88         noContentComponent.setLabel(NbBundle.getMessage(VersioningPanel.class, "MSG_No_Changes_All")); // NOI18N
89
syncTable = new SyncTable();
90
91         initComponents();
92         setComponentsState();
93         setVersioningComponent(syncTable.getComponent());
94         reScheduleRefresh(0);
95
96         // XXX click it in form editor, probbaly requires Mattisse >=v2
97
jPanel2.setFloatable(false);
98         jPanel2.putClientProperty("JToolBar.isRollover", Boolean.TRUE); // NOI18N
99
jPanel2.setLayout(new ToolbarLayout());
100
101         parent.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.SHIFT_MASK | InputEvent.ALT_MASK), "prevInnerView"); // NOI18N
102
parent.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.SHIFT_MASK | InputEvent.ALT_MASK), "prevInnerView"); // NOI18N
103
parent.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.SHIFT_MASK | InputEvent.ALT_MASK), "nextInnerView"); // NOI18N
104
parent.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.SHIFT_MASK | InputEvent.ALT_MASK), "nextInnerView"); // NOI18N
105

106         getActionMap().put("prevInnerView", new AbstractAction("") { // NOI18N
107
public void actionPerformed(ActionEvent e) {
108                 onNextInnerView();
109             }
110         });
111         getActionMap().put("nextInnerView", new AbstractAction("") { // NOI18N
112
public void actionPerformed(ActionEvent e) {
113                 onPrevInnerView();
114             }
115         });
116     }
117
118     private void onPrevInnerView() {
119         if (tgbLocal.isSelected()) {
120             tgbRemote.setSelected(true);
121         } else if (tgbRemote.isSelected()) {
122             tgbAll.setSelected(true);
123         } else {
124             tgbLocal.setSelected(true);
125         }
126         onDisplayedStatusChanged();
127     }
128
129     private void onNextInnerView() {
130         if (tgbLocal.isSelected()) {
131             tgbAll.setSelected(true);
132         } else if (tgbRemote.isSelected()) {
133             tgbLocal.setSelected(true);
134         } else {
135             tgbRemote.setSelected(true);
136         }
137         onDisplayedStatusChanged();
138     }
139     
140     public void preferenceChange(PreferenceChangeEvent JavaDoc evt) {
141         if (evt.getKey().startsWith(SvnModuleConfig.PROP_COMMIT_EXCLUSIONS)) {
142             repaint();
143         }
144     }
145     
146     public void propertyChange(PropertyChangeEvent JavaDoc evt) {
147         if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName())) {
148             TopComponent tc = (TopComponent) SwingUtilities.getAncestorOfClass(TopComponent.class, this);
149             if (tc == null) return;
150             tc.setActivatedNodes((Node[]) evt.getNewValue());
151         }
152     }
153
154     /**
155      * Sets roots (directories) to display in the view.
156      *
157      * @param ctx new context if the Versioning panel
158      */

159     void setContext(Context ctx) {
160         context = ctx;
161         reScheduleRefresh(0);
162     }
163     
164     public ExplorerManager getExplorerManager () {
165         return explorerManager;
166     }
167     
168     public void addNotify() {
169         super.addNotify();
170         SvnModuleConfig.getDefault().getPreferences().addPreferenceChangeListener(this);
171         subversion.getStatusCache().addVersioningListener(this);
172 // subversion.addVersioningListener(this);
173
explorerManager.addPropertyChangeListener(this);
174         reScheduleRefresh(0); // the view does not listen for changes when it is not visible
175
}
176
177     public void removeNotify() {
178         SvnModuleConfig.getDefault().getPreferences().removePreferenceChangeListener(this);
179         subversion.getStatusCache().removeVersioningListener(this);
180 // subversion.removeVersioningListener(this);
181
explorerManager.removePropertyChangeListener(this);
182         super.removeNotify();
183     }
184     
185     private void setVersioningComponent(JComponent component) {
186         Component [] children = getComponents();
187         for (int i = 0; i < children.length; i++) {
188             Component child = children[i];
189             if (child != jPanel2) {
190                 if (child == component) {
191                     return;
192                 } else {
193                     remove(child);
194                     break;
195                 }
196             }
197         }
198         GridBagConstraints gbc = new GridBagConstraints();
199         gbc.gridx = 0; gbc.gridy = 2; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.gridheight = 1;
200         gbc.anchor = GridBagConstraints.FIRST_LINE_START; gbc.fill = GridBagConstraints.BOTH;
201         gbc.weightx = 1; gbc.weighty = 1;
202         
203         add(component, gbc);
204         revalidate();
205         repaint();
206     }
207     
208     private void setComponentsState() {
209         ButtonGroup grp = new ButtonGroup();
210         grp.add(tgbLocal);
211         grp.add(tgbRemote);
212         grp.add(tgbAll);
213         if (displayStatuses == FileInformation.STATUS_LOCAL_CHANGE) {
214             tgbLocal.setSelected(true);
215         }
216         else if (displayStatuses == FileInformation.STATUS_REMOTE_CHANGE) {
217             tgbRemote.setSelected(true);
218         }
219         else {
220             tgbAll.setSelected(true);
221         }
222     }
223
224     /**
225      * Must NOT be run from AWT.
226      */

227     private void setupModels() {
228         if (context == null) {
229             SwingUtilities.invokeLater(new Runnable JavaDoc() {
230                 public void run() {
231                     syncTable.setTableModel(new SyncFileNode[0]);
232                 }
233             });
234             return;
235         }
236         // XXX attach Cancelable hook
237
final ProgressHandle ph = ProgressHandleFactory.createHandle(NbBundle.getMessage(VersioningPanel.class, "MSG_Refreshing_Versioning_View")); // NOI18N
238
try {
239             refreshViewThread = Thread.currentThread();
240             Thread.interrupted(); // clear interupted status
241
ph.start();
242             final SyncFileNode [] nodes = getNodes(context, displayStatuses); // takes long
243
if (nodes == null) {
244                 return;
245                 // finally section
246
}
247
248             final String JavaDoc [] tableColumns;
249             final String JavaDoc branchTitle;
250             if (nodes.length > 0) {
251                 boolean stickyCommon = true;
252                 String JavaDoc currentSticky = SvnUtils.getCopy(nodes[0].getFile());
253                 for (int i = 1; i < nodes.length; i++) {
254                     if (Thread.interrupted()) {
255                         // TODO set model that displays that fact to user
256
return;
257                     }
258                     String JavaDoc sticky = SvnUtils.getCopy(nodes[i].getFile());
259                     if (sticky != currentSticky && (sticky == null || currentSticky == null || !sticky.equals(currentSticky))) {
260                         stickyCommon = false;
261                         break;
262                     }
263                 }
264                 if (stickyCommon) {
265                     tableColumns = new String JavaDoc [] { SyncFileNode.COLUMN_NAME_NAME, SyncFileNode.COLUMN_NAME_STATUS, SyncFileNode.COLUMN_NAME_PATH };
266                     branchTitle = currentSticky == null ? null : NbBundle.getMessage(VersioningPanel.class, "CTL_VersioningView_BranchTitle_Single", currentSticky); // NOI18N
267
} else {
268                     tableColumns = new String JavaDoc [] { SyncFileNode.COLUMN_NAME_NAME, SyncFileNode.COLUMN_NAME_BRANCH, SyncFileNode.COLUMN_NAME_STATUS, SyncFileNode.COLUMN_NAME_PATH };
269                     branchTitle = NbBundle.getMessage(VersioningPanel.class, "CTL_VersioningView_BranchTitle_Multi"); // NOI18N
270
}
271             } else {
272                 tableColumns = null;
273                 branchTitle = null;
274             }
275
276             SwingUtilities.invokeLater(new Runnable JavaDoc() {
277                 public void run() {
278                     if (nodes.length > 0) {
279                         syncTable.setColumns(tableColumns);
280                         parentTopComponent.setBranchTitle(branchTitle);
281                         setVersioningComponent(syncTable.getComponent());
282                     } else {
283                         setVersioningComponent(noContentComponent);
284                     }
285                     syncTable.setTableModel(nodes);
286                     // finally section, it's enqueued after this request
287
}
288             });
289         } finally {
290             SwingUtilities.invokeLater(new Runnable JavaDoc() {
291                 public void run() {
292                     ph.finish();
293                     refreshViewThread = null;
294                 }
295             });
296         }
297     }
298     
299     private SyncFileNode [] getNodes(Context context, int includeStatus) {
300         SvnFileNode [] fnodes = subversion.getNodes(context, includeStatus);
301         SyncFileNode [] nodes = new SyncFileNode[fnodes.length];
302         for (int i = 0; i < fnodes.length; i++) {
303             if (Thread.interrupted()) return null;
304             SvnFileNode fnode = fnodes[i];
305             nodes[i] = new SyncFileNode(fnode, this);
306         }
307         return nodes;
308     }
309
310     public int getDisplayStatuses() {
311         return displayStatuses;
312     }
313
314     /**
315      * Performs the "cvs commit" command on all diplayed roots plus "cvs add" for files that are not yet added.
316      */

317     private void onCommitAction() {
318         LifecycleManager.getDefault().saveAll();
319         CommitAction.commit(parentTopComponent.getContentTitle(), context);
320     }
321     
322     /**
323      * Performs the "cvs update" command on all diplayed roots.
324      */

325     private void onUpdateAction() {
326         UpdateAction.performUpdate(context);
327         parentTopComponent.contentRefreshed();
328     }
329     
330     /**
331      * Refreshes statuses of all files in the view. It does
332      * that by issuing the "svn status -u" command, updating the cache
333      * and refreshing file nodes.
334      */

335     private void onRefreshAction() {
336         LifecycleManager.getDefault().saveAll();
337         if(context.getRootFiles().length < 1) {
338             return;
339         }
340         refreshStatuses();
341     }
342
343     /**
344      * Programmatically invokes the Refresh action.
345      * Connects to repository and gets recent status.
346      */

347     RequestProcessor.Task performRefreshAction() {
348         return refreshStatuses();
349     }
350
351     /* Async Connects to repository and gets recent status. */
352     private RequestProcessor.Task refreshStatuses() {
353         if(svnProgressSupport!=null) {
354             svnProgressSupport.cancel();
355             svnProgressSupport = null;
356         }
357
358         SVNUrl repository = CommitAction.getSvnUrl(context);
359         RequestProcessor rp = Subversion.getInstance().getRequestProcessor(repository);
360         svnProgressSupport = new SvnProgressSupport() {
361             public void perform() {
362                 StatusAction.executeStatus(context, this);
363                 setupModels();
364             }
365         };
366         parentTopComponent.contentRefreshed();
367         return svnProgressSupport.start(rp, repository, org.openide.util.NbBundle.getMessage(VersioningPanel.class, "LBL_Refresh_Progress")); // NOI18N
368
}
369
370     /**
371      * Shows Diff panel for all files in the view. The initial type of diff depends on the sync mode: Local, Remote, All.
372      * In Local mode, the diff shows CURRENT <-> BASE differences. In Remote mode, it shows BASE<->HEAD differences.
373      */

374     private void onDiffAction() {
375         String JavaDoc title = parentTopComponent.getContentTitle();
376         if (displayStatuses == FileInformation.STATUS_LOCAL_CHANGE) {
377             LifecycleManager.getDefault().saveAll();
378             DiffAction.diff(context, Setup.DIFFTYPE_LOCAL, title);
379         } else if (displayStatuses == FileInformation.STATUS_REMOTE_CHANGE) {
380             DiffAction.diff(context, Setup.DIFFTYPE_REMOTE, title);
381         } else {
382             LifecycleManager.getDefault().saveAll();
383             DiffAction.diff(context, Setup.DIFFTYPE_ALL, title);
384         }
385     }
386
387     
388     
389     private void onDisplayedStatusChanged() {
390         if (tgbLocal.isSelected()) {
391             setDisplayStatuses(FileInformation.STATUS_LOCAL_CHANGE);
392             noContentComponent.setLabel(NbBundle.getMessage(VersioningPanel.class, "MSG_No_Changes_Local")); // NOI18N
393
}
394         else if (tgbRemote.isSelected()) {
395             setDisplayStatuses(FileInformation.STATUS_REMOTE_CHANGE);
396             noContentComponent.setLabel(NbBundle.getMessage(VersioningPanel.class, "MSG_No_Changes_Remote")); // NOI18N
397
}
398         else if (tgbAll.isSelected()) {
399             setDisplayStatuses(FileInformation.STATUS_REMOTE_CHANGE | FileInformation.STATUS_LOCAL_CHANGE);
400             noContentComponent.setLabel(NbBundle.getMessage(VersioningPanel.class, "MSG_No_Changes_All")); // NOI18N
401
}
402     }
403
404     private void setDisplayStatuses(int displayStatuses) {
405         this.displayStatuses = displayStatuses;
406         reScheduleRefresh(0);
407     }
408
409     public void versioningEvent(VersioningEvent event) {
410         if (event.getId() == FileStatusCache.EVENT_FILE_STATUS_CHANGED) {
411             if (!affectsView(event)) return;
412             reScheduleRefresh(1000);
413         }
414     }
415
416     private boolean affectsView(VersioningEvent event) {
417         File JavaDoc file = (File JavaDoc) event.getParams()[0];
418         FileInformation oldInfo = (FileInformation) event.getParams()[1];
419         FileInformation newInfo = (FileInformation) event.getParams()[2];
420         if (oldInfo == null) {
421             if ((newInfo.getStatus() & displayStatuses) == 0) return false;
422         } else {
423             if ((oldInfo.getStatus() & displayStatuses) + (newInfo.getStatus() & displayStatuses) == 0) return false;
424         }
425         return context.contains(file);
426     }
427
428     /** Reloads data from cache */
429     private void reScheduleRefresh(int delayMillis) {
430         refreshViewTask.schedule(delayMillis);
431     }
432
433     // HACK copy&paste HACK, replace by save/restore of column width/position
434
void deserialize() {
435         if (syncTable != null) {
436             SwingUtilities.invokeLater(new Runnable JavaDoc() {
437                 public void run() {
438                     syncTable.setDefaultColumnSizes();
439                 }
440             });
441         }
442     }
443
444     void focus() {
445         syncTable.focus();
446     }
447
448     /**
449      * Cancels both:
450      * <ul>
451      * <li>cache data fetching
452      * <li>background cvs -N update
453      * </ul>
454      */

455     public void cancelRefresh() {
456 /*
457         if (refreshCommandGroup != null) {
458             refreshCommandGroup.cancel();
459         }
460 */

461         refreshViewTask.cancel();
462         if (refreshViewThread != null) {
463             refreshViewThread.interrupt();
464         }
465     }
466
467     private class RefreshViewTask implements Runnable JavaDoc {
468         public void run() {
469             setupModels();
470         }
471     }
472
473     /**
474      * Hardcoded toolbar layout. It eliminates need
475      * for nested panels their look is hardly maintanable
476      * accross several look and feels
477      * (e.g. strange layouting panel borders on GTK+).
478      *
479      * <p>It sets authoritatively component height and takes
480      * "prefered" width from components itself.
481      *
482      */

483     private class ToolbarLayout implements LayoutManager {
484
485         /** Expected border height */
486         private int TOOLBAR_HEIGHT_ADJUSTMENT = 4;
487
488         private int TOOLBAR_SEPARATOR_MIN_WIDTH = 12;
489
490         /** Cached toolbar height */
491         private int toolbarHeight = -1;
492
493         /** Guard for above cache. */
494         private Dimension parentSize;
495
496         private Set<JComponent> adjusted = new HashSet<JComponent>();
497
498         public void removeLayoutComponent(Component comp) {
499         }
500
501         public void layoutContainer(Container parent) {
502             Dimension dim = VersioningPanel.this.getSize();
503             Dimension max = parent.getSize();
504
505             int reminder = max.width - minimumLayoutSize(parent).width;
506
507             int components = parent.getComponentCount();
508             int horizont = 0;
509             for (int i = 0; i<components; i++) {
510                 JComponent comp = (JComponent) parent.getComponent(i);
511                 if (comp.isVisible() == false) continue;
512                 comp.setLocation(horizont, 0);
513                 Dimension pref = comp.getPreferredSize();
514                 int width = pref.width;
515                 if (comp instanceof JSeparator && ((dim.height - dim.width) <= 0)) {
516                     width = Math.max(width, TOOLBAR_SEPARATOR_MIN_WIDTH);
517                 }
518                 if (comp instanceof JProgressBar && reminder > 0) {
519                     width += reminder;
520                 }
521 // if (comp == getMiniStatus()) {
522
// width = reminder;
523
// }
524

525                 // in column layout use taller toolbar
526
int height = getToolbarHeight(dim) -1;
527                 comp.setSize(width, height); // 1 verySoftBevel compensation
528
horizont += width;
529             }
530         }
531
532         public void addLayoutComponent(String JavaDoc name, Component comp) {
533         }
534
535         public Dimension minimumLayoutSize(Container parent) {
536
537             // in column layout use taller toolbar
538
Dimension dim = VersioningPanel.this.getSize();
539             int height = getToolbarHeight(dim);
540
541             int components = parent.getComponentCount();
542             int horizont = 0;
543             for (int i = 0; i<components; i++) {
544                 Component comp = parent.getComponent(i);
545                 if (comp.isVisible() == false) continue;
546                 if (comp instanceof AbstractButton) {
547                     adjustToobarButton((AbstractButton)comp);
548                 } else {
549                     adjustToolbarComponentSize((JComponent)comp);
550                 }
551                 Dimension pref = comp.getPreferredSize();
552                 int width = pref.width;
553                 if (comp instanceof JSeparator && ((dim.height - dim.width) <= 0)) {
554                     width = Math.max(width, TOOLBAR_SEPARATOR_MIN_WIDTH);
555                 }
556                 horizont += width;
557             }
558
559             return new Dimension(horizont, height);
560         }
561
562         public Dimension preferredLayoutSize(Container parent) {
563             // Eliminates double height toolbar problem
564
Dimension dim = VersioningPanel.this.getSize();
565             int height = getToolbarHeight(dim);
566
567             return new Dimension(Integer.MAX_VALUE, height);
568         }
569
570         /**
571          * Computes vertical toolbar components height that can used for layout manager hinting.
572          * @return size based on font size and expected border.
573          */

574         private int getToolbarHeight(Dimension parent) {
575
576             if (parentSize == null || (parentSize.equals(parent) == false)) {
577                 parentSize = parent;
578                 toolbarHeight = -1;
579             }
580
581             if (toolbarHeight == -1) {
582                 BufferedImage JavaDoc image = new BufferedImage JavaDoc(1,1,BufferedImage.TYPE_BYTE_GRAY);
583                 Graphics2D g = image.createGraphics();
584                 UIDefaults def = UIManager.getLookAndFeelDefaults();
585
586                 int height = 0;
587                 String JavaDoc[] fonts = {"Label.font", "Button.font", "ToggleButton.font"}; // NOI18N
588
for (int i=0; i<fonts.length; i++) {
589                     Font f = def.getFont(fonts[i]);
590                     FontMetrics fm = g.getFontMetrics(f);
591                     height = Math.max(height, fm.getHeight());
592                 }
593                 toolbarHeight = height + TOOLBAR_HEIGHT_ADJUSTMENT;
594                 if ((parent.height - parent.width) > 0) {
595                     toolbarHeight += TOOLBAR_HEIGHT_ADJUSTMENT;
596                 }
597             }
598
599             return toolbarHeight;
600         }
601
602
603         /** Toolbar controls must be smaller and should be transparent*/
604         private void adjustToobarButton(final AbstractButton button) {
605
606             if (adjusted.contains(button)) return;
607
608             // workaround for Ocean L&F clutter - toolbars use gradient.
609
// To make the gradient visible under buttons the content area must not
610
// be filled. To support rollover it must be temporarily filled
611
if (button instanceof JToggleButton == false) {
612                 button.setContentAreaFilled(false);
613                 button.setMargin(new Insets(0, 3, 0, 3));
614                 button.setBorderPainted(false);
615                 button.addMouseListener(new MouseAdapter() {
616                     public void mouseEntered(MouseEvent e) {
617                         button.setContentAreaFilled(true);
618                         button.setBorderPainted(true);
619                     }
620
621                     public void mouseExited(MouseEvent e) {
622                         button.setContentAreaFilled(false);
623                         button.setBorderPainted(false);
624                     }
625                 });
626             }
627
628             adjustToolbarComponentSize(button);
629         }
630
631         private void adjustToolbarComponentSize(JComponent button) {
632
633             if (adjusted.contains(button)) return;
634
635             // as we cannot get the button small enough using the margin and border...
636
if (button.getBorder() instanceof CompoundBorder JavaDoc) { // from BasicLookAndFeel
637
Dimension pref = button.getPreferredSize();
638
639                 // XXX #41827 workaround w2k, that adds eclipsis (...) instead of actual text
640
if ("Windows".equals(UIManager.getLookAndFeel().getID())) { // NOI18N
641
pref.width += 9;
642                 }
643                 button.setPreferredSize(pref);
644             }
645
646             adjusted.add(button);
647         }
648     }
649
650     /** This method is called from within the constructor to
651      * initialize the form.
652      * WARNING: Do NOT modify this code. The content of this method is
653      * always regenerated by the Form Editor.
654      */

655     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
656
private void initComponents() {
657         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
658
659         jPanel2 = new javax.swing.JToolBar JavaDoc();
660         tgbAll = new javax.swing.JToggleButton JavaDoc();
661         tgbLocal = new javax.swing.JToggleButton JavaDoc();
662         tgbRemote = new javax.swing.JToggleButton JavaDoc();
663         jSeparator1 = new javax.swing.JSeparator JavaDoc();
664         btnRefresh = new javax.swing.JButton JavaDoc();
665         btnDiff = new javax.swing.JButton JavaDoc();
666         jPanel3 = new javax.swing.JPanel JavaDoc();
667         btnUpdate = new javax.swing.JButton JavaDoc();
668         btnCommit = new javax.swing.JButton JavaDoc();
669
670         setLayout(new java.awt.GridBagLayout JavaDoc());
671
672         org.openide.awt.Mnemonics.setLocalizedText(tgbAll, org.openide.util.NbBundle.getBundle(VersioningPanel.class).getString("CTL_Synchronize_Action_All_Label")); // NOI18N
673
java.util.ResourceBundle JavaDoc bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/subversion/ui/status/Bundle"); // NOI18N
674
tgbAll.setToolTipText(bundle.getString("CTL_Synchronize_Action_All_Tooltip")); // NOI18N
675
tgbAll.setFocusable(false);
676         tgbAll.addActionListener(this);
677         jPanel2.add(tgbAll);
678
679         org.openide.awt.Mnemonics.setLocalizedText(tgbLocal, org.openide.util.NbBundle.getBundle(VersioningPanel.class).getString("CTL_Synchronize_Action_Local_Label")); // NOI18N
680
tgbLocal.setToolTipText(bundle.getString("CTL_Synchronize_Action_Local_Tooltip")); // NOI18N
681
tgbLocal.setFocusable(false);
682         tgbLocal.addActionListener(this);
683         jPanel2.add(tgbLocal);
684
685         org.openide.awt.Mnemonics.setLocalizedText(tgbRemote, org.openide.util.NbBundle.getBundle(VersioningPanel.class).getString("CTL_Synchronize_Action_Remote_Label")); // NOI18N
686
tgbRemote.setToolTipText(bundle.getString("CTL_Synchronize_Action_Remote_Tooltip")); // NOI18N
687
tgbRemote.setFocusable(false);
688         tgbRemote.addActionListener(this);
689         jPanel2.add(tgbRemote);
690
691         jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
692         jSeparator1.setPreferredSize(new java.awt.Dimension JavaDoc(2, 20));
693         jPanel2.add(jSeparator1);
694
695         btnRefresh.setIcon(new javax.swing.ImageIcon JavaDoc(getClass().getResource("/org/netbeans/modules/subversion/resources/icons/refresh.png")));
696         btnRefresh.setToolTipText(bundle.getString("CTL_Synchronize_Action_Refresh_Tooltip")); // NOI18N
697
btnRefresh.setFocusable(false);
698         btnRefresh.setPreferredSize(new java.awt.Dimension JavaDoc(22, 23));
699         btnRefresh.addActionListener(this);
700         jPanel2.add(btnRefresh);
701         btnRefresh.getAccessibleContext().setAccessibleName("Refresh Status");
702
703         btnDiff.setIcon(new javax.swing.ImageIcon JavaDoc(getClass().getResource("/org/netbeans/modules/subversion/resources/icons/diff.png")));
704         btnDiff.setToolTipText(bundle.getString("CTL_Synchronize_Action_Diff_Tooltip")); // NOI18N
705
btnDiff.setFocusable(false);
706         btnDiff.setPreferredSize(new java.awt.Dimension JavaDoc(22, 25));
707         btnDiff.addActionListener(this);
708         jPanel2.add(btnDiff);
709         btnDiff.getAccessibleContext().setAccessibleName("Diff All");
710
711         jPanel3.setOpaque(false);
712         jPanel2.add(jPanel3);
713
714         btnUpdate.setIcon(new javax.swing.ImageIcon JavaDoc(getClass().getResource("/org/netbeans/modules/subversion/resources/icons/update.png")));
715         btnUpdate.setToolTipText(bundle.getString("CTL_Synchronize_Action_Update_Tooltip")); // NOI18N
716
btnUpdate.setFocusable(false);
717         btnUpdate.setPreferredSize(new java.awt.Dimension JavaDoc(22, 25));
718         btnUpdate.addActionListener(this);
719         jPanel2.add(btnUpdate);
720         btnUpdate.getAccessibleContext().setAccessibleName("Update");
721
722         btnCommit.setIcon(new javax.swing.ImageIcon JavaDoc(getClass().getResource("/org/netbeans/modules/subversion/resources/icons/commit.png")));
723         btnCommit.setToolTipText(bundle.getString("CTL_CommitForm_Action_Commit_Tooltip")); // NOI18N
724
btnCommit.setFocusable(false);
725         btnCommit.setPreferredSize(new java.awt.Dimension JavaDoc(22, 25));
726         btnCommit.addActionListener(this);
727         jPanel2.add(btnCommit);
728         btnCommit.getAccessibleContext().setAccessibleName("Commit");
729
730         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
731         gridBagConstraints.gridx = 0;
732         gridBagConstraints.gridy = 0;
733         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
734         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
735         gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START;
736         gridBagConstraints.weightx = 1.0;
737         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 0, 3, 0);
738         add(jPanel2, gridBagConstraints);
739     }
740
741     // Code for dispatching events from components to event handlers.
742

743     public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
744         if (evt.getSource() == tgbAll) {
745             VersioningPanel.this.tgbAllActionPerformed(evt);
746         }
747         else if (evt.getSource() == tgbLocal) {
748             VersioningPanel.this.tgbLocalActionPerformed(evt);
749         }
750         else if (evt.getSource() == tgbRemote) {
751             VersioningPanel.this.tgbRemoteActionPerformed(evt);
752         }
753         else if (evt.getSource() == btnRefresh) {
754             VersioningPanel.this.btnRefreshActionPerformed(evt);
755         }
756         else if (evt.getSource() == btnDiff) {
757             VersioningPanel.this.btnDiffActionPerformed(evt);
758         }
759         else if (evt.getSource() == btnUpdate) {
760             VersioningPanel.this.btnUpdateActionPerformed(evt);
761         }
762         else if (evt.getSource() == btnCommit) {
763             VersioningPanel.this.btnCommitActionPerformed(evt);
764         }
765     }// </editor-fold>//GEN-END:initComponents
766

767     private void btnDiffActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_btnDiffActionPerformed
768
onDiffAction();
769     }//GEN-LAST:event_btnDiffActionPerformed
770

771     private void tgbAllActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_tgbAllActionPerformed
772
onDisplayedStatusChanged();
773     }//GEN-LAST:event_tgbAllActionPerformed
774

775     private void btnUpdateActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_btnUpdateActionPerformed
776
onUpdateAction();
777     }//GEN-LAST:event_btnUpdateActionPerformed
778

779     private void tgbRemoteActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_tgbRemoteActionPerformed
780
onDisplayedStatusChanged();
781     }//GEN-LAST:event_tgbRemoteActionPerformed
782

783     private void tgbLocalActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_tgbLocalActionPerformed
784
onDisplayedStatusChanged();
785     }//GEN-LAST:event_tgbLocalActionPerformed
786

787     private void btnCommitActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_btnCommitActionPerformed
788
onCommitAction();
789     }//GEN-LAST:event_btnCommitActionPerformed
790

791     private void btnRefreshActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_btnRefreshActionPerformed
792
onRefreshAction();
793     }//GEN-LAST:event_btnRefreshActionPerformed
794

795     
796     // Variables declaration - do not modify//GEN-BEGIN:variables
797
private javax.swing.JButton JavaDoc btnCommit;
798     private javax.swing.JButton JavaDoc btnDiff;
799     private javax.swing.JButton JavaDoc btnRefresh;
800     private javax.swing.JButton JavaDoc btnUpdate;
801     private javax.swing.JToolBar JavaDoc jPanel2;
802     private javax.swing.JPanel JavaDoc jPanel3;
803     private javax.swing.JSeparator JavaDoc jSeparator1;
804     private javax.swing.JToggleButton JavaDoc tgbAll;
805     private javax.swing.JToggleButton JavaDoc tgbLocal;
806     private javax.swing.JToggleButton JavaDoc tgbRemote;
807     // End of variables declaration//GEN-END:variables
808

809 }
810
Popular Tags