1 19 package org.netbeans.modules.subversion.options; 20 21 import java.awt.event.ActionEvent ; 22 import java.awt.event.ActionListener ; 23 import java.io.File ; 24 import javax.swing.JFileChooser ; 25 import javax.swing.filechooser.FileFilter ; 26 import org.netbeans.modules.subversion.Subversion; 27 import org.netbeans.modules.subversion.SvnModuleConfig; 28 import org.netbeans.modules.subversion.ui.repository.Repository; 29 import org.netbeans.modules.versioning.util.AccessibleJFileChooser; 30 import org.netbeans.spi.options.OptionsPanelController; 31 import org.openide.filesystems.FileUtil; 32 import org.openide.util.HelpCtx; 33 import org.openide.util.NbBundle; 34 35 39 public final class SvnOptionsController extends OptionsPanelController implements ActionListener { 40 41 private final SvnOptionsPanel panel; 42 private final Repository repository; 43 private final AnnotationSettings annotationSettings; 44 45 public SvnOptionsController() { 46 panel = new SvnOptionsPanel(); 47 48 int repositoryModeMask = Repository.FLAG_URL_ENABLED | Repository.FLAG_SHOW_REMOVE; 49 String title = org.openide.util.NbBundle.getMessage(SvnOptionsController.class, "CTL_Repository_Location"); 50 repository = new Repository(repositoryModeMask, title); 52 annotationSettings = new AnnotationSettings(); 53 54 panel.browseButton.addActionListener(this); 55 panel.manageConnSettingsButton.addActionListener(this); 56 panel.manageLabelsButton.addActionListener(this); 57 58 } 59 60 public void update() { 61 62 panel.executablePathTextField.setText(SvnModuleConfig.getDefault().getExecutableBinaryPath()); 63 64 annotationSettings.update(); 65 repository.refreshUrlHistory(); 66 67 } 68 69 public void applyChanges() { 70 71 SvnModuleConfig.getDefault().setExecutableBinaryPath(panel.executablePathTextField.getText()); 73 76 annotationSettings.applyChanges(); 78 Subversion.getInstance().getAnnotator().refresh(); 79 Subversion.getInstance().refreshAllAnnotations(); 80 81 repository.storeRecentUrls(); 83 } 84 85 public void cancel() { 86 repository.refreshUrlHistory(); 87 } 88 89 public boolean isValid() { 90 return true; 91 } 92 93 public boolean isChanged() { 94 return false; } 96 97 public org.openide.util.HelpCtx getHelpCtx() { 98 return new org.openide.util.HelpCtx("netbeans.optionsDialog.advanced.subversion"); 99 } 100 101 public javax.swing.JComponent getComponent(org.openide.util.Lookup masterLookup) { 102 return panel; 103 } 104 105 public void addPropertyChangeListener(java.beans.PropertyChangeListener l) { 106 107 } 108 109 public void removePropertyChangeListener(java.beans.PropertyChangeListener l) { 110 111 } 112 113 public void actionPerformed(ActionEvent evt) { 114 if(evt.getSource() == panel.browseButton) { 115 onBrowseClick(); 116 } else if(evt.getSource() == panel.manageConnSettingsButton) { 117 onManageConnClick(); 118 } else if(evt.getSource() == panel.manageLabelsButton) { 119 onManageLabelsClick(); 120 } 121 } 122 123 private File getExecutableFile() { 124 String execPath = panel.executablePathTextField.getText(); 125 return FileUtil.normalizeFile(new File (execPath)); 126 } 127 128 private void onBrowseClick() { 129 File oldFile = getExecutableFile(); 130 JFileChooser fileChooser = new AccessibleJFileChooser(NbBundle.getMessage(SvnOptionsController.class, "ACSD_BrowseFolder"), oldFile); fileChooser.setDialogTitle(NbBundle.getMessage(SvnOptionsController.class, "Browse_title")); fileChooser.setMultiSelectionEnabled(false); 133 FileFilter [] old = fileChooser.getChoosableFileFilters(); 134 for (int i = 0; i < old.length; i++) { 135 FileFilter fileFilter = old[i]; 136 fileChooser.removeChoosableFileFilter(fileFilter); 137 138 } 139 fileChooser.addChoosableFileFilter(new FileFilter () { 140 public boolean accept(File f) { 141 return f.isDirectory(); 142 } 143 public String getDescription() { 144 return NbBundle.getMessage(SvnOptionsController.class, "SVNExec"); } 146 }); 147 fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 148 fileChooser.showDialog(panel, NbBundle.getMessage(SvnOptionsController.class, "OK_Button")); File f = fileChooser.getSelectedFile(); 150 if (f != null) { 151 panel.executablePathTextField.setText(f.getAbsolutePath()); 152 } 153 } 154 155 private void onManageConnClick() { 156 boolean ok = repository.show(NbBundle.getMessage(SvnOptionsController.class, "CTL_ManageConnections"), new HelpCtx(Repository.class)); 157 if(!ok) { 158 repository.refreshUrlHistory(); 159 } 160 } 161 162 private void onManageLabelsClick() { 163 annotationSettings.show(); 164 } 165 } 166 | Popular Tags |