Skip to content

Commit

Permalink
Merge pull request #97 from matty-r/milestone-v0.6.1
Browse files Browse the repository at this point in the history
Milestone v0.6.1
  • Loading branch information
matty-r authored Feb 2, 2024
2 parents a23f4bd + 68ccff8 commit 84a188a
Show file tree
Hide file tree
Showing 20 changed files with 196 additions and 200 deletions.
File renamed without changes
4 changes: 2 additions & 2 deletions src/urChatBasic/backend/MessageHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/urChatBasic/backend/logging/URLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/urChatBasic/base/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand All @@ -152,48 +152,48 @@ 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)
{
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
Expand All @@ -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);

Expand All @@ -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));
}

}
Expand All @@ -243,7 +243,7 @@ public void rejoin ()

public void setSettingsPath (Preferences settingsPath)
{
roomPrefs = settingsPath;
channelPrefs = settingsPath;
if(getFontPanel() != null)
{
getFontPanel().setSettingsPath(settingsPath);
Expand All @@ -253,7 +253,7 @@ public void setSettingsPath (Preferences settingsPath)

public Preferences getSettingsPath ()
{
return roomPrefs;
return channelPrefs;
}

public void createChannelPopUp()
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -590,7 +585,7 @@ public void run()
}

// Always alert on IRCPrivate messages
if (IRCRoomBase.this instanceof IRCPrivate)
if (IRCChannelBase.this instanceof IRCPrivate)
{
callForAttention();
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
//
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -1039,7 +1034,7 @@ public void actionPerformed(ActionEvent arg0)
}
}

public void closeRoom()
public void closeChannel ()
{
URProfilesUtil.removeListener(EventType.CHANGE, changeListener);
eventTickerTimer.stop();
Expand Down Expand Up @@ -1205,7 +1200,7 @@ public void actionPerformed(ActionEvent event)
{
public void run()
{
if (IRCRoomBase.this.tickerPanel.isVisible())
if (IRCChannelBase.this.tickerPanel.isVisible())
{
Iterator<JLabel> labelIterator = eventLabels.iterator();
while (labelIterator.hasNext())
Expand Down
27 changes: 11 additions & 16 deletions src/urChatBasic/base/IRCServerBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/urChatBasic/base/UserGUIBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading

0 comments on commit 84a188a

Please sign in to comment.