/bundles/plugins-trunk/SVNPlugin/src/ise/plugin/svn/gui/SubversionOptions.java

# · Java · 141 lines · 92 code · 19 blank · 30 comment · 15 complexity · 56b57ddfba9966f08b9444fa8cac7ad5 MD5 · raw file

  1. /*
  2. Copyright (c) 2007, Dale Anson
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without modification,
  5. are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright notice,
  7. this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright notice,
  9. this list of conditions and the following disclaimer in the documentation
  10. and/or other materials provided with the distribution.
  11. * Neither the name of the author nor the names of its contributors
  12. may be used to endorse or promote products derived from this software without
  13. specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  18. ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  21. ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. package ise.plugin.svn.gui;
  26. import java.awt.*;
  27. import java.awt.event.*;
  28. import java.io.*;
  29. import javax.swing.*;
  30. import javax.swing.event.*;
  31. import org.gjt.sp.jedit.OptionPane;
  32. import org.gjt.sp.jedit.jEdit;
  33. import ise.java.awt.KappaLayout;
  34. import org.tmatesoft.svn.core.internal.wc.admin.SVNAdminAreaFactory;
  35. /**
  36. * Plugin option pane.
  37. */
  38. public class SubversionOptions implements OptionPane {
  39. private JPanel panel = null;
  40. private JCheckBox useTsvnTemplate = null;
  41. private JSpinner maxLogs = null;
  42. private JLabel fileformat_label;
  43. private JComboBox fileformat;
  44. public SubversionOptions( ) { }
  45. public void init() {
  46. if ( panel != null )
  47. return ;
  48. panel = new JPanel( new KappaLayout() );
  49. panel.setName( "SubversionOptions" );
  50. useTsvnTemplate = new JCheckBox( "Use tsvn:logtemplate property for commit template" );
  51. useTsvnTemplate.setName( "useTsvnTemplate" );
  52. useTsvnTemplate.setSelected( jEdit.getBooleanProperty( "ise.plugin.svn.useTsvnTemplate", false ) );
  53. maxLogs = new JSpinner();
  54. maxLogs.setName( "maxLogs" );
  55. ( ( JSpinner.NumberEditor ) maxLogs.getEditor() ).getModel().setMinimum( Integer.valueOf( 1 ) );
  56. int logRows = jEdit.getIntegerProperty( "ise.plugin.svn.logRows", 1000 );
  57. ( ( JSpinner.NumberEditor ) maxLogs.getEditor() ).getModel().setValue( logRows );
  58. ( ( JSpinner.NumberEditor ) maxLogs.getEditor() ).getTextField().setForeground( jEdit.getColorProperty( "view.fgColor", Color.BLACK ) );
  59. ( ( JSpinner.NumberEditor ) maxLogs.getEditor() ).getTextField().setBackground( jEdit.getColorProperty( "view.bgColor", Color.WHITE ) );
  60. JLabel maxLogsLabel = new JLabel( jEdit.getProperty( "ips.Maximum_log_entries_to_show>", "Maximum log entries to show:" ) );
  61. fileformat_label = new JLabel( jEdit.getProperty( "ips.Subversion_file_format>", "Subversion file format:" ) );
  62. fileformat = new JComboBox( new String[] {"1.3", "1.4", "1.5", "1.6"} );
  63. fileformat.setEditable( false );
  64. String wc_item;
  65. int default_wc_format = jEdit.getIntegerProperty( "ise.plugin.svn.defaultWCVersion", SVNAdminAreaFactory.WC_FORMAT_15 );
  66. switch ( default_wc_format ) {
  67. case SVNAdminAreaFactory.WC_FORMAT_13:
  68. wc_item = "1.3";
  69. break;
  70. case SVNAdminAreaFactory.WC_FORMAT_14:
  71. wc_item = "1.4";
  72. break;
  73. case SVNAdminAreaFactory.WC_FORMAT_15:
  74. wc_item = "1.5";
  75. break;
  76. case SVNAdminAreaFactory.WC_FORMAT_16:
  77. default:
  78. wc_item = "1.6";
  79. break;
  80. }
  81. fileformat.setSelectedItem( wc_item );
  82. panel.add( "0, 0, 2, 1, W, w, 3", useTsvnTemplate );
  83. panel.add( "0, 1, 1, 1, W, w, 3", maxLogsLabel);
  84. panel.add( "1, 1, 1, 1, W, w, 3", maxLogs );
  85. panel.add( "0, 2, 1, 1, W, w, 3", fileformat_label );
  86. panel.add( "1, 2, 2, 1, W, w, 3", fileformat );
  87. }
  88. public void save() {
  89. if ( useTsvnTemplate != null ) {
  90. jEdit.setBooleanProperty( "ise.plugin.svn.useTsvnTemplate", useTsvnTemplate.isSelected() );
  91. }
  92. if ( maxLogs != null ) {
  93. jEdit.setIntegerProperty( "ise.plugin.svn.logRows", ( ( Integer ) maxLogs.getValue() ).intValue() );
  94. }
  95. String new_wc_format = ( String ) fileformat.getSelectedItem();
  96. int wc_format;
  97. if ( new_wc_format.equals( "1.3" ) ) {
  98. wc_format = SVNAdminAreaFactory.WC_FORMAT_13;
  99. }
  100. else if ( new_wc_format.equals( "1.4" ) ) {
  101. wc_format = SVNAdminAreaFactory.WC_FORMAT_14;
  102. }
  103. else if ( new_wc_format.equals( "1.6" ) ) {
  104. wc_format = SVNAdminAreaFactory.WC_FORMAT_16;
  105. }
  106. else {
  107. wc_format = SVNAdminAreaFactory.WC_FORMAT_15;
  108. }
  109. jEdit.setIntegerProperty( "ise.plugin.svn.defaultWCVersion", wc_format );
  110. }
  111. public Component getComponent() {
  112. if ( panel == null )
  113. init();
  114. return panel;
  115. }
  116. public String getName() {
  117. return "svnplugin";
  118. }
  119. }