1 19 package org.netbeans.modules.versioning.system.cvss.options; 20 21 import org.netbeans.spi.options.OptionsPanelController; 22 import org.netbeans.modules.versioning.system.cvss.CvsModuleConfig; 23 import org.openide.util.Lookup; 24 import org.openide.util.HelpCtx; 25 26 import javax.swing.*; 27 import java.beans.PropertyChangeListener ; 28 29 33 class CvsOptionsController extends OptionsPanelController { 34 35 private CvsOptionsPanel panel; 36 37 public void update() { 38 panel.getExcludeNewFiles().setSelected(CvsModuleConfig.getDefault().getPreferences().getBoolean(CvsModuleConfig.PROP_EXCLUDE_NEW_FILES, false)); 39 panel.getStatusLabelFormat().setText(CvsModuleConfig.getDefault().getPreferences().get(CvsModuleConfig.PROP_ANNOTATIONS_FORMAT, CvsModuleConfig.DEFAULT_ANNOTATIONS_FORMAT)); 40 int wrapLength = CvsModuleConfig.getDefault().getWrapCommitMessagelength(); 41 panel.getWrapCommitMessages().setSelected(wrapLength > 0); 42 panel.getWrapCharCount().setText(wrapLength > 0 ? Integer.toString(wrapLength) : ""); 43 } 44 45 public void applyChanges() { 46 if (!isValid()) return; 47 CvsModuleConfig.getDefault().getPreferences().putBoolean(CvsModuleConfig.PROP_EXCLUDE_NEW_FILES, panel.getExcludeNewFiles().isSelected()); 48 CvsModuleConfig.getDefault().getPreferences().put(CvsModuleConfig.PROP_ANNOTATIONS_FORMAT, panel.getStatusLabelFormat().getText()); 49 int wrapLength = panel.getWrapCommitMessages().isSelected() ? Integer.parseInt(panel.getWrapCharCount().getText().trim()) : 0; 50 CvsModuleConfig.getDefault().setWrapCommitMessagelength(wrapLength); 51 } 52 53 public void cancel() { 54 } 56 57 public boolean isValid() { 58 try { 59 return !panel.getWrapCommitMessages().isSelected() || Integer.parseInt(panel.getWrapCharCount().getText().trim()) > 0; 60 } catch (Exception e) { 61 return false; 62 } 63 } 64 65 public boolean isChanged() { 66 return true; 67 } 68 69 public JComponent getComponent(Lookup masterLookup) { 70 if (panel == null) { 71 panel = new CvsOptionsPanel(); 72 } 73 return panel; 74 } 75 76 public HelpCtx getHelpCtx() { 77 return new HelpCtx(CvsOptionsController.class); 78 } 79 80 public void addPropertyChangeListener(PropertyChangeListener l) { 81 } 82 83 public void removePropertyChangeListener(PropertyChangeListener l) { 84 } 85 } 86 | Popular Tags |