Skip to content
Browse files

refactored settings, jedit version fully working

  • Loading branch information...
1 parent cba37fd commit a20131037ed62e98f5ec1e3cb55ac9ea83c5f862 @sickill committed
View
5 TODO
@@ -1,3 +1,8 @@
+0.9.4
+- pattern from selected text
+- change regexps to wildacards
+- ignore _ and . at start of filename
+
0.9
- replace html rendering with something else (HtmlRenderer in Netbeans?)
- add group dividers/labels to results
View
47 common-src/net/sickill/off/common/OffDialog.java
@@ -0,0 +1,47 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package net.sickill.off.common;
+
+import java.awt.Frame;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import javax.swing.JDialog;
+import javax.swing.WindowConstants;
+
+/**
+ *
+ * @author kill
+ */
+public abstract class OffDialog extends JDialog implements ComponentListener {
+ protected static Settings settings;
+
+ protected abstract Settings getSettings();
+
+ public OffDialog(Frame f, String name) {
+ super(f, name);
+ addComponentListener(this);
+ addNotify();
+ setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
+ settings = getSettings();
+ setSize(settings.getDialogWidth(), settings.getDialogHeight());
+ setLocationRelativeTo(null);
+ }
+
+ public void componentResized(ComponentEvent e) {
+ settings.setDialogWidth(this.getWidth());
+ settings.setDialogHeight(this.getHeight());
+ }
+
+ public void componentMoved(ComponentEvent e) {
+ }
+
+ public void componentShown(ComponentEvent e) {
+ }
+
+ public void componentHidden(ComponentEvent e) {
+ }
+
+}
View
3 common-src/net/sickill/off/common/OffPanel.java
@@ -98,10 +98,7 @@ private void build() {
JScrollPane scroller = new JScrollPane(resultsList);
add(scroller, BorderLayout.CENTER);
- // projects combo
-
// Add escape-key event handling to widgets
-// KeyHandler keyHandler = new KeyHandler();
addKeyListener(this);
patternInput.addKeyListener(this);
resultsList.addKeyListener(this);
View
157 common-src/net/sickill/off/common/Settings.java
@@ -32,42 +32,27 @@
private Pattern lessPriorityMaskCompiled;
private Pattern ignoreMaskCompiled;
- public abstract boolean isCustomSorting();
- public abstract boolean isDistanceSorting();
- public abstract boolean isExtensionSorting();
- public abstract boolean isMatchFromStart();
- public abstract boolean isPopularitySorting();
- public abstract boolean isShowExt();
- public abstract boolean isShowPath();
- public abstract boolean isShowSize();
- public abstract boolean isSmartMatch();
- public abstract boolean isNameSorting();
- public abstract boolean isClearOnOpen();
- public abstract void setDialogWidth(int w);
- public abstract int getDialogWidth();
- public abstract void setDialogHeight(int h);
- public abstract int getDialogHeight();
- public abstract float getSearchDelay();
- public abstract int getMinPatternLength();
- public abstract String getIgnoreMask();
- public abstract void setIgnoreMask(String mask);
- public abstract void setMatchFromStart(boolean selected);
- public abstract void setMinPatternLength(int value);
- public abstract void setSearchDelay(float value);
- public abstract void setSmartMatch(boolean selected);
- public abstract void setClearOnOpen(boolean selected);
- public abstract void setLessPriorityMask(String mask);
- public abstract String getLessPriorityMask();
- public abstract void setNameSorting(boolean b);
+ public abstract void setBoolean(String prop, boolean b);
+ public abstract boolean getBoolean(String prop, boolean def);
+ public abstract void setString(String prop, String s);
+ public abstract String getString(String prop, String def);
+ public abstract void setInt(String prop, int i);
+ public abstract int getInt(String prop, int def);
+ public abstract void setFloat(String prop, float f);
+ public abstract float getFloat(String prop, float def);
+
+ protected static Pattern compileMask(String mask) {
+ return mask.equals("") ? null : Pattern.compile("(" + mask.replaceAll("\n", ")|(") + ")");
+ }
protected void compileLessPriorityMask() {
String mask = getLessPriorityMask().trim();
- lessPriorityMaskCompiled = mask.equals("") ? null : Pattern.compile("(" + mask.replaceAll("\n", ")|(") + ")");
+ lessPriorityMaskCompiled = compileMask(mask);
}
protected void compileIgnoreMask() {
String mask = getIgnoreMask().trim();
- ignoreMaskCompiled = mask.equals("") ? null : Pattern.compile("(" + mask.replaceAll("\n", ")|(") + ")");
+ ignoreMaskCompiled = compileMask(mask);
}
public Pattern getLessPriorityMaskCompiled() {
@@ -87,4 +72,118 @@ public Pattern getIgnoreMaskCompiled() {
public void lessPriorityMaskChanged() {
lessPriorityMaskCompiled = null;
}
+
+ // dialog
+
+ public void setDialogWidth(int w) {
+ setInt("dialog-width", w);
+ }
+
+ public int getDialogWidth() {
+ return getInt("dialog-width", Settings.DEFAULT_DIALOG_WIDTH);
+ }
+
+ public void setDialogHeight(int h) {
+ setInt("dialog-height", h);
+ }
+
+ public int getDialogHeight() {
+ return getInt("dialog-height", Settings.DEFAULT_DIALOG_HEIGHT);
+ }
+
+ // behaviour
+
+ public float getSearchDelay() {
+ return getFloat("search-delay", Settings.DEFAULT_SEARCH_DELAY);
+ }
+
+ public void setSearchDelay(float value) {
+ setFloat("search-delay", value);
+ }
+
+ public int getMinPatternLength() {
+ return getInt("min-pattern-length", Settings.DEFAULT_MIN_PATTERN_LENGTH);
+ }
+
+ public void setMinPatternLength(int value) {
+ setInt("min-pattern-length", value);
+ }
+
+ public boolean isSmartMatch() {
+ return getBoolean("smart-match", Settings.DEFAULT_SMART_MATCH);
+ }
+
+ public void setSmartMatch(boolean selected) {
+ setBoolean("smart-match", selected);
+ }
+
+ public String getIgnoreMask() {
+ return getString("ignore-mask", Settings.DEFAULT_IGNORE_MASK);
+ }
+
+ public void setIgnoreMask(String mask) {
+ setString("ignore-mask", mask);
+ compileIgnoreMask();
+ }
+
+ public void setMatchFromStart(boolean selected) {
+ setBoolean("match-from-start", selected);
+ }
+
+ public boolean isClearOnOpen() {
+ return getBoolean("clear-on-open", Settings.DEFAULT_CLEAR_ON_OPEN);
+ }
+
+ public void setClearOnOpen(boolean selected) {
+ setBoolean("clear-on-open", selected);
+ }
+
+ // show
+
+ public boolean isShowExt() {
+ return getBoolean("show-ext", Settings.DEFAULT_SHOW_EXTENSION);
+ }
+
+ public boolean isShowPath() {
+ return getBoolean("show-path", Settings.DEFAULT_SHOW_PATH);
+ }
+
+ public boolean isShowSize() {
+ return getBoolean("show-size", Settings.DEFAULT_SHOW_SIZE);
+ }
+
+ // sorting
+
+ public boolean isNameSorting() {
+ return getBoolean("name-sorting", Settings.DEFAULT_NAME_SORTING);
+ }
+
+ public boolean isExtensionSorting() {
+ return getBoolean("extension-sorting", Settings.DEFAULT_EXTENSION_SORTING);
+ }
+
+ public boolean isPopularitySorting() {
+ return getBoolean("popularity-sorting", Settings.DEFAULT_POPULARITY_SORTING);
+ }
+
+ public boolean isCustomSorting() {
+ return false;
+ }
+
+ public boolean isDistanceSorting() {
+ return getBoolean("distance-sorting", Settings.DEFAULT_DISTANCE_SORTING);
+ }
+
+ public boolean isMatchFromStart() {
+ return getBoolean("match-from-start", Settings.DEFAULT_MATCH_FROM_START);
+ }
+
+ public void setLessPriorityMask(String mask) {
+ setString("less-priority-mask", mask);
+ }
+
+ public String getLessPriorityMask() {
+ return getString("less-priority-mask", Settings.DEFAULT_LESS_PRIORITY_MASK);
+ }
+
}
View
17 jedit/Off.props
@@ -25,18 +25,7 @@ offwindow.show.label=Open File Fast Dialog
plugin.net.sickill.off.jedit.OffPlugin.menu=openfilefastdockable offwindow.show
# option pane settings
-plugin.net.sickill.taz.TazPlugin.option-pane=taz
-options.taz.label=Taz
-options.taz.code=new net.sickill.taz.TazOptionsPane();
+plugin.net.sickill.off.jedit.OffPlugin.option-pane=off
+options.off.label=Open File Fast
+options.off.code=new net.sickill.off.jedit.options.OffOptionsPane();
-# defaults
-taz.smart-match=true
-taz.min-pattern-length=3
-taz.sort-results=true
-taz.group-results=true
-taz.clear-on-open=false
-taz.show-icon=true
-taz.show-path=true
-taz.show-ext=true
-taz.show-size=false
-taz.search-delay=300
View
34 jedit/src/net/sickill/off/jedit/JEditDialog.java
@@ -6,50 +6,27 @@
package net.sickill.off.jedit;
import java.awt.BorderLayout;
-import java.awt.event.ComponentEvent;
-import java.awt.event.ComponentListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
-import javax.swing.JDialog;
-import javax.swing.WindowConstants;
+import net.sickill.off.common.OffDialog;
import net.sickill.off.common.OffPanel;
-import org.gjt.sp.jedit.GUIUtilities;
+import net.sickill.off.common.Settings;
import org.gjt.sp.jedit.View;
/**
*
* @author kill
*/
-public class JEditDialog extends JDialog implements ComponentListener, KeyListener {
+public class JEditDialog extends OffDialog implements KeyListener {
OffPanel off;
public JEditDialog(View view, OffPanel off) {
super(view, "Open File Fast");
this.off = off;
- addComponentListener(this);
- addNotify();
- setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
-
addKeyListener(this);
- setSize(554, 182);
- setLocationRelativeTo(null);
-// GUIUtilities.loadGeometry(this, "OffPlugin.window");
getContentPane().add(off, BorderLayout.CENTER);
}
- public void componentResized(ComponentEvent e) {
- GUIUtilities.saveGeometry(this, "OffPlugin.window");
- }
-
- public void componentMoved(ComponentEvent e) {
- }
-
- public void componentShown(ComponentEvent e) {
- }
-
- public void componentHidden(ComponentEvent e) {
- }
-
public void keyTyped(KeyEvent e) {
}
@@ -67,4 +44,9 @@ void showDialog() {
setVisible(true);
off.focusOnDefaultComponent();
}
+
+ @Override
+ protected Settings getSettings() {
+ return JEditSettings.getInstance();
+ }
}
View
243 jedit/src/net/sickill/off/jedit/JEditSettings.java
@@ -6,251 +6,72 @@
package net.sickill.off.jedit;
import net.sickill.off.common.Settings;
+import org.gjt.sp.jedit.jEdit;
/**
*
* @author kill
*/
public class JEditSettings extends Settings {
+ private static JEditSettings settings;
- @Override
- public boolean isCustomSorting() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean isDistanceSorting() {
- return true;
+ public static JEditSettings getInstance() {
+ if (settings == null) {
+ settings = new JEditSettings();
+ }
+ return settings;
}
@Override
- public boolean isExtensionSorting() {
- return true;
+ public void setBoolean(String prop, boolean b) {
+ prop = "OffPlugin." + prop;
+ jEdit.setBooleanProperty(prop, b);
}
@Override
- public boolean isMatchFromStart() {
- return true;
+ public boolean getBoolean(String prop, boolean def) {
+ prop = "OffPlugin." + prop;
+ return jEdit.getBooleanProperty(prop, def);
}
@Override
- public boolean isPopularitySorting() {
- return true;
+ public void setString(String prop, String s) {
+ prop = "OffPlugin." + prop;
+ jEdit.setProperty(prop, s);
}
@Override
- public boolean isShowExt() {
- return true;
+ public String getString(String prop, String def) {
+ prop = "OffPlugin." + prop;
+ return jEdit.getProperty(prop, def);
}
@Override
- public boolean isShowPath() {
- return true;
+ public void setInt(String prop, int i) {
+ prop = "OffPlugin." + prop;
+ jEdit.setIntegerProperty(prop, i);
}
@Override
- public boolean isShowSize() {
- return false;
+ public int getInt(String prop, int def) {
+ prop = "OffPlugin." + prop;
+ return jEdit.getIntegerProperty(prop, def);
}
@Override
- public boolean isSmartMatch() {
- return true;
+ public void setFloat(String prop, float f) {
+ prop = "OffPlugin." + prop;
+ jEdit.setDoubleProperty(prop, f);
}
@Override
- public boolean isNameSorting() {
- return true;
- }
-
- @Override
- public boolean isClearOnOpen() {
- return false;
- }
-
- @Override
- public void setDialogWidth(int w) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public int getDialogWidth() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setDialogHeight(int h) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public int getDialogHeight() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public float getSearchDelay() {
- return 0.2f;
- }
-
- @Override
- public int getMinPatternLength() {
- return 3;
+ public float getFloat(String prop, float def) {
+ prop = "OffPlugin." + prop;
+ return (float)jEdit.getDoubleProperty(prop, def);
}
@Override
public String getIgnoreMask() {
- return "(^|.*\\/).git\\/.*";
+ return "(^|.*\\/)(\\.git|\\.svn)\\/.*" + super.getIgnoreMask();
}
-
- @Override
- public void setIgnoreMask(String mask) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setMatchFromStart(boolean selected) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setMinPatternLength(int value) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setSearchDelay(float value) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setSmartMatch(boolean selected) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setClearOnOpen(boolean selected) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setLessPriorityMask(String mask) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public String getLessPriorityMask() {
- return "";
- }
-
- @Override
- public void setNameSorting(boolean b) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
-// void loadSettings() {
-// setMinPatternLength(jEdit.getIntegerProperty(MIN_PATTERN_LENGTH));
-// setSearchDelay(jEdit.getIntegerProperty(SEARCH_DELAY));
-// setSmartMatch(jEdit.getBooleanProperty(SMART_MATCH));
-// setSortResults(jEdit.getBooleanProperty(SORT_RESULTS));
-// setGroupResults(jEdit.getBooleanProperty(GROUP_RESULTS));
-// setClearOnOpen(jEdit.getBooleanProperty(CLEAR_ON_OPEN));
-// setShowIcon(jEdit.getBooleanProperty(SHOW_ICON));
-// setShowPath(jEdit.getBooleanProperty(SHOW_PATH));
-// setShowExt(jEdit.getBooleanProperty(SHOW_EXT));
-// setShowSize(jEdit.getBooleanProperty(SHOW_SIZE));
-// }
-
-
-
-// public static int getMinPatternLength() {
-// return minPatternLength;
-// }
-//
-// public static void setMinPatternLength(int minPatternLength) {
-// OffPlugin.minPatternLength = minPatternLength;
-// jEdit.setIntegerProperty(OffPlugin.MIN_PATTERN_LENGTH, minPatternLength);
-// }
-//
-// public static int getSearchDelay() {
-// return searchDelay;
-// }
-//
-// public static void setSearchDelay(int searchDelay) {
-// OffPlugin.searchDelay = searchDelay;
-// jEdit.setIntegerProperty(OffPlugin.SEARCH_DELAY, searchDelay);
-// }
-//
-// public static boolean isSmartMatch() {
-// return smartMatch;
-// }
-//
-// public static void setSmartMatch(boolean smartMatch) {
-// OffPlugin.smartMatch = smartMatch;
-// jEdit.setBooleanProperty(OffPlugin.SMART_MATCH, smartMatch);
-// }
-//
-// public static boolean isSortResults() {
-// return sortResults;
-// }
-//
-// public static void setSortResults(boolean sortResults) {
-// OffPlugin.sortResults = sortResults;
-// jEdit.setBooleanProperty(OffPlugin.SORT_RESULTS, sortResults);
-// }
-//
-// public static boolean isGroupResults() {
-// return groupResults;
-// }
-//
-// public static void setGroupResults(boolean groupResults) {
-// OffPlugin.groupResults = groupResults;
-// jEdit.setBooleanProperty(OffPlugin.GROUP_RESULTS, groupResults);
-// }
-//
-// public static boolean isClearOnOpen() {
-// return clearOnOpen;
-// }
-//
-// public static void setClearOnOpen(boolean clearOnOpen) {
-// OffPlugin.clearOnOpen = clearOnOpen;
-// jEdit.setBooleanProperty(OffPlugin.CLEAR_ON_OPEN, clearOnOpen);
-// }
-//
-// public static boolean isShowIcon() {
-// return showIcon;
-// }
-//
-// public static void setShowIcon(boolean showIcon) {
-// OffPlugin.showIcon = showIcon;
-// jEdit.setBooleanProperty(OffPlugin.SHOW_ICON, showIcon);
-// }
-//
-// public static boolean isShowPath() {
-// return showPath;
-// }
-//
-// public static void setShowPath(boolean showPath) {
-// OffPlugin.showPath = showPath;
-// jEdit.setBooleanProperty(OffPlugin.SHOW_PATH, showPath);
-// }
-//
-// public static boolean isShowExt() {
-// return showExt;
-// }
-//
-// public static void setShowExt(boolean showExt) {
-// OffPlugin.showExt = showExt;
-// jEdit.setBooleanProperty(OffPlugin.SHOW_EXT, showExt);
-// }
-//
-// public static boolean isShowSize() {
-// return showSize;
-// }
-//
-// public static void setShowSize(boolean showSize) {
-// OffPlugin.showSize = showSize;
-// jEdit.setBooleanProperty(OffPlugin.SHOW_SIZE, showSize);
-// }
-
}
View
113 jedit/src/net/sickill/off/jedit/options/OffOptionsPane.java
@@ -0,0 +1,113 @@
+package net.sickill.off.jedit.options;
+
+import java.awt.FlowLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridLayout;
+
+import javax.swing.ButtonGroup;
+import javax.swing.JCheckBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JTextField;
+import javax.swing.border.TitledBorder;
+
+import net.sickill.off.common.Settings;
+import net.sickill.off.jedit.JEditSettings;
+import org.gjt.sp.jedit.AbstractOptionPane;
+
+// minimum pattern length (2)
+// group files (using projectviewer groups)
+// clear search field on open
+// use tokens highlighting
+// exact match (without adding *)
+// search results: show icon/extension/directory/size
+
+public class OffOptionsPane extends AbstractOptionPane {
+ private static final long serialVersionUID = 3972719262788345594L;
+
+ JTextField minPatternLength;
+ JTextField searchDelay;
+// JCheckBox sortByExtension;
+ JCheckBox clearOnOpen;
+// JCheckBox exactMatch;
+ //JCheckBox tokensHighlighting;
+ ButtonGroup matchMode;
+ JRadioButton matchModeSmart, matchModeExact;
+
+ public OffOptionsPane() {
+ super("Open File Fast");
+ }
+
+ public void _init() {
+ Settings s = JEditSettings.getInstance();
+ minPatternLength = new JTextField("" + s.getMinPatternLength(), 2);
+ searchDelay = new JTextField("" + s.getSearchDelay(), 3);
+// sortByExtension = new JCheckBox("Group files by extension");
+// sortByExtension.getModel().setSelected(s.isExtensionSorting());
+ clearOnOpen = new JCheckBox("Clear input field on open");
+ clearOnOpen.getModel().setSelected(s.isClearOnOpen());
+ matchMode = new ButtonGroup();
+ boolean smart = s.isSmartMatch();
+ matchModeSmart = new JRadioButton("smart matching", smart);
+ matchModeExact = new JRadioButton("exact matching", !smart);
+ matchMode.add(matchModeSmart);
+ matchMode.add(matchModeExact);
+// tokensHighlighting = new JCheckBox("");
+// showIcon = new JCheckBox("show icon");
+// showIcon.getModel().setSelected(s.isShowIcon());
+// showPath = new JCheckBox("show project path");
+// showPath.getModel().setSelected(s.isShowPath());
+// showExt = new JCheckBox("show file extension");
+// showExt.getModel().setSelected(s.isShowExt());
+// showSize = new JCheckBox("show file size");
+// showSize.getModel().setSelected(s.isShowSize());
+
+ JPanel patternLengthPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 0 , 0));
+ patternLengthPanel.add(new JLabel("Minimum pattern length: "));
+ patternLengthPanel.add(minPatternLength);
+ addComponent(patternLengthPanel);
+
+ JPanel delayPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 0 , 0));
+ delayPanel.add(new JLabel("Search delay (after last keystroke): "));
+ delayPanel.add(searchDelay);
+ addComponent(delayPanel);
+
+ addComponent(clearOnOpen);
+// addComponent(sortFiles);
+// addComponent(sortByExtension);
+
+ // group "mode"
+ JPanel modePane = new JPanel(new GridLayout(0, 1));
+ TitledBorder modeBorder = new TitledBorder("Matching mode:");
+ modePane.setBorder(modeBorder);
+ modePane.add(matchModeSmart);
+ modePane.add(matchModeExact);
+ addComponent(modePane, GridBagConstraints.HORIZONTAL);
+
+ // group "show"
+// JPanel showPane = new JPanel(new GridLayout(0, 1));
+// TitledBorder showBorder = new TitledBorder("On results list:");
+// showPane.setBorder(showBorder);
+// showPane.add(showIcon);
+// showPane.add(showPath);
+// showPane.add(showExt);
+// showPane.add(showSize);
+// addComponent(showPane, GridBagConstraints.HORIZONTAL);
+ }
+
+ public void _save() {
+ Settings s = JEditSettings.getInstance();
+ s.setMinPatternLength(Integer.parseInt(minPatternLength.getText()));
+ s.setSearchDelay(Float.parseFloat(searchDelay.getText()));
+// s.setSortResults(sortFiles.isSelected());
+// s.setGroupResults(sortByExtension.isSelected());
+ s.setClearOnOpen(clearOnOpen.isSelected());
+ s.setSmartMatch(matchModeSmart.isSelected());
+// s.setShowIcon(showIcon.isSelected());
+// s.setShowPath(showPath.isSelected());
+// s.setShowExt(showExt.isSelected());
+// s.setShowSize(showSize.isSelected());
+ }
+
+} // End of TazOptionPane
View
2 netbeans/manifest.mf
@@ -3,5 +3,5 @@ OpenIDE-Module: net.sickill.off
OpenIDE-Module-Install: net/sickill/off/netbeans/Installer.class
OpenIDE-Module-Layer: net/sickill/off/netbeans/layer.xml
OpenIDE-Module-Localizing-Bundle: net/sickill/off/netbeans/Bundle.properties
-OpenIDE-Module-Specification-Version: 0.9.3
+OpenIDE-Module-Specification-Version: 0.9.4
View
32 netbeans/src/net/sickill/off/netbeans/NetbeansDialog.java
@@ -6,11 +6,8 @@
package net.sickill.off.netbeans;
import java.awt.BorderLayout;
-import java.awt.event.ComponentEvent;
-import java.awt.event.ComponentListener;
-import javax.swing.JDialog;
-import javax.swing.WindowConstants;
import net.sickill.off.common.IDE;
+import net.sickill.off.common.OffDialog;
import net.sickill.off.common.Settings;
import net.sickill.off.common.OffPanel;
import org.openide.windows.WindowManager;
@@ -19,11 +16,10 @@
*
* @author kill
*/
-public class NetbeansDialog extends JDialog implements ComponentListener {
- static OffPanel off;
- static IDE ide;
- static Settings settings;
+public class NetbeansDialog extends OffDialog {
static NetbeansDialog instance;
+ static IDE ide;
+ static OffPanel off;
public static NetbeansDialog getInstance() {
if (instance == null) {
@@ -34,17 +30,11 @@ public static NetbeansDialog getInstance() {
public NetbeansDialog() {
super(WindowManager.getDefault().getMainWindow(), "Open File Fast");
- addComponentListener(this);
- addNotify();
- setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
if (off == null) {
- settings = NetbeansSettings.getInstance();
ide = new NetbeansIDE();
off = new OffPanel(ide, settings, NetbeansProject.getInstance());
}
ide.setDialog(this);
- setSize(settings.getDialogWidth(), settings.getDialogHeight());
- setLocationRelativeTo(null);
getContentPane().add(off, BorderLayout.CENTER);
}
@@ -58,17 +48,9 @@ public void closeDialog() {
instance = null;
}
- public void componentResized(ComponentEvent e) {
- settings.setDialogWidth(this.getWidth());
- settings.setDialogHeight(this.getHeight());
+ @Override
+ protected Settings getSettings() {
+ return NetbeansSettings.getInstance();
}
- public void componentMoved(ComponentEvent e) {
- }
-
- public void componentShown(ComponentEvent e) {
- }
-
- public void componentHidden(ComponentEvent e) {
- }
}
View
1 netbeans/src/net/sickill/off/netbeans/NetbeansProject.java
@@ -86,6 +86,7 @@ public ImportWorker(NetbeansProject project) {
}
public void start() {
+ if (model == null) { return; }
setRunning(true);
Thread t = new Thread(this);
t.start();
View
131 netbeans/src/net/sickill/off/netbeans/NetbeansSettings.java
@@ -5,7 +5,6 @@
package net.sickill.off.netbeans;
-import java.util.prefs.Preferences;
import net.sickill.off.common.Settings;
import net.sickill.off.common.OffPanel;
import org.openide.util.NbPreferences;
@@ -17,133 +16,51 @@
public class NetbeansSettings extends Settings {
private static NetbeansSettings settings;
- private NetbeansSettings() {
- }
-
public static NetbeansSettings getInstance() {
if (settings == null) {
settings = new NetbeansSettings();
}
return settings;
}
-
- // dialog
-
- public void setDialogWidth(int w) {
- Preferences prefs = NbPreferences.forModule(OffPanel.class);
- prefs.putInt("dialog-width", w);
- }
-
- public int getDialogWidth() {
- return NbPreferences.forModule(OffPanel.class).getInt("dialog-width", Settings.DEFAULT_DIALOG_WIDTH);
- }
-
- public void setDialogHeight(int h) {
- Preferences prefs = NbPreferences.forModule(OffPanel.class);
- prefs.putInt("dialog-height", h);
- }
-
- public int getDialogHeight() {
- return NbPreferences.forModule(OffPanel.class).getInt("dialog-height", Settings.DEFAULT_DIALOG_HEIGHT);
- }
-
- // behaviour
-
- public float getSearchDelay() {
- return NbPreferences.forModule(OffPanel.class).getFloat("search-delay", Settings.DEFAULT_SEARCH_DELAY);
- }
- public void setSearchDelay(float value) {
- NbPreferences.forModule(OffPanel.class).putFloat("search-delay", value);
- }
-
- public int getMinPatternLength() {
- return NbPreferences.forModule(OffPanel.class).getInt("min-pattern-length", Settings.DEFAULT_MIN_PATTERN_LENGTH);
- }
-
- public void setMinPatternLength(int value) {
- NbPreferences.forModule(OffPanel.class).putInt("min-pattern-length", value);
- }
-
- public boolean isSmartMatch() {
- return NbPreferences.forModule(OffPanel.class).getBoolean("smart-match", Settings.DEFAULT_SMART_MATCH);
- }
-
- public void setSmartMatch(boolean selected) {
- NbPreferences.forModule(OffPanel.class).putBoolean("smart-match", selected);
- }
-
- public String getIgnoreMask() {
- return NbPreferences.forModule(OffPanel.class).get("ignore-mask", Settings.DEFAULT_IGNORE_MASK);
- }
-
- public void setIgnoreMask(String mask) {
- NbPreferences.forModule(OffPanel.class).put("ignore-mask", mask);
- compileIgnoreMask();
- }
-
- public void setMatchFromStart(boolean selected) {
- NbPreferences.forModule(OffPanel.class).putBoolean("match-from-start", selected);
- }
-
- public boolean isClearOnOpen() {
- return NbPreferences.forModule(OffPanel.class).getBoolean("clear-on-open", Settings.DEFAULT_CLEAR_ON_OPEN);
- }
-
- public void setClearOnOpen(boolean selected) {
- NbPreferences.forModule(OffPanel.class).putBoolean("clear-on-open", selected);
- }
-
- // show
-
- public boolean isShowExt() {
- return NbPreferences.forModule(OffPanel.class).getBoolean("show-ext", Settings.DEFAULT_SHOW_EXTENSION);
- }
-
- public boolean isShowPath() {
- return NbPreferences.forModule(OffPanel.class).getBoolean("show-path", Settings.DEFAULT_SHOW_PATH);
- }
-
- public boolean isShowSize() {
- return NbPreferences.forModule(OffPanel.class).getBoolean("show-size", Settings.DEFAULT_SHOW_SIZE);
- }
-
- // sorting
-
- public boolean isNameSorting() {
- return NbPreferences.forModule(OffPanel.class).getBoolean("name-sorting", Settings.DEFAULT_NAME_SORTING);
- }
-
- public boolean isExtensionSorting() {
- return NbPreferences.forModule(OffPanel.class).getBoolean("extension-sorting", Settings.DEFAULT_EXTENSION_SORTING);
+ @Override
+ public void setBoolean(String prop, boolean b) {
+ NbPreferences.forModule(OffPanel.class).putBoolean(prop, b);
}
- public boolean isPopularitySorting() {
- return NbPreferences.forModule(OffPanel.class).getBoolean("popularity-sorting", Settings.DEFAULT_POPULARITY_SORTING);
+ @Override
+ public boolean getBoolean(String prop, boolean def) {
+ return NbPreferences.forModule(OffPanel.class).getBoolean(prop, def);
}
- public boolean isCustomSorting() {
- return false;
+ @Override
+ public void setString(String prop, String s) {
+ NbPreferences.forModule(OffPanel.class).put(prop, s);
}
- public boolean isDistanceSorting() {
- return NbPreferences.forModule(OffPanel.class).getBoolean("distance-sorting", Settings.DEFAULT_DISTANCE_SORTING);
+ @Override
+ public String getString(String prop, String def) {
+ return NbPreferences.forModule(OffPanel.class).get(prop, def);
}
- public boolean isMatchFromStart() {
- return NbPreferences.forModule(OffPanel.class).getBoolean("match-from-start", Settings.DEFAULT_MATCH_FROM_START);
+ @Override
+ public void setInt(String prop, int i) {
+ NbPreferences.forModule(OffPanel.class).putInt(prop, i);
}
- public void setLessPriorityMask(String mask) {
- NbPreferences.forModule(OffPanel.class).put("less-priority-mask", mask);
+ @Override
+ public int getInt(String prop, int def) {
+ return NbPreferences.forModule(OffPanel.class).getInt(prop, def);
}
- public String getLessPriorityMask() {
- return NbPreferences.forModule(OffPanel.class).get("less-priority-mask", Settings.DEFAULT_LESS_PRIORITY_MASK);
+ @Override
+ public void setFloat(String prop, float f) {
+ NbPreferences.forModule(OffPanel.class).putFloat(prop, f);
}
@Override
- public void setNameSorting(boolean b) {
- throw new UnsupportedOperationException("Not supported yet.");
+ public float getFloat(String prop, float def) {
+ return NbPreferences.forModule(OffPanel.class).getFloat(prop, def);
}
+
}

0 comments on commit a201310

Please sign in to comment.
Something went wrong with that request. Please try again.