diff --git a/src/resources/images/Room.png b/src/resources/images/Channel.png similarity index 100% rename from src/resources/images/Room.png rename to src/resources/images/Channel.png diff --git a/src/urChatBasic/backend/MessageHandler.java b/src/urChatBasic/backend/MessageHandler.java index 55b9756..d2739e1 100644 --- a/src/urChatBasic/backend/MessageHandler.java +++ b/src/urChatBasic/backend/MessageHandler.java @@ -528,7 +528,7 @@ public void messageExec (Message myMessage) { if (myMessage.nick.equals(myMessage.messageHandler.serverBase.getNick())) { - myMessage.messageHandler.serverBase.addToCreatedRooms(myMessage.channel, false); + myMessage.messageHandler.serverBase.addToCreatedChannels(myMessage.channel, false); myMessage.messageHandler.serverBase.printEventTicker(myMessage.channel, "You have joined " + myMessage.channel); } else myMessage.messageHandler.serverBase.addToUsersList(myMessage.channel, myMessage.nick); @@ -739,7 +739,7 @@ public void messageExec (Message myMessage) serverBase.reconnectChannels(); } else { - IRCRoomBase messageChannel = myMessage.messageHandler.serverBase.getCreatedChannel(myMessage.getChannel()); + IRCChannelBase messageChannel = myMessage.messageHandler.serverBase.getCreatedChannel(myMessage.getChannel()); if (messageChannel != null) { messageChannel.printText(myMessage.getBody(), Constants.EVENT_USER); diff --git a/src/urChatBasic/backend/logging/URLogger.java b/src/urChatBasic/backend/logging/URLogger.java index e846a30..df33c72 100644 --- a/src/urChatBasic/backend/logging/URLogger.java +++ b/src/urChatBasic/backend/logging/URLogger.java @@ -16,7 +16,7 @@ import org.slf4j.Marker; import org.slf4j.MarkerFactory; import urChatBasic.base.Constants; -import urChatBasic.base.IRCRoomBase; +import urChatBasic.base.IRCChannelBase; import urChatBasic.frontend.DriverGUI; public class URLogger @@ -84,7 +84,7 @@ public static Marker getMarker (String markerName) // } // } - public static void logChannelComms (IRCRoomBase ircChannel, String message) + public static void logChannelComms (IRCChannelBase ircChannel, String message) { LOGGER.info(getMarker(ircChannel.getMarker()), message); diff --git a/src/urChatBasic/base/Constants.java b/src/urChatBasic/base/Constants.java index a37a6ad..2308ebb 100644 --- a/src/urChatBasic/base/Constants.java +++ b/src/urChatBasic/base/Constants.java @@ -156,7 +156,7 @@ public class Constants public static final String URL_REGEX = "((http:\\/\\/|https:\\/\\/)(www.)?(([a-zA-Z0-9-]){2,}\\.){1,4}([a-zA-Z]){2,6}(\\/([a-zA-Z-_\\/\\.0-9#:?=&;,]*)?)?)"; public static final String CHANNEL_REGEX = "(?:^|\s)(#([^\s,]+)(?!,))(?:$|\s)"; // Used to identify a message to be printed from the Event ticker - // like a "user joins room" type message + // like a "user joins channel" type message public static final String EVENT_USER = "****"; // Main text area diff --git a/src/urChatBasic/base/IRCRoomBase.java b/src/urChatBasic/base/IRCChannelBase.java similarity index 94% rename from src/urChatBasic/base/IRCRoomBase.java rename to src/urChatBasic/base/IRCChannelBase.java index b3f27f7..34ed5ba 100644 --- a/src/urChatBasic/base/IRCRoomBase.java +++ b/src/urChatBasic/base/IRCChannelBase.java @@ -2,7 +2,7 @@ import urChatBasic.backend.logging.URLogger; import urChatBasic.backend.utils.URProfilesUtil; -import urChatBasic.base.IRCRoomBase; +import urChatBasic.base.IRCChannelBase; import urChatBasic.base.Constants.EventType; import urChatBasic.frontend.DriverGUI; import urChatBasic.frontend.IRCActions; @@ -31,13 +31,13 @@ import javax.swing.event.MouseInputAdapter; import javax.swing.text.*; -public class IRCRoomBase extends JPanel +public class IRCChannelBase extends JPanel { - // Room information - private String roomName; + // Channel information + private String channelName; // Preferences - private Preferences roomPrefs; + private Preferences channelPrefs; // IRCServer information (Owner of channel) protected IRCServerBase server; @@ -124,13 +124,13 @@ public IRCServerBase getServer() @Override public String getName() { - return this.roomName; + return this.channelName; } @Override public void setName(String newName) { - roomName = newName; + channelName = newName; } public void hideEventTicker() @@ -152,17 +152,17 @@ public void showUsersList() toggleUsersList(usersListShown); } - protected IRCRoomBase(String roomName) + protected IRCChannelBase(String channelName) { - this.roomName = roomName; - initRoom(); + this.channelName = channelName; + initChannel(); } - protected IRCRoomBase(IRCServerBase server, String roomName) + protected IRCChannelBase(IRCServerBase server, String channelName) { - this.roomName = roomName; + this.channelName = channelName; setServer(server); - initRoom(); + initChannel(); } public void setServer(IRCServerBase server) @@ -170,30 +170,30 @@ public void setServer(IRCServerBase server) this.server = server; } - private void initRoom() + private void initChannel() { channelTextArea.setEditable(false); if (getServer() != null) { - String nodeName = getServer().getName() != null ? getServer().getName() : roomName; - markerName = getServer().getName() != null ? getServer().getName() + "-" + roomName : roomName; + String nodeName = getServer().getName() != null ? getServer().getName() : channelName; + markerName = getServer().getName() != null ? getServer().getName() + "-" + channelName : channelName; - if(nodeName.equals(roomName)) + if(nodeName.equals(channelName)) setSettingsPath(URProfilesUtil.getActiveFavouritesPath().node(nodeName)); else - setSettingsPath(URProfilesUtil.getActiveFavouritesPath().node(nodeName).node(roomName)); + setSettingsPath(URProfilesUtil.getActiveFavouritesPath().node(nodeName).node(channelName)); - fontDialog = new FontDialog(roomName, gui.getStyle(), roomPrefs); + fontDialog = new FontDialog(channelName, gui.getStyle(), channelPrefs); - lineFormatter = new LineFormatter(getFontPanel().getStyle(), channelTextArea , getServer(), roomPrefs); + lineFormatter = new LineFormatter(getFontPanel().getStyle(), channelTextArea , getServer(), channelPrefs); } else { - markerName = roomName; - setSettingsPath(URProfilesUtil.getActiveFavouritesPath().node(roomName)); - fontDialog = new FontDialog(roomName, gui.getStyle(), roomPrefs); + markerName = channelName; + setSettingsPath(URProfilesUtil.getActiveFavouritesPath().node(channelName)); + fontDialog = new FontDialog(channelName, gui.getStyle(), channelPrefs); - lineFormatter = new LineFormatter(getFontPanel().getStyle() , channelTextArea, null, roomPrefs); + lineFormatter = new LineFormatter(getFontPanel().getStyle() , channelTextArea, null, channelPrefs); } // Add Logging Marker @@ -208,7 +208,7 @@ private void initRoom() setPreferredSize(new Dimension(Constants.MAIN_WIDTH, Constants.MAIN_HEIGHT)); setupMainPanel(); - setName(roomName); + setName(channelName); this.setLayout(new BorderLayout()); this.add(mainPanel, BorderLayout.CENTER); @@ -226,12 +226,12 @@ private class ProfileChangeListener implements ActionListener @Override public void actionPerformed (ActionEvent arg0) { - String nodeName = getServer().getName() != null ? getServer().getName() : roomName; + String nodeName = getServer().getName() != null ? getServer().getName() : channelName; - if(nodeName.equals(roomName)) + if(nodeName.equals(channelName)) setSettingsPath(URProfilesUtil.getActiveFavouritesPath().node(nodeName)); else - setSettingsPath(URProfilesUtil.getActiveFavouritesPath().node(nodeName).node(roomName)); + setSettingsPath(URProfilesUtil.getActiveFavouritesPath().node(nodeName).node(channelName)); } } @@ -243,7 +243,7 @@ public void rejoin () public void setSettingsPath (Preferences settingsPath) { - roomPrefs = settingsPath; + channelPrefs = settingsPath; if(getFontPanel() != null) { getFontPanel().setSettingsPath(settingsPath); @@ -253,7 +253,7 @@ public void setSettingsPath (Preferences settingsPath) public Preferences getSettingsPath () { - return roomPrefs; + return channelPrefs; } public void createChannelPopUp() @@ -293,11 +293,6 @@ public FontPanel getFontPanel() return fontDialog != null && fontDialog.getFontPanel() != null ? fontDialog.getFontPanel() : null; } - // public void resetLineFormatter() - // { - // lineFormatter = new LineFormatter(getFontPanel().getStyle() , channelTextArea, getServer(), roomPrefs); - // } - protected void setupMainTextArea() { channelScroll.setPreferredSize( @@ -526,7 +521,7 @@ public void run() int lineLimit = ((InterfacePanel) gui.interfacePanel).getLimitChannelLinesCount(); - if(IRCRoomBase.this instanceof IRCServer) + if(IRCChannelBase.this instanceof IRCServer) lineLimit = ((InterfacePanel) gui.interfacePanel).getLimitServerLinesCount(); if(null != messagePair && root.getElementCount() > lineLimit) @@ -574,14 +569,14 @@ public void run() { lineFormatter.formattedDocument(new Date(), fromIRCUser, fromUser, line); - if(IRCRoomBase.this instanceof IRCServerBase) + if(IRCChannelBase.this instanceof IRCServerBase) { if (((InterfacePanel) gui.interfacePanel).saveServerHistory()) - URLogger.logChannelComms(IRCRoomBase.this, (fromIRCUser != null ? fromIRCUser.getName() : fromUser) + ": " + line); - } else if(!(IRCRoomBase.this instanceof IRCServerBase)) + URLogger.logChannelComms(IRCChannelBase.this, (fromIRCUser != null ? fromIRCUser.getName() : fromUser) + ": " + line); + } else if(!(IRCChannelBase.this instanceof IRCServerBase)) { if (((InterfacePanel) gui.interfacePanel).saveChannelHistory()) - URLogger.logChannelComms(IRCRoomBase.this, (fromIRCUser != null ? fromIRCUser.getName() : fromUser) + ": " + line); + URLogger.logChannelComms(IRCChannelBase.this, (fromIRCUser != null ? fromIRCUser.getName() : fromUser) + ": " + line); } if (server.getNick() != null && line.indexOf(server.getNick()) > -1) @@ -590,7 +585,7 @@ public void run() } // Always alert on IRCPrivate messages - if (IRCRoomBase.this instanceof IRCPrivate) + if (IRCChannelBase.this instanceof IRCPrivate) { callForAttention(); } @@ -652,7 +647,7 @@ public void toggleEventTicker (boolean showIt) /** * Return the appropriate created IRC User * - * @param roomName + * @param channelName * @return IRCChannel */ public IRCUser getCreatedUser(String userName) { @@ -719,7 +714,7 @@ public void addToUsersList(final String user) addToUsersList(new String[]{user}); } - public String getChannelTopic(String roomName) + public String getChannelTopic(String channelName) { return getChannelTopic(); } @@ -853,7 +848,7 @@ public class ChannelPopUp extends JPopupMenu public ChannelPopUp() { - nameItem = new JMenuItem(IRCRoomBase.this.getName()); + nameItem = new JMenuItem(IRCChannelBase.this.getName()); add(nameItem); addSeparator(); // @@ -882,12 +877,12 @@ public ChannelPopUp() public void show(Component arg0, int arg1, int arg2) { // TODO: Favourites handling to be done elsewhere - // if (gui.isFavourite(IRCRoomBase.this)) + // if (gui.isFavourite(IRCChannelBase.this)) // { - // ((ChannelPopUp) IRCRoomBase.this.myMenu).addAsFavouriteItem.setText("Remove as Favourite"); + // ((ChannelPopUp) IRCChannelBase.this.myMenu).addAsFavouriteItem.setText("Remove as Favourite"); // } else // { - // ((ChannelPopUp) IRCRoomBase.this.myMenu).addAsFavouriteItem.setText("Add as Favourite"); + // ((ChannelPopUp) IRCChannelBase.this.myMenu).addAsFavouriteItem.setText("Add as Favourite"); // } super.show(arg0, arg1, arg2); @@ -903,7 +898,7 @@ public void actionPerformed(ActionEvent arg0) // TODO: Favourites handling to be done elsewhere // if (null != getServer()) // { - // if (!gui.isFavourite(IRCRoomBase.this)) + // if (!gui.isFavourite(IRCChannelBase.this)) // { // gui.addFavourite(getServer().getName(), getName()); // } else @@ -1039,7 +1034,7 @@ public void actionPerformed(ActionEvent arg0) } } - public void closeRoom() + public void closeChannel () { URProfilesUtil.removeListener(EventType.CHANGE, changeListener); eventTickerTimer.stop(); @@ -1205,7 +1200,7 @@ public void actionPerformed(ActionEvent event) { public void run() { - if (IRCRoomBase.this.tickerPanel.isVisible()) + if (IRCChannelBase.this.tickerPanel.isVisible()) { Iterator labelIterator = eventLabels.iterator(); while (labelIterator.hasNext()) diff --git a/src/urChatBasic/base/IRCServerBase.java b/src/urChatBasic/base/IRCServerBase.java index 93d0af2..f994ad5 100644 --- a/src/urChatBasic/base/IRCServerBase.java +++ b/src/urChatBasic/base/IRCServerBase.java @@ -56,14 +56,9 @@ public interface IRCServerBase */ public abstract IRCUser getIRCUser (String userName); - public abstract void quitRooms(); - - public abstract void quitRoom (IRCRoomBase ircRoom); - - /** - * Closes and removes all private rooms that have been created. - */ + public abstract void quitChannels (); + public abstract void quitChannel (IRCChannelBase ircChannel); /** * Return the appropriate created channel @@ -80,30 +75,30 @@ public interface IRCServerBase * @param serverName * @return IRCServer */ - public abstract IRCPrivate getCreatedPrivateRoom (String privateRoom); + public abstract IRCPrivate getCreatedPrivateChannel (String privateChannel); /** * Return the appropriate created channel * - * @param roomName - * @return IRCRoomBase + * @param channelName + * @return IRCChannelBase */ - public abstract IRCRoomBase getCreatedRoom (String roomName, boolean asPrivate); + public abstract IRCChannelBase getCreatedChannel (String channelName, boolean asPrivate); /** - * Creates a new room based on name + * Creates a new Channel based on name * - * @param roomName + * @param channelName */ - public abstract void addToCreatedRooms (String roomName, boolean asPrivate); + public abstract void addToCreatedChannels (String channelName, boolean asPrivate); /** - * Creates a new Private Room based on IRCUser + * Creates a new Private Channel based on IRCUser * * @param serverName * @return */ - public abstract IRCPrivate addToPrivateRooms (IRCUser privateRoom); + public abstract IRCPrivate addToPrivateChannels (IRCUser privateChannel); /** * Used to negotiate a PLAIN SASL connection to the IRC Server. diff --git a/src/urChatBasic/base/UserGUIBase.java b/src/urChatBasic/base/UserGUIBase.java index b87db66..5d5380b 100644 --- a/src/urChatBasic/base/UserGUIBase.java +++ b/src/urChatBasic/base/UserGUIBase.java @@ -66,7 +66,7 @@ public interface UserGUIBase // * @param channel // * @return // */ - // public abstract Boolean isFavourite(IRCRoomBase channel); + // public abstract Boolean isFavourite(IRCChannelBase channel); // public abstract void removeFavourite(String server, String channel); diff --git a/src/urChatBasic/frontend/DriverGUI.java b/src/urChatBasic/frontend/DriverGUI.java index 3be0398..c750d08 100644 --- a/src/urChatBasic/frontend/DriverGUI.java +++ b/src/urChatBasic/frontend/DriverGUI.java @@ -38,12 +38,18 @@ public static void main(String[] args) throws IOException Constants.LOGGER.info( "Starting up.."); initLAFLoader(); - frame = new JFrame("urChat"); - // This will load the default profile - gui = createGUI(Optional.empty()); + // Fixes #92 + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame = new JFrame("urChat"); - startGUI(); + // This will load the default profile + gui = createGUI(Optional.empty()); + + startGUI(); + } + }); } public static void initLAFLoader() throws IOException diff --git a/src/urChatBasic/frontend/IRCActions.java b/src/urChatBasic/frontend/IRCActions.java index 1c0ea29..353c99b 100644 --- a/src/urChatBasic/frontend/IRCActions.java +++ b/src/urChatBasic/frontend/IRCActions.java @@ -7,7 +7,7 @@ import javax.swing.Timer; import javax.swing.UIManager; import urChatBasic.base.IRCActionsBase; -import urChatBasic.base.IRCRoomBase; +import urChatBasic.base.IRCChannelBase; public class IRCActions implements IRCActionsBase { @@ -16,16 +16,16 @@ public class IRCActions implements IRCActionsBase { private Timer wantsAttentionTimer = new Timer(0, new FlashTab()); private Color originalColour; protected UserGUI gui = DriverGUI.gui; - protected IRCRoomBase ircRoom; + protected IRCChannelBase ircChannel; - public IRCActions(IRCRoomBase ircRoom) + public IRCActions(IRCChannelBase ircChannel) { - this.ircRoom = ircRoom; - // originalColour = ircRoom.getBackground(); + this.ircChannel = ircChannel; + // originalColour = ircChannel.getBackground(); for(int i = 0; i < gui.tabbedPane.getTabCount(); i++) { - if(gui.tabbedPane.getComponentAt(i) == ircRoom) + if(gui.tabbedPane.getComponentAt(i) == ircChannel) { originalColour = gui.tabbedPane.getBackgroundAt(i); break; @@ -38,11 +38,11 @@ private class FlashTab implements ActionListener public void actionPerformed(ActionEvent event) { Component selectedComponent = gui.tabbedPane.getSelectedComponent(); - int tabIndex = gui.tabbedPane.indexOfComponent(ircRoom); + int tabIndex = gui.tabbedPane.indexOfComponent(ircChannel); - if (tabIndex >= 0 && wantsAttention && selectedComponent != ircRoom) + if (tabIndex >= 0 && wantsAttention && selectedComponent != ircChannel) { - ircRoom.getUserTextBox().requestFocus(); + ircChannel.getUserTextBox().requestFocus(); if (gui.tabbedPane.getBackgroundAt(tabIndex) == UIManager.getColor("CheckBoxMenuItem.selectionBackground")) { diff --git a/src/urChatBasic/frontend/IRCChannel.java b/src/urChatBasic/frontend/IRCChannel.java index b430a8b..486f878 100644 --- a/src/urChatBasic/frontend/IRCChannel.java +++ b/src/urChatBasic/frontend/IRCChannel.java @@ -4,9 +4,9 @@ import java.net.URL; import javax.swing.ImageIcon; import urChatBasic.base.Constants; -import urChatBasic.base.IRCRoomBase; +import urChatBasic.base.IRCChannelBase; -public class IRCChannel extends IRCRoomBase +public class IRCChannel extends IRCChannelBase { /** * @@ -26,11 +26,11 @@ public IRCChannel(IRCServer server, String channelName) URL imgPath = null; try { - imgPath = new URL(Constants.IMAGES_DIR + "Room.png"); + imgPath = new URL(Constants.IMAGES_DIR + "Channel.png"); icon = new ImageIcon(imgPath); } catch (IOException e) { - Constants.LOGGER.warn( "COULD NOT LOAD Room.png " + e.getLocalizedMessage()); + Constants.LOGGER.warn( "COULD NOT LOAD Channel.png " + e.getLocalizedMessage()); } } } diff --git a/src/urChatBasic/frontend/IRCPrivate.java b/src/urChatBasic/frontend/IRCPrivate.java index 9f59e1f..de44d2b 100644 --- a/src/urChatBasic/frontend/IRCPrivate.java +++ b/src/urChatBasic/frontend/IRCPrivate.java @@ -7,9 +7,9 @@ import java.net.URL; import javax.swing.ImageIcon; import urChatBasic.base.Constants; -import urChatBasic.base.IRCRoomBase; +import urChatBasic.base.IRCChannelBase; -public class IRCPrivate extends IRCRoomBase +public class IRCPrivate extends IRCChannelBase { /** * diff --git a/src/urChatBasic/frontend/IRCServer.java b/src/urChatBasic/frontend/IRCServer.java index 1f5c174..7f87d3b 100644 --- a/src/urChatBasic/frontend/IRCServer.java +++ b/src/urChatBasic/frontend/IRCServer.java @@ -25,7 +25,7 @@ import urChatBasic.backend.utils.URProfilesUtil; import urChatBasic.base.ConnectionBase; import urChatBasic.base.Constants; -import urChatBasic.base.IRCRoomBase; +import urChatBasic.base.IRCChannelBase; import urChatBasic.base.IRCServerBase; import urChatBasic.base.Constants.EventType; import urChatBasic.base.capabilities.CapTypeBase; @@ -33,7 +33,7 @@ import urChatBasic.base.proxy.ProxyTypeBase; import urChatBasic.frontend.utils.URPanels; -public class IRCServer extends IRCRoomBase implements IRCServerBase +public class IRCServer extends IRCChannelBase implements IRCServerBase { /** * @@ -56,7 +56,7 @@ public class IRCServer extends IRCRoomBase implements IRCServerBase private CapTypeBase authentication; // Created channels/tabs - public List createdRooms = new ArrayList(); + public List createdChannels = new ArrayList(); // Server capabilities private ArrayList capabilities = new ArrayList(); @@ -130,7 +130,7 @@ public void saslDoAuthentication () public void reconnectChannels () { - for (IRCRoomBase channel : createdRooms) + for (IRCChannelBase channel : createdChannels) { sendClientText("/join " + channel.getName(), getServer().getName()); } @@ -382,8 +382,8 @@ public void connect (String[] autoConnectChannels) for (String autoChannel : autoConnectChannels) { - IRCRoomBase newChannel = new IRCChannel(this, autoChannel); - createdRooms.add(newChannel); + IRCChannelBase newChannel = new IRCChannel(this, autoChannel); + createdChannels.add(newChannel); } } catch (Exception e) @@ -403,7 +403,7 @@ public void reconnect () public void disconnect () { serverConnection.disconnect(); - quitRooms(); + quitChannels(); } /* @@ -448,7 +448,7 @@ public String getName () @Override public IRCUser getIRCUser (String userName) { - for (IRCRoomBase tempChannel : createdRooms) + for (IRCChannelBase tempChannel : createdChannels) if (tempChannel.getCreatedUser(userName) != null) return tempChannel.getCreatedUser(userName); return new IRCUser(this, userName); @@ -458,16 +458,16 @@ public IRCUser getIRCUser (String userName) /* * (non-Javadoc) * - * @see urChatBasic.backend.IRCServerBase#getCreatedPrivateRoom(java.lang.String) + * @see urChatBasic.backend.IRCServerBase#getCreatedPrivateChannel(java.lang.String) */ @Override - public IRCPrivate getCreatedPrivateRoom (String privateRoom) + public IRCPrivate getCreatedPrivateChannel (String privateChannel) { - IRCRoomBase tempRoom = getCreatedRoom(privateRoom, true); + IRCChannelBase tempChannel = getCreatedChannel(privateChannel, true); - if (tempRoom != null) + if (tempChannel != null) { - return (IRCPrivate) tempRoom; + return (IRCPrivate) tempChannel; } return null; @@ -476,56 +476,56 @@ public IRCPrivate getCreatedPrivateRoom (String privateRoom) /* * (non-Javadoc) * - * @see urChatBasic.backend.IRCServerBase#getCreatedPrivateRoom(java.lang.String) + * @see urChatBasic.backend.IRCServerBase#getCreatedPrivateChannel(java.lang.String) */ @Override public IRCChannel getCreatedChannel (String channelName) { - IRCRoomBase tempRoom = getCreatedRoom(channelName, false); + IRCChannelBase tempChannel = getCreatedChannel(channelName, false); - if (tempRoom != null && tempRoom instanceof IRCChannel) + if (tempChannel != null && tempChannel instanceof IRCChannel) { - return (IRCChannel) tempRoom; + return (IRCChannel) tempChannel; } return null; } @Override - public void quitRooms () + public void quitChannels () { URProfilesUtil.removeListener(EventType.CHANGE, changeListener); - Iterator channelIterator = createdRooms.iterator(); + Iterator channelIterator = createdChannels.iterator(); while (channelIterator.hasNext()) { - IRCRoomBase removeChannel = channelIterator.next(); + IRCChannelBase removeChannel = channelIterator.next(); channelIterator.remove(); - quitRoom(removeChannel); + quitChannel(removeChannel); } } @Override - public void quitRoom (IRCRoomBase ircRoom) + public void quitChannel (IRCChannelBase ircChannel) { - ircRoom.closeRoom(); - createdRooms.remove(ircRoom); + ircChannel.closeChannel(); + createdChannels.remove(ircChannel); - boolean tabExists = Arrays.stream(gui.tabbedPane.getComponents()).anyMatch(room -> room.equals(ircRoom)); + boolean tabExists = Arrays.stream(gui.tabbedPane.getComponents()).anyMatch(channel -> channel.equals(ircChannel)); - if (tabExists && gui.tabbedPane.getSelectedComponent().equals(ircRoom)) + if (tabExists && gui.tabbedPane.getSelectedComponent().equals(ircChannel)) gui.tabbedPane.setSelectedComponent(gui.previousSelectedTab); - gui.tabbedPane.remove(ircRoom); + gui.tabbedPane.remove(ircChannel); } @Override - public IRCRoomBase getCreatedRoom (String roomName, boolean asPrivate) + public IRCChannelBase getCreatedChannel (String channelName, boolean asPrivate) { - IRCRoomBase returnChannel = null; + IRCChannelBase returnChannel = null; - for (IRCRoomBase tempChannel : createdRooms) - if (tempChannel.getName().equals(roomName)) + for (IRCChannelBase tempChannel : createdChannels) + if (tempChannel.getName().equals(channelName)) { if (asPrivate && tempChannel instanceof IRCPrivate || !asPrivate) returnChannel = tempChannel; @@ -539,15 +539,15 @@ public IRCRoomBase getCreatedRoom (String roomName, boolean asPrivate) * @see urChatBasic.backend.IRCServerBase#addToCreatedChannels(java.lang.String) */ @Override - public void addToCreatedRooms (String roomName, boolean asPrivate) + public void addToCreatedChannels (String channelName, boolean asPrivate) { - if (getCreatedRoom(roomName, asPrivate) == null) + if (getCreatedChannel(channelName, asPrivate) == null) { - createdRooms.add(asPrivate ? new IRCPrivate(this, getIRCUser(roomName)) : new IRCChannel(this, roomName)); + createdChannels.add(asPrivate ? new IRCPrivate(this, getIRCUser(channelName)) : new IRCChannel(this, channelName)); } - if (getCreatedRoom(roomName, asPrivate) == null || DriverGUI.gui.getTabIndex(getCreatedRoom(roomName, asPrivate)) < 0) + if (getCreatedChannel(channelName, asPrivate) == null || DriverGUI.gui.getTabIndex(getCreatedChannel(channelName, asPrivate)) < 0) { boolean iconsShown = (boolean) URPanels.getKeyComponentValue(Constants.KEY_SHOW_TAB_ICON); @@ -558,15 +558,15 @@ public void addToCreatedRooms (String roomName, boolean asPrivate) @Override public void run () { - IRCRoomBase tempChannel = getCreatedRoom(roomName, asPrivate); + IRCChannelBase tempChannel = getCreatedChannel(channelName, asPrivate); int newIndex = gui.tabbedPane.indexOfComponent(gui.currentSelectedTab) + 1; - gui.tabbedPane.insertTab(roomName, iconsShown ? tempChannel.icon : null, tempChannel, null, gui.tabbedPane.indexOfComponent(gui.currentSelectedTab) + 1); + gui.tabbedPane.insertTab(channelName, iconsShown ? tempChannel.icon : null, tempChannel, null, gui.tabbedPane.indexOfComponent(gui.currentSelectedTab) + 1); - // gui.tabbedPane.addTab(roomName, tempChannel.icon, tempChannel); + // gui.tabbedPane.addTab(channelName, tempChannel.icon, tempChannel); Component currentTab = gui.tabbedPane.getSelectedComponent(); - if (currentTab instanceof IRCRoomBase) + if (currentTab instanceof IRCChannelBase) { - if (!((IRCRoomBase) currentTab).userIsTyping()) + if (!((IRCChannelBase) currentTab).userIsTyping()) { gui.tabbedPane.setSelectedIndex(newIndex); tempChannel.getUserTextBox().requestFocus(); @@ -594,23 +594,23 @@ public void run () /* * (non-Javadoc) * - * @see urChatBasic.backend.IRCServerBase#addToPrivateRooms(urChatBasic.frontend.IRCUser) + * @see urChatBasic.backend.IRCServerBase#addToPrivateChannels(urChatBasic.frontend.IRCUser) */ @Override - public IRCPrivate addToPrivateRooms (IRCUser fromUser) + public IRCPrivate addToPrivateChannels (IRCUser fromUser) { - IRCPrivate privateRoom = getCreatedPrivateRoom(fromUser.getName()); - if (privateRoom == null) + IRCPrivate privateChannel = getCreatedPrivateChannel(fromUser.getName()); + if (privateChannel == null) { - addToCreatedRooms(fromUser.getName(), true); - privateRoom = getCreatedPrivateRoom(fromUser.getName()); - // gui.tabbedPane.addTab(privateRoom.getName(), privateRoom.icon, privateRoom); - // gui.tabbedPane.setSelectedIndex(gui.tabbedPane.indexOfComponent(privateRoom)); - // privateRoom.getUserTextBox().requestFocus(); - return privateRoom; + addToCreatedChannels(fromUser.getName(), true); + privateChannel = getCreatedPrivateChannel(fromUser.getName()); + // gui.tabbedPane.addTab(privateChannel.getName(), privateChannel.icon, privateChannel); + // gui.tabbedPane.setSelectedIndex(gui.tabbedPane.indexOfComponent(privateChannel)); + // privateChannel.getUserTextBox().requestFocus(); + return privateChannel; } - return privateRoom; + return privateChannel; } /* @@ -622,7 +622,7 @@ public IRCPrivate addToPrivateRooms (IRCUser fromUser) public void printChannelText (String channelName, String line, String fromUser) { - IRCRoomBase tempChannel = getCreatedRoom(channelName, false); + IRCChannelBase tempChannel = getCreatedChannel(channelName, false); if (channelName.equals(fromUser) || null == tempChannel) { @@ -645,9 +645,9 @@ public void printPrivateText (String userName, String line, String fromUser) // if they aren't muted if (getIRCUser(userName) != null && !getIRCUser(userName).isMuted()) { - IRCPrivate privateRoom = addToPrivateRooms(getIRCUser(userName)); + IRCPrivate privateChannel = addToPrivateChannels(getIRCUser(userName)); - privateRoom.printText(line, fromUser); + privateChannel.printText(line, fromUser); // Make a noise if the user hasn't got the current tab selected // TODO: Make it work on linux, and also add a focus request if (gui.getTabIndex(userName) != gui.tabbedPane.getSelectedIndex()) @@ -724,7 +724,7 @@ public void removeFromUsersList (final String channelName, final String user) if (channelName.equals(getName())) { - for (IRCRoomBase tempChannel : createdRooms) + for (IRCChannelBase tempChannel : createdChannels) { tempChannel.removeFromUsersList(thisUser); } @@ -733,7 +733,7 @@ public void removeFromUsersList (final String channelName, final String user) IRCChannel tempChannel = getCreatedChannel(channelName); if (tempChannel != null) if (thisUser.equals(getNick())) - quitRoom(tempChannel); + quitChannel(tempChannel); else tempChannel.removeFromUsersList(thisUser); } @@ -782,7 +782,7 @@ public void renameUser (final String oldUserName, final String newUserName) { public void run () { - for (IRCRoomBase tempChannel : createdRooms) + for (IRCChannelBase tempChannel : createdChannels) { tempChannel.renameUser(oldUserName.replace(":", ""), newUserName); } diff --git a/src/urChatBasic/frontend/IRCUser.java b/src/urChatBasic/frontend/IRCUser.java index e668d15..b85b137 100644 --- a/src/urChatBasic/frontend/IRCUser.java +++ b/src/urChatBasic/frontend/IRCUser.java @@ -96,7 +96,7 @@ private class StartPrivateMessage implements ActionListener public void actionPerformed(ActionEvent arg0) { if (!isMuted()) - myServer.addToPrivateRooms(IRCUser.this); + myServer.addToPrivateChannels(IRCUser.this); } } diff --git a/src/urChatBasic/frontend/UserGUI.java b/src/urChatBasic/frontend/UserGUI.java index a984604..01ff111 100644 --- a/src/urChatBasic/frontend/UserGUI.java +++ b/src/urChatBasic/frontend/UserGUI.java @@ -22,7 +22,7 @@ import urChatBasic.backend.utils.URStyle; import urChatBasic.backend.utils.URUncaughtExceptionHandler; import urChatBasic.base.Constants; -import urChatBasic.base.IRCRoomBase; +import urChatBasic.base.IRCChannelBase; import urChatBasic.base.IRCServerBase; import urChatBasic.frontend.dialogs.FontDialog; import urChatBasic.frontend.panels.MainOptionsPanel; @@ -132,12 +132,12 @@ public int getTabIndex (String tabName) return -1; } - public int getTabIndex (IRCRoomBase targetTab) + public int getTabIndex (IRCChannelBase targetTab) { for (int i = 0; i < DriverGUI.gui.tabbedPane.getTabCount(); i++) { Component currentTab = DriverGUI.gui.tabbedPane.getComponentAt(i); - if (currentTab instanceof IRCRoomBase && currentTab.equals(targetTab)) + if (currentTab instanceof IRCChannelBase && currentTab.equals(targetTab)) { return i; } @@ -473,10 +473,10 @@ public void run () if (server instanceof IRCServer) { boolean iconsShown = (boolean) URPanels.getKeyComponentValue(Constants.KEY_SHOW_TAB_ICON); - int currentServerIndex = DriverGUI.gui.getTabIndex((IRCRoomBase) server); + int currentServerIndex = DriverGUI.gui.getTabIndex((IRCChannelBase) server); if(currentServerIndex < 0) { - tabbedPane.addTab(server.getName(), iconsShown ? ((IRCRoomBase) server).icon : null, ((IRCServer) server)); + tabbedPane.addTab(server.getName(), iconsShown ? ((IRCChannelBase) server).icon : null, ((IRCServer) server)); setCurrentTab(server.getName()); } // ((IRCServer) server).getUserTextBox().requestFocus(); @@ -636,10 +636,10 @@ public void mouseClicked (MouseEvent e) if (selectedComponent instanceof IRCPrivate) { - ((IRCRoomBase) selectedComponent).getServer().quitRoom((IRCRoomBase) selectedComponent); + ((IRCChannelBase) selectedComponent).getServer().quitChannel((IRCChannelBase) selectedComponent); } else { - ((IRCRoomBase) selectedComponent).myMenu.show(tabbedPane, e.getX(), e.getY()); + ((IRCChannelBase) selectedComponent).myMenu.show(tabbedPane, e.getX(), e.getY()); } } } @@ -657,9 +657,9 @@ private void TabbedPanel_stateChanged (ChangeEvent e) if (index > -1) { Component selectedComponent = tabbedPane.getComponentAt(index); - if (selectedComponent instanceof IRCRoomBase) + if (selectedComponent instanceof IRCChannelBase) { - IRCRoomBase tempTab = (IRCRoomBase) selectedComponent; + IRCChannelBase tempTab = (IRCChannelBase) selectedComponent; if (!(selectedComponent instanceof IRCServer)) { tempTab.toggleEventTicker(((InterfacePanel) interfacePanel).isShowingEventTicker()); @@ -700,10 +700,10 @@ public void actionPerformed (ActionEvent arg0) { Component tab = tabbedPane.getComponentAt(index); - if (tab instanceof IRCRoomBase) + if (tab instanceof IRCChannelBase) { tab.setFont(getStyle().getFont()); - ((IRCRoomBase) tab).getFontPanel().setDefaultStyle(getStyle()); + ((IRCChannelBase) tab).getFontPanel().setDefaultStyle(getStyle()); } } @@ -758,9 +758,9 @@ public void run () { int index = tabbedPane.getSelectedIndex(); Component selectedComponent = tabbedPane.getComponentAt(index); - if (selectedComponent instanceof IRCRoomBase) + if (selectedComponent instanceof IRCChannelBase) { - IRCRoomBase tempTab = (IRCRoomBase) selectedComponent; + IRCChannelBase tempTab = (IRCChannelBase) selectedComponent; tempTab.disableFocus(); } } @@ -886,16 +886,16 @@ public void run () { Component tab = tabbedPane.getComponentAt(index); - if (tab instanceof IRCRoomBase) + if (tab instanceof IRCChannelBase) { // tab.setFont(clientFontPanel.getFont()); - IRCRoomBase roomTab = IRCRoomBase.class.cast(tab); - // roomTab.getFontPanel().setDefaultFont(clientFontPanel.getFont()); - roomTab.getFontPanel().setDefaultStyle(defaultStyle); - // roomTab.resetLineFormatter(); - roomTab.getLineFormatter().updateStyles(getStyle()); - SwingUtilities.updateComponentTreeUI(roomTab.myMenu); - SwingUtilities.updateComponentTreeUI(roomTab.getFontPanel()); + IRCChannelBase channelTab = IRCChannelBase.class.cast(tab); + // channelTab.getFontPanel().setDefaultFont(clientFontPanel.getFont()); + channelTab.getFontPanel().setDefaultStyle(defaultStyle); + // channelTab.resetLineFormatter(); + channelTab.getLineFormatter().updateStyles(getStyle()); + SwingUtilities.updateComponentTreeUI(channelTab.myMenu); + SwingUtilities.updateComponentTreeUI(channelTab.getFontPanel()); } } diff --git a/src/urChatBasic/frontend/panels/ConnectionPanel.java b/src/urChatBasic/frontend/panels/ConnectionPanel.java index 08c22a3..a61c807 100644 --- a/src/urChatBasic/frontend/panels/ConnectionPanel.java +++ b/src/urChatBasic/frontend/panels/ConnectionPanel.java @@ -30,7 +30,7 @@ import urChatBasic.base.Constants.EventType; import urChatBasic.base.Constants.Placement; import urChatBasic.base.Constants.Size; -import urChatBasic.base.IRCRoomBase; +import urChatBasic.base.IRCChannelBase; import urChatBasic.base.IRCServerBase; import urChatBasic.base.capabilities.CapabilityTypes; import urChatBasic.base.proxy.ProxyTypes; @@ -162,7 +162,7 @@ public void addFavourite (String favServer, String favChannel) URProfilesUtil.getActiveFavouritesPath().node(favServer).node(favChannel).put("PORT", DriverGUI.gui.getCreatedServer(favServer).getPort()); } - public Boolean isFavourite (IRCRoomBase channel) + public Boolean isFavourite (IRCChannelBase channel) { FavouritesItem castItem; diff --git a/src/urChatBasic/frontend/panels/InterfacePanel.java b/src/urChatBasic/frontend/panels/InterfacePanel.java index cb1bd82..f70564f 100644 --- a/src/urChatBasic/frontend/panels/InterfacePanel.java +++ b/src/urChatBasic/frontend/panels/InterfacePanel.java @@ -6,7 +6,7 @@ import javax.swing.JSlider; import javax.swing.JTextField; import urChatBasic.base.Constants; -import urChatBasic.base.IRCRoomBase; +import urChatBasic.base.IRCChannelBase; import urChatBasic.base.Constants.Placement; import urChatBasic.frontend.DriverGUI; import urChatBasic.frontend.utils.URPanels; @@ -87,10 +87,10 @@ private void setupInterfacePanel () { ImageIcon setIcon = null; - if (DriverGUI.gui.tabbedPane.getComponentAt(i) instanceof IRCRoomBase) + if (DriverGUI.gui.tabbedPane.getComponentAt(i) instanceof IRCChannelBase) { - IRCRoomBase room = (IRCRoomBase) DriverGUI.gui.tabbedPane.getComponentAt(i); - setIcon = room.icon; + IRCChannelBase channel = (IRCChannelBase) DriverGUI.gui.tabbedPane.getComponentAt(i); + setIcon = channel.icon; DriverGUI.gui.tabbedPane.setIconAt(i, showTabIcons.isSelected() ? setIcon : null); } diff --git a/tests/backend/MessageHandlerTests.java b/tests/backend/MessageHandlerTests.java index f4f4014..a6066e5 100644 --- a/tests/backend/MessageHandlerTests.java +++ b/tests/backend/MessageHandlerTests.java @@ -18,7 +18,7 @@ import urChatBasic.backend.MessageHandler.Message; import urChatBasic.backend.utils.URProfilesUtil; import urChatBasic.base.Constants; -import urChatBasic.base.IRCRoomBase; +import urChatBasic.base.IRCChannelBase; import urChatBasic.base.capabilities.CapabilityTypes; import urChatBasic.base.proxy.ProxyTypes; import urChatBasic.frontend.DriverGUI; @@ -36,9 +36,9 @@ public class MessageHandlerTests IRCServer testServer; TestDriverGUI testDriver; UserGUI testGUI; - IRCRoomBase testPrivChannel; + IRCChannelBase testPrivChannel; final String PUB_CHANNEL_NAME = "#someChannel"; - IRCRoomBase testPubChannel; + IRCChannelBase testPubChannel; IRCUser testUser; Connection testConnection; @@ -50,9 +50,9 @@ public void setUp() throws Exception testServer = new IRCServer("testServer", "testUser", "testUser", "testPassword", "1337", true, "testProxy", "1234", ProxyTypes.NONE.getType(), CapabilityTypes.NONE.getType()); testUser = new IRCUser(testServer, "testUser"); - testServer.addToPrivateRooms(testUser); - testPrivChannel = testServer.getCreatedPrivateRoom(testUser.toString()); - testServer.addToCreatedRooms(PUB_CHANNEL_NAME, false); + testServer.addToPrivateChannels(testUser); + testPrivChannel = testServer.getCreatedPrivateChannel(testUser.toString()); + testServer.addToCreatedChannels(PUB_CHANNEL_NAME, false); testPubChannel = testServer.getCreatedChannel(PUB_CHANNEL_NAME); testConnection = new Connection(testServer); testHandler = testConnection.getMessageHandler(); @@ -62,7 +62,7 @@ public void setUp() throws Exception public void tearDown () throws Exception { // Reporter.log("Deleting testing profile.", true); - testServer.quitRooms(); + testServer.quitChannels(); // URProfilesUtil.getActiveProfilePath().sync(); // URProfilesUtil.getActiveProfilePath().sync(); URProfilesUtil.deleteProfile(testDriver.getTestProfileName()); @@ -72,11 +72,11 @@ public void tearDown () throws Exception @Test(groups = {"Test #001"}) public void nickIsHighStyleTest() throws BadLocationException, InterruptedException { - // This should create a someuser private room + // This should create a someuser private channel String rawMessage = ":someuser!~someuser@urchatclient PRIVMSG testUser :hello testUser!"; Message testMessage = testHandler.new Message(rawMessage); testHandler.parseMessage(testMessage); - IRCPrivate someUserChannel = testServer.getCreatedPrivateRoom("someuser"); + IRCPrivate someUserChannel = testServer.getCreatedPrivateChannel("someuser"); String testLine = someUserChannel.getLineFormatter().getLatestLine(); // "[0629] hello testUser!" while (someUserChannel.messageQueueWorking()) diff --git a/tests/frontend/LineFormatterTests.java b/tests/frontend/LineFormatterTests.java index b28144c..2707c11 100644 --- a/tests/frontend/LineFormatterTests.java +++ b/tests/frontend/LineFormatterTests.java @@ -16,7 +16,7 @@ import urChatBasic.backend.MessageHandler; import urChatBasic.backend.MessageHandler.Message; import urChatBasic.backend.utils.URProfilesUtil; -import urChatBasic.base.IRCRoomBase; +import urChatBasic.base.IRCChannelBase; import urChatBasic.base.capabilities.CapabilityTypes; import urChatBasic.base.proxy.ProxyTypes; import urChatBasic.frontend.DriverGUI; @@ -31,9 +31,9 @@ public class LineFormatterTests IRCServer testServer; TestDriverGUI testDriver; UserGUI testGUI; - // IRCRoomBase testPrivChannel; + // IRCChannelBase testPrivChannel; final String PUB_CHANNEL_NAME = "#someChannel"; - IRCRoomBase testPubChannel; + IRCChannelBase testPubChannel; IRCUser testUser; Connection testConnection; @@ -45,7 +45,7 @@ public void setUp () throws Exception testGUI = DriverGUI.gui; testServer = new IRCServer("testServer", "testUser", "testUser", "testPassword", "1337", true, "testProxy", "1234", ProxyTypes.NONE.getType(), CapabilityTypes.NONE.getType()); testUser = new IRCUser(testServer, "testUser"); - testServer.addToCreatedRooms(PUB_CHANNEL_NAME, false); + testServer.addToCreatedChannels(PUB_CHANNEL_NAME, false); testPubChannel = testServer.getCreatedChannel(PUB_CHANNEL_NAME); testConnection = new Connection(testServer); testHandler = testConnection.getMessageHandler(); @@ -54,7 +54,7 @@ public void setUp () throws Exception @AfterClass(alwaysRun = true) public void tearDown () throws Exception { - testServer.quitRooms(); + testServer.quitChannels(); URProfilesUtil.deleteProfile(testDriver.getTestProfileName()); TestDriverGUI.closeWindow(); } @@ -116,7 +116,7 @@ public void run() // Here we expect it to throw an exception because the TestGUI isn't visible for (MouseListener listener : testPubChannel.getChannelTextPane().getMouseListeners()) { - if(listener instanceof IRCRoomBase.ChannelClickListener) + if(listener instanceof IRCChannelBase.ChannelClickListener) { listener.mouseClicked(event); break; diff --git a/tests/frontend/UserGUITests.java b/tests/frontend/UserGUITests.java index ec45170..961bbf3 100644 --- a/tests/frontend/UserGUITests.java +++ b/tests/frontend/UserGUITests.java @@ -13,13 +13,13 @@ public class UserGUITests { Preferences baseTestPreference; Preferences serverTestPreference; - Preferences roomTestPreference; + Preferences channelTestPreference; @BeforeClass public void setUp() throws Exception { baseTestPreference = Constants.BASE_PREFS.parent().node("testing"); serverTestPreference = baseTestPreference.node("servername"); - roomTestPreference = serverTestPreference.node("#channel"); + channelTestPreference = serverTestPreference.node("#channel"); } @AfterClass @@ -35,13 +35,13 @@ public void nodeExists() throws BackingStoreException { @Test public void nodeIsEmpty() throws BackingStoreException { - assertEquals(0, roomTestPreference.keys().length + roomTestPreference.childrenNames().length); + assertEquals(0, channelTestPreference.keys().length + channelTestPreference.childrenNames().length); } @Test public void nodeNotEmpty() throws BackingStoreException { - roomTestPreference.put("key","value"); - assertNotEquals(0, roomTestPreference.keys().length + roomTestPreference.childrenNames().length); + channelTestPreference.put("key","value"); + assertNotEquals(0, channelTestPreference.keys().length + channelTestPreference.childrenNames().length); } } \ No newline at end of file diff --git a/tests/utils/TestDriverGUI.java b/tests/utils/TestDriverGUI.java index 328c50c..2f8a5b0 100644 --- a/tests/utils/TestDriverGUI.java +++ b/tests/utils/TestDriverGUI.java @@ -13,7 +13,7 @@ import org.testng.Reporter; import urChatBasic.backend.utils.URProfilesUtil; import urChatBasic.base.Constants; -import urChatBasic.base.IRCRoomBase; +import urChatBasic.base.IRCChannelBase; import urChatBasic.base.IRCServerBase; import urChatBasic.frontend.DriverGUI; import urChatBasic.frontend.IRCServer; @@ -59,14 +59,14 @@ public static void waitForEverything (UserGUI gui) throws InterruptedException } for (IRCServerBase server : gui.getCreatedServers()) { - for (IRCRoomBase room : ((IRCServer) server).createdRooms) { - if(room.messageQueueInProgress) + for (IRCChannelBase channel : ((IRCServer) server).createdChannels) { + if(channel.messageQueueInProgress) { Reporter.log("Message Queue in Progress.. waiting", true); wait = true; break; } - if(room.getLineFormatter().updateStylesInProgress.get()) + if(channel.getLineFormatter().updateStylesInProgress.get()) { Reporter.log("Update styles in Progress.. waiting", true); wait = true;