Skip to content

Commit

Permalink
Fix tabs changing, update help
Browse files Browse the repository at this point in the history
- Fix tabs sometimes not switching correctly on System Look&Feel
- Some minor onInfo message forwarding changes/policy
- Add check in WebServer for possible race condition, improve some error messages
- Update help
  • Loading branch information
tduva committed Apr 25, 2016
1 parent 8f69749 commit fcc91e9
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 66 deletions.
2 changes: 0 additions & 2 deletions src/chatty/StatusHistory.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
import chatty.util.settings.SettingsListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;

/**
Expand Down
24 changes: 21 additions & 3 deletions src/chatty/TwitchConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ void onNotice(String nick, String from, String text) {
return;
}
// Should only be from the server for now
listener.onInfo("[Notice] " + text);
listener.onNotice(text);
}

@Override
Expand All @@ -954,7 +954,7 @@ void onQueryMessage(String nick, String from, String text) {
listener.onSpecialMessage(nick, text);
}
if (nick.equals("jtv")) {
infoMessage(null, text);
listener.onInfo("[Info] "+text);
}
}

Expand Down Expand Up @@ -1272,9 +1272,27 @@ public interface ConnectionListener {

void onNotice(String message);

/**
* An info message to a specific channel, usually intended to be
* directly output to the user.
*
* <p>The channel should not be null. If no channel is associated, use
* {@link onInfo(String) onInfo(infoMessage)} instead.</p>
*
* @param channel The channel the info message belongs to
* @param infoMessage The info message
*/
void onInfo(String channel, String infoMessage);

void onInfo(String message);
/**
* An info message, usually intended to be directly output to the user.
*
* <p>Since no channel is associated, this is likely to be output to the
* currently active channel/tab.</p>
*
* @param infoMessage The info message
*/
void onInfo(String infoMessage);

void onGlobalInfo(String message);

Expand Down
12 changes: 6 additions & 6 deletions src/chatty/gui/components/help/help-bouncer.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ <h2>Configuring the Bouncer</h2>
CAP REQ :twitch.tv/tags
CAP REQ :twitch.tv/commands</pre>

<p>To receive a userlist at all, you also need to send (Twitch Chat will
only send the userlist on join and under some circumstances it may not
send a userlist at all):</p>
<p>To receive a userlist at all, you also need to send the following (even
then Twitch Chat will only send the userlist on join and then update it
via JOINs/PARTs, and under some circumstances it may not send a userlist
at all):</p>

<pre>
CAP REQ :twitch.tv/membership</pre>
Expand All @@ -78,9 +79,8 @@ <h2>Notes</h2>
<li>The Channel State (Subonly, Slowmode, ..) won't always be correct
because the Bouncer won't send the state on join if the channel is
already joined on the Bouncer.</li>
<li>Connecting to the Whisper servers directly won't work since that
connection will try to use the same password as you set for the
Bouncer.</li>
<li>Receiving Whispers may not work, depending on whether the Bouncer
forwards the WHISPER command to Chatty.</li>
</ul>
</body>
</html>
Expand Down
21 changes: 12 additions & 9 deletions src/chatty/gui/components/help/help-guide_create_shortcut.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@
<div id="backlink"><a href="help.html">Back to main help page</a></div>
<h1><a name="top">Create Shortcut and add Icon</a></h1>

<p>This applies to Windows 7, not sure about other OS.</p>
<p>This applies to Windows 7, and probably other Windows versions. The info
can probably also be applied to other OS with some adjustments.</p>

<p>You can create a shortcut for Chatty, which has some potential advantages (depending on what you need):</p>
<ul>
<li>You can give Chatty
<a href="help.html#launch">launch options</a>, like
<code>-cd</code> to use a different
<a href="help-guide_folders.html">settings directory</a>.</li>
<li>You can attach Chatty to the taskbar.</li>
<li>You can give the shortcut the Chatty icon, to replace the Java
icon without changing it for all Java programs.</li>
<li>It may fix issues with starting Chatty.</li>
<li>It may allow you to start Chatty even if you otherwise have issues
with that.</li>
<li>You can give Chatty
<a href="help.html#launch">launch options</a>, like
<code>-cd</code> to use a different
<a href="help-guide_folders.html">settings directory</a>.</li>
<li>You can attach Chatty to the taskbar.</li>
<li>You can give the shortcut the Chatty icon, to replace the Java icon
without changing it for all Java programs.</li>

</ul>
<h2>Create shortcut</h2>
<p>Create a shortcut to Java to start Chatty (for this example the
Expand Down
61 changes: 41 additions & 20 deletions src/chatty/gui/components/help/help-releases.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,18 @@ <h2>
(otherwise you might have to add it yourself).</li>
</ul>
</li>
<li>No separate Event Chat servers anymore</li>
<li>Whispers (and Group Chat) got moved to AWS early April</li>
<li>No separate Event Chat servers anymore
<ul>
<li>Access all channels, including of big events, in Chatty
without having to change servers.</li>
</ul>
</li>
<li>Whispers (and Group Chat) got moved to AWS early April
<ul>
<li>No Whisper server configuration required anymore, just
enable Whispers in the settings if you want to use them.</li>
</ul>
</li>
</ul>

<h3>Full Changelog</h3>
Expand All @@ -66,35 +76,44 @@ <h3>Full Changelog</h3>
- Added some account info to User Info Dialog (click on "More..")
- Added auto-unhost feature (to unhost when your stream goes live, disabled by
default)
- Added single-instance mode, with the ability to join channels in the already
running instance
- Emote Dialog: Improved displayed info a bit
- Added `force_verify=true` parameter to Authorize URL (makes Twitch always ask
if you want to Authorize, makes sure you are logged in to the right account)
- Added new Twitch Player URL in context menu
- Added /emoteonly and /emoteonlyoff commands (in case they get enabled again)
- Added "emotesets" parameter to /refresh command
- Changed twitchemotes.com API URL (which is the source of emoteset information)
- Added some support for selecting the correct chat server
- Added auto-responses to whispers for ignored/non-whitelisted users (disabled
by default)
- Added feature to automatically add Addressbook categories on Subscriber
notifications (experimental)
- Added feature to automatically copy messages into clipboard
- Moved debug logs into separate directory
- Increased max reconnection attempts to 40
- Admin Dialog: Added error message for tryint to set invalid stream status
- Admin Dialog: Added error message for trying to set invalid stream status
- Added context menu entries to directly host channel
- Updated help

System
======
- Added single-instance mode, with the ability to join channels in the already
running instance
- Added in-app announcements (Help - Announcements), for more reliable
communication of relevant news about Chatty (if new announcement is available
a window will pop up on start and a notification will be shown in the main
menu bar)
- Moved debug logs into separate directory
- Added /proc command to start native processes out of Chatty
- Added context menu entries to directly host channel
- ShortenDisplayOfExcessivelyLongEmoteCodesLookingOutTheirWindow
- Bouncer: Some changes allowing connection to a Bouncer
- Made restoring window position a bit more lenient with it being off-screen

Connection
==========
- Bouncer: Some changes allowing your to connect to a Bouncer
- Whispering: Moved to main chat, hide userlist for Whisper tabs
- Updated help
- Added auto-responses to whispers for ignored/non-whitelisted users (disabled
by default)
- Increased max reconnection attempts to 40
- Added `force_verify=true` parameter to Authorize URL (makes Twitch always ask
if you want to Authorize, makes sure you are logged in to the right account)
- Added some support for selecting the correct chat server

Emotes
======
- Emote Dialog: Improved shown info a bit
- Added /emoteonly and /emoteonlyoff commands (in case they get enabled again)
- Added "emotesets" parameter to /refresh command
- Changed twitchemotes.com API URL (which is the source of emoteset information)
- ShortenDisplayOfExcessivelyLongEmoteCodesLookingOutTheirWindow

Settings
========
Expand Down Expand Up @@ -128,6 +147,8 @@ <h3>Full Changelog</h3>
prevents high CPU usage (displaying animated GIFs in Java is hard)
- Check if Java supports opening URLs on the current platform and run native
command if necessary
- Fixed sounds not being closed when finished playing
- Fixed tabs not changing correctly on System Look&Feel
</pre>

<h2>
Expand Down
7 changes: 3 additions & 4 deletions src/chatty/gui/components/help/help-settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,9 @@ <h3>Other</h3>
<a href="http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat</a>
class.</li>
<li><strong>Show mod/unmod messages</strong>: Whether to show the MOD/UNMOD
messages as they come in from Twitch Chat (which are used to show the
moderator badge). These messages can be sometimes
be kind of broken (on Twitch's side) and can show some or all mods in the channel
as being modded/unmodded.</li>
messages as they come in from Twitch Chat. These messages are send
not only when someone was modded/unmodded but also when a mod joins
or leaves the chat.</li>
<li><strong>Show joins/parts</strong>: Show joins/parts, which
are always kind of delayed, so don't take them too seriously (only works
when <code>Advanced - Correct Userlist</code> is enabled).</li>
Expand Down
36 changes: 30 additions & 6 deletions src/chatty/gui/components/help/help-troubleshooting.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,20 +207,44 @@ <h2>
<p>If you are sure that the <code>Chatty.jar</code> is actually started with
Java, but no program window appears, it may be that an error occured before
the window (GUI) could be created.</p>

<h3>Run from commandline</h3>
<p>Running Chatty from the commandline has the advantage of being able to
get messages from before the GUI is established. It also may work when Java
isn't integrated into the OS correctly (even when installed).</p>

<ol>
<li>Open a commandline window on the directory where the
<code>Chatty.jar</code> is located
<ul>
<li>Windows: In the File Explorer, while holding <kbd>Shift</kbd>
Right-Click into the folder where the
<code>Chatty.jar</code> is located. Click on <code>Open
command window here</code> in the context menu.</li>
</ul>
</li>
<li>In the commandline window, enter <code>java -jar Chatty.jar</code>
and press Enter.</li>
</ol>

<p>When you enter the above command and Chatty starts correctly (but doesn't
when you double-click the <code>Chatty.jar</code>), this may mean that
Java isn't integrated into the OS properly. You can create a
<a href="help-guide_create_shortcut.html">shortcut</a> or a .bat-file to
start Chatty similiar to entering the command above, but much more
conveniently.</p>

<h3>Check Association of .jar with Java (Windows)</h3>
<p>If the integration of Java into the OS may not be correct, and you want
to try to fix it, you can try this.</p>

<p>Open a commandline window and enter <code>assoc .jar</code> which should output
<code>.jar=jarfile</code> and enter <code>ftype jarfile</code> which should
output something like <code>"C:\Program Files\Java\jre7\bin\javaw.exe" -jar "%1" %*</code>
(see also <a href="http://stackoverflow.com/questions/10875839/jar-file-keeps-giving-me-could-not-find-the-main-class-program-will-exit">
Could not find the main class. Program will exit.</a>)</p>

<h3>Run from commandline</h3>
<p>Running Chatty from the commandline has the advantage of being able to
get messages from before the GUI is established. Open a commandline where
the <code>Chatty.jar</code> is located (Win7/8: Hold <kbd>Shift</kbd> while Right-Clicking to open
the context menu, click <code>Open command window here</code>) and enter
<code>java -jar Chatty.jar</code>.</p>


<h3>Error: Java is not recognized as an internal or external command (Windows)</h3>
<p>If you experience this when entering <code>java -jar Chatty.jar</code>
Expand Down
3 changes: 2 additions & 1 deletion src/chatty/gui/components/settings/MessageSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public void actionPerformed(ActionEvent e) {
gbc.anchor = GridBagConstraints.WEST;
otherSettingsPanel.add(
d.addSimpleBooleanSetting("showModMessages", "Show mod/unmod messages",
"Whether to show when someone was modded/unmodded."),
"Whether to show when someone was modded/unmodded or a "
+ "mod joined/left the channel."),
gbc);

gbc = d.makeGbc(2, 1, 2, 1);
Expand Down
37 changes: 28 additions & 9 deletions src/chatty/gui/components/tabs/Tabs.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public enum TabOrder {

private TabOrder order = TabOrder.INSERTION;

private JPopupMenu popupMenu;

public Tabs() {
setLayout(new BorderLayout());
tabs.setOpaque(false);
Expand All @@ -75,17 +77,34 @@ public void mouseWheelMoved(MouseWheelEvent e) {

@Override
public void mousePressed(MouseEvent e) {
/**
* Switch to clicked tab.
*/
int index = tabs.indexAtLocation(e.getX(), e.getY());
if (index != -1) {
tabs.setSelectedIndex(index);
}
openPopupMenu(e);
}

@Override
public void mouseReleased(MouseEvent e) {
openPopupMenu(e);
}
});
//tabs.setTabPlacement(JTabbedPane.LEFT);
}

/**
* Open context menu manually instead of relying on the JTabbedPane, so we
* can check if it's the currently selected tab (since the context menu will
* trigger actions based on the currently selected tab).
*
* @param e
*/
private void openPopupMenu(MouseEvent e) {
if (!e.isPopupTrigger()) {
return;
}
if (popupMenu == null) {
return;
}
final int index = tabs.indexAtLocation(e.getX(), e.getY());
if (tabs.getSelectedIndex() == index) {
popupMenu.show(tabs, e.getX(), e.getY());
}
}

private boolean isNearLastTab(Point p) {
Expand All @@ -103,7 +122,7 @@ public void setMouseWheelScrollingAnywhereEnabled(boolean enabled) {
}

public void setPopupMenu(JPopupMenu menu) {
tabs.setComponentPopupMenu(menu);
popupMenu = menu;
}

/**
Expand Down
14 changes: 8 additions & 6 deletions src/chatty/util/Webserver.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,21 @@ public void run() {
try {
clientSocket = serverSocket.accept();
} catch (SocketException ex) {
debug("Accept interrupted: "+ex.getLocalizedMessage());
debug("Accept interrupted: "+ex);
// After breaking out of the loop, there is a close() anyway
//close();
break;
} catch (IOException ex) {
debug("ServerSocket accept failed: "+ex.getLocalizedMessage());
debug("ServerSocket accept failed: "+ex);
// TODO: close() necessary?
// Why return instead of break?
//return;
break;
} catch (NullPointerException ex) {
// serverSocket apparently may be null in some circumstances
// (possibly a race condition when stopping the server), if so
// just stop
break;
}
// Connection established, work with it
newConnection(clientSocket);
Expand Down Expand Up @@ -232,11 +237,8 @@ public void run() {
if (request != null) {
respond(request);
}

} catch (SocketTimeoutException ex) {
debugConnection("SoTimeout: "+ex.getLocalizedMessage());
} catch (IOException ex) {
debugConnection("Error reading: "+ex.getLocalizedMessage());
debugConnection("Error reading: "+ex);
}
debugConnection("Closed");
}
Expand Down

0 comments on commit fcc91e9

Please sign in to comment.