1.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties Tue Feb 08 23:13:13 2011 +0100
1.2 +++ b/api/src/org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties Tue Feb 08 23:16:16 2011 +0100
1.3 @@ -69,4 +69,6 @@
1.4 FindDuplicatesRefactoringPanel.knowPatterns.text=&Known patterns
1.5 FindDuplicatesRefactoringPanel.examplesButton.text=
1.6 BTN_Examples=Examples
1.7 -ExamplesList.jLabel1.text=Examples:
1.8 +FindDuplicatesRefactoringPanel.recentButton.toolTipText=Recent Rules
1.9 +FindDuplicatesRefactoringPanel.recentButton.text=
1.10 +ExamplesList.pattern.contentType=text/x-javahints
2.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/ExamplesList.form Tue Feb 08 23:13:13 2011 +0100
2.2 +++ b/api/src/org/netbeans/modules/jackpot30/impl/refactoring/ExamplesList.form Tue Feb 08 23:16:16 2011 +0100
2.3 @@ -16,9 +16,10 @@
2.4 <Layout>
2.5 <DimensionLayout dim="0">
2.6 <Group type="103" groupAlignment="0" attributes="0">
2.7 - <Group type="102" alignment="0" attributes="0">
2.8 + <Group type="102" alignment="1" attributes="0">
2.9 <EmptySpace max="-2" attributes="0"/>
2.10 - <Group type="103" groupAlignment="0" attributes="0">
2.11 + <Group type="103" groupAlignment="1" attributes="0">
2.12 + <Component id="jScrollPane2" alignment="0" pref="376" max="32767" attributes="0"/>
2.13 <Component id="jScrollPane1" alignment="0" pref="376" max="32767" attributes="0"/>
2.14 <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
2.15 </Group>
2.16 @@ -32,7 +33,9 @@
2.17 <EmptySpace max="-2" attributes="0"/>
2.18 <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
2.19 <EmptySpace max="-2" attributes="0"/>
2.20 - <Component id="jScrollPane1" pref="255" max="32767" attributes="0"/>
2.21 + <Component id="jScrollPane1" pref="130" max="32767" attributes="0"/>
2.22 + <EmptySpace max="-2" attributes="0"/>
2.23 + <Component id="jScrollPane2" min="-2" pref="119" max="-2" attributes="0"/>
2.24 <EmptySpace max="-2" attributes="0"/>
2.25 </Group>
2.26 </Group>
2.27 @@ -41,8 +44,8 @@
2.28 <SubComponents>
2.29 <Component class="javax.swing.JLabel" name="jLabel1">
2.30 <Properties>
2.31 - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
2.32 - <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="ExamplesList.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
2.33 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
2.34 + <Connection code="convertor.getHeader()" type="code"/>
2.35 </Property>
2.36 </Properties>
2.37 </Component>
2.38 @@ -67,9 +70,26 @@
2.39 </Properties>
2.40 <Events>
2.41 <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="listMouseClicked"/>
2.42 + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="listValueChanged"/>
2.43 </Events>
2.44 </Component>
2.45 </SubComponents>
2.46 </Container>
2.47 + <Container class="javax.swing.JScrollPane" name="jScrollPane2">
2.48 + <AuxValues>
2.49 + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
2.50 + </AuxValues>
2.51 +
2.52 + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
2.53 + <SubComponents>
2.54 + <Component class="javax.swing.JEditorPane" name="pattern">
2.55 + <Properties>
2.56 + <Property name="contentType" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
2.57 + <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="ExamplesList.pattern.contentType" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
2.58 + </Property>
2.59 + </Properties>
2.60 + </Component>
2.61 + </SubComponents>
2.62 + </Container>
2.63 </SubComponents>
2.64 </Form>
3.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/ExamplesList.java Tue Feb 08 23:13:13 2011 +0100
3.2 +++ b/api/src/org/netbeans/modules/jackpot30/impl/refactoring/ExamplesList.java Tue Feb 08 23:16:16 2011 +0100
3.3 @@ -43,33 +43,41 @@
3.4
3.5 import java.awt.Component;
3.6 import java.awt.Dialog;
3.7 +import java.awt.Rectangle;
3.8 import java.util.Collections;
3.9 import java.util.Set;
3.10 import javax.swing.DefaultListCellRenderer;
3.11 import javax.swing.DefaultListModel;
3.12 import javax.swing.JList;
3.13 -import org.netbeans.modules.jackpot30.impl.examples.Example;
3.14 +import javax.swing.text.BadLocationException;
3.15 import org.netbeans.modules.jackpot30.impl.examples.Example.Option;
3.16 -import org.netbeans.modules.jackpot30.impl.examples.LoadExamples;
3.17 import org.openide.DialogDescriptor;
3.18 import org.openide.DialogDisplayer;
3.19 +import org.openide.util.Exceptions;
3.20
3.21 /**
3.22 *
3.23 * @author lahvac
3.24 */
3.25 -public class ExamplesList extends javax.swing.JPanel {
3.26 +public class ExamplesList<T> extends javax.swing.JPanel {
3.27
3.28 - public ExamplesList(Set<Option> require, Set<Option> forbidden) {
3.29 + private final DialogDescription<T> convertor;
3.30 + private final Class<T> dataClass;
3.31 +
3.32 + public ExamplesList(Iterable<? extends T> data, DialogDescription<T> convertor, Class<T> dataClass, Set<Option> require, Set<Option> forbidden) {
3.33 + this.convertor = convertor;
3.34 + this.dataClass = dataClass;
3.35 +
3.36 initComponents();
3.37
3.38 DefaultListModel listModel = new DefaultListModel();
3.39
3.40 - for (Example e : LoadExamples.loadExamples()) {
3.41 - if (!e.getOptions().containsAll(require)) continue;
3.42 - if (!Collections.disjoint(e.getOptions(), forbidden)) continue;
3.43 + for (T t : data) {
3.44 + Set<Option> options = convertor.getOptions(t);
3.45 + if (!options.containsAll(require)) continue;
3.46 + if (!Collections.disjoint(options, forbidden)) continue;
3.47
3.48 - listModel.addElement(e);
3.49 + listModel.addElement(t);
3.50 }
3.51
3.52 list.setModel(listModel);
3.53 @@ -89,8 +97,10 @@
3.54 jLabel1 = new javax.swing.JLabel();
3.55 jScrollPane1 = new javax.swing.JScrollPane();
3.56 list = new javax.swing.JList();
3.57 + jScrollPane2 = new javax.swing.JScrollPane();
3.58 + pattern = new javax.swing.JEditorPane();
3.59
3.60 - jLabel1.setText(org.openide.util.NbBundle.getMessage(ExamplesList.class, "ExamplesList.jLabel1.text")); // NOI18N
3.61 + jLabel1.setText(convertor.getHeader());
3.62
3.63 list.setModel(new javax.swing.AbstractListModel() {
3.64 String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
3.65 @@ -102,17 +112,26 @@
3.66 listMouseClicked(evt);
3.67 }
3.68 });
3.69 + list.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
3.70 + public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
3.71 + listValueChanged(evt);
3.72 + }
3.73 + });
3.74 jScrollPane1.setViewportView(list);
3.75
3.76 + pattern.setContentType(org.openide.util.NbBundle.getMessage(ExamplesList.class, "ExamplesList.pattern.contentType")); // NOI18N
3.77 + jScrollPane2.setViewportView(pattern);
3.78 +
3.79 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
3.80 this.setLayout(layout);
3.81 layout.setHorizontalGroup(
3.82 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
3.83 - .addGroup(layout.createSequentialGroup()
3.84 + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
3.85 .addContainerGap()
3.86 - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
3.87 - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
3.88 - .addComponent(jLabel1))
3.89 + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
3.90 + .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
3.91 + .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
3.92 + .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING))
3.93 .addContainerGap())
3.94 );
3.95 layout.setVerticalGroup(
3.96 @@ -121,7 +140,9 @@
3.97 .addContainerGap()
3.98 .addComponent(jLabel1)
3.99 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
3.100 - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 255, Short.MAX_VALUE)
3.101 + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE)
3.102 + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
3.103 + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
3.104 .addContainerGap())
3.105 );
3.106 }// </editor-fold>//GEN-END:initComponents
3.107 @@ -133,10 +154,28 @@
3.108 }
3.109 }//GEN-LAST:event_listMouseClicked
3.110
3.111 + private void listValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_listValueChanged
3.112 + T ex = dataClass.cast(list.getSelectedValue());
3.113 +
3.114 + pattern.setText(convertor.getCode(ex));
3.115 +
3.116 + try {
3.117 + Rectangle rect = pattern.modelToView(0);
3.118 +
3.119 + if (rect != null) {
3.120 + pattern.scrollRectToVisible(rect);
3.121 + }
3.122 + } catch (BadLocationException ex1) {
3.123 + Exceptions.printStackTrace(ex1);
3.124 + }
3.125 + }//GEN-LAST:event_listValueChanged
3.126 +
3.127 // Variables declaration - do not modify//GEN-BEGIN:variables
3.128 private javax.swing.JLabel jLabel1;
3.129 private javax.swing.JScrollPane jScrollPane1;
3.130 + private javax.swing.JScrollPane jScrollPane2;
3.131 private javax.swing.JList list;
3.132 + private javax.swing.JEditorPane pattern;
3.133 // End of variables declaration//GEN-END:variables
3.134
3.135 private DialogDescriptor desc;
3.136 @@ -147,23 +186,21 @@
3.137 this.dialog = dialog;
3.138 }
3.139
3.140 - public Example getSelectedExample() {
3.141 - return (Example) list.getSelectedValue();
3.142 + public T getSelectedExample() {
3.143 + return dataClass.cast(list.getSelectedValue());
3.144 }
3.145
3.146 - private static class ExamplesRenderer extends DefaultListCellRenderer {
3.147 + private class ExamplesRenderer extends DefaultListCellRenderer {
3.148 @Override
3.149 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
3.150 - if (value instanceof Example) {
3.151 - value = ((Example) value).getDisplayName();
3.152 - }
3.153 + value = convertor.getDisplayName(dataClass.cast(value));
3.154 return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
3.155 }
3.156 }
3.157
3.158 - public static Example chooseExample(Set<Option> require, Set<Option> forbidden) {
3.159 - ExamplesList examples = new ExamplesList(require, forbidden);
3.160 - DialogDescriptor dd = new DialogDescriptor(examples, "Choose Example", true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, null);
3.161 + public static <T> T chooseExample(Iterable<? extends T> examplesList, DialogDescription<T> convertor, Class<T> dataClass, Set<Option> require, Set<Option> forbidden) {
3.162 + ExamplesList<T> examples = new ExamplesList<T>(examplesList, convertor, dataClass, require, forbidden);
3.163 + DialogDescriptor dd = new DialogDescriptor(examples, convertor.getCaption(), true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, null);
3.164 Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
3.165
3.166 examples.setDialog(dd, dialog);
3.167 @@ -175,4 +212,12 @@
3.168
3.169 return null;
3.170 }
3.171 +
3.172 + public interface DialogDescription<T> {
3.173 + public String getCaption();
3.174 + public String getHeader();
3.175 + public String getDisplayName(T t);
3.176 + public String getCode(T t);
3.177 + public Set<Option> getOptions(T t);
3.178 + }
3.179 }
4.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/FindDuplicatesRefactoringPanel.form Tue Feb 08 23:13:13 2011 +0100
4.2 +++ b/api/src/org/netbeans/modules/jackpot30/impl/refactoring/FindDuplicatesRefactoringPanel.form Tue Feb 08 23:16:16 2011 +0100
4.3 @@ -248,6 +248,24 @@
4.4 <Property name="horizontalGap" type="int" value="0"/>
4.5 </Layout>
4.6 <SubComponents>
4.7 + <Component class="javax.swing.JButton" name="recentButton">
4.8 + <Properties>
4.9 + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
4.10 + <Image iconType="3" name="/org/netbeans/modules/jackpot30/impl/resources/recent_icon.png"/>
4.11 + </Property>
4.12 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
4.13 + <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="FindDuplicatesRefactoringPanel.recentButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
4.14 + </Property>
4.15 + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
4.16 + <ResourceString bundle="org/netbeans/modules/jackpot30/impl/refactoring/Bundle.properties" key="FindDuplicatesRefactoringPanel.recentButton.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
4.17 + </Property>
4.18 + <Property name="borderPainted" type="boolean" value="false"/>
4.19 + <Property name="contentAreaFilled" type="boolean" value="false"/>
4.20 + </Properties>
4.21 + <Events>
4.22 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="recentButtonActionPerformed"/>
4.23 + </Events>
4.24 + </Component>
4.25 <Component class="javax.swing.JButton" name="examplesButton">
4.26 <Properties>
4.27 <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
5.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/FindDuplicatesRefactoringPanel.java Tue Feb 08 23:13:13 2011 +0100
5.2 +++ b/api/src/org/netbeans/modules/jackpot30/impl/refactoring/FindDuplicatesRefactoringPanel.java Tue Feb 08 23:16:16 2011 +0100
5.3 @@ -41,6 +41,7 @@
5.4
5.5 import java.awt.CardLayout;
5.6 import java.util.Collection;
5.7 +import java.util.Collections;
5.8 import java.util.EnumSet;
5.9 import java.util.HashSet;
5.10 import java.util.LinkedList;
5.11 @@ -48,6 +49,8 @@
5.12 import java.util.Map;
5.13 import java.util.Set;
5.14 import java.util.TreeMap;
5.15 +import java.util.prefs.BackingStoreException;
5.16 +import java.util.prefs.Preferences;
5.17 import javax.swing.DefaultListModel;
5.18 import javax.swing.SwingUtilities;
5.19 import javax.swing.event.ChangeEvent;
5.20 @@ -60,7 +63,11 @@
5.21 import org.netbeans.modules.jackpot30.impl.batch.BatchSearch.Scope;
5.22 import org.netbeans.modules.jackpot30.impl.examples.Example;
5.23 import org.netbeans.modules.jackpot30.impl.examples.Example.Option;
5.24 +import org.netbeans.modules.jackpot30.impl.examples.LoadExamples;
5.25 +import org.netbeans.modules.jackpot30.impl.refactoring.ExamplesList.DialogDescription;
5.26 import org.netbeans.modules.jackpot30.spi.HintDescription;
5.27 +import org.openide.util.Exceptions;
5.28 +import org.openide.util.NbPreferences;
5.29 import org.openide.util.Union2;
5.30
5.31 /**
5.32 @@ -147,6 +154,7 @@
5.33 jScrollPane1 = new javax.swing.JScrollPane();
5.34 pattern = new javax.swing.JTextPane();
5.35 jPanel3 = new javax.swing.JPanel();
5.36 + recentButton = new javax.swing.JButton();
5.37 examplesButton = new javax.swing.JButton();
5.38 patternTypeSelectionPanel = new javax.swing.JPanel();
5.39 knowPatterns = new javax.swing.JRadioButton();
5.40 @@ -299,6 +307,18 @@
5.41
5.42 jPanel3.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 5));
5.43
5.44 + recentButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/jackpot30/impl/resources/recent_icon.png"))); // NOI18N
5.45 + org.openide.awt.Mnemonics.setLocalizedText(recentButton, org.openide.util.NbBundle.getMessage(FindDuplicatesRefactoringPanel.class, "FindDuplicatesRefactoringPanel.recentButton.text")); // NOI18N
5.46 + recentButton.setToolTipText(org.openide.util.NbBundle.getMessage(FindDuplicatesRefactoringPanel.class, "FindDuplicatesRefactoringPanel.recentButton.toolTipText")); // NOI18N
5.47 + recentButton.setBorderPainted(false);
5.48 + recentButton.setContentAreaFilled(false);
5.49 + recentButton.addActionListener(new java.awt.event.ActionListener() {
5.50 + public void actionPerformed(java.awt.event.ActionEvent evt) {
5.51 + recentButtonActionPerformed(evt);
5.52 + }
5.53 + });
5.54 + jPanel3.add(recentButton);
5.55 +
5.56 examplesButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/jackpot30/impl/resources/examples_icon.png"))); // NOI18N
5.57 org.openide.awt.Mnemonics.setLocalizedText(examplesButton, org.openide.util.NbBundle.getMessage(FindDuplicatesRefactoringPanel.class, "FindDuplicatesRefactoringPanel.examplesButton.text")); // NOI18N
5.58 examplesButton.setToolTipText(org.openide.util.NbBundle.getMessage(FindDuplicatesRefactoringPanel.class, "BTN_Examples")); // NOI18N
5.59 @@ -419,13 +439,40 @@
5.60 }//GEN-LAST:event_knowPatternsActionPerformed
5.61
5.62 private void examplesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_examplesButtonActionPerformed
5.63 - Example ex = ExamplesList.chooseExample(query ? EnumSet.noneOf(Option.class) : EnumSet.of(Option.FIX), query ? EnumSet.of(Option.FIX) : EnumSet.noneOf(Option.class));
5.64 + Example ex = ExamplesList.chooseExample(LoadExamples.loadExamples(), new ExamplesConvertor(), Example.class, query ? EnumSet.noneOf(Option.class) : EnumSet.of(Option.FIX), query ? EnumSet.of(Option.FIX) : EnumSet.noneOf(Option.class));
5.65
5.66 if (ex != null) {
5.67 pattern.setText(ex.getCode());
5.68 }
5.69 }//GEN-LAST:event_examplesButtonActionPerformed
5.70
5.71 + private void recentButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_recentButtonActionPerformed
5.72 + String cod = ExamplesList.chooseExample(loadRecent(),
5.73 + new DialogDescription<String>() {
5.74 + public String getDisplayName(String t) {
5.75 + return t;
5.76 + }
5.77 + public String getCode(String t) {
5.78 + return t;
5.79 + }
5.80 + public Set<Option> getOptions(String t) {
5.81 + return query ? EnumSet.noneOf(Option.class) : EnumSet.of(Option.FIX);
5.82 + }
5.83 + public String getCaption() {
5.84 + return "Recent patterns";
5.85 + }
5.86 + public String getHeader() {
5.87 + return "Patterns:";
5.88 + }
5.89 + },
5.90 + String.class,
5.91 + query ? EnumSet.noneOf(Option.class) : EnumSet.of(Option.FIX), query ? EnumSet.of(Option.FIX) : EnumSet.noneOf(Option.class));
5.92 +
5.93 + if (cod != null) {
5.94 + pattern.setText(cod);
5.95 + }
5.96 + }//GEN-LAST:event_recentButtonActionPerformed
5.97 +
5.98 private void stateChanged() {
5.99 if (SwingUtilities.isEventDispatchThread()) {
5.100 changeListener.stateChanged(new ChangeEvent(this));
5.101 @@ -508,10 +555,61 @@
5.102
5.103 void fillInFromSettings() {
5.104 scopesPanel.fillInFromSettings();
5.105 +
5.106 + List<String> recent = loadRecent();
5.107 +
5.108 + if (!recent.isEmpty()) {
5.109 + pattern.setText(recent.get(0));
5.110 + }
5.111 }
5.112
5.113 void saveScopesCombo() {
5.114 scopesPanel.saveScopesCombo();
5.115 +
5.116 + String currentPattern = pattern.getText().trim();
5.117 + List<String> recent = loadRecent();
5.118 +
5.119 + recent.remove(currentPattern);
5.120 + recent.add(0, currentPattern);
5.121 +
5.122 + while (recent.size() > MAX_RECENT) {
5.123 + recent.remove(recent.size() - 1);
5.124 + }
5.125 +
5.126 + Preferences prefs = NbPreferences.forModule(FindDuplicatesRefactoringPanel.class);
5.127 + Preferences recentPatterns = prefs.node(query ? RECENT_PATTERNS_QUERY : RECENT_PATTERNS_APPLY);
5.128 + int i = 0;
5.129 +
5.130 + for (String r : recent) {
5.131 + recentPatterns.put("pattern_" + i++, r);
5.132 + }
5.133 + }
5.134 +
5.135 + private static final int MAX_RECENT = 50;
5.136 + private static final String RECENT_PATTERNS_QUERY = "recentPatternsQuery";
5.137 + private static final String RECENT_PATTERNS_APPLY = "recentPatternsApply";
5.138 +
5.139 + private List<String> loadRecent() {
5.140 + Preferences prefs = NbPreferences.forModule(FindDuplicatesRefactoringPanel.class);
5.141 +
5.142 + if (prefs == null) return Collections.emptyList();
5.143 +
5.144 + List<String> recent = new LinkedList<String>();
5.145 + Preferences recentPatterns = prefs.node(query ? RECENT_PATTERNS_QUERY : RECENT_PATTERNS_APPLY);
5.146 +
5.147 + if (recentPatterns != null) {
5.148 + try {
5.149 + for (String k : recentPatterns.keys()) {
5.150 + if (k.startsWith("pattern_")) {
5.151 + recent.add(recentPatterns.get(k, null));
5.152 + }
5.153 + }
5.154 + } catch (BackingStoreException ex) {
5.155 + Exceptions.printStackTrace(ex);
5.156 + }
5.157 + }
5.158 +
5.159 + return recent;
5.160 }
5.161
5.162 // Variables declaration - do not modify//GEN-BEGIN:variables
5.163 @@ -534,6 +632,7 @@
5.164 private javax.swing.JTextPane pattern;
5.165 private javax.swing.JPanel patternSelection;
5.166 private javax.swing.JPanel patternTypeSelectionPanel;
5.167 + private javax.swing.JButton recentButton;
5.168 private javax.swing.JButton removeAllHints;
5.169 private javax.swing.JButton removeHint;
5.170 private org.netbeans.modules.jackpot30.impl.refactoring.ScopesPanel scopesPanel;
5.171 @@ -543,4 +642,28 @@
5.172 // End of variables declaration//GEN-END:variables
5.173
5.174 private static final String HINTS_LIST_PROTOTYPE = "012345678901234567890123456789";
5.175 +
5.176 + private static final class ExamplesConvertor implements DialogDescription<Example> {
5.177 +
5.178 + public String getDisplayName(Example t) {
5.179 + return t.getDisplayName();
5.180 + }
5.181 +
5.182 + public String getCode(Example t) {
5.183 + return t.getCode();
5.184 + }
5.185 +
5.186 + public Set<Option> getOptions(Example t) {
5.187 + return t.getOptions();
5.188 + }
5.189 +
5.190 + public String getCaption() {
5.191 + return "Choose Example";
5.192 + }
5.193 +
5.194 + public String getHeader() {
5.195 + return "Examples:";
5.196 + }
5.197 +
5.198 + }
5.199 }
6.1 Binary file api/src/org/netbeans/modules/jackpot30/impl/resources/examples_icon.png has changed
7.1 Binary file api/src/org/netbeans/modules/jackpot30/impl/resources/recent_icon.png has changed
8.1 --- a/borrowedtests/nbproject/platform.properties Tue Feb 08 23:13:13 2011 +0100
8.2 +++ b/borrowedtests/nbproject/platform.properties Tue Feb 08 23:16:16 2011 +0100
8.3 @@ -16,5 +16,6 @@
8.4 ${nbplatform.active.dir}/java:\
8.5 ${nbplatform.active.dir}/groovy:\
8.6 ${nbplatform.active.dir}/ruby:\
8.7 + ${nbplatform.active.dir}/extra:\
8.8 ${nbplatform.active.dir}/ide
8.9 nbplatform.active=default
9.1 --- a/cmdline/nbproject/platform.properties Tue Feb 08 23:13:13 2011 +0100
9.2 +++ b/cmdline/nbproject/platform.properties Tue Feb 08 23:16:16 2011 +0100
9.3 @@ -10,6 +10,7 @@
9.4 ${nbplatform.active.dir}/platform:\
9.5 ${nbplatform.active.dir}/profiler:\
9.6 ${nbplatform.active.dir}/websvccommon:\
9.7 + ${nbplatform.active.dir}/extra:\
9.8 ../build/cluster:\
9.9 ../borrowedtests/build/cluster
9.10 nbplatform.active=default
10.1 --- a/hudson/trunk Tue Feb 08 23:13:13 2011 +0100
10.2 +++ b/hudson/trunk Tue Feb 08 23:16:16 2011 +0100
10.3 @@ -23,7 +23,7 @@
10.4 unzip -q ../download/*$TRUNK_ID-$1.zip || exit
10.5 }
10.6
10.7 -for cluster in ide platform java harness nb apisupport; do
10.8 +for cluster in ide platform java harness nb apisupport extra; do
10.9 download_and_unpack_cluster $cluster;
10.10 done
10.11
11.1 --- a/nbproject/platform.properties Tue Feb 08 23:13:13 2011 +0100
11.2 +++ b/nbproject/platform.properties Tue Feb 08 23:16:16 2011 +0100
11.3 @@ -16,6 +16,7 @@
11.4 ${nbplatform.active.dir}/java:\
11.5 ${nbplatform.active.dir}/groovy:\
11.6 ${nbplatform.active.dir}/ruby:\
11.7 + ${nbplatform.active.dir}/extra:\
11.8 ${nbplatform.active.dir}/ide:\
11.9 borrowedtests/build/cluster
11.10 nbplatform.active=default