PageRenderTime 32ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/bundles/plugins-trunk/Sessions/sessions/DefaultSessionPropertyPane.java

#
Java | 115 lines | 68 code | 25 blank | 22 comment | 4 complexity | a9b9b66b92f1a601988eec5575e042a0 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /*
  2. * DefaultSessionPropertyPane.java
  3. * Copyright (c) 2001 Dirk Moebius
  4. *
  5. * :tabSize=4:indentSize=4:noTabs=false:maxLineLen=0:
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. */
  21. package sessions;
  22. import java.awt.FlowLayout;
  23. import java.awt.event.ActionEvent;
  24. import java.awt.event.ActionListener;
  25. import javax.swing.JButton;
  26. import javax.swing.JComboBox;
  27. import javax.swing.JFileChooser;
  28. import javax.swing.JPanel;
  29. import javax.swing.JTextField;
  30. import javax.swing.UIManager;
  31. import org.gjt.sp.jedit.jEdit;
  32. import org.gjt.sp.jedit.Mode;
  33. public class DefaultSessionPropertyPane extends SessionPropertyPane
  34. implements ActionListener
  35. {
  36. public DefaultSessionPropertyPane(Session session)
  37. {
  38. super(session);
  39. }
  40. public String getIdentifier()
  41. {
  42. return "plugin.sessions.sessionproperties.default";
  43. }
  44. public String getLabel()
  45. {
  46. return jEdit.getProperty("sessions.sessionproperties.default.label");
  47. }
  48. public void _init()
  49. {
  50. // "Base directory:"
  51. JPanel dirPanel = new JPanel();
  52. dirPanel.add(
  53. tBasedir = new JTextField(session.getProperty(Session.BASE_DIRECTORY, ""), 20));
  54. dirPanel.add(
  55. bBrowse = new JButton(UIManager.getIcon("FileView.directoryIcon")));
  56. bBrowse.setMargin(new java.awt.Insets(0,0,0,0));
  57. bBrowse.addActionListener(this);
  58. addComponent(dirPanel);
  59. // "Preferred mode:"
  60. cMode = new JComboBox(getModeNames());
  61. cMode.setEditable(false);
  62. cMode.setSelectedItem(session.getProperty("mode", jEdit.getProperty("buffer.defaultMode")));
  63. addComponent("sessions.sessionproperties.default.mode", cMode);
  64. }
  65. public void _save()
  66. {
  67. session.setProperty(Session.BASE_DIRECTORY, tBasedir.getText());
  68. session.setProperty("mode", cMode.getSelectedItem() != null
  69. ? cMode.getSelectedItem().toString()
  70. : jEdit.getProperty("buffer.defaultMode"));
  71. }
  72. private String[] getModeNames()
  73. {
  74. Mode[] modes = jEdit.getModes();
  75. String[] modeNames = new String[modes.length];
  76. for(int i = 0; i < modes.length; ++i)
  77. modeNames[i] = modes[i].getName();
  78. return modeNames;
  79. }
  80. public void actionPerformed(ActionEvent evt)
  81. {
  82. JFileChooser chooser = new javax.swing.JFileChooser();
  83. chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  84. if(chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)
  85. tBasedir.setText(chooser.getSelectedFile().getPath());
  86. }
  87. private JTextField tBasedir;
  88. private JButton bBrowse;
  89. private JComboBox cMode;
  90. }