~ubuntu-branches/ubuntu/wily/weka/wily

« back to all changes in this revision

Viewing changes to src/main/java/weka/gui/PropertyPanel.java

  • Committer: Bazaar Package Importer
  • Author(s): tony mancill
  • Date: 2011-08-05 22:40:50 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20110805224050-a01vkwst9epdi4sw
Tags: 3.6.5-1
* Team upload.
* New upstream version (Closes: #632082, #598400)
* Bump Standards-Version to 3.9.2 (no changes required).
* Freshen jar.patch; remove java_cup.patch (incorporated upstream)
* Add README.source to document process of obtaining .png resources.
* Add myself to Uploaders.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
 *
55
55
 * @author Len Trigg (trigg@cs.waikato.ac.nz)
56
56
 * @author Richard Kirkby (rkirkby@cs.waikato.ac.nz)
57
 
 * @version $Revision: 1.14 $
 
57
 * @version $Revision: 7059 $
58
58
 */
59
59
public class PropertyPanel 
60
60
  extends JPanel {
71
71
  /** Whether the editor has provided its own panel */
72
72
  private boolean m_HasCustomPanel = false;
73
73
  
 
74
  /** The custom panel (if any) */
 
75
  private JPanel m_CustomPanel;
 
76
  
74
77
  /**
75
78
   * Create the panel with the supplied property editor.
76
79
   *
94
97
    
95
98
    if (!ignoreCustomPanel && m_Editor instanceof CustomPanelSupplier) {
96
99
      setLayout(new BorderLayout());
97
 
      add(((CustomPanelSupplier)m_Editor).getCustomPanel(), BorderLayout.CENTER);
 
100
      m_CustomPanel = ((CustomPanelSupplier)m_Editor).getCustomPanel();
 
101
      add(m_CustomPanel, BorderLayout.CENTER);
98
102
      m_HasCustomPanel = true;
99
103
    } else {
100
104
      createDefaultPanel();
108
112
  protected void createDefaultPanel() {
109
113
 
110
114
    setBorder(BorderFactory.createEtchedBorder());
111
 
    setToolTipText("Left-click to edit properties for this object, right-click/Alt+Shift+left-click for menu");
 
115
    setToolTipText(Messages.getInstance().getString("PropertyPanel_CreateDefaultPanel_SetToolTipText_Text"));
112
116
    setOpaque(true);
113
117
    final Component comp = this;
114
118
    addMouseListener(new MouseAdapter() {
123
127
            JMenuItem item;
124
128
 
125
129
            if (m_Editor.getValue() != null) {
126
 
              item = new JMenuItem("Show properties...");
 
130
              item = new JMenuItem(Messages.getInstance().getString("PropertyPanel_CreateDefaultPanel_Item_JMenuItem_Text_First"));
127
131
              item.addActionListener(new ActionListener() {
128
132
                public void actionPerformed(ActionEvent e) {
129
133
                  showPropertyDialog();
131
135
              });
132
136
              menu.add(item);
133
137
 
134
 
              item = new JMenuItem("Copy configuration to clipboard");
 
138
              item = new JMenuItem(Messages.getInstance().getString("PropertyPanel_CreateDefaultPanel_Item_JMenuItem_Text_Second"));
135
139
              item.addActionListener(new ActionListener() {
136
140
                public void actionPerformed(ActionEvent e) {
137
141
                  String str = m_Editor.getValue().getClass().getName();
145
149
              menu.add(item);
146
150
            }
147
151
            
148
 
            item = new JMenuItem("Enter configuration...");
 
152
            item = new JMenuItem(Messages.getInstance().getString("PropertyPanel_CreateDefaultPanel_Item_JMenuItem_Text_Third"));
149
153
            item.addActionListener(new ActionListener() {
150
154
              public void actionPerformed(ActionEvent e) {
151
155
                String str = JOptionPane.showInputDialog(
152
156
                                 comp, 
153
 
                                 "Configuration (<classname> [<options>])");
 
157
                                 Messages.getInstance().getString("PropertyPanel_CreateDefaultPanel_Str_JOptionPaneShowInputDialog_Text"));
154
158
                if (str != null) {
155
159
                  try {
156
160
                    String[] options = Utils.splitOptions(str);
164
168
                    ex.printStackTrace();
165
169
                    JOptionPane.showMessageDialog(
166
170
                        comp, 
167
 
                        "Error parsing commandline:\n" + ex, 
168
 
                        "Error...",
 
171
                        Messages.getInstance().getString("PropertyPanel_CreateDefaultPanel_Exception_Text_First") + ex, 
 
172
                        Messages.getInstance().getString("PropertyPanel_CreateDefaultPanel_Exception_Text_Second"),
169
173
                        JOptionPane.ERROR_MESSAGE);
170
174
                  }
171
175
                }
223
227
      m_PD = null;
224
228
    }
225
229
  }
 
230
  
 
231
  /**
 
232
   * Passes on enabled/disabled status to the custom
 
233
   * panel (if one is set).
 
234
   * 
 
235
   * @param enabled true if this panel (and the custom panel is enabled)
 
236
   */
 
237
  public void setEnabled(boolean enabled) {
 
238
    super.setEnabled(enabled);
 
239
    if (m_HasCustomPanel) {
 
240
      m_CustomPanel.setEnabled(enabled);
 
241
    }
 
242
    
 
243
  }
226
244
 
227
245
  /**
228
246
   * Paints the component, using the property editor's paint method.