From: <dal...@us...> - 2011-07-12 02:37:45
|
Revision: 19663 http://jedit.svn.sourceforge.net/jedit/?rev=19663&view=rev Author: daleanson Date: 2011-07-12 02:37:38 +0000 (Tue, 12 Jul 2011) Log Message: ----------- Code clean up, stop button adjustments. Modified Paths: -------------- plugins/SideKick/trunk/sidekick/SideKickPlugin.java plugins/SideKick/trunk/sidekick/SideKickTree.java Modified: plugins/SideKick/trunk/sidekick/SideKickPlugin.java =================================================================== --- plugins/SideKick/trunk/sidekick/SideKickPlugin.java 2011-07-11 18:36:39 UTC (rev 19662) +++ plugins/SideKick/trunk/sidekick/SideKickPlugin.java 2011-07-12 02:37:38 UTC (rev 19663) @@ -289,8 +289,9 @@ public static void execute(View view, SwingWorker worker) { - // TODO: there should be only one worker per view. Is it possible + // QUESTION: there should be only one worker per view. Is it possible // there could be more than one? + // ANSWER: No. workers.put(view, worker); worker.execute(); } Modified: plugins/SideKick/trunk/sidekick/SideKickTree.java =================================================================== --- plugins/SideKick/trunk/sidekick/SideKickTree.java 2011-07-11 18:36:39 UTC (rev 19662) +++ plugins/SideKick/trunk/sidekick/SideKickTree.java 2011-07-12 02:37:38 UTC (rev 19663) @@ -41,7 +41,7 @@ import javax.swing.Box; import javax.swing.DefaultComboBoxModel; -import javax.swing.JButton; +import javax.swing.Icon; import javax.swing.JCheckBoxMenuItem; import javax.swing.JComboBox; import javax.swing.JTextArea; @@ -52,7 +52,6 @@ import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.SwingUtilities; -import javax.swing.SwingWorker; import javax.swing.JToolBar; import javax.swing.JTree; import javax.swing.Timer; @@ -71,7 +70,6 @@ import org.gjt.sp.jedit.EditBus; import org.gjt.sp.jedit.EditPane; import org.gjt.sp.jedit.GUIUtilities; -import org.gjt.sp.jedit.MiscUtilities; import org.gjt.sp.jedit.Mode; import org.gjt.sp.jedit.OperatingSystem; import org.gjt.sp.jedit.ServiceManager; @@ -99,8 +97,9 @@ // {{{ Instance variables private RolloverButton parseBtn; - private RolloverButton propsBtn; - private RolloverButton stopBtn; + + private Icon parseIcon; + private Icon stopIcon; private JComboBox parserCombo; protected JTree tree; @@ -125,9 +124,7 @@ private JPanel toolBox; private JPanel parserPanel = null; - private JLabel search; private JTextField searchField; - private JButton clearSearchBtn; // }}} // {{{ SideKickTree constructor @@ -146,23 +143,21 @@ filterBox.setLayout(new BorderLayout()); filterBox.setFloatable(false); - parseBtn = new RolloverButton(GUIUtilities.loadIcon("Parse.png")); - + parseIcon = GUIUtilities.loadIcon("Parse.png"); + stopIcon = GUIUtilities.loadIcon(jEdit.getProperty("hypersearch-results.stop.icon")); + parseBtn = new RolloverButton(parseIcon); + parseBtn.setToolTipText(jEdit.getProperty("sidekick-tree.parse")); parseBtn.setMargin(new Insets(0,0,0,0)); parseBtn.setRequestFocusEnabled(false); parseBtn.setEnabled(true); ActionListener ah = new ActionHandler(); parseBtn.addActionListener(ah); - - propsBtn = new RolloverButton(GUIUtilities.loadIcon("ButtonProperties.png")); + + RolloverButton propsBtn = new RolloverButton(GUIUtilities.loadIcon("ButtonProperties.png")); propsBtn.setToolTipText(jEdit.getProperty("sidekick-tree.mode-options")); propsBtn.addActionListener(new SideKickProperties()); - stopBtn = new RolloverButton(GUIUtilities.loadIcon(jEdit.getProperty("hypersearch-results.stop.icon"))); - stopBtn.setToolTipText(jEdit.getProperty("sidekick-tree.stop-parsing")); - stopBtn.addActionListener(ah); - configMenu = new JPopupMenu("Parse"); followCaret = new JCheckBoxMenuItem("Follow Caret"); @@ -182,10 +177,10 @@ onChange.addActionListener(ah); onSave.addActionListener(ah); followCaret.addActionListener(ah); - search = new JLabel(jEdit.getProperty("sidekick-tree.filter.label") + " "); + JLabel search = new JLabel(jEdit.getProperty("sidekick-tree.filter.label") + " "); searchField = new JTextField(); searchField.setToolTipText(jEdit.getProperty("sidekick-tree.filter.tooltip")); - clearSearchBtn = new RolloverButton(GUIUtilities.loadIcon("22x22/actions/edit-clear.png")); + RolloverButton clearSearchBtn = new RolloverButton(GUIUtilities.loadIcon("22x22/actions/edit-clear.png")); clearSearchBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) @@ -199,7 +194,6 @@ buttonBox.add(parseBtn); buttonBox.add(propsBtn); - buttonBox.add(stopBtn); filterBox.add(search, BorderLayout.WEST); filterBox.add(searchField, BorderLayout.CENTER); filterBox.add(clearSearchBtn, BorderLayout.EAST); @@ -293,7 +287,17 @@ { public void run() { - stopBtn.setVisible(show); + if (show && parseIcon.equals(parseBtn.getIcon())) + { + parseBtn.setToolTipText(jEdit.getProperty("sidekick-tree.stop-parsing")); + parseBtn.setIcon(stopIcon); + + } + else + { + parseBtn.setToolTipText(jEdit.getProperty("sidekick-tree.parse")); + parseBtn.setIcon(parseIcon); + } } } ); @@ -619,7 +623,10 @@ if (currentParser != null) { String name = currentParser.getName(); - name = name == null ? SideKickPlugin.DEFAULT : name; + if (name == null) + { + name = SideKickPlugin.DEFAULT; + } parserCombo.setSelectedItem(name); } else @@ -692,7 +699,7 @@ // caret position. if (!jEdit.getBooleanProperty("sidekick.persistentFilter")) { - if (searchField.getText().length() > 0) + if (searchField.getText().length() > 0) // NOPMD { searchField.setText(""); updateFilter(false); @@ -811,7 +818,7 @@ } if (!jEdit.getBooleanProperty("sidekick.persistentFilter")) { - if (searchField.getText().length() > 0) + if (searchField.getText().length() > 0) // NOPMD { searchField.setText(""); updateFilter(false); @@ -947,12 +954,32 @@ propertiesChanged(); } - else if (evt.getSource() == stopBtn) + else if (evt.getSource() == parseBtn && stopIcon.equals(parseBtn.getIcon())) { SideKickPlugin.stop(view); + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + parseBtn.setIcon(parseIcon); + parseBtn.setToolTipText(jEdit.getProperty("sidekick-tree.parse")); + } + }); } if (evt.getSource() == parseBtn || evt.getSource() == parserCombo) { + if (evt.getSource() == parseBtn) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + parseBtn.setIcon(stopIcon); + parseBtn.setToolTipText(jEdit.getProperty("sidekick-tree.stop-parsing")); + + } + }); + } level = 0; Object usermode = b.getProperty("usermode"); if (usermode == null || usermode == Boolean.FALSE) @@ -1299,7 +1326,7 @@ { if (!jEdit.getBooleanProperty("sidekick.persistentFilter")) { - if (searchField.getText().length() > 0) + if (searchField.getText().length() > 0) // NOPMD { searchField.setText(""); updateFilter(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |