Added threading while posting to del.icio.us.
This commit is contained in:
parent
c7dcbcc36c
commit
494333ddde
6 changed files with 265 additions and 112 deletions
|
@ -1,3 +1,3 @@
|
|||
#ANT Task: ch.oscg.jreleaseinfo.BuildNumberHandler
|
||||
#Sat Mar 05 13:36:00 PST 2005
|
||||
build.num.last=0
|
||||
#Sun Mar 06 08:26:51 PST 2005
|
||||
build.num.last=2
|
||||
|
|
193
mobibot.iws
193
mobibot.iws
|
@ -25,7 +25,7 @@
|
|||
<option name="MERGE_WITH_BRANCH2_NAME" value="HEAD" />
|
||||
<option name="RESET_STICKY" value="false" />
|
||||
<option name="CREATE_NEW_DIRECTORIES" value="true" />
|
||||
<option name="DEFAULT_TEXT_FILE_SUBSTITUTION" value="v" />
|
||||
<option name="DEFAULT_TEXT_FILE_SUBSTITUTION" value="kv" />
|
||||
<option name="PROCESS_UNKNOWN_FILES" value="false" />
|
||||
<option name="PROCESS_DELETED_FILES" value="false" />
|
||||
<option name="SHOW_EDIT_DIALOG" value="false" />
|
||||
|
@ -71,7 +71,7 @@
|
|||
<option name="PUT_FOCUS_INTO_COMMENT" value="false" />
|
||||
<option name="SHOW_CHECKIN_OPTIONS" value="true" />
|
||||
<option name="FORCE_NON_EMPTY_COMMENT" value="false" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Added support for del.icio.us" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Added delicious-java license. Updated ChangeLog." />
|
||||
<option name="SAVE_LAST_COMMIT_MESSAGE" value="true" />
|
||||
<option name="CHECKIN_DIALOG_SPLITTER_PROPORTION" value="0.8" />
|
||||
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="false" />
|
||||
|
@ -112,47 +112,54 @@
|
|||
<option name="HIDE_WARNINGS" value="false" />
|
||||
</component>
|
||||
<component name="FileEditorManager" split-orientation="vertical" split-proportion="0.5">
|
||||
<first-group selected-file="file://$PROJECT_DIR$/ChangeLog.txt">
|
||||
<first-group selected-file="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot/DeliciousPoster.java">
|
||||
<entry file="file://$PROJECT_DIR$/ChangeLog.txt" pinned="false">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="8" column="34" selection-start="398" selection-end="398" vertical-scroll-proportion="0.14607948">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot/Mobibot.java" pinned="false">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="237" column="117" selection-start="5689" selection-end="5689" vertical-scroll-proportion="-4.324236">
|
||||
<state line="2771" column="46" selection-start="64811" selection-end="64811" vertical-scroll-proportion="0.66593885">
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/website/index.html" pinned="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot/Weather.java" pinned="false">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="45" column="160" selection-start="2992" selection-end="2992" vertical-scroll-proportion="0.70305675">
|
||||
<state line="54" column="13" selection-start="2059" selection-end="2059" vertical-scroll-proportion="0.23737916">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/ChangeLog.txt" pinned="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot/FeedReader.java" pinned="false">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="19" column="51" selection-start="759" selection-end="759" vertical-scroll-proportion="0.3469388">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/build.properties" pinned="false">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="2" column="16" selection-start="44" selection-end="44" vertical-scroll-proportion="0.03651987">
|
||||
<state line="109" column="52" selection-start="3133" selection-end="3133" vertical-scroll-proportion="0.5026853">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot/DeliciousPoster.java" pinned="false">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="49" column="13" selection-start="1911" selection-end="1911" vertical-scroll-proportion="0.2556391">
|
||||
<state line="84" column="23" selection-start="2727" selection-end="2727" vertical-scroll-proportion="0.8947368">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot/EntryComment.java" pinned="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot/SwingWorker.java" pinned="false">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="53" column="13" selection-start="2016" selection-end="2016" vertical-scroll-proportion="0.32867885">
|
||||
<state line="19" column="69" selection-start="616" selection-end="616" vertical-scroll-proportion="-1.1546724">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot/CurrencyConverter.java" pinned="false">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="36" column="0" selection-start="1681" selection-end="1714" vertical-scroll-proportion="0.018558951">
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
|
@ -166,13 +173,6 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/build.xml" pinned="false">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/buildnum.properties" pinned="false">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="3" column="0" selection-start="98" selection-end="98" vertical-scroll-proportion="0.054779805">
|
||||
|
@ -198,22 +198,27 @@
|
|||
<component name="InspectionManager">
|
||||
<option name="AUTOSCROLL_TO_SOURCE" value="false" />
|
||||
<option name="SPLITTER_PROPORTION" value="0.452356" />
|
||||
<profile name="Erik's Inspection Profile" />
|
||||
<profile name="Erik's Inspections" />
|
||||
</component>
|
||||
<component name="J2EEProjectPane" />
|
||||
<component name="NamedScopeManager" />
|
||||
<component name="PackagesPane">
|
||||
<expanded_node url="net.thauvin.erik.mobibot" module="mobibot" type="package" />
|
||||
<expanded_node url="net" module="mobibot" type="package" />
|
||||
<expanded_node url="net.thauvin" module="mobibot" type="package" />
|
||||
<expanded_node url="" module="mobibot" type="module" />
|
||||
<expanded_node url="net.thauvin.erik" module="mobibot" type="package" />
|
||||
<expanded_node url="net.thauvin" module="mobibot" type="package" />
|
||||
<expanded_node url="net.thauvin.erik.mobibot" module="mobibot" type="package" />
|
||||
</component>
|
||||
<component name="ProjectPane">
|
||||
<expanded_node url="file://$PROJECT_DIR$/website" module="mobibot" type="directory" />
|
||||
<expanded_node url="file://$PROJECT_DIR$" module="mobibot" type="directory" />
|
||||
<expanded_node url="file://$PROJECT_DIR$/src/net/thauvin" module="mobibot" type="directory" />
|
||||
<expanded_node url="" module="mobibot" type="module" />
|
||||
<expanded_node url="file://$PROJECT_DIR$/src/net" module="mobibot" type="directory" />
|
||||
<expanded_node url="file://$PROJECT_DIR$/src" module="mobibot" type="directory" />
|
||||
<expanded_node url="file://$PROJECT_DIR$/src/net/thauvin/erik" module="mobibot" type="directory" />
|
||||
<expanded_node url="file://$PROJECT_DIR$/licenses" module="mobibot" type="directory" />
|
||||
<expanded_node url="file://$PROJECT_DIR$" module="mobibot" type="directory" />
|
||||
<expanded_node url="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot" module="mobibot" type="directory" />
|
||||
<expanded_node url="file://$PROJECT_DIR$/website" module="mobibot" type="directory" />
|
||||
</component>
|
||||
<component name="ProjectView">
|
||||
<navigator currentView="ProjectPane" splitterProportion="0.5">
|
||||
|
@ -396,12 +401,12 @@
|
|||
<window_info id="CVS" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33024693" order="8" />
|
||||
<window_info id="Regex" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.44135803" order="10" x="22" y="277" width="980" height="214" />
|
||||
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33024693" order="7" />
|
||||
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.20531228" order="0" />
|
||||
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.23977028" order="0" />
|
||||
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33032128" order="1" />
|
||||
<window_info id="Jalopy" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="8" />
|
||||
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.27959183" order="1" />
|
||||
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33032128" order="9" />
|
||||
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="true" internal_type="docked" type="docked" visible="false" weight="0.39969134" order="6" />
|
||||
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="true" internal_type="docked" type="docked" visible="false" weight="0.3995984" order="6" />
|
||||
<window_info id="Profile" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="8" />
|
||||
<window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="8" />
|
||||
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.10193826" order="1" />
|
||||
|
@ -495,52 +500,29 @@
|
|||
</buildFile>
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/website/index.html">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="45" column="160" selection-start="2992" selection-end="2992" vertical-scroll-proportion="0.7169615">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/build.properties">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="2" column="16" selection-start="44" selection-end="44" vertical-scroll-proportion="0.034836065">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot/StockQuote.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="53" column="13" selection-start="2029" selection-end="2029" vertical-scroll-proportion="0.33333334">
|
||||
<state line="44" column="0" selection-start="1838" selection-end="1838" vertical-scroll-proportion="0.16433942">
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot/Weather.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="54" column="13" selection-start="2059" selection-end="2059" vertical-scroll-proportion="0.33333334">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot/CurrencyConverter.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="63" column="13" selection-start="2150" selection-end="2150" vertical-scroll-proportion="-3.9424703">
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/logs/2004-11-03.xml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot/EntryLink.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="55" column="13" selection-start="2026" selection-end="2026" vertical-scroll-proportion="0.42857143">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot/DeliciousPoster.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="49" column="13" selection-start="1911" selection-end="1911" vertical-scroll-proportion="0.2556391">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot/EntryComment.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="53" column="13" selection-start="2016" selection-end="2016" vertical-scroll-proportion="0.32867885">
|
||||
|
@ -564,29 +546,6 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/website/index.html">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="45" column="160" selection-start="2992" selection-end="2992" vertical-scroll-proportion="0.70305675">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot/Mobibot.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="237" column="117" selection-start="5689" selection-end="5689" vertical-scroll-proportion="-4.324236">
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/build.properties">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="2" column="16" selection-start="44" selection-end="44" vertical-scroll-proportion="0.03651987">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/.cvsignore">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
|
||||
|
@ -603,7 +562,53 @@
|
|||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/ChangeLog.txt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="19" column="51" selection-start="759" selection-end="759" vertical-scroll-proportion="0.3469388">
|
||||
<state line="8" column="34" selection-start="398" selection-end="398" vertical-scroll-proportion="0.14607948">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot/Weather.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="54" column="13" selection-start="2059" selection-end="2059" vertical-scroll-proportion="0.23737916">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot/FeedReader.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="109" column="52" selection-start="3133" selection-end="3133" vertical-scroll-proportion="0.5026853">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot/CurrencyConverter.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="36" column="0" selection-start="1681" selection-end="1714" vertical-scroll-proportion="0.018558951">
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot/Mobibot.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="2771" column="46" selection-start="64811" selection-end="64811" vertical-scroll-proportion="0.66593885">
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot/SwingWorker.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="19" column="69" selection-start="616" selection-end="616" vertical-scroll-proportion="-1.1546724">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/erik/mobibot/DeliciousPoster.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="84" column="23" selection-start="2727" selection-end="2727" vertical-scroll-proportion="0.8947368">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
|
|
@ -71,9 +71,18 @@ public class DeliciousPoster
|
|||
* @param entry The entry to add.
|
||||
* @param extended The del.icio.us extended data.
|
||||
*/
|
||||
public final void addPost(EntryLink entry, String extended)
|
||||
public final void addPost(final EntryLink entry, final String extended)
|
||||
{
|
||||
_delicious.addPost(entry.getLink(), entry.getTitle(), extended, _tags, entry.getDate());
|
||||
final SwingWorker worker = new SwingWorker()
|
||||
{
|
||||
public Object construct()
|
||||
{
|
||||
return new Boolean(_delicious.addPost(entry.getLink(), entry.getTitle(), extended, _tags,
|
||||
entry.getDate()));
|
||||
}
|
||||
};
|
||||
|
||||
worker.start();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,8 +90,16 @@ public class DeliciousPoster
|
|||
*
|
||||
* @param entry The entry to delete.
|
||||
*/
|
||||
public final void deletePost(EntryLink entry)
|
||||
public final void deletePost(final EntryLink entry)
|
||||
{
|
||||
_delicious.deletePost(entry.getLink());
|
||||
final SwingWorker worker = new SwingWorker()
|
||||
{
|
||||
public Object construct()
|
||||
{
|
||||
return new Boolean(_delicious.deletePost(entry.getLink()));
|
||||
}
|
||||
};
|
||||
|
||||
worker.start();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1122,7 +1122,7 @@ public class Mobibot extends PircBot
|
|||
|
||||
if (_delicious != null)
|
||||
{
|
||||
_delicious.addPost(entry, postedBy(sender, channel));
|
||||
_delicious.addPost(entry, postedBy(entry, channel));
|
||||
}
|
||||
|
||||
saveEntries(isBackup);
|
||||
|
@ -1395,7 +1395,7 @@ public class Mobibot extends PircBot
|
|||
|
||||
if (_delicious != null)
|
||||
{
|
||||
_delicious.addPost(entry, postedBy(sender, channel));
|
||||
_delicious.addPost(entry, postedBy(entry, channel));
|
||||
}
|
||||
|
||||
send(getChannel(), buildLink(index, entry));
|
||||
|
@ -1421,7 +1421,7 @@ public class Mobibot extends PircBot
|
|||
|
||||
if (_delicious != null)
|
||||
{
|
||||
_delicious.addPost(entry, postedBy(sender, channel));
|
||||
_delicious.addPost(entry, postedBy(entry, channel));
|
||||
}
|
||||
|
||||
send(getChannel(), buildLink(index, entry));
|
||||
|
@ -2277,14 +2277,14 @@ public class Mobibot extends PircBot
|
|||
/**
|
||||
* Returns he del.icio.us extended attribution line.
|
||||
*
|
||||
* @param sender The sender.
|
||||
* @param entry The entry.
|
||||
* @param channel The channel
|
||||
*
|
||||
* @return The extended attribution line.
|
||||
*/
|
||||
private final String postedBy(String sender, String channel)
|
||||
private String postedBy(EntryLink entry, String channel)
|
||||
{
|
||||
return "Posted by " + sender + " on " + channel + " (" + _ircServer + ')';
|
||||
return "Posted by " + entry.getNick() + " on " + channel + " (" + _ircServer + ')';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Created by JReleaseInfo AntTask from Open Source Competence Group */
|
||||
/* Creation date Sat Mar 05 13:36:00 PST 2005 */
|
||||
/* Creation date Sun Mar 06 08:26:51 PST 2005 */
|
||||
package net.thauvin.erik.mobibot;
|
||||
|
||||
import java.util.Date;
|
||||
|
@ -12,21 +12,21 @@ import java.util.Date;
|
|||
public class ReleaseInfo {
|
||||
|
||||
|
||||
/** buildDate (set during build process to 1110058560437L). */
|
||||
private static Date buildDate = new Date(1110058560437L);
|
||||
/** buildDate (set during build process to 1110126411140L). */
|
||||
private static Date buildDate = new Date(1110126411140L);
|
||||
|
||||
/**
|
||||
* Get buildDate (set during build process to Sat Mar 05 13:36:00 PST 2005).
|
||||
* Get buildDate (set during build process to Sun Mar 06 08:26:51 PST 2005).
|
||||
* @return Date buildDate
|
||||
*/
|
||||
public static final Date getBuildDate() { return buildDate; }
|
||||
|
||||
|
||||
/**
|
||||
* Get buildNumber (set during build process to 0).
|
||||
* Get buildNumber (set during build process to 2).
|
||||
* @return int buildNumber
|
||||
*/
|
||||
public static final int getBuildNumber() { return 0; }
|
||||
public static final int getBuildNumber() { return 2; }
|
||||
|
||||
|
||||
/** version (set during build process to "0.3"). */
|
||||
|
|
131
src/net/thauvin/erik/mobibot/SwingWorker.java
Normal file
131
src/net/thauvin/erik/mobibot/SwingWorker.java
Normal file
|
@ -0,0 +1,131 @@
|
|||
package net.thauvin.erik.mobibot;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/**
|
||||
* This is the 3rd version of SwingWorker (also known as
|
||||
* SwingWorker 3), an abstract class that you subclass to
|
||||
* perform GUI-related work in a dedicated thread. For
|
||||
* instructions on and examples of using this class, see:
|
||||
*
|
||||
* http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html
|
||||
*
|
||||
* Note that the API changed slightly in the 3rd version:
|
||||
* You must now invoke start() on the SwingWorker after
|
||||
* creating it.
|
||||
*/
|
||||
public abstract class SwingWorker {
|
||||
private Object value; // see getValue(), setValue()
|
||||
|
||||
/**
|
||||
* Class to maintain reference to current worker thread
|
||||
* under separate synchronization control.
|
||||
*/
|
||||
private static class ThreadVar {
|
||||
private Thread thread;
|
||||
ThreadVar(Thread t) { thread = t; }
|
||||
synchronized Thread get() { return thread; }
|
||||
synchronized void clear() { thread = null; }
|
||||
}
|
||||
|
||||
private ThreadVar threadVar;
|
||||
|
||||
/**
|
||||
* Get the value produced by the worker thread, or null if it
|
||||
* hasn't been constructed yet.
|
||||
*/
|
||||
protected synchronized Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value produced by worker thread
|
||||
*/
|
||||
private synchronized void setValue(Object x) {
|
||||
value = x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the value to be returned by the <code>get</code> method.
|
||||
*/
|
||||
public abstract Object construct();
|
||||
|
||||
/**
|
||||
* Called on the event dispatching thread (not on the worker thread)
|
||||
* after the <code>construct</code> method has returned.
|
||||
*/
|
||||
public void finished() {
|
||||
}
|
||||
|
||||
/**
|
||||
* A new method that interrupts the worker thread. Call this method
|
||||
* to force the worker to stop what it's doing.
|
||||
*/
|
||||
public void interrupt() {
|
||||
Thread t = threadVar.get();
|
||||
if (t != null) {
|
||||
t.interrupt();
|
||||
}
|
||||
threadVar.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value created by the <code>construct</code> method.
|
||||
* Returns null if either the constructing thread or the current
|
||||
* thread was interrupted before a value was produced.
|
||||
*
|
||||
* @return the value created by the <code>construct</code> method
|
||||
*/
|
||||
public Object get() {
|
||||
while (true) {
|
||||
Thread t = threadVar.get();
|
||||
if (t == null) {
|
||||
return getValue();
|
||||
}
|
||||
try {
|
||||
t.join();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt(); // propagate
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Start a thread that will call the <code>construct</code> method
|
||||
* and then exit.
|
||||
*/
|
||||
public SwingWorker() {
|
||||
final Runnable doFinished = new Runnable() {
|
||||
public void run() { finished(); }
|
||||
};
|
||||
|
||||
Runnable doConstruct = new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
setValue(construct());
|
||||
}
|
||||
finally {
|
||||
threadVar.clear();
|
||||
}
|
||||
|
||||
SwingUtilities.invokeLater(doFinished);
|
||||
}
|
||||
};
|
||||
|
||||
Thread t = new Thread(doConstruct);
|
||||
threadVar = new ThreadVar(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the worker thread.
|
||||
*/
|
||||
public void start() {
|
||||
Thread t = threadVar.get();
|
||||
if (t != null) {
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue