1 19 20 package org.netbeans.modules.versioning.system.cvss.ui.syncview; 21 22 import java.util.prefs.PreferenceChangeEvent ; 23 import org.netbeans.modules.versioning.system.cvss.*; 24 import org.netbeans.modules.versioning.system.cvss.util.Context; 25 import org.netbeans.modules.versioning.system.cvss.CvsModuleConfig; 26 import org.netbeans.modules.versioning.system.cvss.ui.actions.update.UpdateExecutor; 27 import org.netbeans.modules.versioning.system.cvss.ui.actions.commit.CommitAction; 28 import org.netbeans.modules.versioning.system.cvss.ui.actions.diff.DiffExecutor; 29 import org.netbeans.modules.versioning.util.VersioningListener; 30 import org.netbeans.modules.versioning.util.VersioningEvent; 31 import org.netbeans.modules.versioning.util.NoContentPanel; 32 import org.netbeans.lib.cvsclient.command.update.UpdateCommand; 33 import org.netbeans.lib.cvsclient.command.GlobalOptions; 34 import org.netbeans.api.progress.ProgressHandle; 35 import org.netbeans.api.progress.ProgressHandleFactory; 36 import org.openide.explorer.ExplorerManager; 37 import org.openide.nodes.*; 38 import org.openide.windows.TopComponent; 39 import org.openide.util.RequestProcessor; 40 import org.openide.util.NbBundle; 41 import org.openide.LifecycleManager; 42 43 import javax.swing.*; 44 import javax.swing.border.CompoundBorder ; 45 import java.awt.*; 46 import java.awt.image.BufferedImage ; 47 import java.awt.event.*; 48 import java.util.*; 49 import java.beans.PropertyChangeEvent ; 50 import java.beans.PropertyChangeListener ; 51 import java.io.File ; 52 import java.util.prefs.PreferenceChangeListener ; 53 54 59 class SynchronizePanel extends JPanel implements ExplorerManager.Provider, PropertyChangeListener , PreferenceChangeListener , VersioningListener, ActionListener { 60 61 private ExplorerManager explorerManager; 62 private final CvsSynchronizeTopComponent parentTopComponent; 63 private final CvsVersioningSystem cvs; 64 private Context context; 65 private int displayStatuses; 66 private boolean pendingRefresh; 67 68 private SyncTable syncTable; 69 private RequestProcessor.Task refreshViewTask; 70 private Thread refreshViewThread; 71 private ExecutorGroup refreshCommandGroup; 72 73 private static final RequestProcessor rp = new RequestProcessor("CVS-VersioningView", 1); 75 private final NoContentPanel noContentComponent = new NoContentPanel(); 76 77 82 public SynchronizePanel(CvsSynchronizeTopComponent parent) { 83 this.parentTopComponent = parent; 84 this.cvs = CvsVersioningSystem.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(SynchronizePanel.class, "MSG_No_Changes_All")); 89 syncTable = new SyncTable(); 90 91 initComponents(); 92 setComponentsState(); 93 setVersioningComponent(syncTable.getComponent()); 94 reScheduleRefresh(0); 95 96 jPanel2.setFloatable(false); 98 jPanel2.putClientProperty("JToolBar.isRollover", Boolean.TRUE); 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"); parent.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.SHIFT_MASK | InputEvent.ALT_MASK), "prevInnerView"); parent.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.SHIFT_MASK | InputEvent.ALT_MASK), "nextInnerView"); parent.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.SHIFT_MASK | InputEvent.ALT_MASK), "nextInnerView"); 106 getActionMap().put("prevInnerView", new AbstractAction("") { public void actionPerformed(ActionEvent e) { 108 onNextInnerView(); 109 } 110 }); 111 getActionMap().put("nextInnerView", new AbstractAction("") { 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 evt) { 141 if (evt.getKey().startsWith(CvsModuleConfig.PROP_COMMIT_EXCLUSIONS)) { 142 repaint(); 143 } 144 } 145 146 public void propertyChange(PropertyChangeEvent 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 CvsVersioningSystem getCvs() { 155 return cvs; 156 } 157 158 163 void setContext(Context ctx) { 164 context = ctx; 165 reScheduleRefresh(0); 166 } 167 168 public ExplorerManager getExplorerManager () { 169 return explorerManager; 170 } 171 172 public void addNotify() { 173 super.addNotify(); 174 CvsModuleConfig.getDefault().getPreferences().addPreferenceChangeListener(this); 175 cvs.getStatusCache().addVersioningListener(this); 176 cvs.addVersioningListener(this); 177 explorerManager.addPropertyChangeListener(this); 178 reScheduleRefresh(0); } 180 181 public void removeNotify() { 182 CvsModuleConfig.getDefault().getPreferences().removePreferenceChangeListener(this); 183 cvs.getStatusCache().removeVersioningListener(this); 184 cvs.removeVersioningListener(this); 185 explorerManager.removePropertyChangeListener(this); 186 super.removeNotify(); 187 } 188 189 private void setVersioningComponent(JComponent component) { 190 Component [] children = getComponents(); 191 for (int i = 0; i < children.length; i++) { 192 Component child = children[i]; 193 if (child != jPanel2) { 194 if (child == component) { 195 return; 196 } else { 197 remove(child); 198 break; 199 } 200 } 201 } 202 GridBagConstraints gbc = new GridBagConstraints(); 203 gbc.gridx = 0; gbc.gridy = 2; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.gridheight = 1; 204 gbc.anchor = GridBagConstraints.FIRST_LINE_START; gbc.fill = GridBagConstraints.BOTH; 205 gbc.weightx = 1; gbc.weighty = 1; 206 207 add(component, gbc); 208 revalidate(); 209 repaint(); 210 } 211 212 private void setComponentsState() { 213 ButtonGroup grp = new ButtonGroup(); 214 grp.add(tgbLocal); 215 grp.add(tgbRemote); 216 grp.add(tgbAll); 217 if (displayStatuses == FileInformation.STATUS_LOCAL_CHANGE) { 218 tgbLocal.setSelected(true); 219 } 220 else if (displayStatuses == FileInformation.STATUS_REMOTE_CHANGE) { 221 tgbRemote.setSelected(true); 222 } 223 else { 224 tgbAll.setSelected(true); 225 } 226 } 227 228 231 private void setupModels() { 232 if (context == null) { 233 SwingUtilities.invokeLater(new Runnable () { 234 public void run() { 235 syncTable.setTableModel(new SyncFileNode[0]); 236 } 237 }); 238 return; 239 } 240 final ProgressHandle ph = ProgressHandleFactory.createHandle(NbBundle.getMessage(SynchronizePanel.class, "MSG_Refreshing_Versioning_View")); 241 try { 242 refreshViewThread = Thread.currentThread(); 243 refreshViewThread.interrupted(); ph.start(); final SyncFileNode [] nodes = getNodes(cvs.getFileTableModel(context, displayStatuses)); if (nodes == null) { 247 return; 248 } 250 251 final String [] tableColumns; 252 final String branchTitle; 253 if (nodes.length > 0) { 254 boolean stickyCommon = true; 255 String currentSticky = nodes[0].getSticky(); 256 for (int i = 1; i < nodes.length; i++) { 257 if (Thread.interrupted()) { 258 return; 260 } 261 String sticky = nodes[i].getSticky(); 262 if (sticky != currentSticky && (sticky == null || currentSticky == null || !sticky.equals(currentSticky))) { 263 stickyCommon = false; 264 break; 265 } 266 } 267 if (stickyCommon) { 268 tableColumns = new String [] { SyncFileNode.COLUMN_NAME_NAME, SyncFileNode.COLUMN_NAME_STATUS, SyncFileNode.COLUMN_NAME_PATH }; 269 branchTitle = currentSticky.length() == 0 ? null : NbBundle.getMessage(SynchronizePanel.class, "CTL_VersioningView_BranchTitle_Single", currentSticky); 270 } else { 271 tableColumns = new String [] { SyncFileNode.COLUMN_NAME_NAME, SyncFileNode.COLUMN_NAME_STICKY, SyncFileNode.COLUMN_NAME_STATUS, SyncFileNode.COLUMN_NAME_PATH }; 272 branchTitle = NbBundle.getMessage(SynchronizePanel.class, "CTL_VersioningView_BranchTitle_Multi"); 273 } 274 } else { 275 tableColumns = null; 276 branchTitle = null; 277 } 278 279 SwingUtilities.invokeLater(new Runnable () { 280 public void run() { 281 if (nodes.length > 0) { 282 syncTable.setColumns(tableColumns); 283 parentTopComponent.setBranchTitle(branchTitle); 284 setVersioningComponent(syncTable.getComponent()); 285 } else { 286 setVersioningComponent(noContentComponent); 287 } 288 syncTable.setTableModel(nodes); 289 } 291 }); 292 } finally { 293 SwingUtilities.invokeLater(new Runnable () { 294 public void run() { 295 ph.finish(); 296 refreshViewThread = null; 297 } 298 }); 299 } 300 } 301 302 private SyncFileNode [] getNodes(CvsFileTableModel model) { 303 CvsFileNode [] fnodes = model.getNodes(); 304 SyncFileNode [] nodes = new SyncFileNode[fnodes.length]; 305 for (int i = 0; i < fnodes.length; i++) { 306 if (Thread.interrupted()) return null; 307 CvsFileNode fnode = fnodes[i]; 308 nodes[i] = new SyncFileNode(fnode); 309 } 310 return nodes; 311 } 312 313 316 private void onCommitAction() { 317 LifecycleManager.getDefault().saveAll(); 318 CommitAction.invokeCommit(parentTopComponent.getContentTitle(), context, null); 319 } 320 321 324 private void onUpdateAction() { 325 executeUpdateCommand(false); 326 } 327 328 332 private void onRefreshAction() { 333 LifecycleManager.getDefault().saveAll(); 334 refreshStatuses(); 335 } 336 337 340 void performRefreshAction() { 341 refreshStatuses(); 342 } 343 344 private void refreshStatuses() { 345 executeUpdateCommand(true); 346 reScheduleRefresh(1000); 347 } 348 349 353 private void onDiffAction() { 354 ExecutorGroup group = new ExecutorGroup(NbBundle.getMessage(SynchronizePanel.class, "BK0003")); 355 group.progress(NbBundle.getMessage(SynchronizePanel.class, "BK0004")); 356 DiffExecutor exec = new DiffExecutor(context, parentTopComponent.getContentTitle()); 357 if (displayStatuses == FileInformation.STATUS_LOCAL_CHANGE) { 358 LifecycleManager.getDefault().saveAll(); 359 exec.showLocalDiff(group); 360 } else if (displayStatuses == FileInformation.STATUS_REMOTE_CHANGE) { 361 exec.showRemoteDiff(group); 362 } else { 363 LifecycleManager.getDefault().saveAll(); 364 exec.showAllDiff(group); 365 } 366 } 367 368 private void executeUpdateCommand(boolean doNoChanges) { 369 if (context == null || context.getRootFiles().length == 0) return; 370 UpdateCommand cmd = new UpdateCommand(); 371 String msg; 372 if (doNoChanges) { 373 msg = NbBundle.getMessage(SynchronizePanel.class, "BK0001"); 374 } else { 375 msg = NbBundle.getMessage(SynchronizePanel.class, "BK0002"); 376 } 377 cmd.setDisplayName(msg); 378 GlobalOptions options = CvsVersioningSystem.createGlobalOptions(); 379 if (context.getExclusions().size() > 0) { 380 options.setExclusions((File []) context.getExclusions().toArray(new File [context.getExclusions().size()])); 381 } 382 cmd.setFiles(context.getRootFiles()); 383 cmd.setBuildDirectories(true); 384 cmd.setPruneDirectories(true); 385 options.setDoNoChanges(doNoChanges); 386 refreshCommandGroup = new ExecutorGroup(msg); 389 refreshCommandGroup.addExecutors(UpdateExecutor.splitCommand(cmd, cvs, options, parentTopComponent.getContentTitle())); 390 refreshCommandGroup.execute(); 391 parentTopComponent.contentRefreshed(); 393 } 394 395 private void onDisplayedStatusChanged() { 396 if (tgbLocal.isSelected()) { 397 setDisplayStatuses(FileInformation.STATUS_LOCAL_CHANGE); 398 noContentComponent.setLabel(NbBundle.getMessage(SynchronizePanel.class, "MSG_No_Changes_Local")); 399 } 400 else if (tgbRemote.isSelected()) { 401 setDisplayStatuses(FileInformation.STATUS_REMOTE_CHANGE); 402 noContentComponent.setLabel(NbBundle.getMessage(SynchronizePanel.class, "MSG_No_Changes_Remote")); 403 } 404 else if (tgbAll.isSelected()) { 405 setDisplayStatuses(FileInformation.STATUS_REMOTE_CHANGE | FileInformation.STATUS_LOCAL_CHANGE); 406 noContentComponent.setLabel(NbBundle.getMessage(SynchronizePanel.class, "MSG_No_Changes_All")); 407 } 408 } 409 410 private void setDisplayStatuses(int displayStatuses) { 411 this.displayStatuses = displayStatuses; 412 reScheduleRefresh(0); 413 } 414 415 public void versioningEvent(VersioningEvent event) { 416 if (event.getId() == FileStatusCache.EVENT_FILE_STATUS_CHANGED) { 417 if (!affectsView(event)) return; 418 if (cvs.getParameter(CvsVersioningSystem.PARAM_BATCH_REFRESH_RUNNING) != null) { 419 reScheduleRefresh(1000); 420 } else { 421 reScheduleRefresh(200); 422 } 423 } else if (event.getId() == CvsVersioningSystem.EVENT_PARAM_CHANGED) { 424 if (pendingRefresh && event.getParams()[0].equals(CvsVersioningSystem.PARAM_BATCH_REFRESH_RUNNING)) { 425 if (cvs.getParameter(CvsVersioningSystem.PARAM_BATCH_REFRESH_RUNNING) == null) { 426 pendingRefresh = false; 427 reScheduleRefresh(0); 428 } 429 } 430 } 431 } 432 433 private boolean affectsView(VersioningEvent event) { 434 File file = (File ) event.getParams()[0]; 435 FileInformation oldInfo = (FileInformation) event.getParams()[1]; 436 FileInformation newInfo = (FileInformation) event.getParams()[2]; 437 if (oldInfo == null) { 438 if ((newInfo.getStatus() & displayStatuses) == 0) return false; 439 } else { 440 if ((oldInfo.getStatus() & displayStatuses) + (newInfo.getStatus() & displayStatuses) == 0) return false; 441 } 442 if (context != null) { 443 return context.contains(file); 444 } else { 445 return false; 446 } 447 } 448 449 450 private void reScheduleRefresh(int delayMillis) { 451 refreshViewTask.schedule(delayMillis); 452 } 453 454 void deserialize() { 456 if (syncTable != null) { 457 SwingUtilities.invokeLater(new Runnable () { 458 public void run() { 459 syncTable.setDefaultColumnSizes(); 460 } 461 }); 462 } 463 } 464 465 void focus() { 466 syncTable.focus(); 467 } 468 469 476 public void cancelRefresh() { 477 if (refreshCommandGroup != null) { 478 refreshCommandGroup.cancel(); 479 } 480 refreshViewTask.cancel(); 481 if (refreshViewThread != null) { 482 refreshViewThread.interrupt(); 483 } 484 } 485 486 private class RefreshViewTask implements Runnable { 487 public void run() { 488 setupModels(); 489 } 490 } 491 492 502 private class ToolbarLayout implements LayoutManager { 503 504 505 private int TOOLBAR_HEIGHT_ADJUSTMENT = 4; 506 507 private int TOOLBAR_SEPARATOR_MIN_WIDTH = 12; 508 509 510 private int toolbarHeight = -1; 511 512 513 private Dimension parentSize; 514 515 private Set adjusted = new HashSet(); 516 517 public void removeLayoutComponent(Component comp) { 518 } 519 520 public void layoutContainer(Container parent) { 521 Dimension dim = SynchronizePanel.this.getSize(); 522 Dimension max = parent.getSize(); 523 524 int reminder = max.width - minimumLayoutSize(parent).width; 525 526 int components = parent.getComponentCount(); 527 int horizont = 0; 528 for (int i = 0; i<components; i++) { 529 JComponent comp = (JComponent) parent.getComponent(i); 530 if (comp.isVisible() == false) continue; 531 comp.setLocation(horizont, 0); 532 Dimension pref = comp.getPreferredSize(); 533 int width = pref.width; 534 if (comp instanceof JSeparator && ((dim.height - dim.width) <= 0)) { 535 width = Math.max(width, TOOLBAR_SEPARATOR_MIN_WIDTH); 536 } 537 if (comp instanceof JProgressBar && reminder > 0) { 538 width += reminder; 539 } 540 544 int height = getToolbarHeight(dim) -1; 546 comp.setSize(width, height); horizont += width; 548 } 549 } 550 551 public void addLayoutComponent(String name, Component comp) { 552 } 553 554 public Dimension minimumLayoutSize(Container parent) { 555 556 Dimension dim = SynchronizePanel.this.getSize(); 558 int height = getToolbarHeight(dim); 559 560 int components = parent.getComponentCount(); 561 int horizont = 0; 562 for (int i = 0; i<components; i++) { 563 Component comp = parent.getComponent(i); 564 if (comp.isVisible() == false) continue; 565 if (comp instanceof AbstractButton) { 566 adjustToobarButton((AbstractButton)comp); 567 } else { 568 adjustToolbarComponentSize((JComponent)comp); 569 } 570 Dimension pref = comp.getPreferredSize(); 571 int width = pref.width; 572 if (comp instanceof JSeparator && ((dim.height - dim.width) <= 0)) { 573 width = Math.max(width, TOOLBAR_SEPARATOR_MIN_WIDTH); 574 } 575 horizont += width; 576 } 577 578 return new Dimension(horizont, height); 579 } 580 581 public Dimension preferredLayoutSize(Container parent) { 582 Dimension dim = SynchronizePanel.this.getSize(); 584 int height = getToolbarHeight(dim); 585 586 return new Dimension(Integer.MAX_VALUE, height); 587 } 588 589 593 private int getToolbarHeight(Dimension parent) { 594 595 if (parentSize == null || (parentSize.equals(parent) == false)) { 596 parentSize = parent; 597 toolbarHeight = -1; 598 } 599 600 if (toolbarHeight == -1) { 601 BufferedImage image = new BufferedImage (1,1,BufferedImage.TYPE_BYTE_GRAY); 602 Graphics2D g = image.createGraphics(); 603 UIDefaults def = UIManager.getLookAndFeelDefaults(); 604 605 int height = 0; 606 String [] fonts = {"Label.font", "Button.font", "ToggleButton.font"}; for (int i=0; i<fonts.length; i++) { 608 Font f = def.getFont(fonts[i]); 609 FontMetrics fm = g.getFontMetrics(f); 610 height = Math.max(height, fm.getHeight()); 611 } 612 toolbarHeight = height + TOOLBAR_HEIGHT_ADJUSTMENT; 613 if ((parent.height - parent.width) > 0) { 614 toolbarHeight += TOOLBAR_HEIGHT_ADJUSTMENT; 615 } 616 } 617 618 return toolbarHeight; 619 } 620 621 622 623 private void adjustToobarButton(final AbstractButton button) { 624 625 if (adjusted.contains(button)) return; 626 627 if (button instanceof JToggleButton == false) { 631 button.setContentAreaFilled(false); 632 button.setMargin(new Insets(0, 3, 0, 3)); 633 button.setBorderPainted(false); 634 button.addMouseListener(new MouseAdapter() { 635 public void mouseEntered(MouseEvent e) { 636 button.setContentAreaFilled(true); 637 button.setBorderPainted(true); 638 } 639 640 public void mouseExited(MouseEvent e) { 641 button.setContentAreaFilled(false); 642 button.setBorderPainted(false); 643 } 644 }); 645 } 646 647 adjustToolbarComponentSize(button); 648 } 649 650 private void adjustToolbarComponentSize(JComponent button) { 651 652 if (adjusted.contains(button)) return; 653 654 if (button.getBorder() instanceof CompoundBorder ) { Dimension pref = button.getPreferredSize(); 657 658 if ("Windows".equals(UIManager.getLookAndFeel().getID())) { pref.width += 9; 661 } 662 button.setPreferredSize(pref); 663 } 664 665 adjusted.add(button); 666 } 667 } 668 669 674 private void initComponents() { 676 java.awt.GridBagConstraints gridBagConstraints; 677 678 jPanel2 = new javax.swing.JToolBar (); 679 tgbAll = new javax.swing.JToggleButton (); 680 tgbLocal = new javax.swing.JToggleButton (); 681 tgbRemote = new javax.swing.JToggleButton (); 682 jSeparator1 = new javax.swing.JSeparator (); 683 btnRefresh = new javax.swing.JButton (); 684 btnDiff = new javax.swing.JButton (); 685 jPanel3 = new javax.swing.JPanel (); 686 btnUpdate = new javax.swing.JButton (); 687 btnCommit = new javax.swing.JButton (); 688 689 setLayout(new java.awt.GridBagLayout ()); 690 691 org.openide.awt.Mnemonics.setLocalizedText(tgbAll, java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/syncview/Bundle").getString("CTL_Synchronize_Action_All_Label")); 692 tgbAll.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/syncview/Bundle").getString("CTL_Synchronize_Action_All_Tooltip")); 693 tgbAll.addActionListener(this); 694 695 jPanel2.add(tgbAll); 696 697 org.openide.awt.Mnemonics.setLocalizedText(tgbLocal, java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/syncview/Bundle").getString("CTL_Synchronize_Action_Local_Label")); 698 tgbLocal.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/syncview/Bundle").getString("CTL_Synchronize_Action_Local_Tooltip")); 699 tgbLocal.addActionListener(this); 700 701 jPanel2.add(tgbLocal); 702 703 org.openide.awt.Mnemonics.setLocalizedText(tgbRemote, java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/syncview/Bundle").getString("CTL_Synchronize_Action_Remote_Label")); 704 tgbRemote.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/syncview/Bundle").getString("CTL_Synchronize_Action_Remote_Tooltip")); 705 tgbRemote.addActionListener(this); 706 707 jPanel2.add(tgbRemote); 708 709 jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL); 710 jSeparator1.setPreferredSize(new java.awt.Dimension (2, 20)); 711 jPanel2.add(jSeparator1); 712 713 btnRefresh.setIcon(new javax.swing.ImageIcon (getClass().getResource("/org/netbeans/modules/versioning/system/cvss/resources/icons/refresh.png"))); 714 btnRefresh.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/syncview/Bundle").getString("CTL_Synchronize_Action_Refresh_Tooltip")); 715 btnRefresh.setActionCommand(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/syncview/Bundle").getString("CTL_Synchronize_TopComponent_Title")); 716 btnRefresh.setPreferredSize(new java.awt.Dimension (22, 23)); 717 btnRefresh.addActionListener(this); 718 719 jPanel2.add(btnRefresh); 720 721 btnDiff.setIcon(new javax.swing.ImageIcon (getClass().getResource("/org/netbeans/modules/versioning/system/cvss/resources/icons/diff.png"))); 722 btnDiff.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/syncview/Bundle").getString("CTL_Synchronize_Action_Diff_Tooltip")); 723 btnDiff.setPreferredSize(new java.awt.Dimension (22, 25)); 724 btnDiff.addActionListener(this); 725 726 jPanel2.add(btnDiff); 727 728 jPanel3.setOpaque(false); 729 jPanel2.add(jPanel3); 730 731 btnUpdate.setIcon(new javax.swing.ImageIcon (getClass().getResource("/org/netbeans/modules/versioning/system/cvss/resources/icons/update.png"))); 732 btnUpdate.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/syncview/Bundle").getString("CTL_Synchronize_Action_Update_Tooltip")); 733 btnUpdate.setActionCommand(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/syncview/Bundle").getString("CTL_Synchronize_TopComponent_Title")); 734 btnUpdate.setPreferredSize(new java.awt.Dimension (22, 25)); 735 btnUpdate.addActionListener(this); 736 737 jPanel2.add(btnUpdate); 738 739 btnCommit.setIcon(new javax.swing.ImageIcon (getClass().getResource("/org/netbeans/modules/versioning/system/cvss/resources/icons/commit.png"))); 740 btnCommit.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/syncview/Bundle").getString("CTL_CommitForm_Action_Commit_Tooltip")); 741 btnCommit.setPreferredSize(new java.awt.Dimension (22, 25)); 742 btnCommit.addActionListener(this); 743 744 jPanel2.add(btnCommit); 745 746 gridBagConstraints = new java.awt.GridBagConstraints (); 747 gridBagConstraints.gridx = 0; 748 gridBagConstraints.gridy = 0; 749 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 750 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 751 gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START; 752 gridBagConstraints.weightx = 1.0; 753 gridBagConstraints.insets = new java.awt.Insets (3, 0, 3, 0); 754 add(jPanel2, gridBagConstraints); 755 756 } 757 758 760 public void actionPerformed(java.awt.event.ActionEvent evt) { 761 if (evt.getSource() == tgbAll) { 762 SynchronizePanel.this.tgbAllActionPerformed(evt); 763 } 764 else if (evt.getSource() == tgbLocal) { 765 SynchronizePanel.this.tgbLocalActionPerformed(evt); 766 } 767 else if (evt.getSource() == tgbRemote) { 768 SynchronizePanel.this.tgbRemoteActionPerformed(evt); 769 } 770 else if (evt.getSource() == btnRefresh) { 771 SynchronizePanel.this.btnRefreshActionPerformed(evt); 772 } 773 else if (evt.getSource() == btnDiff) { 774 SynchronizePanel.this.btnDiffActionPerformed(evt); 775 } 776 else if (evt.getSource() == btnUpdate) { 777 SynchronizePanel.this.btnUpdateActionPerformed(evt); 778 } 779 else if (evt.getSource() == btnCommit) { 780 SynchronizePanel.this.btnCommitActionPerformed(evt); 781 } 782 } 783 785 private void btnDiffActionPerformed(java.awt.event.ActionEvent evt) { onDiffAction(); 787 } 789 private void tgbAllActionPerformed(java.awt.event.ActionEvent evt) { onDisplayedStatusChanged(); 791 } 793 private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) { onUpdateAction(); 795 } 797 private void tgbRemoteActionPerformed(java.awt.event.ActionEvent evt) { onDisplayedStatusChanged(); 799 } 801 private void tgbLocalActionPerformed(java.awt.event.ActionEvent evt) { onDisplayedStatusChanged(); 803 } 805 private void btnCommitActionPerformed(java.awt.event.ActionEvent evt) { onCommitAction(); 807 } 809 private void btnRefreshActionPerformed(java.awt.event.ActionEvent evt) { onRefreshAction(); 811 } 813 814 private javax.swing.JButton btnCommit; 816 private javax.swing.JButton btnDiff; 817 private javax.swing.JButton btnRefresh; 818 private javax.swing.JButton btnUpdate; 819 private javax.swing.JToolBar jPanel2; 820 private javax.swing.JPanel jPanel3; 821 private javax.swing.JSeparator jSeparator1; 822 private javax.swing.JToggleButton tgbAll; 823 private javax.swing.JToggleButton tgbLocal; 824 private javax.swing.JToggleButton tgbRemote; 825 827 } 828 | Popular Tags |