Skip to content

Commit

Permalink
Merge pull request #74 from rmburkhead/issue_64
Browse files Browse the repository at this point in the history
Issue 64
  • Loading branch information
madflow committed Mar 14, 2015
2 parents e8d4b51 + 8430095 commit c4b1e15
Show file tree
Hide file tree
Showing 5 changed files with 523 additions and 315 deletions.
8 changes: 6 additions & 2 deletions src/flow/netbeans/markdown/options/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ MarkdownPanel.HTML_PANEL_HEADER.text=Template for HTML Export or Preview
MarkdownPanel.EXTENSIONS_PANEL_HEADER.text=Enable one or more of the following extensions over standard Markdown
MarkdownPanel.STRIKETHROUGH.toolTipText=Support strikethroughs as supported in Pandoc and Github.
MarkdownPanel.STRIKETHROUGH.text=STRIKETHROUGH
MarkdownPanel.MISC_PANEL.TabConstraints.tabTitle=Miscellaneous
MarkdownPanel.EXPORT_ON_SAVE.text_1=Export to HTML on save
MarkdownPanel.FX_HTML_VIEW_ENABLED.text=Use JavaFX to display preview in editor
MarkdownPanel.REMOVE_ORDERED_LIST_NUMBER.toolTipText=Number is also removed when white space is removed
MarkdownPanel.REMOVE_ORDERED_LIST_NUMBER.text_1=Remove ordered list number
Expand All @@ -41,4 +41,8 @@ MarkdownPanel.AUTO_ADDITION_LIST.text=Auto addition for lists and block quotes o
MarkdownPanel.TYPING_HOOKS.text_1=Auto operation for lists and quotes (+,*, -, 1., >)
MarkdownPanel.SAVE_IN_SOURCE_DIR.text=Save in same folder as markdown file
MarkdownPanel.VIEW_HTML_ON_SAVE.text=View Html On Save
MarkdownPanel.EXPORT_ON_SAVE.text_1=Export to HTML on save
MarkdownPanel.MISC_PANEL.TabConstraints.tabTitle=Miscellaneous
MarkdownPanel.USE_CUSTOM_PREVIEW_REFRESH_INTERVAL.text_1=Use custom preview refresh interval
MarkdownPanel.CUSTOM_PREVIEW_REFRESH_INTERVAL_LBL.text=Preview refresh interval:
MarkdownPanel.CUSTOM_PREVIEW_REFRESH_INTERVAL.toolTipText=Preview refresh interval, between 10 and 10,000 milliseconds (0.01 and 10.0 seconds)
MarkdownPanel.CUSTOM_PREVIEW_REFRESH_INTERVAL_LBL_MS.text=ms
42 changes: 39 additions & 3 deletions src/flow/netbeans/markdown/options/MarkdownGlobalOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
public final class MarkdownGlobalOptions {

private static final MarkdownGlobalOptions INSTANCE = new MarkdownGlobalOptions();

/** The default for whether to use a custom preview refresh interval. */
private static final boolean DEFAULT_USE_CUSTOM_PREVIEW_REFRESH_INTERVAL = false;
/** The default preview refresh interval in milliseconds. */
private static final int DEFAULT_PREVIEW_REFRESH_INTERVAL = 1000;
/** The minimum preview refresh interval in milliseconds. */
static final int MIN_PREVIEW_INTERVAL = 10;
/** The maximum preview refresh interval in milliseconds. */
static final int MAX_PREVIEW_INTERVAL = 10000;

private static final String SMARTS = "SMARTS"; // NOI18N
private static final String QUOTES = "QUOTES"; // NOI18N
private static final String ABBREVIATIONS = "ABBREVIATIONS"; // NOI18N
Expand All @@ -27,6 +37,8 @@ public final class MarkdownGlobalOptions {
private static final String VIEW_HTML_ON_SAVE = "VIEW_HTML_ON_SAVE"; // NOI18N
private static final String SAVE_IN_SOURCE_DIR = "SAVE_IN_SOURCE_DIR"; // NOI18N
private static final String EXPORT_ON_SAVE = "EXPORT_ON_SAVE"; // NOI18N
private static final String USE_CUSTOM_PREVIEW_REFRESH_INTERVAL = "USE_CUSTOM_PREVIEW_INTERVAL";
private static final String CUSTOM_PREVIEW_REFRESH_INTERVAL = "CUSTOM_PREVIEW_INTERVAL";

// typing hooks
private static final String TYPING_HOOKS = "TYPING_HOOKS"; // NOI18N
Expand Down Expand Up @@ -122,7 +134,7 @@ private void bindPreferences() {
*/
public int getExtensionsValue() {
bindPreferences();

return (smarts ? Extensions.SMARTS : 0)
+ (quotes ? Extensions.QUOTES : 0)
+ (abbreviations ? Extensions.ABBREVIATIONS : 0)
Expand Down Expand Up @@ -208,7 +220,7 @@ public boolean isTables() {
public void setTables(boolean tables) {
getPreferences().putBoolean(TABLES, tables);
}

public boolean isStrikeThrough() {
return getPreferences().getBoolean(STRIKETHROUGH, false);
}
Expand Down Expand Up @@ -305,7 +317,7 @@ public boolean isRemoveOrderedListNumber() {
public void setRemoveOrderedListNumber(boolean isRemoveOrderedList) {
getPreferences().putBoolean(REMOVE_ORDERED_LIST, isRemoveOrderedList);
}

public boolean isFXHtmlViewEnabled() {
return getPreferences().getBoolean(FX_HTML_VIEW_ENABLED, true);
}
Expand All @@ -314,6 +326,30 @@ public void setFXHtmlViewEnabled(boolean fxHtmlViewEnabled) {
getPreferences().putBoolean(FX_HTML_VIEW_ENABLED, fxHtmlViewEnabled);
}

public boolean isCustomPreviewRefreshIntervalUsed() {
return getPreferences()
.getBoolean(USE_CUSTOM_PREVIEW_REFRESH_INTERVAL, DEFAULT_USE_CUSTOM_PREVIEW_REFRESH_INTERVAL);
}

public void setUseCustomPreviewRefreshInterval(final boolean useCustomPreviewRefreshInterval) {
getPreferences().putBoolean(USE_CUSTOM_PREVIEW_REFRESH_INTERVAL, useCustomPreviewRefreshInterval);
}

public int getCustomPreviewRefreshInterval() {
return getPreferences()
.getInt(CUSTOM_PREVIEW_REFRESH_INTERVAL, DEFAULT_PREVIEW_REFRESH_INTERVAL);
}

public int getPreviewRefreshIntervalInUse() {
return isCustomPreviewRefreshIntervalUsed() ?
getPreferences().getInt(CUSTOM_PREVIEW_REFRESH_INTERVAL, DEFAULT_PREVIEW_REFRESH_INTERVAL) :
DEFAULT_PREVIEW_REFRESH_INTERVAL;
}

public void setCustomPreviewRefreshInterval(final int customPreviewRefreshInterval) {
getPreferences().putInt(CUSTOM_PREVIEW_REFRESH_INTERVAL, customPreviewRefreshInterval);
}

private Preferences getPreferences() {
return NbPreferences.forModule(MarkdownGlobalOptions.class);
}
Expand Down
63 changes: 61 additions & 2 deletions src/flow/netbeans/markdown/options/MarkdownPanel.form
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
Expand Down Expand Up @@ -339,6 +339,20 @@
<Component id="EXPORT_ON_SAVE" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="22" pref="22" max="-2" attributes="0"/>
<Component id="CUSTOM_PREVIEW_REFRESH_INTERVAL_LBL" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="CUSTOM_PREVIEW_REFRESH_INTERVAL" min="-2" pref="75" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="CUSTOM_PREVIEW_REFRESH_INTERVAL_LBL_MS" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="USE_CUSTOM_PREVIEW_REFRESH_INTERVAL" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="159" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
Expand All @@ -364,7 +378,15 @@
<Component id="REORDER_ORDERED_LIST_NUMBER" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="REMOVE_ORDERED_LIST_NUMBER" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="144" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="USE_CUSTOM_PREVIEW_REFRESH_INTERVAL" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="CUSTOM_PREVIEW_REFRESH_INTERVAL_LBL" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="CUSTOM_PREVIEW_REFRESH_INTERVAL_LBL_MS" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="CUSTOM_PREVIEW_REFRESH_INTERVAL" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="120" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand Down Expand Up @@ -461,6 +483,43 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="USE_CUSTOM_PREVIEW_REFRESH_INTERVAL">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="flow/netbeans/markdown/options/Bundle.properties" key="MarkdownPanel.USE_CUSTOM_PREVIEW_REFRESH_INTERVAL.text_1" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="USE_CUSTOM_PREVIEW_REFRESH_INTERVALActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="CUSTOM_PREVIEW_REFRESH_INTERVAL_LBL">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="flow/netbeans/markdown/options/Bundle.properties" key="MarkdownPanel.CUSTOM_PREVIEW_REFRESH_INTERVAL_LBL.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="CUSTOM_PREVIEW_REFRESH_INTERVAL_LBL_MS">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="flow/netbeans/markdown/options/Bundle.properties" key="MarkdownPanel.CUSTOM_PREVIEW_REFRESH_INTERVAL_LBL_MS.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="CUSTOM_PREVIEW_REFRESH_INTERVAL">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="10" maximum="10000" minimum="10" numberType="java.lang.Integer" stepSize="10" type="number"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="flow/netbeans/markdown/options/Bundle.properties" key="MarkdownPanel.CUSTOM_PREVIEW_REFRESH_INTERVAL.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="editor" type="javax.swing.JComponent" editor="org.netbeans.modules.form.editors.SpinnerEditorEditor">
<SpinnerEditor format="" type="3"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
Expand Down
Loading

0 comments on commit c4b1e15

Please sign in to comment.