From 07534eb32d7a13d7709aed2a2051a9f54090e622 Mon Sep 17 00:00:00 2001 From: Exslims Date: Tue, 15 Aug 2017 21:09:33 +0400 Subject: [PATCH 01/17] Notification panel rework, added factories, panel providers, inc item panel, inc currency panel, notification frame --- .../interceptor/TradeMessagesInterceptor.java | 12 +- .../platform/shared/HistoryManager.java | 6 +- .../platform/shared/MessageParser.java | 110 ++++---- .../platform/shared/config/ConfigManager.java | 2 +- .../shared/config/MercuryConfigManager.java | 4 +- .../impl/FramesConfigurationServiceImpl.java | 4 +- .../NotificationConfigurationService.java | 38 +-- ...va => NotificationSettingsDescriptor.java} | 2 +- .../config/descriptor/ProfileDescriptor.java | 2 +- .../deserializer/MessageDeserializer.java | 6 +- ... CurrencyTradeNotificationDescriptor.java} | 2 +- ...a => ItemTradeNotificationDescriptor.java} | 2 +- .../message/NotificationDefinition.java | 9 + ...ssage.java => NotificationDescriptor.java} | 7 +- .../entity/message/NotificationType.java | 9 + .../message/TradeNotificationDescriptor.java | 13 + .../shared/store/MercuryStoreCore.java | 12 +- ... => NotificationDescriptorParserTest.java} | 18 +- .../AdrCaptureOutComponentFrame.java | 5 + .../ui/adr/components/AdrManagerFrame.java | 5 +- .../components/AdrSingleComponentFrame.java | 5 + .../adr/components/AdrTrackerGroupFrame.java | 5 + .../components/panel/AdrCaptureOutPanel.java | 2 +- .../adr/components/panel/AdrCapturePanel.java | 2 +- .../components/panel/AdrComponentPanel.java | 7 +- .../panel/AdrDurationCellPanel.java | 4 +- .../panel/AdrTrackerGroupPanel.java | 4 +- .../components/panel/tree/AdrNodePanel.java | 6 +- .../dialog/AdrDialogCaptureNodePanel.java | 2 +- .../tree/dialog/AdrDialogGroupNodePanel.java | 2 +- .../tree/dialog/AdrDialogIconNodePanel.java | 2 +- .../tree/dialog/AdrDialogPBNodePanel.java | 2 +- .../panel/tree/main/AdrCaptureNodePanel.java | 2 +- .../panel/tree/main/AdrGroupNodePanel.java | 2 +- .../panel/tree/main/AdrIconNodePanel.java | 2 +- .../tree/main/AdrProgressBarNodePanel.java | 2 +- .../ui/components/ComponentsFactory.java | 24 ++ .../panel/chat/ChatMessagePanel.java | 8 +- .../components/panel/grid/ItemInfoPanel.java | 14 +- .../grid/ItemInfoPanelControllerImpl.java | 6 +- .../components/panel/grid/ItemsGridPanel.java | 20 +- .../components/panel/grid/TabInfoPanel.java | 8 +- .../panel/message/MessagePanel.java | 16 -- .../panel/message/MessagePanelBuilder.java | 6 - .../panel/message/MessagePanelFactory.java | 5 - .../panel/message/MessagePanelProvider.java | 7 - .../components/panel/misc/AfterViewInit.java | 6 + .../ui/components/panel/misc/ViewDestroy.java | 6 + .../panel/misc/{HasUI.java => ViewInit.java} | 4 +- .../CurrencyIncNotificationPanel.java | 78 ++++++ .../HistoryMessagePanel.java | 2 +- .../InMessagePanel.java | 180 ++++++------ .../IncomingNotificationPanel.java | 256 ++++++++++++++++++ .../ItemIncNotificationPanel.java | 66 +++++ .../MessagePanelController.java | 6 +- .../MessagePanelStyle.java | 2 +- .../NotificationMessageController.java | 34 +-- .../panel/notification/NotificationPanel.java | 21 ++ .../OutMessagePanel.java | 2 +- .../factory/CurrencyIncPanelProvider.java | 30 ++ .../factory/ItemIncPanelProvider.java | 31 +++ .../factory/NotificationPanelFactory.java | 28 ++ .../factory/NotificationPanelProvider.java | 29 ++ .../panel/settings/ConfigurationPanel.java | 9 +- .../components/panel/settings/HelpPanel.java | 8 +- .../components/panel/settings/MenuPanel.java | 8 +- .../panel/settings/page/AboutPagePanel.java | 4 +- .../page/GeneralSettingsPagePanel.java | 9 +- .../page/NotificationSettingsPagePanel.java | 13 +- .../settings/page/SettingsPagePanel.java | 8 +- .../settings/page/SoundSettingsPagePanel.java | 6 +- .../panel/settings/page/SupportPagePanel.java | 2 +- .../page/TaskBarSettingsPagePanel.java | 6 +- .../taskbar/MercuryTaskBarController.java | 4 +- .../panel/taskbar/TaskBarPanel.java | 10 +- .../ui/frame/AbstractComponentFrame.java | 11 +- .../ui/frame/AbstractOverlaidFrame.java | 4 +- .../frame/AbstractScalableComponentFrame.java | 4 +- .../ui/frame/movable/CurrencySearchFrame.java | 2 +- .../ui/frame/movable/ItemsGridFrame.java | 21 +- .../ui/frame/movable/TaskBarFrame.java | 60 ++-- .../frame/movable/container/MessageFrame.java | 121 +++++---- .../movable/container/NotificationFrame.java | 100 +++++++ .../platform/ui/frame/other/AlertFrame.java | 3 + .../ui/frame/other/MercuryLoadingFrame.java | 52 ++-- ...Frame.java => NotificationAlertFrame.java} | 60 ++-- .../ui/frame/other/OutMessageFrame.java | 138 ---------- .../ui/frame/other/SetUpLocationFrame.java | 4 + .../ui/frame/other/SetUpScaleFrame.java | 6 +- .../platform/ui/frame/other/TooltipFrame.java | 12 +- .../ui/frame/other/UpdateReadyFrame.java | 4 +- .../titled/AbstractTitledComponentFrame.java | 2 +- .../ui/frame/titled/GamePathChooser.java | 3 +- .../platform/ui/frame/titled/NotesFrame.java | 16 +- .../ui/frame/titled/SettingsFrame.java | 5 + .../ui/frame/titled/TestCasesFrame.java | 21 +- .../platform/ui/frame/titled/TimerFrame.java | 5 + .../ui/frame/titled/chat/ChatFilterFrame.java | 5 +- .../titled/chat/ChatFilterSettingsFrame.java | 10 +- .../titled/container/HistoryContainer.java | 2 +- .../frame/titled/container/HistoryFrame.java | 28 +- .../platform/ui/manager/FramesManager.java | 7 +- .../platform/ui/misc/MercuryStoreUI.java | 12 +- 103 files changed, 1301 insertions(+), 718 deletions(-) rename app-core/src/main/java/com/mercury/platform/shared/config/descriptor/{NotificationDescriptor.java => NotificationSettingsDescriptor.java} (87%) rename app-core/src/main/java/com/mercury/platform/shared/entity/message/{CurrencyMessage.java => CurrencyTradeNotificationDescriptor.java} (72%) rename app-core/src/main/java/com/mercury/platform/shared/entity/message/{ItemMessage.java => ItemTradeNotificationDescriptor.java} (75%) create mode 100644 app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationDefinition.java rename app-core/src/main/java/com/mercury/platform/shared/entity/message/{Message.java => NotificationDescriptor.java} (60%) create mode 100644 app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationType.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/entity/message/TradeNotificationDescriptor.java rename app-core/src/test/java/com/mercury/platform/shared/{MessageParserTest.java => NotificationDescriptorParserTest.java} (61%) delete mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanel.java delete mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelBuilder.java delete mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelFactory.java delete mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelProvider.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/misc/AfterViewInit.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/misc/ViewDestroy.java rename app-ui/src/main/java/com/mercury/platform/ui/components/panel/misc/{HasUI.java => ViewInit.java} (53%) create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyIncNotificationPanel.java rename app-ui/src/main/java/com/mercury/platform/ui/components/panel/{message => notification}/HistoryMessagePanel.java (60%) rename app-ui/src/main/java/com/mercury/platform/ui/components/panel/{message => notification}/InMessagePanel.java (79%) create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemIncNotificationPanel.java rename app-ui/src/main/java/com/mercury/platform/ui/components/panel/{message => notification}/MessagePanelController.java (75%) rename app-ui/src/main/java/com/mercury/platform/ui/components/panel/{message => notification}/MessagePanelStyle.java (60%) rename app-ui/src/main/java/com/mercury/platform/ui/components/panel/{message => notification}/NotificationMessageController.java (56%) create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java rename app-ui/src/main/java/com/mercury/platform/ui/components/panel/{message => notification}/OutMessagePanel.java (59%) create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyIncPanelProvider.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemIncPanelProvider.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelFactory.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelProvider.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java rename app-ui/src/main/java/com/mercury/platform/ui/frame/other/{NotificationFrame.java => NotificationAlertFrame.java} (64%) delete mode 100644 app-ui/src/main/java/com/mercury/platform/ui/frame/other/OutMessageFrame.java diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeMessagesInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeMessagesInterceptor.java index 1cf4cb2d..bf8ea179 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeMessagesInterceptor.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeMessagesInterceptor.java @@ -5,8 +5,8 @@ import com.mercury.platform.shared.MessageParser; import com.mercury.platform.shared.config.Configuration; import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.descriptor.NotificationDescriptor; -import com.mercury.platform.shared.entity.message.Message; +import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; +import com.mercury.platform.shared.entity.message.NotificationDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; import org.apache.commons.lang3.StringUtils; @@ -15,7 +15,7 @@ public class TradeMessagesInterceptor extends MessageInterceptor { private MessageParser messageParser = new MessageParser(); - private PlainConfigurationService config; + private PlainConfigurationService config; private List clients = new ArrayList<>(); public TradeMessagesInterceptor() { @@ -32,10 +32,10 @@ protected void process(String message) { LocalizationMatcher localizationMatcher = this.clients.stream() .filter(matcher -> matcher.isSuitableFor(message)) .findAny().orElse(null); - Message parsedMessage = messageParser.parse(localizationMatcher.trimString(message)); - if (parsedMessage != null) { + NotificationDescriptor notificationDescriptor = messageParser.parse(localizationMatcher.trimString(message)); + if (notificationDescriptor != null) { MercuryStoreCore.soundSubject.onNext(SoundType.MESSAGE); - MercuryStoreCore.messageSubject.onNext(parsedMessage); + MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); } } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/HistoryManager.java b/app-core/src/main/java/com/mercury/platform/shared/HistoryManager.java index 08c0a117..75cbcea8 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/HistoryManager.java +++ b/app-core/src/main/java/com/mercury/platform/shared/HistoryManager.java @@ -1,6 +1,6 @@ package com.mercury.platform.shared; -import com.mercury.platform.shared.entity.message.Message; +import com.mercury.platform.shared.entity.message.NotificationDescriptor; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.json.simple.JSONArray; @@ -60,12 +60,12 @@ private void createEmptyFile(){ logger.error("Error during creating history file: ", e); } } - public void add(Message message){ + public void add(NotificationDescriptor notificationDescriptor){ JSONParser parser = new JSONParser(); try { JSONObject root = (JSONObject)parser.parse(new FileReader(HISTORY_FILE)); JSONArray msgsArray = (JSONArray) root.get("messages"); - msgsArray.add(0,message.getSourceString()); + msgsArray.add(0, notificationDescriptor.getSourceString()); root.replace("messages",msgsArray); FileWriter fileWriter = new FileWriter(HISTORY_FILE); fileWriter.write(root.toJSONString()); diff --git a/app-core/src/main/java/com/mercury/platform/shared/MessageParser.java b/app-core/src/main/java/com/mercury/platform/shared/MessageParser.java index 13949b14..039954a0 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/MessageParser.java +++ b/app-core/src/main/java/com/mercury/platform/shared/MessageParser.java @@ -1,9 +1,9 @@ package com.mercury.platform.shared; -import com.mercury.platform.shared.entity.message.CurrencyMessage; -import com.mercury.platform.shared.entity.message.ItemMessage; -import com.mercury.platform.shared.entity.message.Message; -import org.apache.commons.lang3.StringUtils; +import com.mercury.platform.shared.entity.message.CurrencyTradeNotificationDescriptor; +import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationType; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -24,77 +24,81 @@ public MessageParser() { this.poeTradeCurrencyPattern = Pattern.compile(poeCurrencyPattern); } - public Message parse(String fullMessage){ + public NotificationDescriptor parse(String fullMessage){ Matcher poeAppItemMatcher = poeAppItemPattern.matcher(fullMessage); if(poeAppItemMatcher.find()){ - ItemMessage message = new ItemMessage(); - message.setSourceString(fullMessage); - message.setWhisperNickname(poeAppItemMatcher.group(2)); - message.setItemName(poeAppItemMatcher.group(3)); + ItemTradeNotificationDescriptor tradeNotification = new ItemTradeNotificationDescriptor(); + tradeNotification.setSourceString(fullMessage); + tradeNotification.setWhisperNickname(poeAppItemMatcher.group(2)); + tradeNotification.setItemName(poeAppItemMatcher.group(3)); if(poeAppItemMatcher.group(5) != null) { - message.setCurCount(Double.parseDouble(poeAppItemMatcher.group(5))); - message.setCurrency(poeAppItemMatcher.group(6)); + tradeNotification.setCurCount(Double.parseDouble(poeAppItemMatcher.group(5))); + tradeNotification.setCurrency(poeAppItemMatcher.group(6)); }else { - message.setCurCount(0d); - message.setCurrency("???"); + tradeNotification.setCurCount(0d); + tradeNotification.setCurrency("???"); } - message.setLeague(poeAppItemMatcher.group(7)); + tradeNotification.setLeague(poeAppItemMatcher.group(7)); if(poeAppItemMatcher.group(8) != null) { - message.setTabName(poeAppItemMatcher.group(8)); - message.setLeft(Integer.parseInt(poeAppItemMatcher.group(9))); - message.setTop(Integer.parseInt(poeAppItemMatcher.group(10))); + tradeNotification.setTabName(poeAppItemMatcher.group(8)); + tradeNotification.setLeft(Integer.parseInt(poeAppItemMatcher.group(9))); + tradeNotification.setTop(Integer.parseInt(poeAppItemMatcher.group(10))); } - message.setOffer(poeAppItemMatcher.group(11)); - return message; + tradeNotification.setOffer(poeAppItemMatcher.group(11)); + tradeNotification.setType(NotificationType.INC_ITEM_MESSAGE); + return tradeNotification; } Matcher poeTradeStashItemMatcher = poeTradeStashItemPattern.matcher(fullMessage); if(poeTradeStashItemMatcher.find()){ - ItemMessage message = new ItemMessage(); - message.setSourceString(fullMessage); - message.setWhisperNickname(poeTradeStashItemMatcher.group(2)); - message.setItemName(poeTradeStashItemMatcher.group(3)); + ItemTradeNotificationDescriptor tradeNotification = new ItemTradeNotificationDescriptor(); + tradeNotification.setSourceString(fullMessage); + tradeNotification.setWhisperNickname(poeTradeStashItemMatcher.group(2)); + tradeNotification.setItemName(poeTradeStashItemMatcher.group(3)); if(poeTradeStashItemMatcher.group(4) != null){ - message.setCurCount(Double.parseDouble(poeTradeStashItemMatcher.group(5))); - message.setCurrency(poeTradeStashItemMatcher.group(6)); + tradeNotification.setCurCount(Double.parseDouble(poeTradeStashItemMatcher.group(5))); + tradeNotification.setCurrency(poeTradeStashItemMatcher.group(6)); }else { - message.setCurCount(0d); - message.setCurrency("???"); + tradeNotification.setCurCount(0d); + tradeNotification.setCurrency("???"); } - message.setLeague(poeTradeStashItemMatcher.group(7)); - message.setTabName(poeTradeStashItemMatcher.group(8)); - message.setLeft(Integer.parseInt(poeTradeStashItemMatcher.group(9))); - message.setTop(Integer.parseInt(poeTradeStashItemMatcher.group(10))); - message.setOffer(poeTradeStashItemMatcher.group(11)); - return message; + tradeNotification.setLeague(poeTradeStashItemMatcher.group(7)); + tradeNotification.setTabName(poeTradeStashItemMatcher.group(8)); + tradeNotification.setLeft(Integer.parseInt(poeTradeStashItemMatcher.group(9))); + tradeNotification.setTop(Integer.parseInt(poeTradeStashItemMatcher.group(10))); + tradeNotification.setOffer(poeTradeStashItemMatcher.group(11)); + tradeNotification.setType(NotificationType.INC_ITEM_MESSAGE); + return tradeNotification; } Matcher poeTradeCurrencyMatcher = poeTradeCurrencyPattern.matcher(fullMessage); if(poeTradeCurrencyMatcher.find()){ - CurrencyMessage message = new CurrencyMessage(); - message.setSourceString(fullMessage); - message.setWhisperNickname(poeTradeCurrencyMatcher.group(2)); - message.setCurrForSaleCount(Double.parseDouble(poeTradeCurrencyMatcher.group(3))); - message.setCurrForSaleTitle(poeTradeCurrencyMatcher.group(5)); - message.setCurCount(Double.parseDouble(poeTradeCurrencyMatcher.group(6))); - message.setCurrency(poeTradeCurrencyMatcher.group(8)); - message.setLeague(poeTradeCurrencyMatcher.group(9)); - message.setOffer(poeTradeCurrencyMatcher.group(10)); - return message; + CurrencyTradeNotificationDescriptor tradeNotification = new CurrencyTradeNotificationDescriptor(); + tradeNotification.setSourceString(fullMessage); + tradeNotification.setWhisperNickname(poeTradeCurrencyMatcher.group(2)); + tradeNotification.setCurrForSaleCount(Double.parseDouble(poeTradeCurrencyMatcher.group(3))); + tradeNotification.setCurrForSaleTitle(poeTradeCurrencyMatcher.group(5)); + tradeNotification.setCurCount(Double.parseDouble(poeTradeCurrencyMatcher.group(6))); + tradeNotification.setCurrency(poeTradeCurrencyMatcher.group(8)); + tradeNotification.setLeague(poeTradeCurrencyMatcher.group(9)); + tradeNotification.setOffer(poeTradeCurrencyMatcher.group(10)); + tradeNotification.setType(NotificationType.INC_CURRENCY_MESSAGE); + return tradeNotification; } Matcher poeTradeItemMatcher = poeTradeItemPattern.matcher(fullMessage); if(poeTradeItemMatcher.find()){ - ItemMessage message = new ItemMessage(); - message.setSourceString(fullMessage); - message.setWhisperNickname(poeTradeItemMatcher.group(2)); - message.setItemName(poeTradeItemMatcher.group(3)); + ItemTradeNotificationDescriptor tradeNotification = new ItemTradeNotificationDescriptor(); + tradeNotification.setSourceString(fullMessage); + tradeNotification.setWhisperNickname(poeTradeItemMatcher.group(2)); + tradeNotification.setItemName(poeTradeItemMatcher.group(3)); if(poeTradeItemMatcher.group(4) != null){ - message.setCurCount(Double.parseDouble(poeTradeItemMatcher.group(5))); - message.setCurrency(poeTradeItemMatcher.group(6)); + tradeNotification.setCurCount(Double.parseDouble(poeTradeItemMatcher.group(5))); + tradeNotification.setCurrency(poeTradeItemMatcher.group(6)); }else { - message.setCurCount(0d); - message.setCurrency("???"); + tradeNotification.setCurCount(0d); + tradeNotification.setCurrency("???"); } - message.setLeague(poeTradeItemMatcher.group(7)); - return message; + tradeNotification.setLeague(poeTradeItemMatcher.group(7)); + tradeNotification.setType(NotificationType.INC_ITEM_MESSAGE); + return tradeNotification; } return null; } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/ConfigManager.java b/app-core/src/main/java/com/mercury/platform/shared/config/ConfigManager.java index 1448fde5..0d5e8d12 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/ConfigManager.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/ConfigManager.java @@ -11,7 +11,7 @@ public interface ConfigManager { FramesConfigurationService framesConfiguration(); PlainConfigurationService applicationConfiguration(); - PlainConfigurationService notificationConfiguration(); + PlainConfigurationService notificationConfiguration(); PlainConfigurationService scannerConfiguration(); KeyValueConfigurationService soundConfiguration(); KeyValueConfigurationService scaleConfiguration(); diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/MercuryConfigManager.java b/app-core/src/main/java/com/mercury/platform/shared/config/MercuryConfigManager.java index e4f0c33e..00cd264e 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/MercuryConfigManager.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/MercuryConfigManager.java @@ -30,7 +30,7 @@ public class MercuryConfigManager implements ConfigManager, AsSubscriber { private ProfileDescriptor selectedProfile; private FramesConfigurationService framesConfigurationService; private PlainConfigurationService applicationConfigurationService; - private PlainConfigurationService notificationConfigurationService; + private PlainConfigurationService notificationConfigurationService; private PlainConfigurationService scannerConfigurationService; private KeyValueConfigurationService soundConfigurationService; private KeyValueConfigurationService scaleConfigurationService; @@ -57,7 +57,7 @@ public PlainConfigurationService applicationConfiguration } @Override - public PlainConfigurationService notificationConfiguration() { + public PlainConfigurationService notificationConfiguration() { return this.notificationConfigurationService; } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/FramesConfigurationServiceImpl.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/FramesConfigurationServiceImpl.java index 2264a062..f06dd294 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/FramesConfigurationServiceImpl.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/FramesConfigurationServiceImpl.java @@ -62,7 +62,7 @@ public Dimension getMinimumSize(String frameClass) { private void initMinimumMap() { minimumFrameSize.put("TaskBarFrame",new Dimension(109,20)); - minimumFrameSize.put("MessageFrame",new Dimension(360,10)); + minimumFrameSize.put("NotificationFrame",new Dimension(360,10)); minimumFrameSize.put("OutMessageFrame",new Dimension(280,115)); minimumFrameSize.put("TestCasesFrame",new Dimension(400,100)); minimumFrameSize.put("SettingsFrame",new Dimension(600,400)); @@ -79,7 +79,7 @@ private void initMinimumMap() { } private void initDefaultMap() { defaultFramesSettings.put("TaskBarFrame", new FrameDescriptor(new Point(400, 500), new Dimension(109, 20))); - defaultFramesSettings.put("MessageFrame", new FrameDescriptor(new Point(700, 600), new Dimension(315, 0))); + defaultFramesSettings.put("NotificationFrame", new FrameDescriptor(new Point(700, 600), new Dimension(315, 0))); defaultFramesSettings.put("OutMessageFrame", new FrameDescriptor(new Point(200, 500), new Dimension(280, 115))); defaultFramesSettings.put("TestCasesFrame", new FrameDescriptor(new Point(1400, 500), new Dimension(400, 100))); defaultFramesSettings.put("SettingsFrame", new FrameDescriptor(new Point(600, 600), new Dimension(800,600))); diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java index 112c9370..1c17f7c9 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java @@ -3,7 +3,7 @@ import com.mercury.platform.shared.config.configration.BaseConfigurationService; import com.mercury.platform.shared.config.configration.PlainConfigurationService; import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; -import com.mercury.platform.shared.config.descriptor.NotificationDescriptor; +import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; import com.mercury.platform.shared.config.descriptor.ProfileDescriptor; import com.mercury.platform.shared.config.descriptor.ResponseButtonDescriptor; import com.mercury.platform.shared.entity.message.FlowDirections; @@ -12,38 +12,38 @@ import java.util.List; -public class NotificationConfigurationService extends BaseConfigurationService implements PlainConfigurationService { +public class NotificationConfigurationService extends BaseConfigurationService implements PlainConfigurationService { public NotificationConfigurationService(ProfileDescriptor selectedProfile) { super(selectedProfile); } @Override - public NotificationDescriptor getDefault() { - NotificationDescriptor notificationDescriptor = new NotificationDescriptor(); + public NotificationSettingsDescriptor getDefault() { + NotificationSettingsDescriptor notificationSettingsDescriptor = new NotificationSettingsDescriptor(); List defaultButtons = new ArrayList<>(); defaultButtons.add(new ResponseButtonDescriptor(0,false,"1m","one minute", new HotKeyDescriptor())); defaultButtons.add(new ResponseButtonDescriptor(1,true,"thx","thanks",new HotKeyDescriptor())); defaultButtons.add(new ResponseButtonDescriptor(2,false,"no thx", "no thanks",new HotKeyDescriptor())); defaultButtons.add(new ResponseButtonDescriptor(3,false,"sold", "sold",new HotKeyDescriptor())); - notificationDescriptor.setButtons(defaultButtons); - notificationDescriptor.setNotificationEnable(true); - notificationDescriptor.setLimitCount(3); - notificationDescriptor.setUnfoldCount(2); - notificationDescriptor.setDismissAfterKick(true); - notificationDescriptor.setShowLeague(false); - notificationDescriptor.setFlowDirections(FlowDirections.DOWNWARDS); - return notificationDescriptor; + notificationSettingsDescriptor.setButtons(defaultButtons); + notificationSettingsDescriptor.setNotificationEnable(true); + notificationSettingsDescriptor.setLimitCount(3); + notificationSettingsDescriptor.setUnfoldCount(2); + notificationSettingsDescriptor.setDismissAfterKick(true); + notificationSettingsDescriptor.setShowLeague(false); + notificationSettingsDescriptor.setFlowDirections(FlowDirections.DOWNWARDS); + return notificationSettingsDescriptor; } @Override public void toDefault() { - this.selectedProfile.setNotificationDescriptor(this.getDefault()); + this.selectedProfile.setNotificationSettingsDescriptor(this.getDefault()); } @Override public void validate() { - if(this.selectedProfile.getNotificationDescriptor() == null) { - this.selectedProfile.setNotificationDescriptor(this.getDefault()); + if(this.selectedProfile.getNotificationSettingsDescriptor() == null) { + this.selectedProfile.setNotificationSettingsDescriptor(this.getDefault()); } this.get().getButtons().forEach(it -> { if(it.getHotKeyDescriptor() == null) { @@ -53,12 +53,12 @@ public void validate() { } @Override - public NotificationDescriptor get() { - return this.selectedProfile.getNotificationDescriptor(); + public NotificationSettingsDescriptor get() { + return this.selectedProfile.getNotificationSettingsDescriptor(); } @Override - public void set(NotificationDescriptor descriptor) { - this.selectedProfile.setNotificationDescriptor(descriptor); + public void set(NotificationSettingsDescriptor descriptor) { + this.selectedProfile.setNotificationSettingsDescriptor(descriptor); } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationSettingsDescriptor.java similarity index 87% rename from app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationDescriptor.java rename to app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationSettingsDescriptor.java index bfe78403..962c7632 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationSettingsDescriptor.java @@ -7,7 +7,7 @@ import java.util.List; @Data -public class NotificationDescriptor implements Serializable{ +public class NotificationSettingsDescriptor implements Serializable{ private boolean notificationEnable; private int limitCount; private int unfoldCount; diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ProfileDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ProfileDescriptor.java index 94a5ec5a..d71e3f86 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ProfileDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ProfileDescriptor.java @@ -13,7 +13,7 @@ public class ProfileDescriptor { private Map frameDescriptorMap; private Map soundDescriptorMap; private ApplicationDescriptor applicationDescriptor; - private NotificationDescriptor notificationDescriptor; + private NotificationSettingsDescriptor notificationSettingsDescriptor; private ScannerDescriptor scannerDescriptor; private Map scaleDataMap; private Map hotKeysDataMap; diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/json/deserializer/MessageDeserializer.java b/app-core/src/main/java/com/mercury/platform/shared/config/json/deserializer/MessageDeserializer.java index a117b4ab..24cdff64 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/json/deserializer/MessageDeserializer.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/json/deserializer/MessageDeserializer.java @@ -5,13 +5,13 @@ import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; import com.google.gson.JsonParseException; -import com.mercury.platform.shared.entity.message.Message; +import com.mercury.platform.shared.entity.message.NotificationDescriptor; import java.lang.reflect.Type; -public class MessageDeserializer implements JsonDeserializer{ +public class MessageDeserializer implements JsonDeserializer{ @Override - public Message deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { + public NotificationDescriptor deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { return null; } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/entity/message/CurrencyMessage.java b/app-core/src/main/java/com/mercury/platform/shared/entity/message/CurrencyTradeNotificationDescriptor.java similarity index 72% rename from app-core/src/main/java/com/mercury/platform/shared/entity/message/CurrencyMessage.java rename to app-core/src/main/java/com/mercury/platform/shared/entity/message/CurrencyTradeNotificationDescriptor.java index 18a38a7b..9e8af2b8 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/entity/message/CurrencyMessage.java +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/message/CurrencyTradeNotificationDescriptor.java @@ -5,7 +5,7 @@ @EqualsAndHashCode(callSuper = true) @Data -public class CurrencyMessage extends Message { +public class CurrencyTradeNotificationDescriptor extends TradeNotificationDescriptor { private Double currForSaleCount; private String currForSaleTitle; } diff --git a/app-core/src/main/java/com/mercury/platform/shared/entity/message/ItemMessage.java b/app-core/src/main/java/com/mercury/platform/shared/entity/message/ItemTradeNotificationDescriptor.java similarity index 75% rename from app-core/src/main/java/com/mercury/platform/shared/entity/message/ItemMessage.java rename to app-core/src/main/java/com/mercury/platform/shared/entity/message/ItemTradeNotificationDescriptor.java index 9879ce13..92a10c58 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/entity/message/ItemMessage.java +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/message/ItemTradeNotificationDescriptor.java @@ -5,7 +5,7 @@ @EqualsAndHashCode(callSuper = true) @Data -public class ItemMessage extends Message { +public class ItemTradeNotificationDescriptor extends TradeNotificationDescriptor { private String itemName; private String tabName; private int left; diff --git a/app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationDefinition.java b/app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationDefinition.java new file mode 100644 index 00000000..cf71400a --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationDefinition.java @@ -0,0 +1,9 @@ +package com.mercury.platform.shared.entity.message; + +import lombok.Data; + +@Data +public class NotificationDefinition { + private T payload; + private NotificationType type; +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/entity/message/Message.java b/app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationDescriptor.java similarity index 60% rename from app-core/src/main/java/com/mercury/platform/shared/entity/message/Message.java rename to app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationDescriptor.java index 1214cff9..e842b226 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/entity/message/Message.java +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationDescriptor.java @@ -5,12 +5,9 @@ import java.util.Date; @Data -public class Message { +public class NotificationDescriptor { private String sourceString; private Date messageDate; private String whisperNickname; - private String offer; - private Double curCount; - private String currency; - private String league; + private NotificationType type; } diff --git a/app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationType.java b/app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationType.java new file mode 100644 index 00000000..c2e6fa01 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationType.java @@ -0,0 +1,9 @@ +package com.mercury.platform.shared.entity.message; + + +public enum NotificationType { + INC_ITEM_MESSAGE, + INC_CURRENCY_MESSAGE, + OUTGOING_MESSAGE, + SCANNER_MESSAGE +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/entity/message/TradeNotificationDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/entity/message/TradeNotificationDescriptor.java new file mode 100644 index 00000000..55b93682 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/message/TradeNotificationDescriptor.java @@ -0,0 +1,13 @@ +package com.mercury.platform.shared.entity.message; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Data +public class TradeNotificationDescriptor extends NotificationDescriptor { + private String offer; + private Double curCount; + private String currency; + private String league; +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java index f2861114..94871df0 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java +++ b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java @@ -7,8 +7,9 @@ import com.mercury.platform.shared.config.descriptor.ProfileDescriptor; import com.mercury.platform.shared.config.descriptor.adr.AdrVisibleState; import com.mercury.platform.shared.entity.message.MercuryError; -import com.mercury.platform.shared.entity.message.Message; +import com.mercury.platform.shared.entity.message.NotificationDescriptor; import com.mercury.platform.shared.config.descriptor.SoundDescriptor; +import com.mercury.platform.shared.entity.message.NotificationDefinition; import rx.subjects.PublishSubject; @@ -22,8 +23,8 @@ public class MercuryStoreCore { public static final PublishSubject removeInterceptorSubject = PublishSubject.create(); public static final PublishSubject chatCommandSubject = PublishSubject.create(); public static final PublishSubject openChatSubject = PublishSubject.create(); - public static final PublishSubject messageSubject = PublishSubject.create(); - public static final PublishSubject outMessageSubject = PublishSubject.create(); + public static final PublishSubject messageSubject = PublishSubject.create(); + public static final PublishSubject outMessageSubject = PublishSubject.create(); public static final PublishSubject appLoadingSubject = PublishSubject.create(); public static final PublishSubject showingDelaySubject = PublishSubject.create(); public static final PublishSubject stringAlertSubject = PublishSubject.create(); @@ -32,7 +33,7 @@ public class MercuryStoreCore { public static final PublishSubject chunkLoadedSubject = PublishSubject.create(); public static final PublishSubject buttonsChangedSubject = PublishSubject.create(); public static final PublishSubject tooltipSubject = PublishSubject.create(); - public static final PublishSubject notificationSubject = PublishSubject.create(); + public static final PublishSubject alertSubject = PublishSubject.create(); public static final PublishSubject playerJoinSubject = PublishSubject.create(); public static final PublishSubject playerLeftSubject = PublishSubject.create(); public static final PublishSubject requestPatchSubject = PublishSubject.create(); @@ -48,4 +49,7 @@ public class MercuryStoreCore { public static final PublishSubject hotKeySubject = PublishSubject.create(); public static final PublishSubject errorHandlerSubject = PublishSubject.create(); public static final PublishSubject adrVisibleSubject = PublishSubject.create(); + + public static final PublishSubject newNotificationSubject = PublishSubject.create(); + public static final PublishSubject removeNotificationSubject = PublishSubject.create(); } diff --git a/app-core/src/test/java/com/mercury/platform/shared/MessageParserTest.java b/app-core/src/test/java/com/mercury/platform/shared/NotificationDescriptorParserTest.java similarity index 61% rename from app-core/src/test/java/com/mercury/platform/shared/MessageParserTest.java rename to app-core/src/test/java/com/mercury/platform/shared/NotificationDescriptorParserTest.java index d042512d..f3b9c2d4 100644 --- a/app-core/src/test/java/com/mercury/platform/shared/MessageParserTest.java +++ b/app-core/src/test/java/com/mercury/platform/shared/NotificationDescriptorParserTest.java @@ -1,7 +1,7 @@ package com.mercury.platform.shared; -import com.mercury.platform.shared.entity.message.CurrencyMessage; -import com.mercury.platform.shared.entity.message.ItemMessage; +import com.mercury.platform.shared.entity.message.CurrencyTradeNotificationDescriptor; +import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; import org.junit.Before; import org.junit.Test; @@ -10,7 +10,7 @@ /** * Created by Константин on 11.01.2017. */ -public class MessageParserTest { +public class NotificationDescriptorParserTest { private MessageParser parser; @Before public void before(){ @@ -19,14 +19,14 @@ public void before(){ @Test public void testPoeTrade() throws Exception{ - ItemMessage message1 = (ItemMessage) parser.parse("@From Pubesmannen: Hi, I would like to buy your Bronn's Lithe Cutthroat's Garb listed for 1 alteration in Hardcore Legacy (stash tab \"Maps\"; position: left 5, top 6)"); + ItemTradeNotificationDescriptor message1 = (ItemTradeNotificationDescriptor) parser.parse("@From Pubesmannen: Hi, I would like to buy your Bronn's Lithe Cutthroat's Garb listed for 1 alteration in Hardcore Legacy (stash tab \"Maps\"; position: left 5, top 6)"); assertEquals(message1.getWhisperNickname(),"Pubesmannen"); assertEquals(message1.getItemName(),"Bronn's Lithe Cutthroat's Garb"); assertEquals(message1.getCurrency(),"alteration"); assertEquals(message1.getCurCount(),new Double(1)); assertEquals(message1.getOffer(),""); - ItemMessage message2 = (ItemMessage) parser.parse("@From Pubesmannen: Hi, I would like to buy your Bronn's Lithe Cutthroat's Garb listed for 15 exalt in Legacy (stash tab \"Maps\"; position: left 5, top 6) offer 32"); + ItemTradeNotificationDescriptor message2 = (ItemTradeNotificationDescriptor) parser.parse("@From Pubesmannen: Hi, I would like to buy your Bronn's Lithe Cutthroat's Garb listed for 15 exalt in Legacy (stash tab \"Maps\"; position: left 5, top 6) offer 32"); assertEquals(message2.getWhisperNickname(),"Pubesmannen"); assertEquals(message2.getItemName(),"Bronn's Lithe Cutthroat's Garb"); assertEquals(message2.getCurrency(),"exalt"); @@ -36,7 +36,7 @@ public void testPoeTrade() throws Exception{ } @Test public void testPoeTradeNoBuyout() throws Exception{ - ItemMessage message1 = (ItemMessage) parser.parse("@From Pubesmannen: Hi, I would like to buy your level 1 4% Reduced Mana Support in Hardcore Legacy (stash tab \"qgems\"; position: left 12, top 4)"); + ItemTradeNotificationDescriptor message1 = (ItemTradeNotificationDescriptor) parser.parse("@From Pubesmannen: Hi, I would like to buy your level 1 4% Reduced Mana Support in Hardcore Legacy (stash tab \"qgems\"; position: left 12, top 4)"); assertEquals(message1.getWhisperNickname(),"Pubesmannen"); assertEquals(message1.getItemName(),"level 1 4% Reduced Mana Support"); assertEquals(message1.getCurCount(),new Double(0d)); @@ -44,7 +44,7 @@ public void testPoeTradeNoBuyout() throws Exception{ assertEquals(message1.getOffer(),""); assertEquals(message1.getLeague(),"Hardcore Legacy"); - ItemMessage message2 = (ItemMessage) parser.parse("@From Pubesmannen: Hi, I would like to buy your level 1 4% Reduced Mana Support in Hardcore (stash tab \"qgems\"; position: left 12, top 4)"); + ItemTradeNotificationDescriptor message2 = (ItemTradeNotificationDescriptor) parser.parse("@From Pubesmannen: Hi, I would like to buy your level 1 4% Reduced Mana Support in Hardcore (stash tab \"qgems\"; position: left 12, top 4)"); assertEquals(message2.getWhisperNickname(),"Pubesmannen"); assertEquals(message2.getItemName(),"level 1 4% Reduced Mana Support"); assertEquals(message2.getCurCount(),new Double(0d)); @@ -55,7 +55,7 @@ public void testPoeTradeNoBuyout() throws Exception{ @Test public void testPoeCurrency() throws Exception{ - CurrencyMessage message1 = (CurrencyMessage) parser.parse("@From tradeeer: Hi, I'd like to buy your 366 chaos for my 5 exalted in Legacy."); + CurrencyTradeNotificationDescriptor message1 = (CurrencyTradeNotificationDescriptor) parser.parse("@From tradeeer: Hi, I'd like to buy your 366 chaos for my 5 exalted in Legacy."); assertEquals(message1.getWhisperNickname(),"tradeeer"); assertEquals(message1.getCurrForSaleCount(),new Double(366)); assertEquals(message1.getCurrForSaleTitle(),"chaos"); @@ -63,7 +63,7 @@ public void testPoeCurrency() throws Exception{ assertEquals(message1.getCurCount(),new Double(5)); assertEquals(message1.getOffer(),""); - CurrencyMessage message2 = (CurrencyMessage) parser.parse("@From tradeeer: Hi, I'd like to buy your 366 chaos for my 5 exalted in Legacy. 123"); + CurrencyTradeNotificationDescriptor message2 = (CurrencyTradeNotificationDescriptor) parser.parse("@From tradeeer: Hi, I'd like to buy your 366 chaos for my 5 exalted in Legacy. 123"); assertEquals(message2.getWhisperNickname(),"tradeeer"); assertEquals(message2.getCurrForSaleCount(),new Double(366)); assertEquals(message2.getCurrForSaleTitle(),"chaos"); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrCaptureOutComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrCaptureOutComponentFrame.java index a3059786..eabad999 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrCaptureOutComponentFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrCaptureOutComponentFrame.java @@ -101,6 +101,11 @@ public void onDestroy() { this.component.onDestroy(); } + @Override + public void onViewInit() { + + } + public class CaptureDraggedFrameMotionListener extends MouseAdapter { @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrManagerFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrManagerFrame.java index f13e4983..d66db814 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrManagerFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrManagerFrame.java @@ -61,10 +61,8 @@ public AdrManagerFrame(AdrProfileDescriptor selectedProfile) { UIManager.put("ComboBox.selectionForeground", AppThemeColor.ADR_POPUP_BG); UIManager.put("ComboBox.disabledForeground", AppThemeColor.ADR_FOOTER_BG); } - @Override - protected void initialize() { - super.initialize(); + public void onViewInit() { this.initRootPanel(); this.hideButton.addMouseListener(new MouseAdapter() { @Override @@ -77,7 +75,6 @@ public void mousePressed(MouseEvent e) { }); this.add(this.root,BorderLayout.CENTER); this.add(this.getBottomPanel(),BorderLayout.PAGE_END); - } public void setPage(AdrPagePanel page){ if(currentPage != null){ diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrSingleComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrSingleComponentFrame.java index 12113523..1aa7edbf 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrSingleComponentFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrSingleComponentFrame.java @@ -71,4 +71,9 @@ public void onDestroy() { this.adrReloadSubscription.unsubscribe(); this.component.onDestroy(); } + + @Override + public void onViewInit() { + + } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrTrackerGroupFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrTrackerGroupFrame.java index fa9e734b..9a9c898a 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrTrackerGroupFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrTrackerGroupFrame.java @@ -72,4 +72,9 @@ public void onDestroy() { this.adrReloadSubscription.unsubscribe(); this.trackerGroupPanel.onDestroy(); } + + @Override + public void onViewInit() { + + } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrCaptureOutPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrCaptureOutPanel.java index b5bf0b61..e9e3f0be 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrCaptureOutPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrCaptureOutPanel.java @@ -15,7 +15,7 @@ public AdrCaptureOutPanel(AdrCaptureDescriptor descriptor, ComponentsFactory com } @Override - public void createUI() { + public void onViewInit() { this.setLayout(new GridLayout(1,1)); this.setPreferredSize(this.descriptor.getCaptureSize()); this.setBackground(AppThemeColor.ADR_CAPTURE_BG); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrCapturePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrCapturePanel.java index 318b4aa8..84397092 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrCapturePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrCapturePanel.java @@ -21,7 +21,7 @@ public AdrCapturePanel(AdrCaptureDescriptor groupDescriptor, ComponentsFactory c } @Override - public void createUI() { + public void onViewInit() { this.setLayout(new GridLayout(1,1)); this.setPreferredSize(this.descriptor.getSize()); this.captureLabel = new JLabel(); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrComponentPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrComponentPanel.java index 6b9a0107..c940342a 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrComponentPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrComponentPanel.java @@ -3,9 +3,8 @@ import com.mercury.platform.shared.AsSubscriber; import com.mercury.platform.shared.config.descriptor.adr.AdrComponentDescriptor; import com.mercury.platform.shared.store.DestroySubscription; -import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.ComponentsFactory; -import com.mercury.platform.ui.components.panel.misc.HasUI; +import com.mercury.platform.ui.components.panel.misc.ViewInit; import com.mercury.platform.ui.misc.MercuryStoreUI; import lombok.Getter; import rx.Subscription; @@ -13,7 +12,7 @@ import javax.swing.*; -public abstract class AdrComponentPanel extends JPanel implements HasUI,AsSubscriber,DestroySubscription { +public abstract class AdrComponentPanel extends JPanel implements ViewInit,AsSubscriber,DestroySubscription { @Getter protected T descriptor; protected ComponentsFactory componentsFactory; @@ -25,7 +24,7 @@ public AdrComponentPanel(T descriptor, ComponentsFactory componentsFactory) { this.descriptor = descriptor; this.componentsFactory = componentsFactory; this.subscribe(); - this.createUI(); + this.onViewInit(); } @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrDurationCellPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrDurationCellPanel.java index d291a0c4..73949db7 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrDurationCellPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrDurationCellPanel.java @@ -70,11 +70,11 @@ protected void onHotKeyPressed() { @Override protected void onUpdate() { this.remove(this.tracker); - this.createUI(); + this.onViewInit(); } @Override - public void createUI() { + public void onViewInit() { this.setLayout(new GridLayout(1,1)); this.setPreferredSize(this.descriptor.getSize()); this.tracker = new MercuryTracker(this.descriptor); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrTrackerGroupPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrTrackerGroupPanel.java index 05995cfa..bfaab406 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrTrackerGroupPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrTrackerGroupPanel.java @@ -33,7 +33,7 @@ public void subscribe() { .collect(Collectors.toList()) .size() != this.descriptor.getCells().size()){ this.removeAll(); - this.createUI(); + this.onViewInit(); MercuryStoreCore.saveConfigSubject.onNext(true); } MercuryStoreUI.adrRepaintSubject.onNext(true); @@ -68,7 +68,7 @@ private void init(){ } @Override - public void createUI() { + public void onViewInit() { this.cells = new ArrayList<>(); this.setLayout(new GridLayout()); this.descriptor.getCells().forEach(component -> { diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/AdrNodePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/AdrNodePanel.java index 5f739479..9dcb6567 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/AdrNodePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/AdrNodePanel.java @@ -4,7 +4,7 @@ import com.mercury.platform.ui.adr.components.AdrComponentsFactory; import com.mercury.platform.ui.adr.components.panel.tree.model.AdrTreeNode; import com.mercury.platform.ui.components.ComponentsFactory; -import com.mercury.platform.ui.components.panel.misc.HasUI; +import com.mercury.platform.ui.components.panel.misc.ViewInit; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.MercuryStoreUI; import lombok.Getter; @@ -13,7 +13,7 @@ import java.awt.*; -public abstract class AdrNodePanel extends JPanel implements HasUI { +public abstract class AdrNodePanel extends JPanel implements ViewInit { @Getter protected D descriptor; protected ComponentsFactory componentsFactory = new ComponentsFactory(); @@ -34,7 +34,7 @@ public AdrNodePanel(AdrTreeNode treeNode) { this.setLayout(new BorderLayout()); this.setBackground(AppThemeColor.SLIDE_BG); this.setBorder(BorderFactory.createLineBorder(AppThemeColor.MSG_HEADER_BORDER)); - this.createUI(); + this.onViewInit(); } protected abstract void update(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogCaptureNodePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogCaptureNodePanel.java index cfbc5874..b2ffe1f6 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogCaptureNodePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogCaptureNodePanel.java @@ -19,7 +19,7 @@ public AdrDialogCaptureNodePanel(AdrTreeNode treeNode) { } @Override - public void createUI() { + public void onViewInit() { JPanel root = this.componentsFactory.getJPanel(new BorderLayout()); root.setPreferredSize(new Dimension(180, 30)); root.setBackground(AppThemeColor.ADR_BG); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogGroupNodePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogGroupNodePanel.java index 0a1b7a6b..062682d9 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogGroupNodePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogGroupNodePanel.java @@ -30,7 +30,7 @@ protected void update() { } @Override - public void createUI() { + public void onViewInit() { this.container = this.componentsFactory.getJPanel(new GridLayout(descriptor.getCells().size(), 1)); this.container.setVisible(false); this.add(this.container,BorderLayout.CENTER); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogIconNodePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogIconNodePanel.java index 9c954f5a..35af0b69 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogIconNodePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogIconNodePanel.java @@ -26,7 +26,7 @@ protected void update() { } @Override - public void createUI() { + public void onViewInit() { JPanel root = this.componentsFactory.getJPanel(new BorderLayout()); root.setBackground(AppThemeColor.ADR_BG); MercuryTracker tracker = new MercuryTracker(this.descriptor); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogPBNodePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogPBNodePanel.java index 98a2d8ad..63b36ec6 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogPBNodePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogPBNodePanel.java @@ -24,7 +24,7 @@ protected void update() { } @Override - public void createUI() { + public void onViewInit() { JPanel root = this.componentsFactory.getJPanel(new FlowLayout(FlowLayout.CENTER)); root.setBackground(AppThemeColor.SLIDE_BG); MercuryTracker tracker = new MercuryTracker(descriptor); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrCaptureNodePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrCaptureNodePanel.java index 745256a7..755b27ac 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrCaptureNodePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrCaptureNodePanel.java @@ -18,7 +18,7 @@ public AdrCaptureNodePanel(AdrTreeNode treeNode) { } @Override - public void createUI() { + public void onViewInit() { JPanel root = this.componentsFactory.getJPanel(new BorderLayout()); root.setBackground(AppThemeColor.ADR_BG); this.titleLabel = this.componentsFactory.getTextLabel(this.descriptor.getTitle()); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrGroupNodePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrGroupNodePanel.java index 89cab97f..67f3f5ed 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrGroupNodePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrGroupNodePanel.java @@ -33,7 +33,7 @@ protected void update() { @Override - public void createUI() { + public void onViewInit() { MercuryStoreUI.adrSelectSubject.subscribe(descriptor -> { if(this.descriptor.equals(descriptor)){ this.container.setVisible(true); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrIconNodePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrIconNodePanel.java index 3324fd4f..3dc41cad 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrIconNodePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrIconNodePanel.java @@ -30,7 +30,7 @@ protected void update() { } @Override - public void createUI() { + public void onViewInit() { JPanel root = this.componentsFactory.getJPanel(new BorderLayout()); root.setBackground(AppThemeColor.ADR_BG); this.tracker = new MercuryTracker(this.descriptor); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrProgressBarNodePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrProgressBarNodePanel.java index 67205cff..f92ca889 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrProgressBarNodePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrProgressBarNodePanel.java @@ -31,7 +31,7 @@ protected void update() { } @Override - public void createUI() { + public void onViewInit() { JPanel root = this.componentsFactory.getJPanel(new FlowLayout(FlowLayout.CENTER)); root.setBackground(AppThemeColor.SLIDE_BG); this.tracker = new MercuryTracker(descriptor); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java b/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java index 5ee670bb..aab7f33f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java @@ -102,6 +102,15 @@ public void mousePressed(MouseEvent e) { MercuryStoreCore.soundSubject.onNext(SoundType.CLICKS); } } + @Override + public void mouseEntered(MouseEvent e) { + button.setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + + @Override + public void mouseExited(MouseEvent e) { + button.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + } }); if(isAscii(text)){ button.setFont(getSelectedFont(fontStyle).deriveFont(scale*fontSize)); @@ -193,6 +202,7 @@ protected void paintBorder(Graphics g) { if(tooltip.length() > 0) { button.addMouseListener(new TooltipMouseListener(tooltip)); } + button.setBorder(BorderFactory.createEmptyBorder(4,4,4,4)); button.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { @@ -200,6 +210,20 @@ public void mousePressed(MouseEvent e) { MercuryStoreCore.soundSubject.onNext(SoundType.CLICKS); } } + @Override + public void mouseEntered(MouseEvent e) { + button.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(AppThemeColor.ADR_SELECTED_BORDER), + BorderFactory.createEmptyBorder(3,3,3,3))); + button.setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + + @Override + public void mouseExited(MouseEvent e) { + button.setBorder(BorderFactory.createEmptyBorder(4,4,4,4)); + button.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + } + }); button.setBorder(BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,4)); button.setVerticalAlignment(SwingConstants.CENTER); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/chat/ChatMessagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/chat/ChatMessagePanel.java index 74482008..fde831a0 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/chat/ChatMessagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/chat/ChatMessagePanel.java @@ -7,7 +7,7 @@ import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.components.panel.misc.HasUI; +import com.mercury.platform.ui.components.panel.misc.ViewInit; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.TooltipConstants; import lombok.NonNull; @@ -18,7 +18,7 @@ import java.awt.event.MouseEvent; -public class ChatMessagePanel extends JPanel implements HasUI{ +public class ChatMessagePanel extends JPanel implements ViewInit { private ComponentsFactory componentsFactory; private PlainConfigurationService scannerService; private String message; @@ -37,11 +37,11 @@ public ChatMessagePanel( this.componentsFactory = componentsFactory; this.setBorder(BorderFactory.createEmptyBorder(2,2,2,2)); this.setBackground(AppThemeColor.TRANSPARENT); - createUI(); + onViewInit(); } @Override - public void createUI() { + public void onViewInit() { JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); root.setBorder(BorderFactory.createMatteBorder(1,1,1,1,AppThemeColor.HEADER)); root.setBackground(AppThemeColor.SLIDE_BG); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/ItemInfoPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/ItemInfoPanel.java index 3a826025..1ca355c3 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/ItemInfoPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/ItemInfoPanel.java @@ -4,9 +4,9 @@ import com.mercury.platform.ui.frame.movable.ItemsGridFrame; import com.mercury.platform.ui.misc.MercuryStoreUI; import com.mercury.platform.ui.misc.TooltipConstants; -import com.mercury.platform.shared.entity.message.ItemMessage; +import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; import com.mercury.platform.ui.components.ComponentsFactory; -import com.mercury.platform.ui.components.panel.misc.HasUI; +import com.mercury.platform.ui.components.panel.misc.ViewInit; import com.mercury.platform.ui.misc.AppThemeColor; import javax.swing.*; @@ -14,9 +14,9 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -public class ItemInfoPanel extends JPanel implements HasUI{ +public class ItemInfoPanel extends JPanel implements ViewInit { private ComponentsFactory componentsFactory; - private ItemMessage message; + private ItemTradeNotificationDescriptor message; private JPanel cell; private StashTabDescriptor stashTabDescriptor; private ItemCell itemCell; @@ -24,7 +24,7 @@ public class ItemInfoPanel extends JPanel implements HasUI{ private ItemInfoPanelController controller; - public ItemInfoPanel(ItemMessage message, ItemCell itemCell, StashTabDescriptor stashTabDescriptor, ComponentsFactory factory){ + public ItemInfoPanel(ItemTradeNotificationDescriptor message, ItemCell itemCell, StashTabDescriptor stashTabDescriptor, ComponentsFactory factory){ this.componentsFactory = factory; this.controller = new ItemInfoPanelControllerImpl(message); this.message = message; @@ -32,11 +32,11 @@ public ItemInfoPanel(ItemMessage message, ItemCell itemCell, StashTabDescriptor this.itemCell = itemCell; this.stashTabDescriptor = stashTabDescriptor; setupMouseOverListener(); - createUI(); + onViewInit(); } @Override - public void createUI() { + public void onViewInit() { this.setLayout(new BorderLayout()); this.setBackground(AppThemeColor.FRAME); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/ItemInfoPanelControllerImpl.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/ItemInfoPanelControllerImpl.java index 8b71528b..bf0ad91b 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/ItemInfoPanelControllerImpl.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/ItemInfoPanelControllerImpl.java @@ -1,13 +1,13 @@ package com.mercury.platform.ui.components.panel.grid; -import com.mercury.platform.shared.entity.message.ItemMessage; +import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; import com.mercury.platform.ui.misc.MercuryStoreUI; import lombok.NonNull; public class ItemInfoPanelControllerImpl implements ItemInfoPanelController { - private ItemMessage message; - public ItemInfoPanelControllerImpl(@NonNull ItemMessage message) { + private ItemTradeNotificationDescriptor message; + public ItemInfoPanelControllerImpl(@NonNull ItemTradeNotificationDescriptor message) { this.message = message; } @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/ItemsGridPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/ItemsGridPanel.java index 592d8592..066d9346 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/ItemsGridPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/ItemsGridPanel.java @@ -1,9 +1,9 @@ package com.mercury.platform.ui.components.panel.grid; -import com.mercury.platform.shared.entity.message.ItemMessage; +import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; import com.mercury.platform.shared.config.descriptor.StashTabDescriptor; import com.mercury.platform.ui.components.ComponentsFactory; -import com.mercury.platform.ui.components.panel.misc.HasUI; +import com.mercury.platform.ui.components.panel.misc.ViewInit; import com.mercury.platform.ui.frame.movable.ItemsGridFrame; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.MercuryStoreUI; @@ -17,7 +17,7 @@ import java.util.List; -public class ItemsGridPanel extends JPanel implements HasUI { +public class ItemsGridPanel extends JPanel implements ViewInit { private ComponentsFactory componentsFactory; private List defaultCells; private List quadCells; @@ -35,7 +35,7 @@ public ItemsGridPanel() { quadCells = new ArrayList<>(); tabButtons = new HashMap<>(); stashTabsContainer = new StashTabsContainer(); - createUI(); + onViewInit(); } public ItemsGridPanel(@NonNull ComponentsFactory factory){ super(new BorderLayout()); @@ -44,11 +44,11 @@ public ItemsGridPanel(@NonNull ComponentsFactory factory){ quadCells = new ArrayList<>(); tabButtons = new HashMap<>(); stashTabsContainer = new StashTabsContainer(); - createUI(); + onViewInit(); } @Override - public void createUI() { + public void onViewInit() { this.setBackground(AppThemeColor.TRANSPARENT); this.setBorder(null); @@ -85,7 +85,7 @@ public void createUI() { this.setPreferredSize(this.getMaximumSize()); } - public void add(@NonNull ItemMessage message, ItemInfoPanelController controller){ + public void add(@NonNull ItemTradeNotificationDescriptor message, ItemInfoPanelController controller){ String nickname = message.getWhisperNickname(); if (!tabButtons.containsKey(nickname + message.getTabName())) { int x = message.getLeft(); @@ -108,7 +108,7 @@ public void add(@NonNull ItemMessage message, ItemInfoPanelController controller } } } - public void remove(@NonNull ItemMessage message){ + public void remove(@NonNull ItemTradeNotificationDescriptor message){ closeGridItem(message); } public void changeTabType(@NonNull ItemInfoPanel itemInfoPanel){ @@ -157,7 +157,7 @@ private Optional getCellByCoordinates(@NonNull StashTabDescriptor tab, return targetCell; } - private ItemInfoPanel createGridItem(@NonNull ItemMessage message, @NonNull ItemCell cell, @NonNull StashTabDescriptor stashTabDescriptor){ + private ItemInfoPanel createGridItem(@NonNull ItemTradeNotificationDescriptor message, @NonNull ItemCell cell, @NonNull StashTabDescriptor stashTabDescriptor){ ItemInfoPanel itemInfoPanel = new ItemInfoPanel(message,cell, stashTabDescriptor,componentsFactory); itemInfoPanel.setAlignmentY(SwingConstants.CENTER); itemInfoPanel.addMouseListener(new MouseAdapter() { @@ -175,7 +175,7 @@ public void mouseEntered(MouseEvent e) { }); return itemInfoPanel; } - private void closeGridItem(@NonNull ItemMessage message) { + private void closeGridItem(@NonNull ItemTradeNotificationDescriptor message) { String nickname = message.getWhisperNickname(); ItemInfoPanel itemInfoPanel = tabButtons.get(nickname + message.getTabName()); if (itemInfoPanel != null) { diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/TabInfoPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/TabInfoPanel.java index 9ab6c8f5..adc2d9dd 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/TabInfoPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/TabInfoPanel.java @@ -3,7 +3,7 @@ import com.mercury.platform.shared.config.descriptor.StashTabDescriptor; import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.fields.font.FontStyle; -import com.mercury.platform.ui.components.panel.misc.HasUI; +import com.mercury.platform.ui.components.panel.misc.ViewInit; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.MercuryStoreUI; import lombok.NonNull; @@ -11,18 +11,18 @@ import javax.swing.*; import java.awt.*; -public class TabInfoPanel extends JPanel implements HasUI{ +public class TabInfoPanel extends JPanel implements ViewInit { private ComponentsFactory componentsFactory; private StashTabDescriptor stashTabDescriptor; public TabInfoPanel(@NonNull StashTabDescriptor stashTabDescriptor, @NonNull ComponentsFactory componentsFactory) { this.stashTabDescriptor = stashTabDescriptor; this.componentsFactory = componentsFactory; - createUI(); + onViewInit(); } @Override - public void createUI() { + public void onViewInit() { this.setLayout(new BorderLayout()); this.setBackground(AppThemeColor.FRAME); JButton hideButton = componentsFactory.getIconButton("app/close.png", 12, AppThemeColor.FRAME_ALPHA, "Dismiss"); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanel.java deleted file mode 100644 index b44f42bd..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanel.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.mercury.platform.ui.components.panel.message; - - -import com.mercury.platform.shared.AsSubscriber; -import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.descriptor.NotificationDescriptor; -import com.mercury.platform.ui.components.ComponentsFactory; -import com.mercury.platform.ui.components.panel.misc.HasUI; -import com.mercury.platform.ui.misc.HasHotkey; - -import javax.swing.*; - -public abstract class MessagePanel extends JPanel implements AsSubscriber, HasUI { - protected ComponentsFactory componentsFactory; - protected PlainConfigurationService notificationService; -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelBuilder.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelBuilder.java deleted file mode 100644 index da5a667f..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelBuilder.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.mercury.platform.ui.components.panel.message; - - -public class MessagePanelBuilder { - private MessagePanelStyle style; -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelFactory.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelFactory.java deleted file mode 100644 index 36c0bb5b..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelFactory.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.mercury.platform.ui.components.panel.message; - - -public class MessagePanelFactory { -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelProvider.java deleted file mode 100644 index ed7d2e26..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelProvider.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.mercury.platform.ui.components.panel.message; - - -public interface MessagePanelProvider { - boolean isSuitable(MessagePanelStyle style); - -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/misc/AfterViewInit.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/misc/AfterViewInit.java new file mode 100644 index 00000000..0029b586 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/misc/AfterViewInit.java @@ -0,0 +1,6 @@ +package com.mercury.platform.ui.components.panel.misc; + + +public interface AfterViewInit { + void onAfterViewInit(); +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/misc/ViewDestroy.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/misc/ViewDestroy.java new file mode 100644 index 00000000..99eaf061 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/misc/ViewDestroy.java @@ -0,0 +1,6 @@ +package com.mercury.platform.ui.components.panel.misc; + + +public interface ViewDestroy { + void onViewDestroy(); +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/misc/HasUI.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/misc/ViewInit.java similarity index 53% rename from app-ui/src/main/java/com/mercury/platform/ui/components/panel/misc/HasUI.java rename to app-ui/src/main/java/com/mercury/platform/ui/components/panel/misc/ViewInit.java index 32c09db1..00194f41 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/misc/HasUI.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/misc/ViewInit.java @@ -1,5 +1,5 @@ package com.mercury.platform.ui.components.panel.misc; -public interface HasUI { - void createUI(); +public interface ViewInit { + void onViewInit(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyIncNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyIncNotificationPanel.java new file mode 100644 index 00000000..f0e3c37f --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyIncNotificationPanel.java @@ -0,0 +1,78 @@ +package com.mercury.platform.ui.components.panel.notification; + +import com.mercury.platform.shared.entity.message.CurrencyTradeNotificationDescriptor; +import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.components.fields.font.TextAlignment; +import com.mercury.platform.ui.frame.movable.container.MessageFrame; +import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.MercuryStoreUI; +import com.mercury.platform.ui.misc.TooltipConstants; + +import javax.swing.*; +import javax.swing.border.CompoundBorder; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.text.DecimalFormat; + + +public class CurrencyIncNotificationPanel extends IncomingNotificationPanel { + @Override + protected JPanel getMessagePanel() { + JPanel labelsPanel = this.componentsFactory.getJPanel(new BorderLayout(),AppThemeColor.FRAME); + JPanel tradePanel = this.componentsFactory.getJPanel(new BorderLayout(),AppThemeColor.FRAME); + + tradePanel.add(this.getFromPanel(),BorderLayout.CENTER); + tradePanel.add(this.getForPanel(),BorderLayout.LINE_END); + labelsPanel.add(tradePanel,BorderLayout.CENTER); + JLabel offerLabel = this.getOfferLabel(); + if(offerLabel != null) { + labelsPanel.add(offerLabel, BorderLayout.PAGE_END); + } + return labelsPanel; + } + private JPanel getFromPanel(){ + JPanel fromPanel = this.componentsFactory.getJPanel(new FlowLayout(FlowLayout.LEFT,5,0),AppThemeColor.FRAME); + fromPanel.add(this.getCurrencyPanel(this.data.getCurrForSaleCount(),this.data.getCurrForSaleTitle())); + fromPanel.add(getCurrencyRatePanel()); + return fromPanel; + } + + private JPanel getCurrencyRatePanel(){ + Double currForSaleCount = this.data.getCurrForSaleCount(); + Double curCount = this.data.getCurCount(); + double rate = curCount / currForSaleCount; + DecimalFormat decimalFormat = new DecimalFormat("#.####"); + JPanel ratePanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); + ratePanel.add(componentsFactory. + getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 18f, null,"(")); + JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + this.data.getCurrency() + ".png", 26); + currencyLabel.setBorder(null); + ratePanel.add(currencyLabel); + ratePanel.add(componentsFactory. + getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 18f, null,decimalFormat.format(rate))); + ratePanel.add(componentsFactory. + getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 18f, null,")")); + ratePanel.setBorder(BorderFactory.createEmptyBorder(-5,0,-5,0)); + return ratePanel; + } + + @Override + protected JButton getStillInterestedButton() { + JButton stillIntButton = componentsFactory.getIconButton("app/still-interesting.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.STILL_INTERESTED); + stillIntButton.addActionListener(action -> { + String curCount = this.data.getCurCount() % 1 == 0 ? + String.valueOf(this.data.getCurCount().intValue()) : + String.valueOf(this.data.getCurCount()); + String responseText = "Hi, are you still interested in "; + String curForSaleCount = this.data.getCurCount() % 1 == 0 ? + String.valueOf(this.data.getCurrForSaleCount().intValue()) : + String.valueOf(this.data.getCurrForSaleCount()); + responseText += curForSaleCount + " " + this.data.getCurrForSaleTitle() + " for " + + curCount + " " + this.data.getCurrency() + "?"; + this.controller.performResponse(responseText); + }); + return stillIntButton; + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/HistoryMessagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/HistoryMessagePanel.java similarity index 60% rename from app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/HistoryMessagePanel.java rename to app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/HistoryMessagePanel.java index 845a610b..2dd9e901 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/HistoryMessagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/HistoryMessagePanel.java @@ -1,4 +1,4 @@ -package com.mercury.platform.ui.components.panel.message; +package com.mercury.platform.ui.components.panel.notification; /** * Created by Константин on 10.08.2017. diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/InMessagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/InMessagePanel.java similarity index 79% rename from app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/InMessagePanel.java rename to app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/InMessagePanel.java index bc018b19..298018db 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/InMessagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/InMessagePanel.java @@ -1,4 +1,4 @@ -package com.mercury.platform.ui.components.panel.message; +package com.mercury.platform.ui.components.panel.notification; import com.mercury.platform.shared.AsSubscriber; import com.mercury.platform.shared.config.Configuration; @@ -6,16 +6,16 @@ import com.mercury.platform.shared.config.configration.PlainConfigurationService; import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; import com.mercury.platform.shared.config.descriptor.HotKeyType; -import com.mercury.platform.shared.config.descriptor.NotificationDescriptor; -import com.mercury.platform.shared.entity.message.CurrencyMessage; -import com.mercury.platform.shared.entity.message.ItemMessage; -import com.mercury.platform.shared.entity.message.Message; +import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; +import com.mercury.platform.shared.entity.message.CurrencyTradeNotificationDescriptor; +import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationDescriptor; import com.mercury.platform.shared.config.descriptor.ResponseButtonDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.components.panel.misc.HasUI; +import com.mercury.platform.ui.components.panel.misc.ViewInit; import com.mercury.platform.ui.frame.movable.container.MessageFrame; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.HasHotkey; @@ -40,11 +40,11 @@ import java.util.List; -public class InMessagePanel extends JPanel implements AsSubscriber, HasUI,HasHotkey{ +public class InMessagePanel extends JPanel implements AsSubscriber, ViewInit,HasHotkey{ private static final Logger logger = LogManager.getLogger(InMessagePanel.class.getSimpleName()); private ComponentsFactory componentsFactory; - private PlainConfigurationService notificationService; + private PlainConfigurationService notificationService; private MessagePanelController controller; private MessagePanelStyle style; @@ -54,7 +54,7 @@ public class InMessagePanel extends JPanel implements AsSubscriber, HasUI,HasHot private JButton expandButton; @Getter - private Message message; + private NotificationDescriptor notificationDescriptor; private Timer timeAgo; private String cachedTime = "0m"; @@ -66,25 +66,25 @@ public class InMessagePanel extends JPanel implements AsSubscriber, HasUI,HasHot private boolean expanded = false; - private InMessagePanel(Message message, MessagePanelStyle style) { + private InMessagePanel(NotificationDescriptor notificationDescriptor, MessagePanelStyle style) { super(new BorderLayout()); - this.message = message; + this.notificationDescriptor = notificationDescriptor; this.style = style; - this.whisper = message.getWhisperNickname(); + this.whisper = notificationDescriptor.getWhisperNickname(); this.notificationService = Configuration.get().notificationConfiguration(); if(!style.equals(MessagePanelStyle.HISTORY)) { this.initHotKeyListeners(); } } - public InMessagePanel(Message message, MessagePanelStyle style, MessagePanelController controller, ComponentsFactory componentsFactory){ - this(message,style); + public InMessagePanel(NotificationDescriptor notificationDescriptor, MessagePanelStyle style, MessagePanelController controller, ComponentsFactory componentsFactory){ + this(notificationDescriptor,style); this.componentsFactory = componentsFactory; this.controller = controller; - createUI(); + onViewInit(); } @Override - public void createUI() { + public void onViewInit() { this.setBackground(AppThemeColor.FRAME); this.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,1), @@ -144,12 +144,12 @@ private JPanel getFormattedMessagePanel(){ JPanel tradePanel = new JPanel(new BorderLayout()); tradePanel.setBackground(AppThemeColor.TRANSPARENT); tradePanel.setBorder(BorderFactory.createEmptyBorder(-11,2,-11,0)); - if(message instanceof ItemMessage) { + if(notificationDescriptor instanceof ItemTradeNotificationDescriptor) { JButton itemButton = componentsFactory.getButton( FontStyle.BOLD, AppThemeColor.BUTTON, BorderFactory.createEmptyBorder(0,4,0,2), - ((ItemMessage) message).getItemName(), 17f); + ((ItemTradeNotificationDescriptor) notificationDescriptor).getItemName(), 17f); itemButton.setForeground(AppThemeColor.TEXT_IMPORTANT); itemButton.setBackground(AppThemeColor.TRANSPARENT); @@ -182,10 +182,10 @@ public void mouseExited(MouseEvent e) { } }); tradePanel.add(itemButton,BorderLayout.CENTER); - }else if(message instanceof CurrencyMessage){ + }else if(notificationDescriptor instanceof CurrencyTradeNotificationDescriptor){ JPanel fromPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); fromPanel.setBackground(AppThemeColor.TRANSPARENT); - CurrencyMessage message = (CurrencyMessage) this.message; + CurrencyTradeNotificationDescriptor message = (CurrencyTradeNotificationDescriptor) this.notificationDescriptor; String curCount = message.getCurrForSaleCount() % 1 == 0 ? String.valueOf(message.getCurrForSaleCount().intValue()) : @@ -212,30 +212,30 @@ public void mouseExited(MouseEvent e) { "=>"); separator.setHorizontalAlignment(SwingConstants.CENTER); String curCount = " "; - if(message.getCurCount() > 0) { - curCount = message.getCurCount() % 1 == 0 ? - String.valueOf(message.getCurCount().intValue()) : - String.valueOf(message.getCurCount()); - } - String currency = message.getCurrency(); - if(!Objects.equals(curCount, "") && currency != null) { - JPanel curCountPanel = getCurrencyPanel(curCount); - JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + currency + ".png", 26); - JPanel curPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); - curPanel.setBackground(AppThemeColor.TRANSPARENT); - curPanel.add(separator); - curPanel.add(curCountPanel); - curPanel.add(currencyLabel); - forPanel.add(curPanel); - } - tradePanel.add(forPanel,BorderLayout.LINE_END); - labelsPanel.add(tradePanel); - String offer = message.getOffer(); - if(offer != null && offer.trim().length() > 0) { - JLabel offerLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 17f, offer); - offerLabel.setAlignmentY(Component.TOP_ALIGNMENT); - labelsPanel.add(offerLabel); - } +// if(notificationDescriptor.getCurCount() > 0) { +// curCount = notificationDescriptor.getCurCount() % 1 == 0 ? +// String.valueOf(notificationDescriptor.getCurCount().intValue()) : +// String.valueOf(notificationDescriptor.getCurCount()); +// } +// String currency = notificationDescriptor.getCurrency(); +// if(!Objects.equals(curCount, "") && currency != null) { +// JPanel curCountPanel = getCurrencyPanel(curCount); +// JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + currency + ".png", 26); +// JPanel curPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); +// curPanel.setBackground(AppThemeColor.TRANSPARENT); +// curPanel.add(separator); +// curPanel.add(curCountPanel); +// curPanel.add(currencyLabel); +// forPanel.add(curPanel); +// } +// tradePanel.add(forPanel,BorderLayout.LINE_END); +// labelsPanel.add(tradePanel); +// String offer = notificationDescriptor.getOffer(); +// if(offer != null && offer.trim().length() > 0) { +// JLabel offerLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 17f, offer); +// offerLabel.setAlignmentY(Component.TOP_ALIGNMENT); +// labelsPanel.add(offerLabel); +// } return labelsPanel; } private JPanel getCurrencyPanel(String curCount){ @@ -248,7 +248,7 @@ private JPanel getCurrencyPanel(String curCount){ return curCountPanel; } private JPanel getCurrencyRatePanel(){ - CurrencyMessage message = (CurrencyMessage) this.message; + CurrencyTradeNotificationDescriptor message = (CurrencyTradeNotificationDescriptor) this.notificationDescriptor; Double currForSaleCount = message.getCurrForSaleCount(); Double curCount = message.getCurCount(); double rate = curCount / currForSaleCount; @@ -336,27 +336,27 @@ public void mousePressed(MouseEvent e) { return topPanel; } private String getNicknameLabel(){ - String whisperNickname = message.getWhisperNickname(); + String whisperNickname = notificationDescriptor.getWhisperNickname(); String result = whisperNickname + ":"; - if(this.notificationService.get().isShowLeague()) { - if (message.getLeague() != null) { - String league = message.getLeague().trim(); - if (league.length() == 0) { - return result; - } - if (league.contains("Hardcore")) { - if (league.equals("Hardcore")) { - result = "HC " + result; - } else { - result = String.valueOf(league.split(" ")[1].charAt(0)) + "HC " + result; - } - } else if (league.contains("Standard")) { - result = "Standard " + result; - } else { - result = String.valueOf(league.charAt(0)) + "SC " + result; - } - } - } +// if(this.notificationService.get().isShowLeague()) { +// if (notificationDescriptor.getLeague() != null) { +// String league = notificationDescriptor.getLeague().trim(); +// if (league.length() == 0) { +// return result; +// } +// if (league.contains("Hardcore")) { +// if (league.equals("Hardcore")) { +// result = "HC " + result; +// } else { +// result = String.valueOf(league.split(" ")[1].charAt(0)) + "HC " + result; +// } +// } else if (league.contains("Standard")) { +// result = "Standard " + result; +// } else { +// result = String.valueOf(league.charAt(0)) + "SC " + result; +// } +// } +// } return result; } private JPanel getTimePanel(){ @@ -526,31 +526,31 @@ private void initResponseButtons(JPanel panel){ } private JButton getStillInterestedButton(){ JButton stillIntButton = componentsFactory.getIconButton("app/still-interesting.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.STILL_INTERESTED); - - String curCount = message.getCurCount() % 1 == 0 ? - String.valueOf(message.getCurCount().intValue()) : - String.valueOf(message.getCurCount()); - String responseText = "Hi, are you still interested in "; - if(message instanceof ItemMessage){ - ItemMessage message = (ItemMessage) this.message; - if(message.getCurrency().equals("???")){ - responseText += message.getItemName() + "?"; - }else { - responseText += message.getItemName() + - " for " + curCount + " " + message.getCurrency() + "?"; - } - }else { - CurrencyMessage message = (CurrencyMessage) this.message; - String curForSaleCount = message.getCurCount() % 1 == 0 ? - String.valueOf(message.getCurrForSaleCount().intValue()) : - String.valueOf(message.getCurrForSaleCount()); - responseText += curForSaleCount + " " + message.getCurrForSaleTitle() + " for " + - curCount + " " + message.getCurrency() + "?"; - } - String finalResponseText = responseText; // hate java - stillIntButton.addActionListener( - (action)->controller.performResponse(finalResponseText) - ); +// +// String curCount = notificationDescriptor.getCurCount() % 1 == 0 ? +// String.valueOf(notificationDescriptor.getCurCount().intValue()) : +// String.valueOf(notificationDescriptor.getCurCount()); +// String responseText = "Hi, are you still interested in "; +// if(notificationDescriptor instanceof ItemTradeNotificationDescriptor){ +// ItemTradeNotificationDescriptor message = (ItemTradeNotificationDescriptor) this.notificationDescriptor; +// if(message.getCurrency().equals("???")){ +// responseText += message.getItemName() + "?"; +// }else { +// responseText += message.getItemName() + +// " for " + curCount + " " + message.getCurrency() + "?"; +// } +// }else { +// CurrencyTradeNotificationDescriptor message = (CurrencyTradeNotificationDescriptor) this.notificationDescriptor; +// String curForSaleCount = message.getCurCount() % 1 == 0 ? +// String.valueOf(message.getCurrForSaleCount().intValue()) : +// String.valueOf(message.getCurrForSaleCount()); +// responseText += curForSaleCount + " " + message.getCurrForSaleTitle() + " for " + +// curCount + " " + message.getCurrency() + "?"; +// } +// String finalResponseText = responseText; // hate java +// stillIntButton.addActionListener( +// (action)->controller.performResponse(finalResponseText) +// ); return stillIntButton; } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java new file mode 100644 index 00000000..59b8c93f --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java @@ -0,0 +1,256 @@ +package com.mercury.platform.ui.components.panel.notification; + + +import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.configration.PlainConfigurationService; +import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; +import com.mercury.platform.shared.config.descriptor.ResponseButtonDescriptor; +import com.mercury.platform.shared.entity.message.TradeNotificationDescriptor; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.components.fields.font.TextAlignment; +import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.TooltipConstants; + +import javax.swing.*; +import javax.swing.Timer; +import javax.swing.border.CompoundBorder; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.*; +import java.util.List; + +public abstract class IncomingNotificationPanel extends NotificationPanel{ + private PlainConfigurationService config; + @Override + public void onViewInit() { + this.config = Configuration.get().notificationConfiguration(); + this.setLayout(new BorderLayout()); + this.setBackground(AppThemeColor.FRAME); + this.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createEmptyBorder(1,1,1,1), + BorderFactory.createLineBorder(AppThemeColor.BORDER, 1))); + + this.add(this.getHeader(),BorderLayout.PAGE_START); + this.add(this.getMessagePanel(),BorderLayout.CENTER); + this.add(this.getResponseButtonsPanel(),BorderLayout.PAGE_END); + } + private JPanel getHeader(){ + JPanel root = new JPanel(new BorderLayout()); + root.setBackground(AppThemeColor.MSG_HEADER); + + JLabel nicknameLabel = this.componentsFactory.getTextLabel(FontStyle.BOLD,AppThemeColor.TEXT_NICKNAME, TextAlignment.LEFTOP,15f,this.getNicknameText()); + nicknameLabel.setBorder(BorderFactory.createEmptyBorder(0,5,0,5)); + + root.add(this.getExpandButton(),BorderLayout.LINE_START); + root.add(nicknameLabel,BorderLayout.CENTER); + + JPanel interactionPanel = new JPanel(new GridLayout(1,0)); + interactionPanel.setPreferredSize(new Dimension(220, 16)); + interactionPanel.setBackground(AppThemeColor.MSG_HEADER); + JButton inviteButton = componentsFactory.getIconButton("app/invite.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.INVITE); + inviteButton.addActionListener(e -> this.controller.performInvite()); + JButton kickButton = componentsFactory.getIconButton("app/kick.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.KICK); + kickButton.addActionListener(e -> { + this.controller.performKick(); + if(this.config.get().isDismissAfterKick()){ + this.controller.performHide(); + } + }); + JButton tradeButton = componentsFactory.getIconButton("app/trade.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.TRADE); + tradeButton.addActionListener(e -> this.controller.performOfferTrade()); + JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); + openChatButton.addActionListener(e -> controller.performOpenChat()); + JButton hideButton = componentsFactory.getIconButton("app/close.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.HIDE_PANEL); + hideButton.addActionListener(action -> { + this.controller.performHide(); + }); + interactionPanel.add(this.getTimePanel()); + interactionPanel.add(inviteButton); + interactionPanel.add(kickButton); + interactionPanel.add(tradeButton); + interactionPanel.add(getStillInterestedButton()); + interactionPanel.add(openChatButton); + interactionPanel.add(hideButton); + + root.add(interactionPanel,BorderLayout.LINE_END); + return root; + } + @Override + public void subscribe() { + + } + + @Override + public void onViewDestroy() { + + } + protected JPanel getForPanel(){ + JPanel forPanel = new JPanel(new BorderLayout()); + forPanel.setPreferredSize(new Dimension(110,36)); + forPanel.setBackground(AppThemeColor.FRAME); + JLabel separator = componentsFactory.getTextLabel( + FontStyle.BOLD, + AppThemeColor.TEXT_MESSAGE, + TextAlignment.CENTER, + 18f, + "=>"); + forPanel.add(separator,BorderLayout.CENTER); + separator.setHorizontalAlignment(SwingConstants.CENTER); + JPanel currencyPanel = this.getCurrencyPanel(this.data.getCurCount(),this.data.getCurrency()); + if(currencyPanel != null) { + forPanel.add(currencyPanel, BorderLayout.LINE_END); + } + return forPanel; + } + protected JPanel getCurrencyPanel(Double curCount, String curIconPath){ + String curCountStr = " "; + if(curCount > 0) { + curCountStr = curCount % 1 == 0 ? + String.valueOf(curCount.intValue()) : + String.valueOf(curCount); + } + if(!Objects.equals(curCountStr, "") && curIconPath != null) { + JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + curIconPath + ".png", 26); + JPanel curPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + curPanel.setBackground(AppThemeColor.FRAME); + curPanel.add(this.componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER,17f,null, curCountStr)); + curPanel.add(currencyLabel); + return curPanel; + } + return null; + } + protected JLabel getOfferLabel(){ + String offer = this.data.getOffer(); + if(offer != null && offer.trim().length() > 0) { + JLabel offerLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 17f, offer); + offerLabel.setHorizontalAlignment(SwingConstants.CENTER); + return offerLabel; + } + return null; + } + protected abstract JPanel getMessagePanel(); + protected abstract JButton getStillInterestedButton(); + private JPanel getResponseButtonsPanel(){ + JPanel root = new JPanel(new FlowLayout(FlowLayout.CENTER,5,2)); + root.setBackground(AppThemeColor.FRAME); + List buttonsConfig = this.config.get().getButtons(); + Collections.sort(buttonsConfig); + buttonsConfig.forEach((buttonConfig)->{ + JButton button = componentsFactory.getBorderedButton(buttonConfig.getTitle(),16f); + if(buttonConfig.getTitle().length() < 10) { + button.setPreferredSize(new Dimension(70, 26)); + } + button.addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + button.setBorder( BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(AppThemeColor.ADR_SELECTED_BORDER, 1), + BorderFactory.createLineBorder(AppThemeColor.BUTTON, 3) + )); + } + + @Override + public void mouseExited(MouseEvent e) { + button.setBorder( BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(AppThemeColor.BORDER, 1), + BorderFactory.createLineBorder(AppThemeColor.BUTTON, 3) + )); + } + }); + button.addActionListener(e -> { + this.controller.performResponse(buttonConfig.getResponseText()); + if(buttonConfig.isClose()){ + this.controller.performHide(); + } + }); + root.add(button); + }); + return root; + } + private JPanel getTimePanel() { + JPanel root = new JPanel(new BorderLayout()); + root.setBackground(AppThemeColor.MSG_HEADER); + JLabel timeLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MISC, TextAlignment.CENTER, 14, "0m"); + Timer timeAgo = new Timer(60000, new ActionListener() { + private int minute = 0; + private int hours = 0; + private int day = 0; + + @Override + public void actionPerformed(ActionEvent e) { + String labelText = ""; + minute++; + if (minute > 60) { + hours++; + minute = 0; + if (hours > 24) { + day++; + hours = 0; + } + } + if (hours == 0 && day == 0) { + labelText = minute + "m"; + } else if (hours > 0) { + labelText = hours + "h " + minute + "m"; + } else if (day > 0) { + labelText = day + "d " + hours + "h " + minute + "m"; + } + timeLabel.setText(labelText); + } + }); + timeAgo.start(); + root.add(timeLabel,BorderLayout.CENTER); + return root; + } + private String getNicknameText(){ + String whisperNickname = data.getWhisperNickname(); + String result = whisperNickname + ":"; + if(this.config.get().isShowLeague()) { + if (data.getLeague() != null) { + String league = data.getLeague().trim(); + if (league.length() == 0) { + return result; + } + if (league.contains("Hardcore")) { + if (league.equals("Hardcore")) { + result = "HC " + result; + } else { + result = String.valueOf(league.split(" ")[1].charAt(0)) + "HC " + result; + } + } else if (league.contains("Standard")) { + result = "Standard " + result; + } else { + result = String.valueOf(league.charAt(0)) + "SC " + result; + } + } + } + return result; + } + private JButton getExpandButton(){ + String iconPath = "app/default-mp.png"; +// if(expanded){ +// if(style.equals(MessagePanelStyle.IN_DOWNWARDS)){ +// iconPath = "app/expand-mp.png"; +// }else { +// iconPath = "app/collapse-mp.png"; +// } +// } + JButton expandButton = componentsFactory.getIconButton(iconPath, 18f, AppThemeColor.MSG_HEADER,""); + expandButton.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { +// if(SwingUtilities.isLeftMouseButton(e)) { +// if (!messagePanel.isVisible()) { +// expand(); +// } else { +// collapse(); +// } +// } + } + }); + return expandButton; + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemIncNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemIncNotificationPanel.java new file mode 100644 index 00000000..84780642 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemIncNotificationPanel.java @@ -0,0 +1,66 @@ +package com.mercury.platform.ui.components.panel.notification; + +import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.components.fields.font.TextAlignment; +import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.TooltipConstants; + +import javax.swing.*; +import java.awt.*; +import java.util.Objects; + + +public class ItemIncNotificationPanel extends IncomingNotificationPanel { + @Override + protected JPanel getMessagePanel() { + JPanel labelsPanel = new JPanel(); + labelsPanel.setLayout(new BorderLayout()); + labelsPanel.setBackground(AppThemeColor.FRAME); + + JPanel tradePanel = new JPanel(new BorderLayout()); + tradePanel.setBackground(AppThemeColor.FRAME); + JButton itemButton = componentsFactory.getButton( + FontStyle.BOLD, + AppThemeColor.BUTTON, + BorderFactory.createEmptyBorder(0,4,0,2), + this.data.getItemName(), 17f); + + itemButton.setForeground(AppThemeColor.TEXT_IMPORTANT); + itemButton.setBackground(AppThemeColor.TRANSPARENT); + itemButton.setHorizontalAlignment(SwingConstants.LEFT); + itemButton.setContentAreaFilled(false); + itemButton.setRolloverEnabled(false); + itemButton.addActionListener(action -> { + this.controller.showITH(); + }); + tradePanel.add(itemButton,BorderLayout.CENTER); + tradePanel.add(this.getForPanel(),BorderLayout.LINE_END); + + labelsPanel.add(tradePanel,BorderLayout.CENTER); + JLabel offerLabel = this.getOfferLabel(); + if(offerLabel != null) { + labelsPanel.add(offerLabel, BorderLayout.PAGE_END); + } + return labelsPanel; + } + + @Override + protected JButton getStillInterestedButton() { + JButton stillIntButton = componentsFactory.getIconButton("app/still-interesting.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.STILL_INTERESTED); + stillIntButton.addActionListener(action-> { + String curCount = this.data.getCurCount() % 1 == 0 ? + String.valueOf(this.data.getCurCount().intValue()) : + String.valueOf(this.data.getCurCount()); + String responseText = "Hi, are you still interested in "; + if(this.data.getCurrency().equals("???")){ + responseText += this.data.getItemName() + "?"; + }else { + responseText += this.data.getItemName() + + " for " + curCount + " " + this.data.getCurrency() + "?"; + } + this.controller.performResponse(responseText); + }); + return stillIntButton; + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/MessagePanelController.java similarity index 75% rename from app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelController.java rename to app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/MessagePanelController.java index 5fd05539..1ed4f23e 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/MessagePanelController.java @@ -1,4 +1,4 @@ -package com.mercury.platform.ui.components.panel.message; +package com.mercury.platform.ui.components.panel.notification; import lombok.NonNull; @@ -9,10 +9,6 @@ public interface MessagePanelController { void performOpenChat(); void performResponse(@NonNull String responseText); void performHide(); - - /** - * Show Item Stash Highlights - */ void showITH(); void reloadMessage(@NonNull InMessagePanel panel); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelStyle.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/MessagePanelStyle.java similarity index 60% rename from app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelStyle.java rename to app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/MessagePanelStyle.java index 0c549a83..cdfaccf6 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelStyle.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/MessagePanelStyle.java @@ -1,4 +1,4 @@ -package com.mercury.platform.ui.components.panel.message; +package com.mercury.platform.ui.components.panel.notification; public enum MessagePanelStyle { OUT_MESSAGE, IN_DOWNWARDS, IN_UPWARDS,HISTORY, RELOADED diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/NotificationMessageController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationMessageController.java similarity index 56% rename from app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/NotificationMessageController.java rename to app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationMessageController.java index 12fc186c..989a7592 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/NotificationMessageController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationMessageController.java @@ -1,7 +1,7 @@ -package com.mercury.platform.ui.components.panel.message; +package com.mercury.platform.ui.components.panel.notification; -import com.mercury.platform.shared.entity.message.ItemMessage; -import com.mercury.platform.shared.entity.message.Message; +import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.misc.MercuryStoreUI; import lombok.NonNull; @@ -16,48 +16,48 @@ //todo proxy public class NotificationMessageController implements MessagePanelController { private static final Logger log = LogManager.getLogger(NotificationMessageController.class); - private Message message; - public NotificationMessageController(Message message){ - this.message = message; + private NotificationDescriptor notificationDescriptor; + public NotificationMessageController(NotificationDescriptor notificationDescriptor){ + this.notificationDescriptor = notificationDescriptor; } @Override public void performInvite() { - MercuryStoreCore.chatCommandSubject.onNext("/invite " + message.getWhisperNickname()); + MercuryStoreCore.chatCommandSubject.onNext("/invite " + notificationDescriptor.getWhisperNickname()); showITH(); } @Override public void performKick() { - MercuryStoreCore.chatCommandSubject.onNext("/kick " + message.getWhisperNickname()); + MercuryStoreCore.chatCommandSubject.onNext("/kick " + notificationDescriptor.getWhisperNickname()); } @Override public void performOfferTrade() { - MercuryStoreCore.chatCommandSubject.onNext("/tradewith " + message.getWhisperNickname()); + MercuryStoreCore.chatCommandSubject.onNext("/tradewith " + notificationDescriptor.getWhisperNickname()); } @Override public void performOpenChat() { - MercuryStoreCore.openChatSubject.onNext(message.getWhisperNickname()); + MercuryStoreCore.openChatSubject.onNext(notificationDescriptor.getWhisperNickname()); } @Override public void performResponse(@NonNull String responseText) { - MercuryStoreCore.chatCommandSubject.onNext("@" + message.getWhisperNickname() + " " + responseText); + MercuryStoreCore.chatCommandSubject.onNext("@" + notificationDescriptor.getWhisperNickname() + " " + responseText); } @Override public void performHide() { - closeMessagePanel(); + this.closeMessagePanel(); } @Override public void showITH() { - if(message instanceof ItemMessage) { - this.copyItemNameToClipboard(((ItemMessage) message).getItemName()); - if (((ItemMessage) message).getTabName() != null) { - MercuryStoreUI.showItemGridSubject.onNext((ItemMessage) message); + if(notificationDescriptor instanceof ItemTradeNotificationDescriptor) { + this.copyItemNameToClipboard(((ItemTradeNotificationDescriptor) notificationDescriptor).getItemName()); + if (((ItemTradeNotificationDescriptor) notificationDescriptor).getTabName() != null) { + MercuryStoreUI.showItemGridSubject.onNext((ItemTradeNotificationDescriptor) notificationDescriptor); } } } @@ -79,7 +79,7 @@ private void copyItemNameToClipboard(@NonNull String itemName){ private void closeMessagePanel(){ Timer timer = new Timer(30, action -> { - MercuryStoreUI.closeMessage.onNext(message); + MercuryStoreCore.removeNotificationSubject.onNext(notificationDescriptor); }); timer.setRepeats(false); timer.start(); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java new file mode 100644 index 00000000..40e67ce9 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java @@ -0,0 +1,21 @@ +package com.mercury.platform.ui.components.panel.notification; + + +import com.mercury.platform.shared.AsSubscriber; +import com.mercury.platform.ui.components.ComponentsFactory; +import com.mercury.platform.ui.components.panel.misc.ViewDestroy; +import com.mercury.platform.ui.components.panel.misc.ViewInit; +import lombok.Getter; +import lombok.Setter; + +import javax.swing.*; + +public abstract class NotificationPanel extends JPanel implements AsSubscriber, ViewInit,ViewDestroy { + @Setter + @Getter + protected T data; + @Setter + protected C controller; + @Setter + protected ComponentsFactory componentsFactory; +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/OutMessagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutMessagePanel.java similarity index 59% rename from app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/OutMessagePanel.java rename to app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutMessagePanel.java index e617bd57..9d2792ae 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/OutMessagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutMessagePanel.java @@ -1,4 +1,4 @@ -package com.mercury.platform.ui.components.panel.message; +package com.mercury.platform.ui.components.panel.notification; /** * Created by Константин on 10.08.2017. diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyIncPanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyIncPanelProvider.java new file mode 100644 index 00000000..bc7809b7 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyIncPanelProvider.java @@ -0,0 +1,30 @@ +package com.mercury.platform.ui.components.panel.notification.factory; + +import com.mercury.platform.shared.entity.message.CurrencyTradeNotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationType; +import com.mercury.platform.ui.components.panel.notification.CurrencyIncNotificationPanel; +import com.mercury.platform.ui.components.panel.notification.MessagePanelController; +import com.mercury.platform.ui.components.panel.notification.NotificationMessageController; +import com.mercury.platform.ui.components.panel.notification.NotificationPanel; + +public class CurrencyIncPanelProvider extends NotificationPanelProvider { + @Override + public boolean isSuitable(NotificationType type) { + return type.equals(NotificationType.INC_CURRENCY_MESSAGE); + } + + @Override + public NotificationPanel build() { + CurrencyIncNotificationPanel panel = new CurrencyIncNotificationPanel(); + panel.setData(this.data); + if(this.controller != null){ + panel.setController(this.controller); + }else { + panel.setController(new NotificationMessageController(this.data)); + } + panel.setComponentsFactory(this.componentsFactory); + panel.subscribe(); + panel.onViewInit(); + return panel; + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemIncPanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemIncPanelProvider.java new file mode 100644 index 00000000..4946f58b --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemIncPanelProvider.java @@ -0,0 +1,31 @@ +package com.mercury.platform.ui.components.panel.notification.factory; + +import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationType; +import com.mercury.platform.ui.components.panel.notification.ItemIncNotificationPanel; +import com.mercury.platform.ui.components.panel.notification.MessagePanelController; +import com.mercury.platform.ui.components.panel.notification.NotificationMessageController; +import com.mercury.platform.ui.components.panel.notification.NotificationPanel; + + +public class ItemIncPanelProvider extends NotificationPanelProvider { + @Override + public boolean isSuitable(NotificationType type) { + return type.equals(NotificationType.INC_ITEM_MESSAGE); + } + + @Override + public NotificationPanel build() { + ItemIncNotificationPanel panel = new ItemIncNotificationPanel(); + panel.setData(this.data); + if(this.controller != null){ + panel.setController(this.controller); + }else { + panel.setController(new NotificationMessageController(this.data)); + } + panel.setComponentsFactory(this.componentsFactory); + panel.subscribe(); + panel.onViewInit(); + return panel; + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelFactory.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelFactory.java new file mode 100644 index 00000000..ebd16c54 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelFactory.java @@ -0,0 +1,28 @@ +package com.mercury.platform.ui.components.panel.notification.factory; + + +import com.mercury.platform.shared.entity.message.NotificationType; + +import java.util.ArrayList; +import java.util.List; +import java.util.NoSuchElementException; + +public class NotificationPanelFactory { + private List providers = new ArrayList<>(); + + public NotificationPanelFactory() { + this.providers.add(new ItemIncPanelProvider()); + this.providers.add(new CurrencyIncPanelProvider()); + } + + public NotificationPanelProvider getProviderFor(NotificationType type){ + NotificationPanelProvider provider = this.providers.stream() + .filter(it -> it.isSuitable(type)) + .findAny().orElse(null); + if(provider != null){ + return provider; + }else { + throw new NoSuchElementException("Notification panel provider for <" + type + "> doesn't exist."); + } + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelProvider.java new file mode 100644 index 00000000..3d667ef1 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelProvider.java @@ -0,0 +1,29 @@ +package com.mercury.platform.ui.components.panel.notification.factory; + + +import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationType; +import com.mercury.platform.ui.components.ComponentsFactory; +import com.mercury.platform.ui.components.panel.notification.NotificationPanel; + +public abstract class NotificationPanelProvider { + protected T data; + protected C controller; + protected ComponentsFactory componentsFactory; + + public abstract boolean isSuitable(NotificationType type); + public NotificationPanelProvider setController(C controller) { + this.controller = controller; + return this; + } + public NotificationPanelProvider setData(T data) { + this.data = data; + return this; + } + public NotificationPanelProvider setComponentsFactory(ComponentsFactory factory) { + this.componentsFactory = factory; + return this; + } + + public abstract NotificationPanel build(); +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/ConfigurationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/ConfigurationPanel.java index 60c28e93..6ad50148 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/ConfigurationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/ConfigurationPanel.java @@ -1,14 +1,9 @@ package com.mercury.platform.ui.components.panel.settings; -import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.configration.impl.ApplicationConfigurationService; import com.mercury.platform.ui.components.panel.TransparentPanel; -import com.mercury.platform.ui.components.panel.misc.HasUI; -import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.components.panel.misc.ViewInit; -import javax.swing.*; - -public abstract class ConfigurationPanel extends TransparentPanel implements HasUI{ +public abstract class ConfigurationPanel extends TransparentPanel implements ViewInit { public abstract boolean processAndSave(); public abstract void restore(); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/HelpPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/HelpPanel.java index e77bd56c..efc23d4b 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/HelpPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/HelpPanel.java @@ -3,7 +3,7 @@ import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.ComponentsFactory; -import com.mercury.platform.ui.components.panel.misc.HasUI; +import com.mercury.platform.ui.components.panel.misc.ViewInit; import com.mercury.platform.ui.frame.titled.NotesFrame; import com.mercury.platform.ui.frame.titled.SettingsFrame; import com.mercury.platform.ui.frame.titled.TestCasesFrame; @@ -17,17 +17,17 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -public class HelpPanel extends JPanel implements HasUI { +public class HelpPanel extends JPanel implements ViewInit { private ComponentsFactory componentsFactory; public HelpPanel() { super(); componentsFactory = new ComponentsFactory(); this.setBackground(AppThemeColor.TRANSPARENT); - createUI(); + onViewInit(); } @Override - public void createUI() { + public void onViewInit() { this.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton openTutorial = componentsFactory.getBorderedButton("Open tutorial"); openTutorial.addMouseListener(new MouseAdapter() { diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuPanel.java index 8086984b..2959cd90 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuPanel.java @@ -2,7 +2,7 @@ import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.fields.font.FontStyle; -import com.mercury.platform.ui.components.panel.misc.HasUI; +import com.mercury.platform.ui.components.panel.misc.ViewInit; import com.mercury.platform.ui.manager.routing.SettingsPage; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.MercuryStoreUI; @@ -12,17 +12,17 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -public class MenuPanel extends JPanel implements HasUI { +public class MenuPanel extends JPanel implements ViewInit { private ComponentsFactory componentsFactory = new ComponentsFactory(); public MenuPanel() { super(); this.setBackground(AppThemeColor.FRAME); this.setPreferredSize(new Dimension(220, 20)); this.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, AppThemeColor.ADR_PANEL_BORDER)); - this.createUI(); + this.onViewInit(); } @Override - public void createUI() { + public void onViewInit() { JList list = new JList<>(getEntries()); list.addMouseListener(new MouseAdapter() { @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/AboutPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/AboutPagePanel.java index 5f7ecd6f..6a03b013 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/AboutPagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/AboutPagePanel.java @@ -14,8 +14,8 @@ public class AboutPagePanel extends SettingsPagePanel { @Override - public void createUI() { - super.createUI(); + public void onViewInit() { + super.onViewInit(); this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); JPanel imgPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); imgPanel.add(componentsFactory.getIconLabel("app/app-icon-big.png")); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/GeneralSettingsPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/GeneralSettingsPagePanel.java index 5ca752e5..1a145bc9 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/GeneralSettingsPagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/GeneralSettingsPagePanel.java @@ -6,12 +6,9 @@ import com.mercury.platform.shared.config.Configuration; import com.mercury.platform.shared.config.configration.PlainConfigurationService; import com.mercury.platform.shared.config.descriptor.ApplicationDescriptor; -import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.fields.font.FontStyle; -import com.mercury.platform.ui.frame.titled.SettingsFrame; import com.mercury.platform.ui.manager.HideSettingsManager; import com.mercury.platform.ui.misc.AppThemeColor; -import com.mercury.platform.ui.misc.MercuryStoreUI; import javax.swing.*; import java.awt.*; @@ -27,8 +24,8 @@ public class GeneralSettingsPagePanel extends SettingsPagePanel { private JSlider minSlider; private JSlider maxSlider; @Override - public void createUI() { - super.createUI(); + public void onViewInit() { + super.onViewInit(); this.applicationConfig = Configuration.get().applicationConfiguration(); this.applicationSnapshot = CloneHelper.cloneObject(this.applicationConfig.get()); @@ -124,6 +121,6 @@ public void onSave() { public void restore() { this.applicationSnapshot = CloneHelper.cloneObject(this.applicationConfig.get()); this.removeAll(); - this.createUI(); + this.onViewInit(); } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java index aa3c0ff0..8f10ddfa 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java @@ -6,7 +6,7 @@ import com.mercury.platform.shared.config.configration.PlainConfigurationService; import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; import com.mercury.platform.shared.config.descriptor.HotKeyType; -import com.mercury.platform.shared.config.descriptor.NotificationDescriptor; +import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; import com.mercury.platform.shared.config.descriptor.ResponseButtonDescriptor; import com.mercury.platform.shared.entity.message.FlowDirections; import com.mercury.platform.shared.store.MercuryStoreCore; @@ -21,15 +21,15 @@ import java.util.Map; public class NotificationSettingsPagePanel extends SettingsPagePanel { - private PlainConfigurationService notificationService; + private PlainConfigurationService notificationService; private KeyValueConfigurationService hotKeyService; - private NotificationDescriptor generalSnapshot; + private NotificationSettingsDescriptor generalSnapshot; private Map hotKeySnapshot; private JPanel buttonsTable; @Override - public void createUI() { - super.createUI(); + public void onViewInit() { + super.onViewInit(); this.notificationService = Configuration.get().notificationConfiguration(); this.hotKeyService = Configuration.get().hotKeysConfiguration(); this.generalSnapshot = CloneHelper.cloneObject(notificationService.get()); @@ -55,7 +55,7 @@ public void restore() { this.generalSnapshot = CloneHelper.cloneObject(notificationService.get()); this.hotKeySnapshot = CloneHelper.cloneObject(hotKeyService.getMap()); this.removeAll(); - this.createUI(); + this.onViewInit(); } private JPanel getIncomingPanel() { @@ -167,7 +167,6 @@ private JPanel getResponseRow(ResponseButtonDescriptor descriptor){ @Override public void focusLost(FocusEvent e) { descriptor.setTitle(titleField.getText()); - System.out.println(".qwe"); } }); titleField.setPreferredSize(new Dimension(120,26)); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SettingsPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SettingsPagePanel.java index f874b49c..6bb478ee 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SettingsPagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SettingsPagePanel.java @@ -4,13 +4,13 @@ import com.mercury.platform.ui.adr.components.AdrComponentsFactory; import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.panel.VerticalScrollContainer; -import com.mercury.platform.ui.components.panel.misc.HasUI; +import com.mercury.platform.ui.components.panel.misc.ViewInit; import com.mercury.platform.ui.misc.AppThemeColor; import javax.swing.*; import java.awt.*; -public abstract class SettingsPagePanel extends JPanel implements HasUI{ +public abstract class SettingsPagePanel extends JPanel implements ViewInit { protected ComponentsFactory componentsFactory = new ComponentsFactory(); protected AdrComponentsFactory adrComponentsFactory = new AdrComponentsFactory(this.componentsFactory); protected JPanel container; @@ -19,11 +19,11 @@ public SettingsPagePanel() { this.setLayout(new BorderLayout()); this.setBackground(AppThemeColor.FRAME); - this.createUI(); + this.onViewInit(); } @Override - public void createUI() { + public void onViewInit() { this.container = new VerticalScrollContainer(); this.container.setBackground(AppThemeColor.FRAME); this.container.setLayout(new BoxLayout(container,BoxLayout.Y_AXIS)); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SoundSettingsPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SoundSettingsPagePanel.java index 2e127160..04a3e808 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SoundSettingsPagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SoundSettingsPagePanel.java @@ -28,8 +28,8 @@ public class SoundSettingsPagePanel extends SettingsPagePanel { Map soundSnapshot; KeyValueConfigurationService soundConfiguration; @Override - public void createUI() { - super.createUI(); + public void onViewInit() { + super.onViewInit(); this.wavPaths = new HashMap<>(); this.wavPaths.put("notification","app/notification.wav"); this.wavPaths.put("chat_scanner","app/chat-filter.wav"); @@ -119,6 +119,6 @@ public void onSave() { public void restore() { this.soundSnapshot = CloneHelper.cloneObject(this.soundConfiguration.getMap()); this.removeAll(); - this.createUI(); + this.onViewInit(); } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SupportPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SupportPagePanel.java index 03f9c7e1..bc8f84a8 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SupportPagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SupportPagePanel.java @@ -19,7 +19,7 @@ public class SupportPagePanel extends SettingsPagePanel{ @Override - public void createUI() { + public void onViewInit() { JPanel donatePanel = componentsFactory.getTransparentPanel(); donatePanel.setBackground(AppThemeColor.ADR_BG); donatePanel.setLayout(new GridLayout(0,1,5,5)); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/TaskBarSettingsPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/TaskBarSettingsPagePanel.java index 6854396a..f311e638 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/TaskBarSettingsPagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/TaskBarSettingsPagePanel.java @@ -16,8 +16,8 @@ public class TaskBarSettingsPagePanel extends SettingsPagePanel { private ApplicationDescriptor applicationSnapshot; @Override - public void createUI() { - super.createUI(); + public void onViewInit() { + super.onViewInit(); this.applicationConfig = Configuration.get().applicationConfiguration(); this.applicationSnapshot = CloneHelper.cloneObject(this.applicationConfig.get()); @@ -47,6 +47,6 @@ public void onSave() { public void restore() { this.applicationSnapshot = CloneHelper.cloneObject(this.applicationConfig.get()); this.removeAll(); - this.createUI(); + this.onViewInit(); } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/MercuryTaskBarController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/MercuryTaskBarController.java index 785d3f0d..9c5c320b 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/MercuryTaskBarController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/MercuryTaskBarController.java @@ -13,14 +13,14 @@ public class MercuryTaskBarController implements TaskBarController { @Override public void enableDND() { MercuryStoreUI.repaintSubject.onNext(TaskBarFrame.class); - MercuryStoreCore.notificationSubject.onNext("DND on"); + MercuryStoreCore.alertSubject.onNext("DND on"); MercuryStoreCore.dndSubject.onNext(true); } @Override public void disableDND() { MercuryStoreUI.repaintSubject.onNext(TaskBarFrame.class); - MercuryStoreCore.notificationSubject.onNext("DND off"); + MercuryStoreCore.alertSubject.onNext("DND off"); MercuryStoreCore.dndSubject.onNext(false); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarPanel.java index be03e950..f0e98403 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarPanel.java @@ -1,7 +1,7 @@ package com.mercury.platform.ui.components.panel.taskbar; import com.mercury.platform.ui.components.ComponentsFactory; -import com.mercury.platform.ui.components.panel.misc.HasUI; +import com.mercury.platform.ui.components.panel.misc.ViewInit; import com.mercury.platform.ui.manager.FramesManager; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.TooltipConstants; @@ -12,22 +12,22 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -public class TaskBarPanel extends JPanel implements HasUI{ +public class TaskBarPanel extends JPanel implements ViewInit { private ComponentsFactory componentsFactory; private TaskBarController controller; public TaskBarPanel(@NonNull TaskBarController controller){ this.controller = controller; this.componentsFactory = new ComponentsFactory(); - createUI(); + onViewInit(); } public TaskBarPanel(@NonNull TaskBarController controller, @NonNull ComponentsFactory factory){ this.controller = controller; this.componentsFactory = factory; - createUI(); + onViewInit(); } @Override - public void createUI() { + public void onViewInit() { this.setBackground(AppThemeColor.TRANSPARENT); this.setLayout(new BoxLayout(this,BoxLayout.X_AXIS)); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractComponentFrame.java index b6c13f5f..e7cfc2d3 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractComponentFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractComponentFrame.java @@ -2,6 +2,7 @@ import com.mercury.platform.shared.config.descriptor.FrameDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; +import com.mercury.platform.ui.components.panel.misc.ViewInit; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.manager.HideSettingsManager; import org.pushingpixels.trident.Timeline; @@ -13,7 +14,7 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; -public abstract class AbstractComponentFrame extends AbstractOverlaidFrame { +public abstract class AbstractComponentFrame extends AbstractOverlaidFrame implements ViewInit { private final int HIDE_TIME = 200; private final int SHOW_TIME = 150; private final int BORDER_THICKNESS = 1; @@ -162,11 +163,13 @@ public void mouseReleased(MouseEvent e) { Dimension size = AbstractComponentFrame.this.getSize(); FrameDescriptor frameDescriptor = framesConfig.getMap().get(AbstractComponentFrame.this.getClass().getSimpleName()); if(EResizeSpace){ - AbstractComponentFrame.this.setMaximumSize(size); - AbstractComponentFrame.this.setMinimumSize(size); - if(AbstractComponentFrame.this.getClass().getSimpleName().equals("MessageFrame")){ + if(AbstractComponentFrame.this.getClass().getSimpleName().equals("NotificationFrame")){ + AbstractComponentFrame.this.setMaximumSize(new Dimension(size.width,0)); + AbstractComponentFrame.this.setMinimumSize(new Dimension(size.width,0)); frameDescriptor.setFrameSize(new Dimension(size.width,0)); }else { + AbstractComponentFrame.this.setMaximumSize(size); + AbstractComponentFrame.this.setMinimumSize(size); frameDescriptor.setFrameSize(size); } onSizeChange(); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractOverlaidFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractOverlaidFrame.java index ffdf60e7..18f4c7f7 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractOverlaidFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractOverlaidFrame.java @@ -9,6 +9,7 @@ import com.mercury.platform.shared.config.descriptor.ApplicationDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.ComponentsFactory; +import com.mercury.platform.ui.components.panel.misc.ViewInit; import com.mercury.platform.ui.frame.other.MercuryLoadingFrame; import com.mercury.platform.ui.misc.AppThemeColor; @@ -17,7 +18,7 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -public abstract class AbstractOverlaidFrame extends JFrame implements AsSubscriber { +public abstract class AbstractOverlaidFrame extends JFrame implements AsSubscriber,ViewInit { protected FrameVisibleState prevState; protected boolean processingHideEvent = true; @@ -78,6 +79,7 @@ public void init(){ this.layout = getFrameLayout(); this.setLayout(layout); this.initialize(); + this.onViewInit(); this.subscribe(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractScalableComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractScalableComponentFrame.java index 74961b66..47006df0 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractScalableComponentFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractScalableComponentFrame.java @@ -1,7 +1,6 @@ package com.mercury.platform.ui.frame; import com.mercury.platform.ui.components.ComponentsFactory; -import com.mercury.platform.ui.components.panel.misc.HasUI; import com.mercury.platform.ui.frame.setup.scale.ScaleState; import com.mercury.platform.ui.misc.MercuryStoreUI; @@ -9,7 +8,7 @@ import java.awt.*; import java.util.Map; //todo need generalization -public abstract class AbstractScalableComponentFrame extends AbstractComponentFrame implements HasUI{ +public abstract class AbstractScalableComponentFrame extends AbstractComponentFrame { protected Container mainContainer; private ScaleState scaleState = ScaleState.DEFAULT; protected ComponentsFactory stubComponentsFactory; @@ -25,7 +24,6 @@ protected AbstractScalableComponentFrame() { this.registerDirectScaleHandler(); } - protected void onScaleLock(){ this.pack(); this.repaint(); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/CurrencySearchFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/CurrencySearchFrame.java index 122a8d6c..c235df96 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/CurrencySearchFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/CurrencySearchFrame.java @@ -120,7 +120,7 @@ protected void performScaling(Map scaleData) { } @Override - public void createUI() { + public void onViewInit() { } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/ItemsGridFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/ItemsGridFrame.java index 21ea9698..5a410279 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/ItemsGridFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/ItemsGridFrame.java @@ -6,7 +6,7 @@ import com.mercury.platform.ui.components.panel.HorizontalScrollContainer; import com.mercury.platform.ui.components.panel.grid.*; import com.mercury.platform.ui.misc.MercuryStoreUI; -import com.mercury.platform.shared.entity.message.ItemMessage; +import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; import com.mercury.platform.ui.manager.FramesManager; @@ -28,13 +28,17 @@ public ItemsGridFrame() { stubComponentsFactory.setScale(this.scaleConfig.get("itemcell")); enableMouseOverBorder = false; processHideEffect = false; - itemsGridPanel = new ItemsGridPanel(componentsFactory); - stashTabsContainer = new StashTabsContainer(); } @Override protected void initialize() { super.initialize(); + this.itemsGridPanel = new ItemsGridPanel(componentsFactory); + this.stashTabsContainer = new StashTabsContainer(); + } + + @Override + public void onViewInit() { this.setBackground(AppThemeColor.TRANSPARENT); this.getRootPane().setBorder(null); this.add(itemsGridPanel,BorderLayout.CENTER); @@ -54,8 +58,8 @@ public void subscribe() { } }); MercuryStoreUI.closeMessage.subscribe(message -> { - if(message instanceof ItemMessage) { - this.itemsGridPanel.remove((ItemMessage) message); + if(message instanceof ItemTradeNotificationDescriptor) { + this.itemsGridPanel.remove((ItemTradeNotificationDescriptor) message); if (itemsGridPanel.getActiveTabsCount() == 0) { this.setVisible(false); } @@ -247,7 +251,7 @@ protected JPanel defaultView(ComponentsFactory factory) { JPanel root = factory.getTransparentPanel(new BorderLayout()); root.setSize(this.getSize()); ItemsGridPanel defaultView = new ItemsGridPanel(factory); - ItemMessage message = new ItemMessage(); + ItemTradeNotificationDescriptor message = new ItemTradeNotificationDescriptor(); message.setWhisperNickname("Example1"); message.setTabName("Example"); message.setLeft(5); @@ -269,11 +273,6 @@ protected void performScaling(Map scaleData) { this.componentsFactory.setScale(scaleData.get("itemcell")); } - @Override - public void createUI() { - - } - private class ResizeByWidthMouseMotionListener extends MouseMotionAdapter { @Override public void mouseDragged(MouseEvent e) { diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/TaskBarFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/TaskBarFrame.java index 033aa731..e0a2fb9e 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/TaskBarFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/TaskBarFrame.java @@ -33,36 +33,6 @@ public TaskBarFrame() { this.prevState = FrameVisibleState.SHOW; } - @Override - protected void initialize() { - super.initialize(); - createUI(); - this.setMaximumSize(taskBarPanel.getPreferredSize()); - collapseListener = new MouseAdapter() { - @Override - public void mouseEntered(MouseEvent e) { - TaskBarFrame.this.repaint(); - if (collapseAnimation != null) { - collapseAnimation.abort(); - } - initCollapseAnimations("expand"); - collapseAnimation.play(); - } - - @Override - public void mouseExited(MouseEvent e) { - TaskBarFrame.this.repaint(); - if(isVisible() && !withInPanel((JPanel)TaskBarFrame.this.getContentPane()) && !EResizeSpace) { - if (collapseAnimation != null) { - collapseAnimation.abort(); - } - initCollapseAnimations("collapse"); - collapseAnimation.play(); - } - } - }; - enableCollapseAnimation(); - } private void enableCollapseAnimation(){ this.setWidth(MIN_WIDTH); this.addMouseListener(collapseListener); @@ -131,11 +101,11 @@ protected void registerDirectScaleHandler() { @Override protected void performScaling(Map scaleData) { this.componentsFactory.setScale(scaleData.get("taskbar")); - createUI(); + onViewInit(); } @Override - public void createUI() { + public void onViewInit() { JPanel panel = componentsFactory.getTransparentPanel(new BorderLayout()); taskBarPanel = new TaskBarPanel(new MercuryTaskBarController(),componentsFactory); panel.add(taskBarPanel, BorderLayout.CENTER); @@ -147,6 +117,32 @@ public void createUI() { this.MIN_WIDTH = taskBarPanel.getWidthOf(4); this.MAX_WIDTH = taskBarPanel.getPreferredSize().width; this.setWidth(MIN_WIDTH); + + this.setMaximumSize(taskBarPanel.getPreferredSize()); + collapseListener = new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + TaskBarFrame.this.repaint(); + if (collapseAnimation != null) { + collapseAnimation.abort(); + } + initCollapseAnimations("expand"); + collapseAnimation.play(); + } + + @Override + public void mouseExited(MouseEvent e) { + TaskBarFrame.this.repaint(); + if(isVisible() && !withInPanel((JPanel)TaskBarFrame.this.getContentPane()) && !EResizeSpace) { + if (collapseAnimation != null) { + collapseAnimation.abort(); + } + initCollapseAnimations("collapse"); + collapseAnimation.play(); + } + } + }; + this.enableCollapseAnimation(); } @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java index b869485c..3fe36348 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java @@ -4,18 +4,17 @@ import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.config.Configuration; import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.descriptor.NotificationDescriptor; +import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; import com.mercury.platform.shared.entity.message.FlowDirections; -import com.mercury.platform.shared.entity.message.ItemMessage; -import com.mercury.platform.shared.entity.message.Message; +import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationType; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.components.panel.message.InMessagePanel; -import com.mercury.platform.ui.components.panel.message.MessagePanelController; -import com.mercury.platform.ui.components.panel.message.NotificationMessageController; -import com.mercury.platform.ui.components.panel.message.MessagePanelStyle; +import com.mercury.platform.ui.components.panel.notification.*; +import com.mercury.platform.ui.components.panel.notification.factory.NotificationPanelFactory; import com.mercury.platform.ui.frame.movable.AbstractMovableComponentFrame; import com.mercury.platform.ui.frame.AbstractOverlaidFrame; import com.mercury.platform.ui.frame.setup.location.LocationState; @@ -31,11 +30,10 @@ import java.awt.event.MouseEvent; import java.util.*; import java.util.List; -import java.util.stream.Collectors; public class MessageFrame extends AbstractMovableComponentFrame implements MessagesContainer { - private List currentMessages = new ArrayList<>(); - private PlainConfigurationService notificationConfig; + private List currentMessages = new ArrayList<>(); + private PlainConfigurationService notificationConfig; private boolean wasVisible; private FlowDirections flowDirections; private FlowDirections pikerDirection; @@ -70,11 +68,10 @@ public MessageFrame(){ @Override protected void initialize() { super.initialize(); - this.createUI(); } @Override - public void createUI() { + public void onViewInit() { this.setBackground(AppThemeColor.TRANSPARENT); this.getRootPane().setBorder(null); if(this.currentMessages.size() > 0){ @@ -112,54 +109,59 @@ public void subscribe() { } }); MercuryStoreCore.messageSubject.subscribe(message -> SwingUtilities.invokeLater(()-> { - List collect = this.currentMessages.stream() - .filter(panel -> panel.getMessage().equals(message)) - .collect(Collectors.toList()); - if(collect.size() == 0) { +// List collect = this.currentMessages.stream() +// .filter(panel -> panel.getMessage().equals(message)) +// .collect(Collectors.toList()); +// if(collect.size() == 0) { this.addMessage(message); - } +// } })); - MercuryStoreUI.closeMessage.subscribe(message -> { - List panels = this.currentMessages.stream() - .filter(panel -> panel.getMessage().equals(message)) - .collect(Collectors.toList()); - if(panels.size() > 0) { - InMessagePanel inMessagePanel = panels.get(0); - if (inMessagePanel.isExpanded()) { - this.currentUnfoldCount--; - if (this.currentUnfoldCount < 0) { - this.currentUnfoldCount = 0; - } - } - this.remove(inMessagePanel); - this.currentMessages.remove(inMessagePanel); - - if (this.currentMessages.size() == 0) { - this.setVisible(false); - } else if (this.currentMessages.size() >= this.limitMsgCount) { - if (this.currentMessages.size() == this.limitMsgCount) { - this.expandAllFrame.setVisible(false); - } - this.currentMessages.get(this.limitMsgCount - 1).setVisible(true); - this.expandAllFrame.decMessageCount(); - } - this.pack(); - this.repaint(); - this.setUpExpandButton(); - } - }); +// MercuryStoreUI.closeMessage.subscribe(message -> { +// List panels = this.currentMessages.stream() +// .filter(panel -> panel.getMessage().equals(message)) +// .collect(Collectors.toList()); +// if(panels.size() > 0) { +// InMessagePanel inMessagePanel = panels.get(0); +// if (inMessagePanel.isExpanded()) { +// this.currentUnfoldCount--; +// if (this.currentUnfoldCount < 0) { +// this.currentUnfoldCount = 0; +// } +// } +// this.remove(inMessagePanel); +// this.currentMessages.remove(inMessagePanel); +// +// if (this.currentMessages.size() == 0) { +// this.setVisible(false); +// } else if (this.currentMessages.size() >= this.limitMsgCount) { +// if (this.currentMessages.size() == this.limitMsgCount) { +// this.expandAllFrame.setVisible(false); +// } +// this.currentMessages.get(this.limitMsgCount - 1).setVisible(true); +// this.expandAllFrame.decMessageCount(); +// } +// this.pack(); +// this.repaint(); +// this.setUpExpandButton(); +// } +// }); MercuryStoreUI.expandMessageSubject.subscribe(state -> this.onExpandMessage()); MercuryStoreUI.collapseMessageSubject.subscribe(state -> this.onCollapseMessage()); } - private void addMessage(Message message){ + private void addMessage(NotificationDescriptor notificationDescriptor){ MessagePanelStyle style = flowDirections.equals(FlowDirections.DOWNWARDS)? MessagePanelStyle.IN_DOWNWARDS : MessagePanelStyle.IN_UPWARDS; - InMessagePanel inMessagePanel = new InMessagePanel( - message, - style, - new NotificationMessageController(message), - this.componentsFactory); + NotificationPanelFactory factory = new NotificationPanelFactory(); + NotificationPanel inMessagePanel = factory.getProviderFor(NotificationType.INC_ITEM_MESSAGE) + .setData(notificationDescriptor) + .setComponentsFactory(this.componentsFactory) + .build(); +// InMessagePanel inMessagePanel = new InMessagePanel( +// message, +// style, +// new NotificationMessageController(message), +// this.componentsFactory); if (!dnd && !this.isVisible() && ProdStarter.APP_STATUS == FrameVisibleState.SHOW) { this.showComponent(); } else { @@ -174,7 +176,7 @@ private void addMessage(Message message){ this.pack(); this.repaint(); if (this.currentUnfoldCount < this.unfoldCount) { - inMessagePanel.expand(); +// inMessagePanel.expand(); } if(this.currentMessages.size() > this.limitMsgCount){ if(!expanded) { @@ -325,10 +327,10 @@ private void onLimitCountChange(){ private void onExpandedCountChange(){ this.currentUnfoldCount = 0; - this.currentMessages.forEach(InMessagePanel::collapse); +// this.currentMessages.forEach(InMessagePanel::collapse); this.currentUnfoldCount = 0; this.currentMessages.stream().limit(this.unfoldCount).forEach(panel -> { - panel.expand(); +// panel.expand(); this.currentUnfoldCount++; }); } @@ -494,7 +496,7 @@ protected void performScaling(Map scaleData) { this.componentsFactory.setScale(scaleData.get("notification")); this.currentMessages.forEach(panel -> { panel.setComponentsFactory(this.componentsFactory); - panel.setStyle(panel.getStyle()); +// panel.setStyle(panel.getStyle()); }); if(this.wasVisible) { this.showComponent(); @@ -513,7 +515,7 @@ protected void registerDirectScaleHandler() { @Override protected JPanel defaultView(ComponentsFactory factory) { - ItemMessage message = new ItemMessage(); + ItemTradeNotificationDescriptor message = new ItemTradeNotificationDescriptor(); message.setWhisperNickname("Example1"); message.setItemName("Example example example"); message.setCurrency("chaos"); @@ -760,6 +762,11 @@ protected LayoutManager getFrameLayout() { return new BorderLayout(); } + @Override + public void onViewInit() { + + } + private class ExpandAllFrameConstraints { private boolean visible; private Border border; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java new file mode 100644 index 00000000..0c6499b4 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java @@ -0,0 +1,100 @@ +package com.mercury.platform.ui.frame.movable.container; + +import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.configration.PlainConfigurationService; +import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; +import com.mercury.platform.shared.store.MercuryStoreCore; +import com.mercury.platform.ui.components.ComponentsFactory; +import com.mercury.platform.ui.components.panel.VerticalScrollContainer; +import com.mercury.platform.ui.components.panel.notification.NotificationPanel; +import com.mercury.platform.ui.components.panel.notification.factory.NotificationPanelFactory; +import com.mercury.platform.ui.frame.movable.AbstractMovableComponentFrame; +import com.mercury.platform.ui.misc.AppThemeColor; + +import javax.swing.*; +import java.awt.*; +import java.util.*; +import java.util.List; + + +public class NotificationFrame extends AbstractMovableComponentFrame { + private List notificationPanels; + private PlainConfigurationService config; + private NotificationPanelFactory factory; + private JPanel container; + @Override + protected void initialize() { + super.initialize(); + this.processSEResize = false; + this.notificationPanels = new ArrayList<>(); + this.config = Configuration.get().notificationConfiguration(); + this.componentsFactory.setScale(this.scaleConfig.get("notification")); + this.stubComponentsFactory.setScale(this.scaleConfig.get("notification")); + this.factory = new NotificationPanelFactory(); + } + + @Override + public void onViewInit() { + this.getRootPane().setBorder(null); + this.setBackground(AppThemeColor.TRANSPARENT); + this.container = new VerticalScrollContainer(); + this.container.setBackground(AppThemeColor.TRANSPARENT); + this.container.setLayout(new BoxLayout(container,BoxLayout.Y_AXIS)); + + this.add(this.getExpandPanel(),BorderLayout.LINE_START); + this.add(this.container,BorderLayout.CENTER); + this.setVisible(true); + this.pack(); + } + + @Override + @SuppressWarnings("all") + public void subscribe() { + MercuryStoreCore.newNotificationSubject.subscribe(notification -> { + NotificationPanel notificationPanel = this.factory.getProviderFor(notification.getType()) + .setData(notification) + .setComponentsFactory(this.componentsFactory) + .build(); + this.notificationPanels.add(notificationPanel); + this.container.add(notificationPanel); + this.pack(); + this.repaint(); + }); + MercuryStoreCore.removeNotificationSubject.subscribe(notification -> { + NotificationPanel notificationPanel = this.notificationPanels.stream() + .filter(it -> it.getData().equals(notification)) + .findAny().orElse(null); + notificationPanel.onViewDestroy(); + this.container.remove(notificationPanel); + this.notificationPanels.remove(notificationPanel); + this.pack(); + this.repaint(); + }); + } + + @Override + protected JPanel getPanelForPINSettings() { + return new JPanel(); + } + + @Override + protected void registerDirectScaleHandler() { + } + + @Override + protected void performScaling(Map scaleData) { + } + @Override + protected JPanel defaultView(ComponentsFactory factory) { + return null; + } + + @Override + protected LayoutManager getFrameLayout() { + return new BorderLayout(); + } + + private JPanel getExpandPanel(){ + return new JPanel(); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/other/AlertFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/AlertFrame.java index d158ee04..47c61b5f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/other/AlertFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/AlertFrame.java @@ -17,6 +17,9 @@ public AlertFrame() { @Override protected void initialize() { this.getRootPane().setBorder(BorderFactory.createLineBorder(AppThemeColor.BORDER)); + } + @Override + public void onViewInit() { JPanel messagePanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); messageLabel = componentsFactory.getTextLabel(""); messagePanel.add(messageLabel); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/other/MercuryLoadingFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/MercuryLoadingFrame.java index 96109dee..77574b70 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/other/MercuryLoadingFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/MercuryLoadingFrame.java @@ -16,13 +16,39 @@ public class MercuryLoadingFrame extends AbstractOverlaidFrame { private MercuryLoading loadingTracker; public MercuryLoadingFrame() { super(); - this.setOpacity(0f); - this.setBackground(AppThemeColor.TRANSPARENT); processingHideEvent = false; } @Override protected void initialize() { + this.setOpacity(0f); + this.setBackground(AppThemeColor.TRANSPARENT); + } + + @Override + public void subscribe() { + MercuryStoreCore.appLoadingSubject + .subscribe(state -> { + hideAnimation.play(); + }); + MercuryStoreCore.errorHandlerSubject.subscribe(error -> { + this.loadingTracker.abort(); + }); + } + + @Override + public void showComponent() { + super.showComponent(); + showAnimation.play(); + } + + @Override + protected LayoutManager getFrameLayout() { + return new FlowLayout(); + } + + @Override + public void onViewInit() { this.loadingTracker = new MercuryLoading(); this.loadingTracker.setSwapEnable(true); this.loadingTracker.setLoadingUI(new MercuryAppLoadingUI(this.loadingTracker)); @@ -55,26 +81,4 @@ public void onTimelinePulse(float durationFraction, float timelinePosition) { Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2); } - - @Override - public void subscribe() { - MercuryStoreCore.appLoadingSubject - .subscribe(state -> { - hideAnimation.play(); - }); - MercuryStoreCore.errorHandlerSubject.subscribe(error -> { - this.loadingTracker.abort(); - }); - } - - @Override - public void showComponent() { - super.showComponent(); - showAnimation.play(); - } - - @Override - protected LayoutManager getFrameLayout() { - return new FlowLayout(); - } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/other/NotificationFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/NotificationAlertFrame.java similarity index 64% rename from app-ui/src/main/java/com/mercury/platform/ui/frame/other/NotificationFrame.java rename to app-ui/src/main/java/com/mercury/platform/ui/frame/other/NotificationAlertFrame.java index dfe8b2fb..dad36168 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/other/NotificationFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/NotificationAlertFrame.java @@ -11,50 +11,30 @@ import javax.swing.*; import java.awt.*; -public class NotificationFrame extends AbstractOverlaidFrame { +public class NotificationAlertFrame extends AbstractOverlaidFrame { private JLabel messageLabel; private Timeline showAnimation; - public NotificationFrame() { + public NotificationAlertFrame() { super(); - this.setOpacity(0.9f); - this.setBackground(AppThemeColor.TRANSPARENT); } @Override protected void initialize() { - messageLabel = componentsFactory.getTextLabel(FontStyle.BOLD,AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER,38,""); - - showAnimation = new Timeline(this); - showAnimation.setDuration(1400); - showAnimation.addPropertyToInterpolate("opacity", 0.9f, 0f); - showAnimation.addCallback(new TimelineCallback() { - @Override - public void onTimelineStateChanged(Timeline.TimelineState oldState, Timeline.TimelineState newState, float durationFraction, float timelinePosition) { - if(newState.equals(Timeline.TimelineState.DONE)){ - NotificationFrame.this.setAlwaysOnTop(false); - NotificationFrame.this.setVisible(false); - NotificationFrame.this.setOpacity(0.9f); - messageLabel.setText(""); - } - } - @Override - public void onTimelinePulse(float durationFraction, float timelinePosition) { - } - }); - this.add(messageLabel); + this.setOpacity(0.9f); + this.setBackground(AppThemeColor.TRANSPARENT); } @Override public void subscribe() { - MercuryStoreCore.notificationSubject.subscribe(message -> { - messageLabel.setText(message); + MercuryStoreCore.alertSubject.subscribe(message -> { + this.messageLabel.setText(message); this.pack(); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2); this.setAlwaysOnTop(true); this.setVisible(true); - showAnimation.abort(); - showAnimation.play(); + this.showAnimation.abort(); + this.showAnimation.play(); }); } @@ -62,4 +42,28 @@ public void subscribe() { protected LayoutManager getFrameLayout() { return new FlowLayout(); } + + @Override + public void onViewInit() { + this.messageLabel = componentsFactory.getTextLabel(FontStyle.BOLD,AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER,38,""); + + this.showAnimation = new Timeline(this); + this.showAnimation.setDuration(1400); + this.showAnimation.addPropertyToInterpolate("opacity", 0.9f, 0f); + this.showAnimation.addCallback(new TimelineCallback() { + @Override + public void onTimelineStateChanged(Timeline.TimelineState oldState, Timeline.TimelineState newState, float durationFraction, float timelinePosition) { + if(newState.equals(Timeline.TimelineState.DONE)){ + NotificationAlertFrame.this.setAlwaysOnTop(false); + NotificationAlertFrame.this.setVisible(false); + NotificationAlertFrame.this.setOpacity(0.9f); + messageLabel.setText(""); + } + } + @Override + public void onTimelinePulse(float durationFraction, float timelinePosition) { + } + }); + this.add(messageLabel); + } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/other/OutMessageFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/OutMessageFrame.java deleted file mode 100644 index e4e7f9bb..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/other/OutMessageFrame.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.mercury.platform.ui.frame.other; - -import com.mercury.platform.core.ProdStarter; -import com.mercury.platform.shared.FrameVisibleState; -import com.mercury.platform.shared.entity.message.CurrencyMessage; -import com.mercury.platform.shared.entity.message.ItemMessage; -import com.mercury.platform.shared.entity.message.Message; -import com.mercury.platform.shared.store.MercuryStoreCore; -import com.mercury.platform.ui.components.fields.font.FontStyle; -import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.frame.AbstractComponentFrame; -import com.mercury.platform.ui.misc.AppThemeColor; -import com.mercury.platform.ui.misc.TooltipConstants; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -/** - * Created by Константин on 12.01.2017. - */ -public class OutMessageFrame extends AbstractComponentFrame { - public OutMessageFrame() { - super(); - } - - private void addNewMessage(Message message){ - JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); - root.setBackground(AppThemeColor.HEADER); - root.setBorder(BorderFactory.createEmptyBorder(-10,0,-10,0)); - JLabel whisperLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_NICKNAME, TextAlignment.LEFTOP,15f,message.getWhisperNickname() + ":"); - whisperLabel.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - x = e.getX(); - y = e.getY(); - } - }); -// whisperLabel.addMouseMotionListener(new MouseAdapter() { -// @Override -// public void mouseDragged(MouseEvent e) { -// OutMessageFrame.this.setLocation(e.getLocationOnScreen().x -x,e.getLocationOnScreen().y -y); -// configManager.saveFrameLocation(OutMessageFrame.this.getClass().getSimpleName(),OutMessageFrame.this.getLocation()); -// } -// }); - - JPanel interactionPanel = componentsFactory.getTransparentPanel(new BorderLayout()); - JPanel miscPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); - miscPanel.add(componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 17f, "=>")); - if(message.getCurrency() != null) { - miscPanel.add(getCurCountPanel(message.getCurCount(),message.getCurrency())); - } - if(message instanceof CurrencyMessage){ - CurrencyMessage msg = (CurrencyMessage) message; - JPanel curCountPanel = getCurCountPanel(msg.getCurrForSaleCount(), msg.getCurrForSaleTitle()); - curCountPanel.setBorder(BorderFactory.createEmptyBorder(10,0,0,0)); - interactionPanel.add(curCountPanel,BorderLayout.CENTER); - }else { - JLabel itemLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_IMPORTANT, TextAlignment.CENTER, 16f, ((ItemMessage)message).getItemName()); - interactionPanel.add(itemLabel,BorderLayout.CENTER); - } - JButton hoIn = componentsFactory.getIconButton("app/hideout-in.png", 16, AppThemeColor.HEADER, TooltipConstants.HO_IN); - hoIn.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - MercuryStoreCore.chatCommandSubject.onNext("/hideout " + message.getWhisperNickname()); - } - }); - miscPanel.add(hoIn); - JButton hoOut = componentsFactory.getIconButton("app/hideout-out.png", 16, AppThemeColor.HEADER, TooltipConstants.HO_OUT); - hoOut.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - MercuryStoreCore.chatCommandSubject.onNext("/hideout"); - } - }); - miscPanel.add(hoOut); - JButton hideButton = componentsFactory.getIconButton("app/close.png", 14, AppThemeColor.HEADER,TooltipConstants.HIDE_PANEL); - hideButton.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - OutMessageFrame.this.getContentPane().remove(root); - OutMessageFrame.this.pack(); - if(OutMessageFrame.this.getContentPane().getComponentCount() == 0){ - OutMessageFrame.this.setAlwaysOnTop(false); - OutMessageFrame.this.setVisible(false); - } - } - }); - miscPanel.add(hideButton); - - interactionPanel.add(miscPanel,BorderLayout.LINE_END); - root.add(interactionPanel,BorderLayout.LINE_END); - root.add(whisperLabel,BorderLayout.CENTER); - - this.add(root); - pack(); - } - - private JPanel getCurCountPanel(Double curCount, String currency){ - JPanel curCountPanel = new JPanel(); - curCountPanel.setPreferredSize(new Dimension(30,20)); - curCountPanel.setBackground(AppThemeColor.TRANSPARENT); - curCountPanel.setBorder(BorderFactory.createEmptyBorder(-8,0,-8,0)); - - JLabel priceLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 17f, String.valueOf(curCount)); - curCountPanel.add(priceLabel); - JLabel currencyLabel; - //todo - currencyLabel = componentsFactory.getIconLabel("currency/" + currency + ".png", 26); - JPanel curPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); - curPanel.setBackground(AppThemeColor.TRANSPARENT); - curPanel.add(curCountPanel); - curPanel.add(currencyLabel); - curPanel.setBorder(BorderFactory.createMatteBorder(4,0,0,0,AppThemeColor.TRANSPARENT)); - return curPanel; - } - @Override - public void subscribe() { - MercuryStoreCore.outMessageSubject.subscribe(message -> { - if (!this.isVisible() && ProdStarter.APP_STATUS == FrameVisibleState.SHOW) { - this.setAlwaysOnTop(true); - this.setVisible(true); - } else { - prevState = FrameVisibleState.SHOW; - } - addNewMessage(message); - }); - } - - @Override - protected LayoutManager getFrameLayout() { - return new BoxLayout(this.getContentPane(),BoxLayout.Y_AXIS); - } - - -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/other/SetUpLocationFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/SetUpLocationFrame.java index f78b545d..27cb3e77 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/other/SetUpLocationFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/SetUpLocationFrame.java @@ -19,6 +19,10 @@ protected void initialize() { this.getRootPane().setBorder(BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,2), BorderFactory.createLineBorder(AppThemeColor.BORDER, 1))); + } + + @Override + public void onViewInit() { JPanel rootPanel = componentsFactory.getTransparentPanel(new BorderLayout()); rootPanel.setBorder(BorderFactory.createEmptyBorder(6,6,0,6)); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/other/SetUpScaleFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/SetUpScaleFrame.java index d4550666..174f6ea9 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/other/SetUpScaleFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/SetUpScaleFrame.java @@ -25,8 +25,11 @@ protected void initialize() { this.getRootPane().setBorder(BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,2), BorderFactory.createLineBorder(AppThemeColor.BORDER, 1))); - this.scaleData = this.scaleConfig.getMap(); + } + + @Override + public void onViewInit() { JPanel rootPanel = componentsFactory.getTransparentPanel(new BorderLayout()); rootPanel.setBorder(BorderFactory.createEmptyBorder(6,6,0,6)); @@ -182,4 +185,5 @@ public void subscribe() { protected LayoutManager getFrameLayout() { return new BorderLayout(); } + } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/other/TooltipFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/TooltipFrame.java index 578bae17..b9bf6b10 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/other/TooltipFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/TooltipFrame.java @@ -13,10 +13,6 @@ public class TooltipFrame extends AbstractOverlaidFrame { private Timer tooltipTimer; public TooltipFrame() { super(); - this.setOpacity(this.applicationConfig.get().getMaxOpacity()/100f); - this.getRootPane().setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createLineBorder(AppThemeColor.BORDER, 1), - BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,2))); } @Override @@ -73,4 +69,12 @@ public void subscribe() { protected LayoutManager getFrameLayout() { return new BorderLayout(); } + + @Override + public void onViewInit() { + this.setOpacity(this.applicationConfig.get().getMaxOpacity()/100f); + this.getRootPane().setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(AppThemeColor.BORDER, 1), + BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,2))); + } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/other/UpdateReadyFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/UpdateReadyFrame.java index 6ab2d8d3..46d4f805 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/other/UpdateReadyFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/UpdateReadyFrame.java @@ -24,6 +24,9 @@ protected void initialize() { this.getRootPane().setBorder(BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,2), BorderFactory.createLineBorder(AppThemeColor.BORDER, 1))); + } + @Override + public void onViewInit() { this.add(getUpdatePanel()); this.setOpacity(this.applicationConfig.get().getMaxOpacity()/100f); this.pack(); @@ -95,5 +98,4 @@ public void subscribe() { protected LayoutManager getFrameLayout() { return new FlowLayout(FlowLayout.LEFT); } - } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/AbstractTitledComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/AbstractTitledComponentFrame.java index cb0fb25f..812630cc 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/AbstractTitledComponentFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/AbstractTitledComponentFrame.java @@ -15,7 +15,6 @@ public abstract class AbstractTitledComponentFrame extends AbstractComponentFram private JLabel frameTitleLabel; protected AbstractTitledComponentFrame() { super(); - this.miscPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); } @Override @@ -26,6 +25,7 @@ protected void initialize() { private void initHeaderPanel(){ if(layout instanceof BorderLayout) { + this.miscPanel = new JPanel(new GridLayout(1,0,5,0)); this.headerPanel = new JPanel(new BorderLayout()); this.headerPanel.setBackground(AppThemeColor.HEADER); this.headerPanel.setPreferredSize(new Dimension(100,26)); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/GamePathChooser.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/GamePathChooser.java index 8f749af8..e39d87af 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/GamePathChooser.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/GamePathChooser.java @@ -29,8 +29,7 @@ public GamePathChooser() { } @Override - protected void initialize() { - super.initialize(); + public void onViewInit() { this.removeHideButton(); this.add(getChooserPanel(),BorderLayout.CENTER); this.add(getMiscPanel(),BorderLayout.PAGE_END); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/NotesFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/NotesFrame.java index db31b8be..48d4221f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/NotesFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/NotesFrame.java @@ -42,10 +42,8 @@ public NotesFrame(List notes, NotesType type) { } } } - @Override - protected void initialize() { - super.initialize(); + public void onViewInit() { JPanel rootPanel = componentsFactory.getTransparentPanel(new BorderLayout()); rootPanel.setBorder(BorderFactory.createEmptyBorder(6,6,6,6)); @@ -267,10 +265,6 @@ private ProgressBarFrame() { protected void initialize() { this.setMinimumSize(new Dimension(310, 60)); this.getRootPane().setBorder(BorderFactory.createLineBorder(AppThemeColor.BORDER)); - this.add(getProgressBarPanel(),BorderLayout.CENTER); - this.pack(); - Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2); } private JPanel getProgressBarPanel() { @@ -323,5 +317,13 @@ public void subscribe() { protected LayoutManager getFrameLayout() { return new BorderLayout(); } + + @Override + public void onViewInit() { + this.add(getProgressBarPanel(),BorderLayout.CENTER); + this.pack(); + Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); + this.setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2); + } } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/SettingsFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/SettingsFrame.java index b52eaa19..ce3721e1 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/SettingsFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/SettingsFrame.java @@ -36,6 +36,11 @@ public SettingsFrame(){ @Override protected void initialize() { super.initialize(); + this.setPreferredSize(new Dimension(1000,600)); + } + + @Override + public void onViewInit() { this.root = new JPanel(new BorderLayout()); this.menuPanel = new MenuPanel(); JPanel leftPanel = this.componentsFactory.getJPanel(new BorderLayout()); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java index 05ec5ce3..adc1e12a 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java @@ -2,7 +2,7 @@ import com.mercury.platform.core.misc.SoundType; import com.mercury.platform.shared.MessageParser; -import com.mercury.platform.shared.entity.message.Message; +import com.mercury.platform.shared.entity.message.NotificationDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.misc.AppThemeColor; @@ -133,10 +133,9 @@ public TestCasesFrame() { } @Override - protected void initialize() { - super.initialize(); - add(getTestCasesPanel(), BorderLayout.CENTER); - pack(); + public void onViewInit() { + this.add(getTestCasesPanel(), BorderLayout.CENTER); + this.pack(); } @Override @@ -168,7 +167,7 @@ private JPanel getTestCasesPanel(){ button.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { - Message message = parser.parse(String.format(poeTradeTemplate, + NotificationDescriptor notificationDescriptor = parser.parse(String.format(poeTradeTemplate, nickNames.get(random.nextInt(nickNames.size())), items.get(random.nextInt(items.size())), random.nextInt(200), @@ -179,7 +178,7 @@ public void mousePressed(MouseEvent e) { random.nextInt(12) + 1, offer.get(random.nextInt(offer.size())) )); - MercuryStoreCore.messageSubject.onNext(message); + MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); } }); testPanel.add(button,buttonColumn); @@ -192,7 +191,7 @@ public void mousePressed(MouseEvent e) { button1.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { - Message message = parser.parse(String.format(currencyTemplate, + NotificationDescriptor notificationDescriptor = parser.parse(String.format(currencyTemplate, nickNames.get(random.nextInt(nickNames.size())), random.nextInt(200), currency.get(random.nextInt(currency.size())), @@ -201,7 +200,7 @@ public void mousePressed(MouseEvent e) { leagues.get(random.nextInt(leagues.size())), offer.get(random.nextInt(offer.size())) )); - MercuryStoreCore.messageSubject.onNext(message); + MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); } }); testPanel.add(button1,buttonColumn); @@ -217,7 +216,7 @@ public void mousePressed(MouseEvent e) { @Override public void mousePressed(MouseEvent e) { String nickname = nickNames.get(random.nextInt(nickNames.size())); - Message message = parser.parse(String.format(currencyTemplate, + NotificationDescriptor notificationDescriptor = parser.parse(String.format(currencyTemplate, nickname, random.nextInt(200), currency.get(random.nextInt(currency.size())), @@ -226,7 +225,7 @@ public void mousePressed(MouseEvent e) { leagues.get(random.nextInt(leagues.size())), offer.get(random.nextInt(offer.size())) )); - MercuryStoreCore.messageSubject.onNext(message); + MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); MercuryStoreCore.soundSubject.onNext(SoundType.MESSAGE); Timer joinedTimer = new Timer(1000,null); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TimerFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TimerFrame.java index d9a0572d..c6d45270 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TimerFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TimerFrame.java @@ -187,4 +187,9 @@ public void subscribe() { protected String getFrameTitle() { return "Timer"; } + + @Override + public void onViewInit() { + + } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterFrame.java index 5050ce69..6dc01013 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterFrame.java @@ -34,7 +34,6 @@ public class ChatFilterFrame extends AbstractTitledComponentFrame { public ChatFilterFrame() { super(); - this.scannerService = Configuration.get().scannerConfiguration(); FrameDescriptor frameDescriptor = this.framesConfig.get(this.getClass().getSimpleName()); this.setPreferredSize(frameDescriptor.getFrameSize()); this.settingsFrame = new ChatFilterSettingsFrame(strings -> { @@ -47,7 +46,11 @@ public ChatFilterFrame() { @Override protected void initialize() { super.initialize(); + this.scannerService = Configuration.get().scannerConfiguration(); + } + @Override + public void onViewInit() { this.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterSettingsFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterSettingsFrame.java index 6328ed7b..2426ae14 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterSettingsFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterSettingsFrame.java @@ -29,9 +29,7 @@ public ChatFilterSettingsFrame(ChatSettingsCallback callback) { } @Override - protected void initialize() { - super.initialize(); - this.setPreferredSize(new Dimension(350,300)); + public void onViewInit() { JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); JPanel setupArea = componentsFactory.getTransparentPanel(new BorderLayout()); setupArea.setBorder(BorderFactory.createEmptyBorder(4,4,4,4)); @@ -91,6 +89,12 @@ protected void initialize() { this.add(navBar,BorderLayout.PAGE_END); this.pack(); } + + @Override + protected void initialize() { + super.initialize(); + this.setPreferredSize(new Dimension(350,300)); + } private JPanel getResponsePanel(){ JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); JPanel setupArea = componentsFactory.getTransparentPanel(new BorderLayout()); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryContainer.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryContainer.java index f5b2be32..e2d45e42 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryContainer.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryContainer.java @@ -1,6 +1,6 @@ package com.mercury.platform.ui.frame.titled.container; -import com.mercury.platform.ui.components.panel.message.InMessagePanel; +import com.mercury.platform.ui.components.panel.notification.InMessagePanel; public interface HistoryContainer { void onReloadMessage(InMessagePanel inMessagePanel); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryFrame.java index b495a9be..cf265e2a 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryFrame.java @@ -3,13 +3,13 @@ import com.mercury.platform.shared.HistoryManager; import com.mercury.platform.shared.MessageParser; import com.mercury.platform.shared.config.descriptor.FrameDescriptor; -import com.mercury.platform.shared.entity.message.Message; +import com.mercury.platform.shared.entity.message.NotificationDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.fields.style.MercuryScrollBarUI; -import com.mercury.platform.ui.components.panel.message.InMessagePanel; +import com.mercury.platform.ui.components.panel.notification.InMessagePanel; import com.mercury.platform.ui.components.panel.VerticalScrollContainer; -import com.mercury.platform.ui.components.panel.message.NotificationMessageController; -import com.mercury.platform.ui.components.panel.message.MessagePanelStyle; +import com.mercury.platform.ui.components.panel.notification.NotificationMessageController; +import com.mercury.platform.ui.components.panel.notification.MessagePanelStyle; import com.mercury.platform.ui.frame.titled.AbstractTitledComponentFrame; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.MercuryStoreUI; @@ -28,10 +28,8 @@ public HistoryFrame() { this.setPreferredSize(frameDescriptor.getFrameSize()); this.componentsFactory.setScale(this.scaleConfig.get("other")); } - @Override - protected void initialize() { - super.initialize(); + public void onViewInit() { this.mainContainer = new VerticalScrollContainer(); this.mainContainer.setBackground(AppThemeColor.TRANSPARENT); this.mainContainer.setLayout(new BoxLayout(this.mainContainer,BoxLayout.Y_AXIS)); @@ -62,12 +60,12 @@ public void mouseWheelMoved(MouseWheelEvent e) { ArrayUtils.reverse(messages); for (String message : messages) { MessageParser parser = new MessageParser(); - Message parsedMessage = parser.parse(message); - if(parsedMessage != null) { + NotificationDescriptor parsedNotificationDescriptor = parser.parse(message); + if(parsedNotificationDescriptor != null) { InMessagePanel inMessagePanel = new InMessagePanel( - parsedMessage, + parsedNotificationDescriptor, MessagePanelStyle.HISTORY, - new NotificationMessageController(parsedMessage), + new NotificationMessageController(parsedNotificationDescriptor), this.componentsFactory); inMessagePanel.disableTime(); mainContainer.add(inMessagePanel); @@ -81,12 +79,12 @@ public void mouseWheelMoved(MouseWheelEvent e) { String[] nextMessages = HistoryManager.INSTANCE.fetchNext(5); for (String message : nextMessages) { MessageParser parser = new MessageParser(); - Message parsedMessage = parser.parse(message); - if(parsedMessage != null) { + NotificationDescriptor parsedNotificationDescriptor = parser.parse(message); + if(parsedNotificationDescriptor != null) { InMessagePanel inMessagePanel = new InMessagePanel( - parsedMessage, + parsedNotificationDescriptor, MessagePanelStyle.HISTORY, - new NotificationMessageController(parsedMessage), + new NotificationMessageController(parsedNotificationDescriptor), this.componentsFactory); inMessagePanel.disableTime(); this.mainContainer.add(inMessagePanel, 0); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java b/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java index 27dcc682..7cab202f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java @@ -12,6 +12,7 @@ import com.mercury.platform.ui.frame.movable.ItemsGridFrame; import com.mercury.platform.ui.frame.movable.AbstractMovableComponentFrame; import com.mercury.platform.ui.frame.movable.container.MessageFrame; +import com.mercury.platform.ui.frame.movable.container.NotificationFrame; import com.mercury.platform.ui.frame.other.*; import com.mercury.platform.ui.frame.movable.TaskBarFrame; import com.mercury.platform.ui.adr.AdrState; @@ -55,8 +56,8 @@ private FramesManager() { public void start(){ this.createTrayIcon(); - AbstractOverlaidFrame incMessageFrame = new MessageFrame(); - this.framesMap.put(MessageFrame.class,incMessageFrame); + AbstractOverlaidFrame incMessageFrame = new NotificationFrame(); + this.framesMap.put(NotificationFrame.class,incMessageFrame); AbstractOverlaidFrame taskBarFrame = new TaskBarFrame(); AbstractOverlaidFrame itemsMeshFrame = new ItemsGridFrame(); this.framesMap.put(ItemsGridFrame.class,itemsMeshFrame); @@ -78,7 +79,7 @@ public void start(){ this.framesMap.put(SettingsFrame.class,settingsFrame); this.framesMap.put(TestCasesFrame.class,new TestCasesFrame()); this.framesMap.put(TooltipFrame.class,new TooltipFrame()); - this.framesMap.put(NotificationFrame.class,new NotificationFrame()); + this.framesMap.put(NotificationAlertFrame.class,new NotificationAlertFrame()); this.framesMap.put(MercuryLoadingFrame.class,new MercuryLoadingFrame()); this.framesMap.put(ChatFilterFrame.class,new ChatFilterFrame()); this.framesMap.put(UpdateReadyFrame.class,new UpdateReadyFrame()); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java b/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java index 0f697b96..e121e797 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java @@ -3,13 +3,13 @@ import com.mercury.platform.shared.config.descriptor.adr.AdrComponentDescriptor; import com.mercury.platform.shared.config.descriptor.adr.AdrProfileDescriptor; -import com.mercury.platform.shared.entity.message.ItemMessage; -import com.mercury.platform.shared.entity.message.Message; +import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationDescriptor; import com.mercury.platform.ui.adr.routing.AdrComponentDefinition; import com.mercury.platform.ui.adr.routing.AdrPageDefinition; import com.mercury.platform.ui.components.panel.grid.ItemInfoPanel; import com.mercury.platform.ui.components.panel.grid.TabInfoPanel; -import com.mercury.platform.ui.components.panel.message.InMessagePanel; +import com.mercury.platform.ui.components.panel.notification.InMessagePanel; import com.mercury.platform.ui.dialog.DialogCallback; import com.mercury.platform.ui.manager.routing.SettingsPage; import rx.subjects.PublishSubject; @@ -17,8 +17,8 @@ import java.util.Map; public class MercuryStoreUI { - public static final PublishSubject closeGridItemSubject = PublishSubject.create(); - public static final PublishSubject closeMessage = PublishSubject.create(); + public static final PublishSubject closeGridItemSubject = PublishSubject.create(); + public static final PublishSubject closeMessage = PublishSubject.create(); public static final PublishSubject collapseMessageSubject = PublishSubject.create(); public static final PublishSubject dismissTabInfoPanelSubject = PublishSubject.create(); public static final PublishSubject expandMessageSubject = PublishSubject.create(); @@ -31,7 +31,7 @@ public class MercuryStoreUI { public static final PublishSubject itemPanelScaleSubject = PublishSubject.create(); public static final PublishSubject scrollToEndSubject = PublishSubject.create(); - public static final PublishSubject showItemGridSubject = PublishSubject.create(); + public static final PublishSubject showItemGridSubject = PublishSubject.create(); public static final PublishSubject> packSubject = PublishSubject.create(); public static final PublishSubject> repaintSubject = PublishSubject.create(); From 87c3d862ee77ab194f2306c282315dd73313d9cf Mon Sep 17 00:00:00 2001 From: Exslims Date: Wed, 16 Aug 2017 01:36:40 +0400 Subject: [PATCH 02/17] Notification panel rework, added outgoing panel + restyling --- .../NotificationConfigurationService.java | 8 +- .../NotificationSettingsDescriptor.java | 4 +- .../entity/message/NotificationType.java | 3 +- .../ui/components/ComponentsFactory.java | 7 + .../CurrencyIncNotificationPanel.java | 12 +- .../panel/notification/InMessagePanel.java | 5 +- .../IncomingNotificationPanel.java | 49 +++--- .../ItemIncNotificationPanel.java | 2 +- .../ItemOutNotificationPanel.java | 32 ++++ .../OutgoingNotificationPanel.java | 160 ++++++++++++++++++ .../IncomingPanelController.java} | 5 +- .../NotificationIncomingController.java} | 9 +- .../NotificationOutgoingController.java | 58 +++++++ .../controller/OutgoingPanelController.java | 12 ++ .../factory/CurrencyIncPanelProvider.java | 10 +- .../factory/ItemIncPanelProvider.java | 10 +- .../factory/ItemOutPanelProvider.java | 31 ++++ .../factory/NotificationPanelFactory.java | 1 + .../frame/movable/container/MessageFrame.java | 7 +- .../movable/container/NotificationFrame.java | 23 ++- .../ui/frame/titled/TestCasesFrame.java | 62 +++---- .../frame/titled/container/HistoryFrame.java | 8 +- .../platform/ui/misc/AppThemeColor.java | 13 +- app-ui/src/main/resources/app/invite.png | Bin 421 -> 373 bytes 24 files changed, 428 insertions(+), 103 deletions(-) create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemOutNotificationPanel.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutgoingNotificationPanel.java rename app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/{MessagePanelController.java => controller/IncomingPanelController.java} (59%) rename app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/{NotificationMessageController.java => controller/NotificationIncomingController.java} (89%) create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationOutgoingController.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/OutgoingPanelController.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemOutPanelProvider.java diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java index 1c17f7c9..becfc98c 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java @@ -25,8 +25,11 @@ public NotificationSettingsDescriptor getDefault() { defaultButtons.add(new ResponseButtonDescriptor(1,true,"thx","thanks",new HotKeyDescriptor())); defaultButtons.add(new ResponseButtonDescriptor(2,false,"no thx", "no thanks",new HotKeyDescriptor())); defaultButtons.add(new ResponseButtonDescriptor(3,false,"sold", "sold",new HotKeyDescriptor())); + + List defaultOutButtons = new ArrayList<>(); + defaultOutButtons.add(new ResponseButtonDescriptor(0,false,"thanks","thanks", new HotKeyDescriptor())); + notificationSettingsDescriptor.setButtons(defaultButtons); - notificationSettingsDescriptor.setNotificationEnable(true); notificationSettingsDescriptor.setLimitCount(3); notificationSettingsDescriptor.setUnfoldCount(2); notificationSettingsDescriptor.setDismissAfterKick(true); @@ -50,6 +53,9 @@ public void validate() { it.setHotKeyDescriptor(new HotKeyDescriptor()); } }); + if(this.get().getOutButtons().size() == 0){ + this.get().getOutButtons().add(new ResponseButtonDescriptor(0,false,"thanks","thanks", new HotKeyDescriptor())); + } } @Override diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationSettingsDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationSettingsDescriptor.java index 962c7632..f07ef9e5 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationSettingsDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationSettingsDescriptor.java @@ -4,6 +4,7 @@ import lombok.Data; import java.io.Serializable; +import java.util.ArrayList; import java.util.List; @Data @@ -14,5 +15,6 @@ public class NotificationSettingsDescriptor implements Serializable{ private FlowDirections flowDirections; private boolean dismissAfterKick; private boolean showLeague; - private List buttons; + private List buttons = new ArrayList<>(); + private List outButtons = new ArrayList<>(); } diff --git a/app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationType.java b/app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationType.java index c2e6fa01..c88690fe 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationType.java +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationType.java @@ -4,6 +4,7 @@ public enum NotificationType { INC_ITEM_MESSAGE, INC_CURRENCY_MESSAGE, - OUTGOING_MESSAGE, + OUT_ITEM_MESSAGE, + OUT_CURRENCY_MESSAGE, SCANNER_MESSAGE } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java b/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java index aab7f33f..d286af06 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java @@ -159,6 +159,13 @@ public JButton getBorderedButton(String text, float fontSize){ ); return getButton(FontStyle.BOLD, AppThemeColor.BUTTON, compoundBorder, text, scale*fontSize); } + public JButton getBorderedButton(String text, float fontSize, Color background, Color outerBorderColor, Color innerBorderColor){ + CompoundBorder compoundBorder = BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(outerBorderColor, 1), + BorderFactory.createLineBorder(innerBorderColor, 3) + ); + return getButton(FontStyle.BOLD, background, compoundBorder, text, scale*fontSize); + } public Component setUpToggleCallbacks(Component button,ToggleCallback firstState, ToggleCallback secondState, boolean initialState){ button.addMouseListener(new MouseAdapter() { diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyIncNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyIncNotificationPanel.java index f0e3c37f..163d02cc 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyIncNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyIncNotificationPanel.java @@ -1,19 +1,13 @@ package com.mercury.platform.ui.components.panel.notification; import com.mercury.platform.shared.entity.message.CurrencyTradeNotificationDescriptor; -import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.frame.movable.container.MessageFrame; import com.mercury.platform.ui.misc.AppThemeColor; -import com.mercury.platform.ui.misc.MercuryStoreUI; import com.mercury.platform.ui.misc.TooltipConstants; import javax.swing.*; -import javax.swing.border.CompoundBorder; import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; import java.text.DecimalFormat; @@ -46,14 +40,14 @@ private JPanel getCurrencyRatePanel(){ DecimalFormat decimalFormat = new DecimalFormat("#.####"); JPanel ratePanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); ratePanel.add(componentsFactory. - getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 18f, null,"(")); + getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 18f, null,"(")); JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + this.data.getCurrency() + ".png", 26); currencyLabel.setBorder(null); ratePanel.add(currencyLabel); ratePanel.add(componentsFactory. - getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 18f, null,decimalFormat.format(rate))); + getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 18f, null,decimalFormat.format(rate))); ratePanel.add(componentsFactory. - getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 18f, null,")")); + getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 18f, null,")")); ratePanel.setBorder(BorderFactory.createEmptyBorder(-5,0,-5,0)); return ratePanel; } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/InMessagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/InMessagePanel.java index 298018db..223b1cff 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/InMessagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/InMessagePanel.java @@ -16,6 +16,7 @@ import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; import com.mercury.platform.ui.components.panel.misc.ViewInit; +import com.mercury.platform.ui.components.panel.notification.controller.IncomingPanelController; import com.mercury.platform.ui.frame.movable.container.MessageFrame; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.HasHotkey; @@ -45,7 +46,7 @@ public class InMessagePanel extends JPanel implements AsSubscriber, ViewInit,Has private ComponentsFactory componentsFactory; private PlainConfigurationService notificationService; - private MessagePanelController controller; + private IncomingPanelController controller; private MessagePanelStyle style; private String whisper; @@ -76,7 +77,7 @@ private InMessagePanel(NotificationDescriptor notificationDescriptor, MessagePan this.initHotKeyListeners(); } } - public InMessagePanel(NotificationDescriptor notificationDescriptor, MessagePanelStyle style, MessagePanelController controller, ComponentsFactory componentsFactory){ + public InMessagePanel(NotificationDescriptor notificationDescriptor, MessagePanelStyle style, IncomingPanelController controller, ComponentsFactory componentsFactory){ this(notificationDescriptor,style); this.componentsFactory = componentsFactory; this.controller = controller; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java index 59b8c93f..b6ac20c6 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java @@ -8,12 +8,12 @@ import com.mercury.platform.shared.entity.message.TradeNotificationDescriptor; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; +import com.mercury.platform.ui.components.panel.notification.controller.IncomingPanelController; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.TooltipConstants; import javax.swing.*; import javax.swing.Timer; -import javax.swing.border.CompoundBorder; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -22,7 +22,7 @@ import java.util.*; import java.util.List; -public abstract class IncomingNotificationPanel extends NotificationPanel{ +public abstract class IncomingNotificationPanel extends NotificationPanel{ private PlainConfigurationService config; @Override public void onViewInit() { @@ -31,7 +31,7 @@ public void onViewInit() { this.setBackground(AppThemeColor.FRAME); this.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(1,1,1,1), - BorderFactory.createLineBorder(AppThemeColor.BORDER, 1))); + BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON_BORDER, 1))); this.add(this.getHeader(),BorderLayout.PAGE_START); this.add(this.getMessagePanel(),BorderLayout.CENTER); @@ -43,31 +43,29 @@ private JPanel getHeader(){ JLabel nicknameLabel = this.componentsFactory.getTextLabel(FontStyle.BOLD,AppThemeColor.TEXT_NICKNAME, TextAlignment.LEFTOP,15f,this.getNicknameText()); nicknameLabel.setBorder(BorderFactory.createEmptyBorder(0,5,0,5)); - - root.add(this.getExpandButton(),BorderLayout.LINE_START); root.add(nicknameLabel,BorderLayout.CENTER); - JPanel interactionPanel = new JPanel(new GridLayout(1,0)); - interactionPanel.setPreferredSize(new Dimension(220, 16)); + JPanel opPanel = this.componentsFactory.getJPanel(new BorderLayout(),AppThemeColor.MSG_HEADER); + JPanel interactionPanel = new JPanel(new GridLayout(1,0,4,0)); + interactionPanel.setPreferredSize(new Dimension(200,26)); interactionPanel.setBackground(AppThemeColor.MSG_HEADER); - JButton inviteButton = componentsFactory.getIconButton("app/invite.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.INVITE); + JButton inviteButton = componentsFactory.getIconButton("app/invite.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.INVITE); inviteButton.addActionListener(e -> this.controller.performInvite()); - JButton kickButton = componentsFactory.getIconButton("app/kick.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.KICK); + JButton kickButton = componentsFactory.getIconButton("app/kick.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.KICK); kickButton.addActionListener(e -> { this.controller.performKick(); if(this.config.get().isDismissAfterKick()){ this.controller.performHide(); } }); - JButton tradeButton = componentsFactory.getIconButton("app/trade.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.TRADE); + JButton tradeButton = componentsFactory.getIconButton("app/trade.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.TRADE); tradeButton.addActionListener(e -> this.controller.performOfferTrade()); - JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); + JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); openChatButton.addActionListener(e -> controller.performOpenChat()); - JButton hideButton = componentsFactory.getIconButton("app/close.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.HIDE_PANEL); + JButton hideButton = componentsFactory.getIconButton("app/close.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.HIDE_PANEL); hideButton.addActionListener(action -> { this.controller.performHide(); }); - interactionPanel.add(this.getTimePanel()); interactionPanel.add(inviteButton); interactionPanel.add(kickButton); interactionPanel.add(tradeButton); @@ -75,7 +73,12 @@ private JPanel getHeader(){ interactionPanel.add(openChatButton); interactionPanel.add(hideButton); - root.add(interactionPanel,BorderLayout.LINE_END); + JPanel timePanel = this.getTimePanel(); + timePanel.setPreferredSize(new Dimension(50,26)); + opPanel.add(timePanel,BorderLayout.CENTER); + opPanel.add(interactionPanel,BorderLayout.LINE_END); + + root.add(opPanel,BorderLayout.LINE_END); return root; } @Override @@ -93,7 +96,7 @@ protected JPanel getForPanel(){ forPanel.setBackground(AppThemeColor.FRAME); JLabel separator = componentsFactory.getTextLabel( FontStyle.BOLD, - AppThemeColor.TEXT_MESSAGE, + AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 18f, "=>"); @@ -113,10 +116,10 @@ protected JPanel getCurrencyPanel(Double curCount, String curIconPath){ String.valueOf(curCount); } if(!Objects.equals(curCountStr, "") && curIconPath != null) { - JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + curIconPath + ".png", 26); + JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + curIconPath + ".png", 28); JPanel curPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); curPanel.setBackground(AppThemeColor.FRAME); - curPanel.add(this.componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER,17f,null, curCountStr)); + curPanel.add(this.componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER,17f,null, curCountStr)); curPanel.add(currencyLabel); return curPanel; } @@ -125,7 +128,7 @@ protected JPanel getCurrencyPanel(Double curCount, String curIconPath){ protected JLabel getOfferLabel(){ String offer = this.data.getOffer(); if(offer != null && offer.trim().length() > 0) { - JLabel offerLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 17f, offer); + JLabel offerLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 16f, offer); offerLabel.setHorizontalAlignment(SwingConstants.CENTER); return offerLabel; } @@ -139,24 +142,24 @@ private JPanel getResponseButtonsPanel(){ List buttonsConfig = this.config.get().getButtons(); Collections.sort(buttonsConfig); buttonsConfig.forEach((buttonConfig)->{ - JButton button = componentsFactory.getBorderedButton(buttonConfig.getTitle(),16f); + JButton button = componentsFactory.getBorderedButton(buttonConfig.getTitle(),16f,AppThemeColor.RESPONSE_BUTTON, AppThemeColor.RESPONSE_BUTTON_BORDER,AppThemeColor.RESPONSE_BUTTON); if(buttonConfig.getTitle().length() < 10) { - button.setPreferredSize(new Dimension(70, 26)); + button.setPreferredSize(new Dimension(60, 26)); } button.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { button.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(AppThemeColor.ADR_SELECTED_BORDER, 1), - BorderFactory.createLineBorder(AppThemeColor.BUTTON, 3) + BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON, 3) )); } @Override public void mouseExited(MouseEvent e) { button.setBorder( BorderFactory.createCompoundBorder( - BorderFactory.createLineBorder(AppThemeColor.BORDER, 1), - BorderFactory.createLineBorder(AppThemeColor.BUTTON, 3) + BorderFactory.createLineBorder(AppThemeColor.MSG_HEADER_BORDER, 1), + BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON, 3) )); } }); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemIncNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemIncNotificationPanel.java index 84780642..949f5da7 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemIncNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemIncNotificationPanel.java @@ -24,7 +24,7 @@ protected JPanel getMessagePanel() { FontStyle.BOLD, AppThemeColor.BUTTON, BorderFactory.createEmptyBorder(0,4,0,2), - this.data.getItemName(), 17f); + this.data.getItemName(), 16f); itemButton.setForeground(AppThemeColor.TEXT_IMPORTANT); itemButton.setBackground(AppThemeColor.TRANSPARENT); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemOutNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemOutNotificationPanel.java new file mode 100644 index 00000000..a227f819 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemOutNotificationPanel.java @@ -0,0 +1,32 @@ +package com.mercury.platform.ui.components.panel.notification; + +import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.misc.AppThemeColor; + +import javax.swing.*; +import java.awt.*; + + +public class ItemOutNotificationPanel extends OutgoingNotificationPanel { + @Override + protected JPanel getContentPanel() { + JPanel root = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); + JButton itemButton = componentsFactory.getButton( + FontStyle.BOLD, + AppThemeColor.BUTTON, + BorderFactory.createEmptyBorder(0,4,0,2), + this.data.getItemName(), 16f); + + itemButton.setForeground(AppThemeColor.TEXT_IMPORTANT); + itemButton.setBackground(AppThemeColor.TRANSPARENT); + itemButton.setHorizontalAlignment(SwingConstants.LEFT); + itemButton.setContentAreaFilled(false); + itemButton.setRolloverEnabled(false); + itemButton.addActionListener(action -> { + }); + root.add(this.getFromPanel(),BorderLayout.LINE_START); + root.add(itemButton,BorderLayout.CENTER); + return root; + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutgoingNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutgoingNotificationPanel.java new file mode 100644 index 00000000..a29528d8 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutgoingNotificationPanel.java @@ -0,0 +1,160 @@ +package com.mercury.platform.ui.components.panel.notification; + +import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.configration.PlainConfigurationService; +import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; +import com.mercury.platform.shared.config.descriptor.ResponseButtonDescriptor; +import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.shared.entity.message.TradeNotificationDescriptor; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.components.fields.font.TextAlignment; +import com.mercury.platform.ui.components.panel.notification.controller.OutgoingPanelController; +import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.TooltipConstants; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.*; +import java.util.List; + +public abstract class OutgoingNotificationPanel extends NotificationPanel { + private PlainConfigurationService config; + @Override + public void onViewInit() { + this.config = Configuration.get().notificationConfiguration(); + this.setBackground(AppThemeColor.FRAME); + this.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createEmptyBorder(1,1,1,1), + BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON_BORDER, 1))); + this.setLayout(new BorderLayout()); + this.add(this.getHeader(),BorderLayout.PAGE_START); + JPanel bottomPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); + bottomPanel.add(this.getContentPanel(),BorderLayout.CENTER); + bottomPanel.add(this.componentsFactory.wrapToSlide(this.getResponseButtonsPanel(),AppThemeColor.FRAME),BorderLayout.LINE_END); + this.add(bottomPanel,BorderLayout.CENTER); + } + + private JPanel getHeader(){ + JPanel root = new JPanel(new BorderLayout()); + root.setBackground(AppThemeColor.MSG_HEADER); + + JLabel nicknameLabel = this.componentsFactory.getTextLabel(FontStyle.BOLD,AppThemeColor.TEXT_NICKNAME, TextAlignment.LEFTOP,15f,this.data.getWhisperNickname()); + nicknameLabel.setBorder(BorderFactory.createEmptyBorder(0,5,0,5)); + + root.add(nicknameLabel,BorderLayout.CENTER); + + JPanel interactionPanel = new JPanel(new GridLayout(1,0,4,0)); + interactionPanel.setPreferredSize(new Dimension(200,26)); + interactionPanel.setBackground(AppThemeColor.MSG_HEADER); + JButton visiteHideout = componentsFactory.getIconButton("app/visiteHideout.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.INVITE); + visiteHideout.addActionListener(e -> this.controller.visitHideout()); + JButton tradeButton = componentsFactory.getIconButton("app/trade.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.TRADE); + tradeButton.addActionListener(e -> this.controller.performTrade()); + JButton leaveButton = componentsFactory.getIconButton("app/leave.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.KICK); + leaveButton.addActionListener(e -> { + this.controller.performLeave(); + if(this.config.get().isDismissAfterKick()){ + this.controller.performHide(); + } + }); + JButton backToHo = componentsFactory.getIconButton("app/backToHideout.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); + backToHo.addActionListener(e -> controller.backToHideout()); + JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); + openChatButton.addActionListener(e -> controller.performOpenChat()); + JButton hideButton = componentsFactory.getIconButton("app/close.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.HIDE_PANEL); + hideButton.addActionListener(action -> { + this.controller.performHide(); + }); + interactionPanel.add(visiteHideout); + interactionPanel.add(tradeButton); + interactionPanel.add(leaveButton); + interactionPanel.add(backToHo); + interactionPanel.add(openChatButton); + interactionPanel.add(hideButton); + + root.add(interactionPanel,BorderLayout.LINE_END); + return root; + } + private JPanel getResponseButtonsPanel(){ + JPanel root = new JPanel(new GridLayout(1,0,0,5)); + root.setBackground(AppThemeColor.FRAME); + List buttonsConfig = this.config.get().getOutButtons(); + Collections.sort(buttonsConfig); + buttonsConfig.forEach((buttonConfig)->{ + JButton button = componentsFactory.getBorderedButton(buttonConfig.getTitle(),16f,AppThemeColor.RESPONSE_BUTTON, AppThemeColor.RESPONSE_BUTTON_BORDER,AppThemeColor.RESPONSE_BUTTON); + button.addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + button.setBorder( BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(AppThemeColor.ADR_SELECTED_BORDER, 1), + BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON, 3) + )); + } + + @Override + public void mouseExited(MouseEvent e) { + button.setBorder( BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(AppThemeColor.MSG_HEADER_BORDER, 1), + BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON, 3) + )); + } + }); + button.addActionListener(e -> { + this.controller.performResponse(buttonConfig.getResponseText()); + if(buttonConfig.isClose()){ + this.controller.performHide(); + } + }); + root.add(button); + }); + return root; + } + protected JPanel getFromPanel(){ + JPanel forPanel = new JPanel(new BorderLayout()); + forPanel.setBackground(AppThemeColor.FRAME); + JPanel currencyPanel = this.getCurrencyPanel(this.data.getCurCount(),this.data.getCurrency()); + if(currencyPanel != null) { + currencyPanel.setPreferredSize(new Dimension(70,36)); + forPanel.add(currencyPanel, BorderLayout.LINE_START); + } + JLabel separator = componentsFactory.getTextLabel( + FontStyle.BOLD, + AppThemeColor.TEXT_DEFAULT, + TextAlignment.CENTER, + 18f, + "=>"); + forPanel.add(separator,BorderLayout.CENTER); + separator.setHorizontalAlignment(SwingConstants.CENTER); + return forPanel; + } + protected JPanel getCurrencyPanel(Double curCount, String curIconPath){ + String curCountStr = " "; + if(curCount > 0) { + curCountStr = curCount % 1 == 0 ? + String.valueOf(curCount.intValue()) : + String.valueOf(curCount); + } + if(!Objects.equals(curCountStr, "") && curIconPath != null) { + JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + curIconPath + ".png", 28); + JPanel curPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + curPanel.setBackground(AppThemeColor.FRAME); + curPanel.add(this.componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP,17f,null, curCountStr)); + curPanel.add(currencyLabel); + return curPanel; + } + return null; + } + @Override + public void subscribe() { + + } + + protected abstract JPanel getContentPanel(); + + @Override + public void onViewDestroy() { + + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/MessagePanelController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/IncomingPanelController.java similarity index 59% rename from app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/MessagePanelController.java rename to app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/IncomingPanelController.java index 1ed4f23e..06e1a89e 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/MessagePanelController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/IncomingPanelController.java @@ -1,8 +1,9 @@ -package com.mercury.platform.ui.components.panel.notification; +package com.mercury.platform.ui.components.panel.notification.controller; +import com.mercury.platform.ui.components.panel.notification.InMessagePanel; import lombok.NonNull; -public interface MessagePanelController { +public interface IncomingPanelController { void performInvite(); void performKick(); void performOfferTrade(); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationMessageController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationIncomingController.java similarity index 89% rename from app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationMessageController.java rename to app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationIncomingController.java index 989a7592..0361bc51 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationMessageController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationIncomingController.java @@ -1,8 +1,9 @@ -package com.mercury.platform.ui.components.panel.notification; +package com.mercury.platform.ui.components.panel.notification.controller; import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; import com.mercury.platform.shared.entity.message.NotificationDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; +import com.mercury.platform.ui.components.panel.notification.InMessagePanel; import com.mercury.platform.ui.misc.MercuryStoreUI; import lombok.NonNull; import org.apache.logging.log4j.LogManager; @@ -14,10 +15,10 @@ import java.awt.datatransfer.StringSelection; //todo proxy -public class NotificationMessageController implements MessagePanelController { - private static final Logger log = LogManager.getLogger(NotificationMessageController.class); +public class NotificationIncomingController implements IncomingPanelController { + private static final Logger log = LogManager.getLogger(NotificationIncomingController.class); private NotificationDescriptor notificationDescriptor; - public NotificationMessageController(NotificationDescriptor notificationDescriptor){ + public NotificationIncomingController(NotificationDescriptor notificationDescriptor){ this.notificationDescriptor = notificationDescriptor; } @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationOutgoingController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationOutgoingController.java new file mode 100644 index 00000000..58e153ef --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationOutgoingController.java @@ -0,0 +1,58 @@ +package com.mercury.platform.ui.components.panel.notification.controller; + + +import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.shared.store.MercuryStoreCore; + +import javax.swing.*; + +public class NotificationOutgoingController implements OutgoingPanelController{ + private NotificationDescriptor notificationDescriptor; + + public NotificationOutgoingController(NotificationDescriptor notificationDescriptor) { + this.notificationDescriptor = notificationDescriptor; + } + + @Override + public void visitHideout() { + + } + + @Override + public void backToHideout() { + + } + + @Override + public void performTrade() { + + } + + @Override + public void performLeave() { + + } + + @Override + public void performHide() { + this.closeMessagePanel(); + } + + @Override + public void performOpenChat() { + + } + + @Override + public void performResponse(String response) { + + } + + private void closeMessagePanel(){ + Timer timer = new Timer(30, action -> { + MercuryStoreCore.removeNotificationSubject.onNext(notificationDescriptor); + }); + timer.setRepeats(false); + timer.start(); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/OutgoingPanelController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/OutgoingPanelController.java new file mode 100644 index 00000000..7ece358d --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/OutgoingPanelController.java @@ -0,0 +1,12 @@ +package com.mercury.platform.ui.components.panel.notification.controller; + + +public interface OutgoingPanelController { + void visitHideout(); + void backToHideout(); + void performTrade(); + void performLeave(); + void performHide(); + void performOpenChat(); + void performResponse(String response); +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyIncPanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyIncPanelProvider.java index bc7809b7..624dab8c 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyIncPanelProvider.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyIncPanelProvider.java @@ -3,24 +3,24 @@ import com.mercury.platform.shared.entity.message.CurrencyTradeNotificationDescriptor; import com.mercury.platform.shared.entity.message.NotificationType; import com.mercury.platform.ui.components.panel.notification.CurrencyIncNotificationPanel; -import com.mercury.platform.ui.components.panel.notification.MessagePanelController; -import com.mercury.platform.ui.components.panel.notification.NotificationMessageController; +import com.mercury.platform.ui.components.panel.notification.controller.IncomingPanelController; +import com.mercury.platform.ui.components.panel.notification.controller.NotificationIncomingController; import com.mercury.platform.ui.components.panel.notification.NotificationPanel; -public class CurrencyIncPanelProvider extends NotificationPanelProvider { +public class CurrencyIncPanelProvider extends NotificationPanelProvider { @Override public boolean isSuitable(NotificationType type) { return type.equals(NotificationType.INC_CURRENCY_MESSAGE); } @Override - public NotificationPanel build() { + public NotificationPanel build() { CurrencyIncNotificationPanel panel = new CurrencyIncNotificationPanel(); panel.setData(this.data); if(this.controller != null){ panel.setController(this.controller); }else { - panel.setController(new NotificationMessageController(this.data)); + panel.setController(new NotificationIncomingController(this.data)); } panel.setComponentsFactory(this.componentsFactory); panel.subscribe(); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemIncPanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemIncPanelProvider.java index 4946f58b..cb0c3320 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemIncPanelProvider.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemIncPanelProvider.java @@ -3,25 +3,25 @@ import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; import com.mercury.platform.shared.entity.message.NotificationType; import com.mercury.platform.ui.components.panel.notification.ItemIncNotificationPanel; -import com.mercury.platform.ui.components.panel.notification.MessagePanelController; -import com.mercury.platform.ui.components.panel.notification.NotificationMessageController; +import com.mercury.platform.ui.components.panel.notification.controller.IncomingPanelController; +import com.mercury.platform.ui.components.panel.notification.controller.NotificationIncomingController; import com.mercury.platform.ui.components.panel.notification.NotificationPanel; -public class ItemIncPanelProvider extends NotificationPanelProvider { +public class ItemIncPanelProvider extends NotificationPanelProvider { @Override public boolean isSuitable(NotificationType type) { return type.equals(NotificationType.INC_ITEM_MESSAGE); } @Override - public NotificationPanel build() { + public NotificationPanel build() { ItemIncNotificationPanel panel = new ItemIncNotificationPanel(); panel.setData(this.data); if(this.controller != null){ panel.setController(this.controller); }else { - panel.setController(new NotificationMessageController(this.data)); + panel.setController(new NotificationIncomingController(this.data)); } panel.setComponentsFactory(this.componentsFactory); panel.subscribe(); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemOutPanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemOutPanelProvider.java new file mode 100644 index 00000000..cdc673ba --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemOutPanelProvider.java @@ -0,0 +1,31 @@ +package com.mercury.platform.ui.components.panel.notification.factory; + +import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationType; +import com.mercury.platform.ui.components.panel.notification.ItemOutNotificationPanel; +import com.mercury.platform.ui.components.panel.notification.NotificationPanel; +import com.mercury.platform.ui.components.panel.notification.controller.NotificationOutgoingController; +import com.mercury.platform.ui.components.panel.notification.controller.OutgoingPanelController; + + +public class ItemOutPanelProvider extends NotificationPanelProvider { + @Override + public boolean isSuitable(NotificationType type) { + return type.equals(NotificationType.OUT_ITEM_MESSAGE); + } + + @Override + public NotificationPanel build() { + ItemOutNotificationPanel panel = new ItemOutNotificationPanel(); + panel.setData(this.data); + if(this.controller != null){ + panel.setController(this.controller); + }else { + panel.setController(new NotificationOutgoingController(this.data)); + } + panel.setComponentsFactory(this.componentsFactory); + panel.subscribe(); + panel.onViewInit(); + return panel; + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelFactory.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelFactory.java index ebd16c54..fab82337 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelFactory.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelFactory.java @@ -13,6 +13,7 @@ public class NotificationPanelFactory { public NotificationPanelFactory() { this.providers.add(new ItemIncPanelProvider()); this.providers.add(new CurrencyIncPanelProvider()); + this.providers.add(new ItemOutPanelProvider()); } public NotificationPanelProvider getProviderFor(NotificationType type){ diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java index 3fe36348..90f73126 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java @@ -14,6 +14,7 @@ import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; import com.mercury.platform.ui.components.panel.notification.*; +import com.mercury.platform.ui.components.panel.notification.controller.IncomingPanelController; import com.mercury.platform.ui.components.panel.notification.factory.NotificationPanelFactory; import com.mercury.platform.ui.frame.movable.AbstractMovableComponentFrame; import com.mercury.platform.ui.frame.AbstractOverlaidFrame; @@ -526,7 +527,7 @@ protected JPanel defaultView(ComponentsFactory factory) { JPanel panel = factory.getTransparentPanel(); panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS)); panel.setBackground(AppThemeColor.FRAME); - MessagePanelController stubController = new MessagePanelController() { + IncomingPanelController stubController = new IncomingPanelController() { @Override public void performInvite() {} @Override @@ -568,8 +569,8 @@ protected void initialize() { this.componentsFactory = MessageFrame.this.componentsFactory; this.setBackground(AppThemeColor.MSG_HEADER); this.getRootPane().setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createMatteBorder(1,1,1,0,AppThemeColor.TRANSPARENT), - BorderFactory.createMatteBorder(1,1,1,1,AppThemeColor.BORDER))); + BorderFactory.createMatteBorder(1,1,1,0,AppThemeColor.TRANSPARENT), + BorderFactory.createMatteBorder(1,1,1,1,AppThemeColor.BORDER))); labelPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); labelPanel.setBackground(AppThemeColor.MSG_HEADER); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java index 0c6499b4..3c44d237 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java @@ -3,6 +3,7 @@ import com.mercury.platform.shared.config.Configuration; import com.mercury.platform.shared.config.configration.PlainConfigurationService; import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; +import com.mercury.platform.shared.entity.message.FlowDirections; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.panel.VerticalScrollContainer; @@ -95,6 +96,26 @@ protected LayoutManager getFrameLayout() { } private JPanel getExpandPanel(){ - return new JPanel(); + JPanel root = this.componentsFactory.getJPanel(new BorderLayout()); + root.setBackground(AppThemeColor.MSG_HEADER); + root.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createMatteBorder(1,1,1,0,AppThemeColor.FRAME), + BorderFactory.createMatteBorder(1,1,1,1,AppThemeColor.RESPONSE_BUTTON_BORDER))); + + JPanel labelPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); + labelPanel.setBackground(AppThemeColor.MSG_HEADER); + labelPanel.setPreferredSize(new Dimension((int)(10 * componentsFactory.getScale()),(int)(22 * componentsFactory.getScale()))); + labelPanel.setBorder(BorderFactory.createEmptyBorder(-4,0,0,0)); + JLabel msgCountLabel = componentsFactory.getTextLabel("+" + String.valueOf("12")); + String iconPath = "app/collapse-all.png"; + JButton expandButton = componentsFactory.getIconButton(iconPath,22,AppThemeColor.MSG_HEADER,""); + expandButton.addActionListener(action -> { + + }); + expandButton.setAlignmentY(SwingConstants.CENTER); + labelPanel.add(msgCountLabel); + root.add(expandButton,BorderLayout.CENTER); + root.add(labelPanel,BorderLayout.PAGE_END); + return root; } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java index adc1e12a..c640801e 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java @@ -3,6 +3,7 @@ import com.mercury.platform.core.misc.SoundType; import com.mercury.platform.shared.MessageParser; import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationType; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.misc.AppThemeColor; @@ -183,7 +184,7 @@ public void mousePressed(MouseEvent e) { }); testPanel.add(button,buttonColumn); buttonColumn.gridy++; - JLabel textLabel = componentsFactory.getTextLabel("Random item message"); + JLabel textLabel = componentsFactory.getTextLabel("Random incoming item message"); testPanel.add(textLabel,titleColumn); titleColumn.gridy++; @@ -249,41 +250,30 @@ public void mousePressed(MouseEvent e) { testPanel.add(textLabel2,titleColumn); titleColumn.gridy++; -// JButton button3 = componentsFactory.getBorderedButton("Click"); -// button3.addMouseListener(new MouseAdapter() { -// @Override -// public void mousePressed(MouseEvent e) { -// EventRouter.CORE.fireEvent(new UpdateReadyEvent()); -// } -// }); -// testPanel.add(button3,buttonColumn); -// buttonColumn.gridy++; -// JLabel textLabel3 = componentsFactory.getTextLabel("Test update frame"); -// testPanel.add(textLabel3,titleColumn); -// titleColumn.gridy++; -// testPanel.setBackground(AppThemeColor.TRANSPARENT); - -// JButton button4 = componentsFactory.getBorderedButton("Click"); -// button4.addMouseListener(new MouseAdapter() { -// @Override -// public void mousePressed(MouseEvent e) { -// Message message = parser.parse(String.format(poeTradeTemplate, -// "Example", -// items.get(random.nextInt(items.size())), -// random.nextInt(200), -// "chaos", -// random.nextInt(12) + 1, -// random.nextInt(12) + 1, -// "can sell cheaper??" -// )); -// EventRouter.CORE.fireEvent(new NewWhispersEvent(message)); -// } -// }); -// testPanel.add(button4,buttonColumn); -// buttonColumn.gridy++; -// JLabel textLabel4 = componentsFactory.getTextLabel("Placeholder"); -// testPanel.add(textLabel4,titleColumn); -// titleColumn.gridy++; + JButton outItemButton = componentsFactory.getBorderedButton("Click"); + outItemButton.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + NotificationDescriptor notificationDescriptor = parser.parse(String.format(poeTradeTemplate, + nickNames.get(random.nextInt(nickNames.size())), + items.get(random.nextInt(items.size())), + random.nextInt(200), + currency.get(random.nextInt(currency.size())), + leagues.get(random.nextInt(leagues.size())), + random.nextInt(30), + random.nextInt(12) + 1, + random.nextInt(12) + 1, + offer.get(random.nextInt(offer.size())) + )); + notificationDescriptor.setType(NotificationType.OUT_ITEM_MESSAGE); + MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); + } + }); + testPanel.add(outItemButton,buttonColumn); + buttonColumn.gridy++; + JLabel outItemLabel = componentsFactory.getTextLabel("Random outgoing item message"); + testPanel.add(outItemLabel,titleColumn); + titleColumn.gridy++; testPanel.setBackground(AppThemeColor.TRANSPARENT); return testPanel; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryFrame.java index cf265e2a..c60996cb 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryFrame.java @@ -8,7 +8,7 @@ import com.mercury.platform.ui.components.fields.style.MercuryScrollBarUI; import com.mercury.platform.ui.components.panel.notification.InMessagePanel; import com.mercury.platform.ui.components.panel.VerticalScrollContainer; -import com.mercury.platform.ui.components.panel.notification.NotificationMessageController; +import com.mercury.platform.ui.components.panel.notification.controller.NotificationIncomingController; import com.mercury.platform.ui.components.panel.notification.MessagePanelStyle; import com.mercury.platform.ui.frame.titled.AbstractTitledComponentFrame; import com.mercury.platform.ui.misc.AppThemeColor; @@ -65,7 +65,7 @@ public void mouseWheelMoved(MouseWheelEvent e) { InMessagePanel inMessagePanel = new InMessagePanel( parsedNotificationDescriptor, MessagePanelStyle.HISTORY, - new NotificationMessageController(parsedNotificationDescriptor), + new NotificationIncomingController(parsedNotificationDescriptor), this.componentsFactory); inMessagePanel.disableTime(); mainContainer.add(inMessagePanel); @@ -84,7 +84,7 @@ public void mouseWheelMoved(MouseWheelEvent e) { InMessagePanel inMessagePanel = new InMessagePanel( parsedNotificationDescriptor, MessagePanelStyle.HISTORY, - new NotificationMessageController(parsedNotificationDescriptor), + new NotificationIncomingController(parsedNotificationDescriptor), this.componentsFactory); inMessagePanel.disableTime(); this.mainContainer.add(inMessagePanel, 0); @@ -125,7 +125,7 @@ public void subscribe() { InMessagePanel inMessagePanel = new InMessagePanel( message, MessagePanelStyle.HISTORY, - new NotificationMessageController(message), + new NotificationIncomingController(message), this.componentsFactory); this.mainContainer.add(inMessagePanel); this.trimContainer(); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/misc/AppThemeColor.java b/app-ui/src/main/java/com/mercury/platform/ui/misc/AppThemeColor.java index d4192e09..a9398f91 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/misc/AppThemeColor.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/misc/AppThemeColor.java @@ -3,7 +3,7 @@ import java.awt.*; public class AppThemeColor { - public static final Color BUTTON = new Color(16,91,99); + public static final Color BUTTON = new Color(52, 62, 61); public static final Color SCROLL_BAR = new Color(44, 70, 80); public static final Color TEXT_DEFAULT = new Color(255,250,250); public static final Color TEXT_MESSAGE = new Color(255,250,213); @@ -12,8 +12,8 @@ public class AppThemeColor { public static final Color TEXT_IMPORTANT = new Color(224,86,60); public static final Color TEXT_SUCCESS = new Color(111, 173, 39); public static final Color TEXT_DISABLE = new Color(126,130,122); - public static final Color BORDER = new Color(22,126,138); - public static final Color BORDER_DARK = new Color(23, 103, 115); + public static final Color BORDER = new Color(70, 81, 80); + public static final Color BORDER_DARK = new Color(62, 73, 72); public static final Color FRAME = new Color(42, 44, 43,254); public static final Color FRAME_RGB = new Color(42, 44, 43); public static final Color FRAME_ALPHA = new Color(42, 44, 43,1); @@ -25,13 +25,16 @@ public class AppThemeColor { public static final Color MSG_HEADER = new Color(52, 62, 61); public static final Color MSG_HEADER_BORDER = new Color(62, 73, 72); - public static final Color ADR_SELECTED_BORDER = new Color(255,250,213); + public static final Color RESPONSE_BUTTON = new Color(52, 62, 61); + public static final Color RESPONSE_BUTTON_BORDER = new Color(70, 81, 80); + + public static final Color ADR_SELECTED_BORDER = new Color(198, 193, 154); public static final Color ADR_POPUP_BG = new Color(212, 207, 171); public static final Color ADR_MOUSE_OVER_BORDER = new Color(155, 150, 120); public static final Color ADR_DEFAULT_BORDER = new Color(62, 73, 72); public static final Color ADR_BG = new Color(45, 55, 54); public static final Color ADR_TRACKER_GROUP_BG = new Color(35, 45, 44); - public static final Color ADR_PANEL_BORDER = new Color(23, 103, 115); + public static final Color ADR_PANEL_BORDER = new Color(70, 81, 80); public static final Color ADR_TEXT_ARE_BG = new Color(50, 52, 51); public static final Color ADR_FOOTER_BG = new Color(55,65,64); public static final Color ADR_CAPTURE_BG = new Color(42, 44, 43,1); diff --git a/app-ui/src/main/resources/app/invite.png b/app-ui/src/main/resources/app/invite.png index 27238704af444bd9cece74b28bd5ac8fda0c19eb..4b11cdde3294f9c8419e865e43d53700773238de 100644 GIT binary patch delta 294 zcmZ3={FP~f4c7q%2EGG~S=Tx_C%P%r8=EjkS1~X!eDZX045^5Fdqa`$kb{8RLphf7 z%SvS!nYS}EEnqpgF<`f%#3A1R4Ivdi?zE@++m<@bg5do5~He3Rd4ONWOp5LthBXHPVHf)yV0kf^@ ztIG`UTn%)7m0YoM`|(wQ@?S+5vR-O3T)7m?uwvi2EK!gJ0@noo#>`eZ{*C9{f2>oQOVQAF{C2y?Tn4ROojrku^h4i zjGD`1y%ZL(W-aLK?(jIlnV8ww)6>FqVXofJ9tO37hBfkQE=C=iWq#@Q1Mh#=_MDOK zI#*}L)m|pr_x7>xxnnBZLM=EP7?=ba7+4e(BDL6ABse;9Mfo5C42&Ee(@rtgGqN!y zMYlEsl|1;&T5@)WLj1AvO(A^Z*83}7O3VFT!@Y_3_%ju;*QeK)zL|6`QE>V%r?z<$ z7OJPb;FPSw$=vY#)mjDnWBd2);E%1|uKqgylBLeKnPQ8xpB;14yWYNT@2#Ip-^g_> zI_zlg$f5vr3(%dDmKHfQG&bA_dk7T}XlO`TDI<`epaArVyuLz<`i&zCW-7$<14EF3 N!PC{xWt~$(695OQhkXD5 From b54fbd265570b043b12e86e1b36a70981ffe455f Mon Sep 17 00:00:00 2001 From: Exslims Date: Wed, 16 Aug 2017 19:02:48 +0400 Subject: [PATCH 03/17] Notification panel rework, added outgoing currency panel + chat scanner panel --- .../panel/chat/ChatFilterPanel.java | 7 + .../CurrencyIncNotificationPanel.java | 2 +- .../CurrencyOutNotificationPanel.java | 46 +++++++ .../panel/notification/NotificationPanel.java | 25 ++++ .../ScannerNotificationPanel.java | 85 ++++++++++++ .../NotificationScannerController.java | 57 ++++++++ .../controller/ScannerPanelController.java | 11 ++ .../factory/CurrencyIncPanelProvider.java | 12 +- .../factory/CurrencyOutPanelProvider.java | 22 ++++ .../factory/ItemIncPanelProvider.java | 12 +- .../factory/ItemOutPanelProvider.java | 12 +- .../factory/NotificationPanelFactory.java | 2 + .../factory/NotificationPanelProvider.java | 13 +- .../factory/ScannerPanelProvider.java | 22 ++++ .../movable/container/NotificationFrame.java | 4 +- .../ui/frame/titled/TestCasesFrame.java | 124 +++++++++++++----- 16 files changed, 386 insertions(+), 70 deletions(-) create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyOutNotificationPanel.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationScannerController.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/ScannerPanelController.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyOutPanelProvider.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ScannerPanelProvider.java diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/chat/ChatFilterPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/chat/ChatFilterPanel.java index 7fad8e30..9a83b5c0 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/chat/ChatFilterPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/chat/ChatFilterPanel.java @@ -1,6 +1,8 @@ package com.mercury.platform.ui.components.panel.chat; import com.mercury.platform.core.misc.SoundType; +import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationType; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.fields.style.MercuryScrollBarUI; @@ -104,6 +106,11 @@ private void addMessageToFilter(String message) { this.componentsFactory, nickname, messageBuilder.build(messageContent)); + NotificationDescriptor notificationDescriptor = new NotificationDescriptor(); + notificationDescriptor.setType(NotificationType.SCANNER_MESSAGE); + notificationDescriptor.setSourceString(messageBuilder.build(messageContent)); + notificationDescriptor.setWhisperNickname(nickname); + MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); container.add(chatMessagePanel); trimContainer(); expiresMessages.put(nickname,message); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyIncNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyIncNotificationPanel.java index 163d02cc..0ce5fb36 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyIncNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyIncNotificationPanel.java @@ -27,7 +27,7 @@ protected JPanel getMessagePanel() { return labelsPanel; } private JPanel getFromPanel(){ - JPanel fromPanel = this.componentsFactory.getJPanel(new FlowLayout(FlowLayout.LEFT,5,0),AppThemeColor.FRAME); + JPanel fromPanel = this.componentsFactory.getJPanel(new FlowLayout(FlowLayout.LEFT,0,0),AppThemeColor.FRAME); fromPanel.add(this.getCurrencyPanel(this.data.getCurrForSaleCount(),this.data.getCurrForSaleTitle())); fromPanel.add(getCurrencyRatePanel()); return fromPanel; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyOutNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyOutNotificationPanel.java new file mode 100644 index 00000000..ba8c3f0c --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyOutNotificationPanel.java @@ -0,0 +1,46 @@ +package com.mercury.platform.ui.components.panel.notification; + +import com.mercury.platform.shared.entity.message.CurrencyTradeNotificationDescriptor; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.components.fields.font.TextAlignment; +import com.mercury.platform.ui.misc.AppThemeColor; + +import javax.swing.*; +import java.awt.*; +import java.text.DecimalFormat; + + +public class CurrencyOutNotificationPanel extends OutgoingNotificationPanel { + @Override + protected JPanel getContentPanel() { + JPanel root = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); + root.add(this.getFromPanel(),BorderLayout.LINE_START); + root.add(this.getForPanel(),BorderLayout.CENTER); + return root; + } + private JPanel getForPanel(){ + JPanel fromPanel = this.componentsFactory.getJPanel(new FlowLayout(FlowLayout.LEFT,0,0),AppThemeColor.FRAME); + fromPanel.add(this.getCurrencyPanel(this.data.getCurrForSaleCount(),this.data.getCurrForSaleTitle())); + fromPanel.add(getCurrencyRatePanel()); + return fromPanel; + } + + private JPanel getCurrencyRatePanel(){ + Double currForSaleCount = this.data.getCurrForSaleCount(); + Double curCount = this.data.getCurCount(); + double rate = curCount / currForSaleCount; + DecimalFormat decimalFormat = new DecimalFormat("#.####"); + JPanel ratePanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); + ratePanel.add(componentsFactory. + getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 18f, null,"(")); + JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + this.data.getCurrency() + ".png", 26); + currencyLabel.setBorder(null); + ratePanel.add(currencyLabel); + ratePanel.add(componentsFactory. + getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 18f, null,decimalFormat.format(rate))); + ratePanel.add(componentsFactory. + getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 18f, null,")")); + ratePanel.setBorder(BorderFactory.createEmptyBorder(-5,0,-5,0)); + return ratePanel; + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java index 40e67ce9..4ffb3439 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java @@ -9,6 +9,7 @@ import lombok.Setter; import javax.swing.*; +import java.awt.*; public abstract class NotificationPanel extends JPanel implements AsSubscriber, ViewInit,ViewDestroy { @Setter @@ -18,4 +19,28 @@ public abstract class NotificationPanel extends JPanel implements AsSubscri protected C controller; @Setter protected ComponentsFactory componentsFactory; + + private float alphaValue = 0f; + @Override + public void paint(Graphics g) { + Graphics2D g2 = (Graphics2D) g.create(); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,this.alphaValue)); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); + g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); + super.paint(g2); + if (this.alphaValue < 1.0f) { + this.alphaValue += 0.004; + if(this.alphaValue > 1.0f){ + this.alphaValue = 1.0f; + } + this.repaint(); + } + } + + @Override + public void setVisible(boolean aFlag) { + this.alphaValue = 0f; + super.setVisible(aFlag); + } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java new file mode 100644 index 00000000..335a1381 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java @@ -0,0 +1,85 @@ +package com.mercury.platform.ui.components.panel.notification; + +import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.configration.PlainConfigurationService; +import com.mercury.platform.shared.config.descriptor.ResponseButtonDescriptor; +import com.mercury.platform.shared.config.descriptor.ScannerDescriptor; +import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.components.fields.font.TextAlignment; +import com.mercury.platform.ui.components.panel.notification.controller.ScannerPanelController; +import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.TooltipConstants; + +import javax.swing.*; +import java.awt.*; + + +public class ScannerNotificationPanel extends NotificationPanel { + private PlainConfigurationService config; + @Override + public void onViewInit() { + this.config = Configuration.get().scannerConfiguration(); + this.setBackground(AppThemeColor.FRAME); + this.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createEmptyBorder(1,1,1,1), + BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON_BORDER, 1))); + this.setLayout(new BorderLayout()); + this.add(this.getHeader(),BorderLayout.PAGE_START); + JLabel sourceLabel = this.componentsFactory.getTextLabel(this.data.getSourceString(),FontStyle.BOLD,16f); + sourceLabel.setMaximumSize(new Dimension(200,56)); + sourceLabel.setBackground(AppThemeColor.FRAME); + sourceLabel.setHorizontalAlignment(SwingConstants.LEFT); + sourceLabel.setVerticalAlignment(SwingConstants.TOP); + this.add(this.componentsFactory.wrapToSlide(sourceLabel,AppThemeColor.FRAME,2,2,2,2),BorderLayout.CENTER); + } + private JPanel getHeader(){ + JPanel root = new JPanel(new BorderLayout()); + root.setBackground(AppThemeColor.MSG_HEADER); + + JLabel nicknameLabel = this.componentsFactory.getTextLabel(FontStyle.BOLD,AppThemeColor.TEXT_NICKNAME, TextAlignment.LEFTOP,15f,this.data.getWhisperNickname()); + nicknameLabel.setBorder(BorderFactory.createEmptyBorder(0,5,0,5)); + + root.add(nicknameLabel,BorderLayout.CENTER); + + JPanel interactionPanel = new JPanel(new GridLayout(1,0,4,0)); + interactionPanel.setPreferredSize(new Dimension(234,26)); + interactionPanel.setBackground(AppThemeColor.MSG_HEADER); + JButton inviteMeButton = componentsFactory.getIconButton("app/chat_scanner_response.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.INVITE); + inviteMeButton.addActionListener(e -> this.controller.performResponse(this.config.get().getResponseMessage())); + JButton visiteHideout = componentsFactory.getIconButton("app/visiteHideout.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.INVITE); + visiteHideout.addActionListener(e -> this.controller.visitHideout()); + JButton tradeButton = componentsFactory.getIconButton("app/trade.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.TRADE); + tradeButton.addActionListener(e -> this.controller.performTrade()); + JButton leaveButton = componentsFactory.getIconButton("app/leave.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.KICK); + leaveButton.addActionListener(e -> { + this.controller.performLeave(); + }); + JButton backToHo = componentsFactory.getIconButton("app/backToHideout.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); + backToHo.addActionListener(e -> controller.backToHideout()); + JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); + openChatButton.addActionListener(e -> controller.performOpenChat()); + JButton hideButton = componentsFactory.getIconButton("app/close.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.HIDE_PANEL); + hideButton.addActionListener(action -> { + this.controller.performHide(); + }); + interactionPanel.add(inviteMeButton); + interactionPanel.add(visiteHideout); + interactionPanel.add(tradeButton); + interactionPanel.add(leaveButton); + interactionPanel.add(backToHo); + interactionPanel.add(openChatButton); + interactionPanel.add(hideButton); + + root.add(interactionPanel,BorderLayout.LINE_END); + return root; + } + @Override + public void subscribe() { + + } + @Override + public void onViewDestroy() { + + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationScannerController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationScannerController.java new file mode 100644 index 00000000..955ff75c --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationScannerController.java @@ -0,0 +1,57 @@ +package com.mercury.platform.ui.components.panel.notification.controller; + + +import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.shared.store.MercuryStoreCore; + +import javax.swing.*; + +public class NotificationScannerController implements ScannerPanelController { + private NotificationDescriptor notificationDescriptor; + + public NotificationScannerController(NotificationDescriptor notificationDescriptor) { + this.notificationDescriptor = notificationDescriptor; + } + + @Override + public void visitHideout() { + + } + + @Override + public void backToHideout() { + + } + + @Override + public void performTrade() { + + } + + @Override + public void performLeave() { + + } + + @Override + public void performHide() { + this.closeMessagePanel(); + } + + @Override + public void performOpenChat() { + + } + + @Override + public void performResponse(String response) { + + } + private void closeMessagePanel(){ + Timer timer = new Timer(30, action -> { + MercuryStoreCore.removeNotificationSubject.onNext(notificationDescriptor); + }); + timer.setRepeats(false); + timer.start(); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/ScannerPanelController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/ScannerPanelController.java new file mode 100644 index 00000000..24819fe9 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/ScannerPanelController.java @@ -0,0 +1,11 @@ +package com.mercury.platform.ui.components.panel.notification.controller; + +public interface ScannerPanelController { + void visitHideout(); + void backToHideout(); + void performTrade(); + void performLeave(); + void performHide(); + void performOpenChat(); + void performResponse(String response); +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyIncPanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyIncPanelProvider.java index 624dab8c..fcd58e6d 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyIncPanelProvider.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyIncPanelProvider.java @@ -14,17 +14,9 @@ public boolean isSuitable(NotificationType type) { } @Override - public NotificationPanel build() { + protected NotificationPanel getPanel() { CurrencyIncNotificationPanel panel = new CurrencyIncNotificationPanel(); - panel.setData(this.data); - if(this.controller != null){ - panel.setController(this.controller); - }else { - panel.setController(new NotificationIncomingController(this.data)); - } - panel.setComponentsFactory(this.componentsFactory); - panel.subscribe(); - panel.onViewInit(); + panel.setController(new NotificationIncomingController(this.data)); return panel; } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyOutPanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyOutPanelProvider.java new file mode 100644 index 00000000..45fed54b --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyOutPanelProvider.java @@ -0,0 +1,22 @@ +package com.mercury.platform.ui.components.panel.notification.factory; + +import com.mercury.platform.shared.entity.message.CurrencyTradeNotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationType; +import com.mercury.platform.ui.components.panel.notification.CurrencyOutNotificationPanel; +import com.mercury.platform.ui.components.panel.notification.NotificationPanel; +import com.mercury.platform.ui.components.panel.notification.controller.NotificationOutgoingController; +import com.mercury.platform.ui.components.panel.notification.controller.OutgoingPanelController; + + +public class CurrencyOutPanelProvider extends NotificationPanelProvider { + @Override + public boolean isSuitable(NotificationType type) { + return type.equals(NotificationType.OUT_CURRENCY_MESSAGE); + } + @Override + protected NotificationPanel getPanel() { + CurrencyOutNotificationPanel panel = new CurrencyOutNotificationPanel(); + panel.setController(new NotificationOutgoingController(this.data)); + return panel; + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemIncPanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemIncPanelProvider.java index cb0c3320..7c0ee07e 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemIncPanelProvider.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemIncPanelProvider.java @@ -15,17 +15,9 @@ public boolean isSuitable(NotificationType type) { } @Override - public NotificationPanel build() { + protected NotificationPanel getPanel() { ItemIncNotificationPanel panel = new ItemIncNotificationPanel(); - panel.setData(this.data); - if(this.controller != null){ - panel.setController(this.controller); - }else { - panel.setController(new NotificationIncomingController(this.data)); - } - panel.setComponentsFactory(this.componentsFactory); - panel.subscribe(); - panel.onViewInit(); + panel.setController(new NotificationIncomingController(this.data)); return panel; } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemOutPanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemOutPanelProvider.java index cdc673ba..ddc21c75 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemOutPanelProvider.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemOutPanelProvider.java @@ -15,17 +15,9 @@ public boolean isSuitable(NotificationType type) { } @Override - public NotificationPanel build() { + protected NotificationPanel getPanel() { ItemOutNotificationPanel panel = new ItemOutNotificationPanel(); - panel.setData(this.data); - if(this.controller != null){ - panel.setController(this.controller); - }else { - panel.setController(new NotificationOutgoingController(this.data)); - } - panel.setComponentsFactory(this.componentsFactory); - panel.subscribe(); - panel.onViewInit(); + panel.setController(new NotificationOutgoingController(this.data)); return panel; } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelFactory.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelFactory.java index fab82337..8a327706 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelFactory.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelFactory.java @@ -14,6 +14,8 @@ public NotificationPanelFactory() { this.providers.add(new ItemIncPanelProvider()); this.providers.add(new CurrencyIncPanelProvider()); this.providers.add(new ItemOutPanelProvider()); + this.providers.add(new CurrencyOutPanelProvider()); + this.providers.add(new ScannerPanelProvider()); } public NotificationPanelProvider getProviderFor(NotificationType type){ diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelProvider.java index 3d667ef1..de3eabb5 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelProvider.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelProvider.java @@ -25,5 +25,16 @@ public NotificationPanelProvider setComponentsFactory(ComponentsFactory fac return this; } - public abstract NotificationPanel build(); + public NotificationPanel build() { + NotificationPanel panel = this.getPanel(); + panel.setData(this.data); + if(this.controller != null){ + panel.setController(this.controller); + } + panel.setComponentsFactory(this.componentsFactory); + panel.subscribe(); + panel.onViewInit(); + return panel; + } + protected abstract NotificationPanel getPanel(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ScannerPanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ScannerPanelProvider.java new file mode 100644 index 00000000..f562e0a1 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ScannerPanelProvider.java @@ -0,0 +1,22 @@ +package com.mercury.platform.ui.components.panel.notification.factory; + +import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationType; +import com.mercury.platform.ui.components.panel.notification.NotificationPanel; +import com.mercury.platform.ui.components.panel.notification.ScannerNotificationPanel; +import com.mercury.platform.ui.components.panel.notification.controller.NotificationScannerController; +import com.mercury.platform.ui.components.panel.notification.controller.ScannerPanelController; + +public class ScannerPanelProvider extends NotificationPanelProvider { + @Override + public boolean isSuitable(NotificationType type) { + return type.equals(NotificationType.SCANNER_MESSAGE); + } + + @Override + protected NotificationPanel getPanel() { + ScannerNotificationPanel panel = new ScannerNotificationPanel(); + panel.setController(new NotificationScannerController(this.data)); + return panel; + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java index 3c44d237..cec9d9c0 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java @@ -3,10 +3,8 @@ import com.mercury.platform.shared.config.Configuration; import com.mercury.platform.shared.config.configration.PlainConfigurationService; import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; -import com.mercury.platform.shared.entity.message.FlowDirections; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.ComponentsFactory; -import com.mercury.platform.ui.components.panel.VerticalScrollContainer; import com.mercury.platform.ui.components.panel.notification.NotificationPanel; import com.mercury.platform.ui.components.panel.notification.factory.NotificationPanelFactory; import com.mercury.platform.ui.frame.movable.AbstractMovableComponentFrame; @@ -38,7 +36,7 @@ protected void initialize() { public void onViewInit() { this.getRootPane().setBorder(null); this.setBackground(AppThemeColor.TRANSPARENT); - this.container = new VerticalScrollContainer(); + this.container = new JPanel(); this.container.setBackground(AppThemeColor.TRANSPARENT); this.container.setLayout(new BoxLayout(container,BoxLayout.Y_AXIS)); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java index c640801e..6937894c 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java @@ -5,7 +5,9 @@ import com.mercury.platform.shared.entity.message.NotificationDescriptor; import com.mercury.platform.shared.entity.message.NotificationType; import com.mercury.platform.shared.store.MercuryStoreCore; +import com.mercury.platform.ui.components.panel.chat.HtmlMessageBuilder; import com.mercury.platform.ui.misc.AppThemeColor; +import org.apache.commons.lang3.StringUtils; import javax.swing.*; import javax.swing.Timer; @@ -21,8 +23,9 @@ public class TestCasesFrame extends AbstractTitledComponentFrame { private List nickNames; private List offer; private List leagues; - private String poeTradeTemplate = "2017/02/11 18:40:32 9029890 951 [INFO Client 8980] @From %s: Hi, I would like to buy your %s listed for %d %s in %s (stash tab \"%d\"; position: left %d, top %d) %s"; - private String currencyTemplate = "2017/02/11 18:56:15 9973390 951 [INFO Client 8980] @From %s: Hi, I'd like to buy your %d %s for my %d %s in %s. %s"; + private HtmlMessageBuilder messageBuilder; + private String poeTradeTemplate = "%s: Hi, I would like to buy your %s listed for %d %s in %s (stash tab \"%d\"; position: left %d, top %d) %s"; + private String currencyTemplate = "%s: Hi, I'd like to buy your %d %s for my %d %s in %s. %s"; public TestCasesFrame() { super(); @@ -31,6 +34,8 @@ public TestCasesFrame() { nickNames = new ArrayList<>(); offer = new ArrayList<>(); leagues = new ArrayList<>(); + this.messageBuilder = new HtmlMessageBuilder(); + this.messageBuilder.setChunkStrings(Arrays.asList("Hi","buy","listed","like")); items.add("Wondertrap Velvet Slippers"); items.add("Rain of Arrows"); items.add("Dreadarc Cleaver"); @@ -194,9 +199,9 @@ public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) { NotificationDescriptor notificationDescriptor = parser.parse(String.format(currencyTemplate, nickNames.get(random.nextInt(nickNames.size())), - random.nextInt(200), + random.nextInt(200) + 1, currency.get(random.nextInt(currency.size())), - random.nextInt(200), + random.nextInt(200) + 1, currency.get(random.nextInt(currency.size())), leagues.get(random.nextInt(leagues.size())), offer.get(random.nextInt(offer.size())) @@ -206,52 +211,99 @@ public void mousePressed(MouseEvent e) { }); testPanel.add(button1,buttonColumn); buttonColumn.gridy++; - JLabel textLabel1 = componentsFactory.getTextLabel("Random currency message"); + JLabel textLabel1 = componentsFactory.getTextLabel("Random incoming currency message"); testPanel.add(textLabel1,titleColumn); titleColumn.gridy++; +// JButton button2 = componentsFactory.getBorderedButton("Click"); +// button2.addMouseListener(new MouseAdapter() { +// @Override +// public void mousePressed(MouseEvent e) { +// String nickname = nickNames.get(random.nextInt(nickNames.size())); +// NotificationDescriptor notificationDescriptor = parser.parse(String.format(currencyTemplate, +// nickname, +// random.nextInt(200), +// currency.get(random.nextInt(currency.size())), +// random.nextInt(200), +// currency.get(random.nextInt(currency.size())), +// leagues.get(random.nextInt(leagues.size())), +// offer.get(random.nextInt(offer.size())) +// )); +// MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); +// MercuryStoreCore.soundSubject.onNext(SoundType.MESSAGE); +// +// Timer joinedTimer = new Timer(1000,null); +// joinedTimer.addActionListener(e1 -> { +// MercuryStoreCore.playerJoinSubject.onNext(nickname); +// joinedTimer.stop(); +// }); +// joinedTimer.start(); +// +// Timer leftTimer = new Timer(2000,null); +// leftTimer.addActionListener(e1 -> { +// MercuryStoreCore.playerLeftSubject.onNext(nickname); +// leftTimer.stop(); +// }); +// leftTimer.start(); +// } +// }); +// testPanel.add(button2,buttonColumn); +// buttonColumn.gridy++; +// JLabel textLabel2 = componentsFactory.getTextLabel("Test accessibility status"); +// testPanel.add(textLabel2,titleColumn); +// titleColumn.gridy++; + JButton outItemButton = componentsFactory.getBorderedButton("Click"); + outItemButton.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + NotificationDescriptor notificationDescriptor = parser.parse(String.format(poeTradeTemplate, + nickNames.get(random.nextInt(nickNames.size())), + items.get(random.nextInt(items.size())), + random.nextInt(200), + currency.get(random.nextInt(currency.size())), + leagues.get(random.nextInt(leagues.size())), + random.nextInt(30), + random.nextInt(12) + 1, + random.nextInt(12) + 1, + offer.get(random.nextInt(offer.size())) + )); + notificationDescriptor.setType(NotificationType.OUT_ITEM_MESSAGE); + MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); + } + }); + testPanel.add(outItemButton,buttonColumn); + buttonColumn.gridy++; + JLabel outItemLabel = componentsFactory.getTextLabel("Random outgoing item message"); + testPanel.add(outItemLabel,titleColumn); + titleColumn.gridy++; - JButton button2 = componentsFactory.getBorderedButton("Click"); - button2.addMouseListener(new MouseAdapter() { + JButton outCurrencyButton = componentsFactory.getBorderedButton("Click"); + outCurrencyButton.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { - String nickname = nickNames.get(random.nextInt(nickNames.size())); NotificationDescriptor notificationDescriptor = parser.parse(String.format(currencyTemplate, - nickname, - random.nextInt(200), + nickNames.get(random.nextInt(nickNames.size())), + random.nextInt(200) + 1, currency.get(random.nextInt(currency.size())), - random.nextInt(200), + random.nextInt(200) + 1, currency.get(random.nextInt(currency.size())), leagues.get(random.nextInt(leagues.size())), offer.get(random.nextInt(offer.size())) )); + notificationDescriptor.setType(NotificationType.OUT_CURRENCY_MESSAGE); MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); - MercuryStoreCore.soundSubject.onNext(SoundType.MESSAGE); - - Timer joinedTimer = new Timer(1000,null); - joinedTimer.addActionListener(e1 -> { - MercuryStoreCore.playerJoinSubject.onNext(nickname); - joinedTimer.stop(); - }); - joinedTimer.start(); - - Timer leftTimer = new Timer(2000,null); - leftTimer.addActionListener(e1 -> { - MercuryStoreCore.playerLeftSubject.onNext(nickname); - leftTimer.stop(); - }); - leftTimer.start(); } }); - testPanel.add(button2,buttonColumn); + testPanel.add(outCurrencyButton,buttonColumn); buttonColumn.gridy++; - JLabel textLabel2 = componentsFactory.getTextLabel("Test accessibility status"); - testPanel.add(textLabel2,titleColumn); + JLabel outCurrencyLabel = componentsFactory.getTextLabel("Random outgoing currency message"); + testPanel.add(outCurrencyLabel,titleColumn); titleColumn.gridy++; + testPanel.setBackground(AppThemeColor.TRANSPARENT); - JButton outItemButton = componentsFactory.getBorderedButton("Click"); - outItemButton.addMouseListener(new MouseAdapter() { + JButton chatScannerButton = componentsFactory.getBorderedButton("Click"); + chatScannerButton.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { NotificationDescriptor notificationDescriptor = parser.parse(String.format(poeTradeTemplate, @@ -265,14 +317,16 @@ public void mousePressed(MouseEvent e) { random.nextInt(12) + 1, offer.get(random.nextInt(offer.size())) )); - notificationDescriptor.setType(NotificationType.OUT_ITEM_MESSAGE); + String source = StringUtils.substringAfter(notificationDescriptor.getSourceString(), ": "); + notificationDescriptor.setSourceString(messageBuilder.build(source)); + notificationDescriptor.setType(NotificationType.SCANNER_MESSAGE); MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); } }); - testPanel.add(outItemButton,buttonColumn); + testPanel.add(chatScannerButton,buttonColumn); buttonColumn.gridy++; - JLabel outItemLabel = componentsFactory.getTextLabel("Random outgoing item message"); - testPanel.add(outItemLabel,titleColumn); + JLabel chatScannerLabel = componentsFactory.getTextLabel("Random chat scanner message"); + testPanel.add(chatScannerLabel,titleColumn); titleColumn.gridy++; testPanel.setBackground(AppThemeColor.TRANSPARENT); From 674980b4814769eeccbb2b2490826844450db2fc Mon Sep 17 00:00:00 2001 From: Exslims Date: Thu, 17 Aug 2017 01:44:40 +0400 Subject: [PATCH 04/17] Notification panel rework, added limit code, added blur effect --- .../IncomingNotificationPanel.java | 14 ++-- .../panel/notification/NotificationPanel.java | 66 +++++++++++++-- .../OutgoingNotificationPanel.java | 6 +- .../ScannerNotificationPanel.java | 11 +-- .../movable/container/NotificationFrame.java | 83 +++++++++++++------ 5 files changed, 123 insertions(+), 57 deletions(-) diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java index b6ac20c6..b3ba2b29 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java @@ -26,13 +26,8 @@ public abstract class IncomingNotificationPanel config; @Override public void onViewInit() { + super.onViewInit(); this.config = Configuration.get().notificationConfiguration(); - this.setLayout(new BorderLayout()); - this.setBackground(AppThemeColor.FRAME); - this.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createEmptyBorder(1,1,1,1), - BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON_BORDER, 1))); - this.add(this.getHeader(),BorderLayout.PAGE_START); this.add(this.getMessagePanel(),BorderLayout.CENTER); this.add(this.getResponseButtonsPanel(),BorderLayout.PAGE_END); @@ -59,7 +54,10 @@ private JPanel getHeader(){ } }); JButton tradeButton = componentsFactory.getIconButton("app/trade.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.TRADE); - tradeButton.addActionListener(e -> this.controller.performOfferTrade()); + tradeButton.addActionListener(e -> { + this.controller.performOfferTrade(); + this.onBlur(); + }); JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); openChatButton.addActionListener(e -> controller.performOpenChat()); JButton hideButton = componentsFactory.getIconButton("app/close.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.HIDE_PANEL); @@ -67,8 +65,8 @@ private JPanel getHeader(){ this.controller.performHide(); }); interactionPanel.add(inviteButton); - interactionPanel.add(kickButton); interactionPanel.add(tradeButton); + interactionPanel.add(kickButton); interactionPanel.add(getStillInterestedButton()); interactionPanel.add(openChatButton); interactionPanel.add(hideButton); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java index 4ffb3439..1eeb3ff9 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java @@ -5,6 +5,7 @@ import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.panel.misc.ViewDestroy; import com.mercury.platform.ui.components.panel.misc.ViewInit; +import com.mercury.platform.ui.misc.AppThemeColor; import lombok.Getter; import lombok.Setter; @@ -19,28 +20,75 @@ public abstract class NotificationPanel extends JPanel implements AsSubscri protected C controller; @Setter protected ComponentsFactory componentsFactory; + @Setter + private float paintAlphaValue = 0f; + @Setter + private float paintBorderValue = 0f; + private boolean blurEffect; + private boolean blurReverse; + + @Override + public void onViewInit() { + this.setLayout(new BorderLayout()); + this.setBackground(AppThemeColor.FRAME); + this.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createEmptyBorder(1,1,1,1), + BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON_BORDER, 1))); + } - private float alphaValue = 0f; @Override public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g.create(); - g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,this.alphaValue)); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,this.paintAlphaValue)); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); super.paint(g2); - if (this.alphaValue < 1.0f) { - this.alphaValue += 0.004; - if(this.alphaValue > 1.0f){ - this.alphaValue = 1.0f; + if (this.paintAlphaValue < 1.0f) { + this.paintAlphaValue += 0.004; + if(this.paintAlphaValue > 1.0f){ + this.paintAlphaValue = 1.0f; } this.repaint(); } } + protected void onBlur(){ + this.blurEffect = true; + this.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createEmptyBorder(1,1,1,1), + BorderFactory.createLineBorder(AppThemeColor.ADR_SELECTED_BORDER, 1))); + this.repaint(); + } @Override - public void setVisible(boolean aFlag) { - this.alphaValue = 0f; - super.setVisible(aFlag); + protected void paintBorder(Graphics g) { + if(this.blurEffect) { + Graphics2D g2 = (Graphics2D) g.create(); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, this.paintBorderValue)); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); + g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); + super.paintBorder(g2); + if(this.blurReverse){ + if (this.paintBorderValue <= 1.0f) { + this.paintBorderValue += 0.002; + if (this.paintBorderValue >= 1.0f) { + this.blurReverse = false; + this.paintBorderValue = 1.0f; + } + } + }else { + if (this.paintBorderValue >= 0f) { + this.paintBorderValue -= 0.002; + if (this.paintBorderValue <= 0f) { + this.blurReverse = true; + this.paintBorderValue = 0f; + } + } + } + this.repaint(); + }else { + super.paintBorder(g); + } } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutgoingNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutgoingNotificationPanel.java index a29528d8..ab22aacc 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutgoingNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutgoingNotificationPanel.java @@ -23,12 +23,8 @@ public abstract class OutgoingNotificationPanel config; @Override public void onViewInit() { + super.onViewInit(); this.config = Configuration.get().notificationConfiguration(); - this.setBackground(AppThemeColor.FRAME); - this.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createEmptyBorder(1,1,1,1), - BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON_BORDER, 1))); - this.setLayout(new BorderLayout()); this.add(this.getHeader(),BorderLayout.PAGE_START); JPanel bottomPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); bottomPanel.add(this.getContentPanel(),BorderLayout.CENTER); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java index 335a1381..45f7244a 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java @@ -2,7 +2,6 @@ import com.mercury.platform.shared.config.Configuration; import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.descriptor.ResponseButtonDescriptor; import com.mercury.platform.shared.config.descriptor.ScannerDescriptor; import com.mercury.platform.shared.entity.message.NotificationDescriptor; import com.mercury.platform.ui.components.fields.font.FontStyle; @@ -19,19 +18,15 @@ public class ScannerNotificationPanel extends NotificationPanel config; @Override public void onViewInit() { + super.onViewInit(); this.config = Configuration.get().scannerConfiguration(); - this.setBackground(AppThemeColor.FRAME); - this.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createEmptyBorder(1,1,1,1), - BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON_BORDER, 1))); - this.setLayout(new BorderLayout()); this.add(this.getHeader(),BorderLayout.PAGE_START); - JLabel sourceLabel = this.componentsFactory.getTextLabel(this.data.getSourceString(),FontStyle.BOLD,16f); - sourceLabel.setMaximumSize(new Dimension(200,56)); + JLabel sourceLabel = this.componentsFactory.getTextLabel(this.data.getSourceString(),FontStyle.BOLD,17f); sourceLabel.setBackground(AppThemeColor.FRAME); sourceLabel.setHorizontalAlignment(SwingConstants.LEFT); sourceLabel.setVerticalAlignment(SwingConstants.TOP); this.add(this.componentsFactory.wrapToSlide(sourceLabel,AppThemeColor.FRAME,2,2,2,2),BorderLayout.CENTER); + this.validate(); } private JPanel getHeader(){ JPanel root = new JPanel(new BorderLayout()); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java index cec9d9c0..6787f35c 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java @@ -21,6 +21,8 @@ public class NotificationFrame extends AbstractMovableComponentFrame { private PlainConfigurationService config; private NotificationPanelFactory factory; private JPanel container; + private JPanel expandPanel; + private boolean expanded; @Override protected void initialize() { super.initialize(); @@ -39,8 +41,9 @@ public void onViewInit() { this.container = new JPanel(); this.container.setBackground(AppThemeColor.TRANSPARENT); this.container.setLayout(new BoxLayout(container,BoxLayout.Y_AXIS)); - - this.add(this.getExpandPanel(),BorderLayout.LINE_START); + this.expandPanel = this.getExpandPanel(); + this.expandPanel.setVisible(false); + this.add(this.expandPanel,BorderLayout.LINE_START); this.add(this.container,BorderLayout.CENTER); this.setVisible(true); this.pack(); @@ -50,24 +53,42 @@ public void onViewInit() { @SuppressWarnings("all") public void subscribe() { MercuryStoreCore.newNotificationSubject.subscribe(notification -> { - NotificationPanel notificationPanel = this.factory.getProviderFor(notification.getType()) - .setData(notification) - .setComponentsFactory(this.componentsFactory) - .build(); - this.notificationPanels.add(notificationPanel); - this.container.add(notificationPanel); - this.pack(); - this.repaint(); + SwingUtilities.invokeLater(() -> { + NotificationPanel notificationPanel = this.factory.getProviderFor(notification.getType()) + .setData(notification) + .setComponentsFactory(this.componentsFactory) + .build(); + this.notificationPanels.add(notificationPanel); + this.container.add(notificationPanel); + if(this.notificationPanels.size() > this.config.get().getLimitCount()){ + if(!this.expanded) { + notificationPanel.setPaintAlphaValue(1f); + notificationPanel.setVisible(false); + } + this.expandPanel.setVisible(true); + } + this.pack(); + this.repaint(); + }); }); MercuryStoreCore.removeNotificationSubject.subscribe(notification -> { - NotificationPanel notificationPanel = this.notificationPanels.stream() - .filter(it -> it.getData().equals(notification)) - .findAny().orElse(null); - notificationPanel.onViewDestroy(); - this.container.remove(notificationPanel); - this.notificationPanels.remove(notificationPanel); - this.pack(); - this.repaint(); + SwingUtilities.invokeLater(() -> { + NotificationPanel notificationPanel = this.notificationPanels.stream() + .filter(it -> it.getData().equals(notification)) + .findAny().orElse(null); + notificationPanel.onViewDestroy(); + int limitCount = this.config.get().getLimitCount(); + if(!this.expanded && this.notificationPanels.size() > limitCount){ + this.notificationPanels.get(limitCount).setVisible(true); + } + this.container.remove(notificationPanel); + this.notificationPanels.remove(notificationPanel); + if(this.notificationPanels.size() - 1 < this.config.get().getLimitCount()){ + this.expandPanel.setVisible(false); + } + this.pack(); + this.repaint(); + }); }); } @@ -99,21 +120,29 @@ private JPanel getExpandPanel(){ root.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder(1,1,1,0,AppThemeColor.FRAME), BorderFactory.createMatteBorder(1,1,1,1,AppThemeColor.RESPONSE_BUTTON_BORDER))); - - JPanel labelPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); - labelPanel.setBackground(AppThemeColor.MSG_HEADER); - labelPanel.setPreferredSize(new Dimension((int)(10 * componentsFactory.getScale()),(int)(22 * componentsFactory.getScale()))); - labelPanel.setBorder(BorderFactory.createEmptyBorder(-4,0,0,0)); - JLabel msgCountLabel = componentsFactory.getTextLabel("+" + String.valueOf("12")); String iconPath = "app/collapse-all.png"; JButton expandButton = componentsFactory.getIconButton(iconPath,22,AppThemeColor.MSG_HEADER,""); expandButton.addActionListener(action -> { - + if(this.expanded) { + expandButton.setIcon(this.componentsFactory.getIcon("app/collapse-all.png",22)); + this.notificationPanels + .stream() + .skip(this.config.get().getLimitCount()) + .forEach(it -> it.setVisible(false)); + }else { + expandButton.setIcon(this.componentsFactory.getIcon("app/expand-all.png",22)); + this.notificationPanels.forEach(it -> { + if (!it.isVisible()) { + it.setVisible(true); + } + }); + } + this.expanded = !this.expanded; + this.pack(); + this.repaint(); }); expandButton.setAlignmentY(SwingConstants.CENTER); - labelPanel.add(msgCountLabel); root.add(expandButton,BorderLayout.CENTER); - root.add(labelPanel,BorderLayout.PAGE_END); return root; } } From adf7081320d8996aced04065fd9e06d9ac4702e5 Mon Sep 17 00:00:00 2001 From: Exslims Date: Sun, 20 Aug 2017 01:03:41 +0400 Subject: [PATCH 05/17] Notification panel rework, added scanner panel, added history panel, updated notification settings, updated history, chat scanner --- .../com/mercury/platform/core/ChatHelper.java | 7 +- .../interceptor/TradeMessagesInterceptor.java | 2 +- .../platform/shared/config/ConfigManager.java | 2 +- .../shared/config/MercuryConfigManager.java | 7 +- .../impl/ApplicationConfigurationService.java | 1 + .../impl/HotKeyConfigurationService.java | 77 ++++++ .../impl/HotKeysConfigurationService.java | 66 ----- .../NotificationConfigurationService.java | 19 +- .../config/descriptor/HotKeyDescriptor.java | 1 - .../shared/config/descriptor/HotKeyPair.java | 13 + .../shared/config/descriptor/HotKeyType.java | 78 ++++-- .../descriptor/HotKeysSettingsDescriptor.java | 15 ++ .../NotificationSettingsDescriptor.java | 14 +- .../config/descriptor/ProfileDescriptor.java | 4 +- .../config/descriptor/ScannerDescriptor.java | 4 +- .../entity/message/NotificationType.java | 3 +- .../hotkey/MercuryNativeKeyListener.java | 34 ++- .../shared/store/MercuryStoreCore.java | 2 + .../panel/AdrDurationComponentPanel.java | 12 +- .../panel/page/AdrMainPagePanel.java | 2 +- .../ui/components/ComponentsFactory.java | 53 ++-- .../ui/components/fields/font/FontStyle.java | 2 +- .../fields/style/MercuryComboBoxUI.java | 2 +- .../fields/style/MercuryScrollBarUI.java | 2 +- .../components/panel/grid/ItemInfoPanel.java | 6 +- .../components/panel/grid/TabInfoPanel.java | 4 +- .../HistoryNotificationPanel.java | 55 ++++ .../panel/notification/InMessagePanel.java | 14 +- .../IncomingNotificationPanel.java | 176 ++++++++----- .../panel/notification/NotificationPanel.java | 75 +++++- .../OutgoingNotificationPanel.java | 99 +++++-- .../ScannerNotificationPanel.java | 82 ++++-- .../controller/HistoryController.java | 7 + .../controller/IncomingPanelController.java | 6 +- .../controller/NotificationController.java | 9 + .../NotificationIncomingController.java | 1 - .../NotificationOutgoingController.java | 19 +- .../NotificationScannerController.java | 19 +- .../controller/OutgoingPanelController.java | 9 +- .../controller/ScannerPanelController.java | 9 +- .../factory/HistoryPanelProvider.java | 33 +++ .../factory/NotificationPanelFactory.java | 1 + .../panel/settings/page/HotKeyPanel.java | 61 +++++ .../page/NotificationSettingsPagePanel.java | 249 ++++++++++-------- .../page/TaskBarSettingsPagePanel.java | 16 ++ .../taskbar/MercuryTaskBarController.java | 3 +- .../panel/taskbar/TaskBarPanel.java | 32 ++- .../ui/frame/AbstractOverlaidFrame.java | 3 +- .../AbstractMovableComponentFrame.java | 6 +- .../ui/frame/movable/TaskBarFrame.java | 17 +- .../frame/movable/container/MessageFrame.java | 10 +- .../movable/container/NotificationFrame.java | 39 ++- .../titled/AbstractTitledComponentFrame.java | 14 +- .../ui/frame/titled/SettingsFrame.java | 2 +- .../ui/frame/titled/chat/ChatFilterFrame.java | 18 +- .../titled/chat/ChatFilterSettingsFrame.java | 92 ++++++- .../frame/titled/container/HistoryFrame.java | 86 +++--- .../platform/ui/manager/FramesManager.java | 3 +- .../platform/ui/misc/AppThemeColor.java | 3 +- .../java/com/mercury/platform/AppMain.java | 1 + 60 files changed, 1162 insertions(+), 539 deletions(-) create mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeyConfigurationService.java delete mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeysConfigurationService.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyPair.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeysSettingsDescriptor.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/HistoryNotificationPanel.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/HistoryController.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationController.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/HistoryPanelProvider.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/HotKeyPanel.java diff --git a/app-core/src/main/java/com/mercury/platform/core/ChatHelper.java b/app-core/src/main/java/com/mercury/platform/core/ChatHelper.java index 536d627b..c48d80ae 100644 --- a/app-core/src/main/java/com/mercury/platform/core/ChatHelper.java +++ b/app-core/src/main/java/com/mercury/platform/core/ChatHelper.java @@ -30,6 +30,8 @@ private void executeMessage(String message) { StringSelection selection = new StringSelection(message); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(selection, null); + MercuryStoreCore.blockHotkeySubject.onNext(true); + robot.keyRelease(KeyEvent.VK_ALT); robot.keyPress(KeyEvent.VK_ENTER); robot.keyRelease(KeyEvent.VK_ENTER); @@ -48,13 +50,15 @@ private void executeMessage(String message) { robot.keyRelease(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_ENTER); robot.keyRelease(KeyEvent.VK_ENTER); + MercuryStoreCore.blockHotkeySubject.onNext(false); } private void openChat(String whisper) { this.gameToFront(); StringSelection selection = new StringSelection("@" + whisper); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(selection, selection); - + MercuryStoreCore.blockHotkeySubject.onNext(true); + robot.keyRelease(KeyEvent.VK_ALT); robot.keyPress(KeyEvent.VK_ENTER); robot.keyRelease(KeyEvent.VK_ENTER); @@ -72,6 +76,7 @@ private void openChat(String whisper) { robot.keyRelease(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_SPACE); robot.keyRelease(KeyEvent.VK_SPACE); + MercuryStoreCore.blockHotkeySubject.onNext(false); } private void gameToFront(){ User32.INSTANCE.EnumWindows((hWnd, arg1) -> { diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeMessagesInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeMessagesInterceptor.java index bf8ea179..280e59d2 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeMessagesInterceptor.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeMessagesInterceptor.java @@ -28,7 +28,7 @@ public TradeMessagesInterceptor() { @Override protected void process(String message) { - if(this.config.get().isNotificationEnable()) { + if(this.config.get().isIncNotificationEnable()) { LocalizationMatcher localizationMatcher = this.clients.stream() .filter(matcher -> matcher.isSuitableFor(message)) .findAny().orElse(null); diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/ConfigManager.java b/app-core/src/main/java/com/mercury/platform/shared/config/ConfigManager.java index 0d5e8d12..a11a556c 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/ConfigManager.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/ConfigManager.java @@ -15,7 +15,7 @@ public interface ConfigManager { PlainConfigurationService scannerConfiguration(); KeyValueConfigurationService soundConfiguration(); KeyValueConfigurationService scaleConfiguration(); - KeyValueConfigurationService hotKeysConfiguration(); + PlainConfigurationService hotKeysConfiguration(); AdrConfigurationService adrConfiguration(); ListConfigurationService stashTabConfiguration(); IconBundleConfigurationService iconBundleConfiguration(); diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/MercuryConfigManager.java b/app-core/src/main/java/com/mercury/platform/shared/config/MercuryConfigManager.java index 00cd264e..89acc361 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/MercuryConfigManager.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/MercuryConfigManager.java @@ -7,7 +7,6 @@ import com.mercury.platform.shared.config.configration.impl.adr.AdrConfigurationServiceMock; import com.mercury.platform.shared.config.descriptor.*; import com.mercury.platform.shared.config.descriptor.StashTabDescriptor; -import com.mercury.platform.shared.config.descriptor.adr.AdrProfileDescriptor; import com.mercury.platform.shared.config.json.JSONHelper; import com.mercury.platform.shared.store.MercuryStoreCore; import org.apache.commons.io.FileUtils; @@ -34,7 +33,7 @@ public class MercuryConfigManager implements ConfigManager, AsSubscriber { private PlainConfigurationService scannerConfigurationService; private KeyValueConfigurationService soundConfigurationService; private KeyValueConfigurationService scaleConfigurationService; - private KeyValueConfigurationService hotKeyConfigurationService; + private PlainConfigurationService hotKeyConfigurationService; private ListConfigurationService stashTabConfigurationService; private IconBundleConfigurationService iconBundleConfigurationService; private AdrConfigurationService adrConfigurationService; @@ -92,7 +91,7 @@ public IconBundleConfigurationService iconBundleConfiguration() { } @Override - public KeyValueConfigurationService hotKeysConfiguration() { + public PlainConfigurationService hotKeysConfiguration() { return this.hotKeyConfigurationService; } @@ -143,7 +142,7 @@ public void load(){ this.notificationConfigurationService = new NotificationConfigurationService(selectedProfile); this.scaleConfigurationService = new ScaleConfigurationService(selectedProfile); this.stashTabConfigurationService = new StashTabConfigurationService(selectedProfile); - this.hotKeyConfigurationService = new HotKeysConfigurationService(selectedProfile); + this.hotKeyConfigurationService = new HotKeyConfigurationService(selectedProfile); this.adrConfigurationService = new AdrConfigurationServiceMock(selectedProfile); this.iconBundleConfigurationService = new IconBundleConfigurationServiceImpl(selectedProfile); diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ApplicationConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ApplicationConfigurationService.java index 9814e580..f69449b2 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ApplicationConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ApplicationConfigurationService.java @@ -44,6 +44,7 @@ public ApplicationDescriptor getDefault() { descriptor.setCheckOutUpdate(true); descriptor.setInGameDnd(false); descriptor.setDndResponseText("Response text"); + System.out.println("qwe"); return descriptor; } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeyConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeyConfigurationService.java new file mode 100644 index 00000000..6aa37b1a --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeyConfigurationService.java @@ -0,0 +1,77 @@ +package com.mercury.platform.shared.config.configration.impl; + + +import com.mercury.platform.shared.config.configration.BaseConfigurationService; +import com.mercury.platform.shared.config.configration.KeyValueConfigurationService; +import com.mercury.platform.shared.config.configration.PlainConfigurationService; +import com.mercury.platform.shared.config.descriptor.*; +import com.mercury.platform.shared.store.MercuryStoreCore; +import org.jnativehook.keyboard.NativeKeyEvent; + +import java.util.*; + +public class HotKeyConfigurationService extends BaseConfigurationService implements PlainConfigurationService { + public HotKeyConfigurationService(ProfileDescriptor selectedProfile) { + super(selectedProfile); + } + + @Override + public HotKeysSettingsDescriptor getDefault() { + HotKeysSettingsDescriptor hotKeysSettingsDescriptor = new HotKeysSettingsDescriptor(); + List incNDataList = new ArrayList<>(); + incNDataList.add(new HotKeyPair(HotKeyType.N_INVITE_PLAYER,new HotKeyDescriptor("F1", NativeKeyEvent.VC_F1,true,false,false))); + incNDataList.add(new HotKeyPair(HotKeyType.N_TRADE_PLAYER,new HotKeyDescriptor("F2",NativeKeyEvent.VC_F2,true,false,false))); + incNDataList.add(new HotKeyPair(HotKeyType.N_KICK_PLAYER,new HotKeyDescriptor("F3",NativeKeyEvent.VC_F3,true,false,false))); + incNDataList.add(new HotKeyPair(HotKeyType.N_STILL_INTERESTING,new HotKeyDescriptor("F4",NativeKeyEvent.VC_F4,true,false,false))); + incNDataList.add(new HotKeyPair(HotKeyType.N_OPEN_CHAT,new HotKeyDescriptor("F5",NativeKeyEvent.VC_F5,true,false,false))); + incNDataList.add(new HotKeyPair(HotKeyType.N_SWITCH_CHAT,new HotKeyDescriptor("F6",NativeKeyEvent.VC_F6,true,false,false))); + incNDataList.add(new HotKeyPair(HotKeyType.N_CLOSE_NOTIFICATION,new HotKeyDescriptor("F7",NativeKeyEvent.VC_F7,true,false,false))); + + List outNDataList = new ArrayList<>(); + outNDataList.add(new HotKeyPair(HotKeyType.N_VISITE_HIDEOUT,new HotKeyDescriptor("F1", NativeKeyEvent.VC_F1,true,false,false))); + outNDataList.add(new HotKeyPair(HotKeyType.N_TRADE_PLAYER,new HotKeyDescriptor("F2",NativeKeyEvent.VC_F2,true,false,false))); + outNDataList.add(new HotKeyPair(HotKeyType.N_LEAVE,new HotKeyDescriptor("F3",NativeKeyEvent.VC_F3,true,false,false))); + outNDataList.add(new HotKeyPair(HotKeyType.N_OPEN_CHAT,new HotKeyDescriptor("F4",NativeKeyEvent.VC_F4,true,false,false))); + outNDataList.add(new HotKeyPair(HotKeyType.N_CLOSE_NOTIFICATION,new HotKeyDescriptor("F5",NativeKeyEvent.VC_F5,true,false,false))); + + List scannerNDataList = new ArrayList<>(); + scannerNDataList.add(new HotKeyPair(HotKeyType.N_QUICK_RESPONSE,new HotKeyDescriptor("F1", NativeKeyEvent.VC_F1,true,false,false))); + scannerNDataList.add(new HotKeyPair(HotKeyType.N_VISITE_HIDEOUT,new HotKeyDescriptor("F2", NativeKeyEvent.VC_F2,true,false,false))); + scannerNDataList.add(new HotKeyPair(HotKeyType.N_TRADE_PLAYER,new HotKeyDescriptor("F3",NativeKeyEvent.VC_F3,true,false,false))); + scannerNDataList.add(new HotKeyPair(HotKeyType.N_LEAVE,new HotKeyDescriptor("F4",NativeKeyEvent.VC_F4,true,false,false))); + scannerNDataList.add(new HotKeyPair(HotKeyType.N_OPEN_CHAT,new HotKeyDescriptor("F5",NativeKeyEvent.VC_F5,true,false,false))); + scannerNDataList.add(new HotKeyPair(HotKeyType.N_CLOSE_NOTIFICATION,new HotKeyDescriptor("F6",NativeKeyEvent.VC_F6,true,false,false))); + + List taskBarNDataList = new ArrayList<>(); + taskBarNDataList.add(new HotKeyPair(HotKeyType.T_TO_HIDEOUT,new HotKeyDescriptor("F1",NativeKeyEvent.VC_F1,true,false,false))); + taskBarNDataList.add(new HotKeyPair(HotKeyType.T_DND,new HotKeyDescriptor("F2",NativeKeyEvent.VC_F2,true,false,false))); + + hotKeysSettingsDescriptor.setIncNHotKeysList(incNDataList); + hotKeysSettingsDescriptor.setOutNHotKeysList(outNDataList); + hotKeysSettingsDescriptor.setScannerNHotKeysList(scannerNDataList); + hotKeysSettingsDescriptor.setTaskBarNHotKeysList(taskBarNDataList); + return hotKeysSettingsDescriptor; + } + + @Override + public void toDefault() { + this.selectedProfile.setHotKeysSettingsDescriptor(this.getDefault()); + } + + @Override + public void validate() { + if (this.selectedProfile.getHotKeysSettingsDescriptor() == null){ + this.selectedProfile.setHotKeysSettingsDescriptor(this.getDefault()); + } + } + + @Override + public HotKeysSettingsDescriptor get() { + return this.selectedProfile.getHotKeysSettingsDescriptor(); + } + + @Override + public void set(HotKeysSettingsDescriptor descriptor) { + this.selectedProfile.setHotKeysSettingsDescriptor(descriptor); + } +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeysConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeysConfigurationService.java deleted file mode 100644 index 6971f1b8..00000000 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeysConfigurationService.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.mercury.platform.shared.config.configration.impl; - - -import com.mercury.platform.shared.config.configration.BaseConfigurationService; -import com.mercury.platform.shared.config.configration.KeyValueConfigurationService; -import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; -import com.mercury.platform.shared.config.descriptor.HotKeyType; -import com.mercury.platform.shared.config.descriptor.ProfileDescriptor; -import com.mercury.platform.shared.store.MercuryStoreCore; -import org.jnativehook.keyboard.NativeKeyEvent; - -import java.util.HashMap; -import java.util.Map; - -public class HotKeysConfigurationService extends BaseConfigurationService> implements KeyValueConfigurationService { - public HotKeysConfigurationService(ProfileDescriptor selectedProfile) { - super(selectedProfile); - } - - @Override - public Map getDefault() { - Map keyMap = new HashMap<>(); - keyMap.put(HotKeyType.INVITE_PLAYER.name(),new HotKeyDescriptor("Alt + 1", NativeKeyEvent.VC_1,'1',true,false,false)); - keyMap.put(HotKeyType.TRADE_PLAYER.name(),new HotKeyDescriptor("Alt + 2",NativeKeyEvent.VC_2,'2',true,false,false)); - keyMap.put(HotKeyType.KICK_PLAYER.name(),new HotKeyDescriptor("Alt + 3",NativeKeyEvent.VC_3,'3',true,false,false)); - keyMap.put(HotKeyType.STILL_INTERESTING.name(),new HotKeyDescriptor("Alt + 4",NativeKeyEvent.VC_4,'4',true,false,false)); - keyMap.put(HotKeyType.CLOSE_NOTIFICATION.name(),new HotKeyDescriptor("Alt + 5",NativeKeyEvent.VC_5,'5',true,false,false)); - return keyMap; - } - - @Override - public void toDefault() { - this.selectedProfile.setHotKeysDataMap(this.getDefault()); - } - - @Override - public HotKeyDescriptor get(String key) { - return this.selectedProfile.getHotKeysDataMap().computeIfAbsent(key, k -> { - this.selectedProfile.getHotKeysDataMap().put(key,this.getDefault().get(key)); - MercuryStoreCore.saveConfigSubject.onNext(true); - return this.getDefault().get(key); - }); - } - - @Override - public Map getMap() { - return this.selectedProfile.getHotKeysDataMap(); - } - - @Override - public void set(Map map) { - this.selectedProfile.setHotKeysDataMap(map); - } - - @Override - public void validate() { - if (this.selectedProfile.getHotKeysDataMap() == null){ - this.selectedProfile.setHotKeysDataMap(this.getDefault()); - } - this.getMap().values().forEach(it -> { - if(it.getTitle().equals("")){ - it.setTitle("..."); - } - }); - } -} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java index becfc98c..c3ae10f4 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java @@ -25,28 +25,21 @@ public NotificationSettingsDescriptor getDefault() { defaultButtons.add(new ResponseButtonDescriptor(1,true,"thx","thanks",new HotKeyDescriptor())); defaultButtons.add(new ResponseButtonDescriptor(2,false,"no thx", "no thanks",new HotKeyDescriptor())); defaultButtons.add(new ResponseButtonDescriptor(3,false,"sold", "sold",new HotKeyDescriptor())); - List defaultOutButtons = new ArrayList<>(); defaultOutButtons.add(new ResponseButtonDescriptor(0,false,"thanks","thanks", new HotKeyDescriptor())); - - notificationSettingsDescriptor.setButtons(defaultButtons); - notificationSettingsDescriptor.setLimitCount(3); - notificationSettingsDescriptor.setUnfoldCount(2); - notificationSettingsDescriptor.setDismissAfterKick(true); - notificationSettingsDescriptor.setShowLeague(false); - notificationSettingsDescriptor.setFlowDirections(FlowDirections.DOWNWARDS); + notificationSettingsDescriptor.setButtons(defaultOutButtons); return notificationSettingsDescriptor; } @Override public void toDefault() { - this.selectedProfile.setNotificationSettingsDescriptor(this.getDefault()); + this.selectedProfile.setNotificationDescriptor(this.getDefault()); } @Override public void validate() { - if(this.selectedProfile.getNotificationSettingsDescriptor() == null) { - this.selectedProfile.setNotificationSettingsDescriptor(this.getDefault()); + if(this.selectedProfile.getNotificationDescriptor() == null) { + this.selectedProfile.setNotificationDescriptor(this.getDefault()); } this.get().getButtons().forEach(it -> { if(it.getHotKeyDescriptor() == null) { @@ -60,11 +53,11 @@ public void validate() { @Override public NotificationSettingsDescriptor get() { - return this.selectedProfile.getNotificationSettingsDescriptor(); + return this.selectedProfile.getNotificationDescriptor(); } @Override public void set(NotificationSettingsDescriptor descriptor) { - this.selectedProfile.setNotificationSettingsDescriptor(descriptor); + this.selectedProfile.setNotificationDescriptor(descriptor); } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyDescriptor.java index 69d6dd8c..752fe9a1 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyDescriptor.java @@ -12,7 +12,6 @@ public class HotKeyDescriptor implements Serializable{ private String title = "..."; private int virtualKeyCode; - private char keyChar; private boolean menuPressed; private boolean shiftPressed; private boolean controlPressed; diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyPair.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyPair.java new file mode 100644 index 00000000..52c165d2 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyPair.java @@ -0,0 +1,13 @@ +package com.mercury.platform.shared.config.descriptor; + +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.io.Serializable; + +@Data +@AllArgsConstructor +public class HotKeyPair implements Serializable{ + private HotKeyType type; + private HotKeyDescriptor descriptor; +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyType.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyType.java index 682a04ae..a5c106f8 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyType.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyType.java @@ -5,47 +5,91 @@ import java.util.stream.Collectors; public enum HotKeyType { - INVITE_PLAYER { + N_TRADE_PLAYER { @Override public String getIconPath() { - return "app/invite.png"; + return "app/trade.png"; } }, - TRADE_PLAYER { + N_OPEN_CHAT { @Override public String getIconPath() { - return "app/trade.png"; + return "app/openChat.png"; + } + }, + N_CLOSE_NOTIFICATION { + @Override + public String getIconPath() { + return "app/close.png"; + } + }, + //Incoming notification + N_INVITE_PLAYER { + @Override + public String getIconPath() { + return "app/invite.png"; } }, - KICK_PLAYER { + N_KICK_PLAYER { @Override public String getIconPath() { return "app/kick.png"; } }, - STILL_INTERESTING { + N_STILL_INTERESTING { @Override public String getIconPath() { return "app/still-interesting.png"; } }, - CLOSE_NOTIFICATION { + N_SWITCH_CHAT { @Override public String getIconPath() { - return "app/close.png"; + return "app/chat_history.png"; + } + }, + //Outgoing/scanner notification + N_VISITE_HIDEOUT { + @Override + public String getIconPath() { + return "app/visiteHideout.png"; + } + }, + N_LEAVE { + @Override + public String getIconPath() { + return "app/leave.png"; + } + }, + N_BACK_TO_HIDEOUT { + @Override + public String getIconPath() { + return "app/backToHideout.png"; + } + }, + //scanner + N_QUICK_RESPONSE { + @Override + public String getIconPath() { + return "app/chat_scanner_response.png"; + } + }, + T_TO_HIDEOUT { + @Override + public String getIconPath() { + return "app/hideout.png"; + } + }, + T_DND { + @Override + public String getIconPath() { + return "app/visible-dnd-mode.png"; } }; -// EXPAND_ALL { -// @Override -// public String getIconPath() { -// return null; -// } -// }; - public abstract String getIconPath(); - public static boolean contains(String entry){ + public static boolean contains(HotKeyType entry){ return Arrays.stream(HotKeyType.values()) - .filter(it -> it.name().equals(entry)) + .filter(it -> it.equals(entry)) .collect(Collectors.toList()) .size() != 0; } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeysSettingsDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeysSettingsDescriptor.java new file mode 100644 index 00000000..73551fab --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeysSettingsDescriptor.java @@ -0,0 +1,15 @@ +package com.mercury.platform.shared.config.descriptor; + +import lombok.Data; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +@Data +public class HotKeysSettingsDescriptor implements Serializable { + private List incNHotKeysList = new ArrayList<>(); + private List outNHotKeysList = new ArrayList<>(); + private List scannerNHotKeysList = new ArrayList<>(); + private List taskBarNHotKeysList = new ArrayList<>(); +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationSettingsDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationSettingsDescriptor.java index f07ef9e5..54e469dd 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationSettingsDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationSettingsDescriptor.java @@ -9,12 +9,16 @@ @Data public class NotificationSettingsDescriptor implements Serializable{ - private boolean notificationEnable; - private int limitCount; - private int unfoldCount; - private FlowDirections flowDirections; - private boolean dismissAfterKick; + private boolean incNotificationEnable = true; + private boolean outNotificationEnable = true; + private boolean scannerNotificationEnable = true; + private int limitCount = 3; + private int unfoldCount = 2; + private FlowDirections flowDirections = FlowDirections.DOWNWARDS; + private boolean dismissAfterKick = true; + private boolean dismissAfterLeave = true; private boolean showLeague; private List buttons = new ArrayList<>(); private List outButtons = new ArrayList<>(); + private String playerNickname = "Set up your nickname in settings"; } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ProfileDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ProfileDescriptor.java index d71e3f86..e8d8c9d3 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ProfileDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ProfileDescriptor.java @@ -13,10 +13,10 @@ public class ProfileDescriptor { private Map frameDescriptorMap; private Map soundDescriptorMap; private ApplicationDescriptor applicationDescriptor; - private NotificationSettingsDescriptor notificationSettingsDescriptor; + private NotificationSettingsDescriptor notificationDescriptor; private ScannerDescriptor scannerDescriptor; private Map scaleDataMap; - private Map hotKeysDataMap; + private HotKeysSettingsDescriptor hotKeysSettingsDescriptor; private List stashTabDescriptors; private List adrProfileDescriptorList; private List iconBundleList; diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ScannerDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ScannerDescriptor.java index e73bfd48..13ef838c 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ScannerDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ScannerDescriptor.java @@ -2,8 +2,10 @@ import lombok.Data; +import java.io.Serializable; + @Data -public class ScannerDescriptor { +public class ScannerDescriptor implements Serializable{ private String words; private String responseMessage; } diff --git a/app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationType.java b/app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationType.java index c88690fe..76910d53 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationType.java +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationType.java @@ -6,5 +6,6 @@ public enum NotificationType { INC_CURRENCY_MESSAGE, OUT_ITEM_MESSAGE, OUT_CURRENCY_MESSAGE, - SCANNER_MESSAGE + SCANNER_MESSAGE, + HISTORY } diff --git a/app-core/src/main/java/com/mercury/platform/shared/hotkey/MercuryNativeKeyListener.java b/app-core/src/main/java/com/mercury/platform/shared/hotkey/MercuryNativeKeyListener.java index 51090bcc..8bac84be 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/hotkey/MercuryNativeKeyListener.java +++ b/app-core/src/main/java/com/mercury/platform/shared/hotkey/MercuryNativeKeyListener.java @@ -6,10 +6,20 @@ import org.jnativehook.keyboard.NativeKeyEvent; import org.jnativehook.keyboard.NativeKeyListener; +import java.awt.*; +import java.awt.event.KeyEvent; + public class MercuryNativeKeyListener implements NativeKeyListener{ private boolean menuPressed; private boolean shiftPressed; private boolean ctrlpressed; + + private boolean block; + + public MercuryNativeKeyListener() { + MercuryStoreCore.blockHotkeySubject.subscribe(state -> this.block = state); + } + @Override public void nativeKeyPressed(NativeKeyEvent nativeKeyEvent) { switch (nativeKeyEvent.getKeyCode()){ @@ -26,15 +36,9 @@ public void nativeKeyPressed(NativeKeyEvent nativeKeyEvent) { break; } default:{ - HotKeyDescriptor hotKeyDescriptor = new HotKeyDescriptor(); - hotKeyDescriptor.setTitle(NativeKeyEvent.getKeyText(nativeKeyEvent.getKeyCode())); - hotKeyDescriptor.setVirtualKeyCode(nativeKeyEvent.getKeyCode()); - hotKeyDescriptor.setControlPressed(this.ctrlpressed); - hotKeyDescriptor.setShiftPressed(this.shiftPressed); - hotKeyDescriptor.setMenuPressed(this.menuPressed); - - hotKeyDescriptor.setTitle(this.getButtonText(hotKeyDescriptor)); - MercuryStoreCore.hotKeySubject.onNext(hotKeyDescriptor); + if(!this.block) { + MercuryStoreCore.hotKeySubject.onNext(this.getDescriptor(nativeKeyEvent)); + } } } } @@ -59,7 +63,6 @@ public void nativeKeyReleased(NativeKeyEvent nativeKeyEvent) { @Override public void nativeKeyTyped(NativeKeyEvent nativeKeyEvent) { - } private String getButtonText(HotKeyDescriptor descriptor){ String text = descriptor.getTitle(); @@ -71,4 +74,15 @@ private String getButtonText(HotKeyDescriptor descriptor){ text = "Ctrl + " + text; return text; } + private HotKeyDescriptor getDescriptor(NativeKeyEvent nativeKeyEvent){ + HotKeyDescriptor hotKeyDescriptor = new HotKeyDescriptor(); + hotKeyDescriptor.setTitle(NativeKeyEvent.getKeyText(nativeKeyEvent.getKeyCode())); + hotKeyDescriptor.setVirtualKeyCode(nativeKeyEvent.getKeyCode()); + hotKeyDescriptor.setControlPressed(this.ctrlpressed); + hotKeyDescriptor.setShiftPressed(this.shiftPressed); + hotKeyDescriptor.setMenuPressed(this.menuPressed); + + hotKeyDescriptor.setTitle(this.getButtonText(hotKeyDescriptor)); + return hotKeyDescriptor; + } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java index 94871df0..00a7ae85 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java +++ b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java @@ -47,6 +47,8 @@ public class MercuryStoreCore { public static final PublishSubject toDefaultSubject = PublishSubject.create(); public static final PublishSubject changeProfileSubject = PublishSubject.create(); public static final PublishSubject hotKeySubject = PublishSubject.create(); + public static final PublishSubject hotKeyReleaseSubject = PublishSubject.create(); + public static final PublishSubject blockHotkeySubject = PublishSubject.create(); public static final PublishSubject errorHandlerSubject = PublishSubject.create(); public static final PublishSubject adrVisibleSubject = PublishSubject.create(); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrDurationComponentPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrDurationComponentPanel.java index c3726a41..e943e27e 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrDurationComponentPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrDurationComponentPanel.java @@ -5,6 +5,8 @@ import com.mercury.platform.ui.components.ComponentsFactory; import rx.Subscription; +import javax.swing.*; + public abstract class AdrDurationComponentPanel extends AdrComponentPanel{ private Subscription adrHotKeySubscription; @@ -16,11 +18,13 @@ public AdrDurationComponentPanel(T descriptor, ComponentsFactory componentsFacto public void subscribe() { super.subscribe(); this.adrHotKeySubscription = MercuryStoreCore.hotKeySubject.subscribe(hotKey -> { - if(this.descriptor.getHotKeyDescriptor() != null) { - if (this.descriptor.getHotKeyDescriptor().equals(hotKey) && !this.inSettings) { - this.onHotKeyPressed(); + SwingUtilities.invokeLater(()-> { + if(this.descriptor.getHotKeyDescriptor() != null) { + if (this.descriptor.getHotKeyDescriptor().equals(hotKey) && !this.inSettings) { + this.onHotKeyPressed(); + } } - } + }); }); } protected abstract void onHotKeyPressed(); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrMainPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrMainPagePanel.java index 4643a9fc..bc8cc5b5 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrMainPagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrMainPagePanel.java @@ -127,7 +127,7 @@ public void mouseClicked(MouseEvent e) { container.add(this.componentsFactory.wrapToSlide(createIconsGroup)); container.add(this.componentsFactory.wrapToSlide(createPbGroup)); } -// container.add(this.componentsFactory.wrapToSlide(createCaptureComponent)); + container.add(this.componentsFactory.wrapToSlide(createCaptureComponent)); container.add(this.componentsFactory.wrapToSlide(importButton)); this.add(verticalContainer,BorderLayout.CENTER); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java b/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java index d286af06..a2cd2f2f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java @@ -15,6 +15,7 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; +import lombok.Getter; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -45,6 +46,7 @@ public class ComponentsFactory{ private Font ITALIC_FONT; private Font REGULAR_FONT; private Font SMALLCAPS_FONT; + @Getter private Font DEFAULT_FONT; private float scale = 1f; @@ -96,22 +98,27 @@ protected void paintBorder(Graphics g) { button.setForeground(AppThemeColor.TEXT_DEFAULT); button.setFocusPainted(false); button.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - if(SwingUtilities.isLeftMouseButton(e)) { - MercuryStoreCore.soundSubject.onNext(SoundType.CLICKS); - } - } + Border prevBorder; @Override public void mouseEntered(MouseEvent e) { + this.prevBorder = button.getBorder(); + CompoundBorder compoundBorder = BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(AppThemeColor.ADR_SELECTED_BORDER, 1), + BorderFactory.createLineBorder(button.getBackground(), 3) + ); + button.setBorder(compoundBorder); button.setCursor(new Cursor(Cursor.HAND_CURSOR)); } @Override public void mouseExited(MouseEvent e) { + button.setBorder(prevBorder); button.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); + button.addActionListener(action -> { + MercuryStoreCore.soundSubject.onNext(SoundType.CLICKS); + }); if(isAscii(text)){ button.setFont(getSelectedFont(fontStyle).deriveFont(scale*fontSize)); }else { @@ -210,15 +217,15 @@ protected void paintBorder(Graphics g) { button.addMouseListener(new TooltipMouseListener(tooltip)); } button.setBorder(BorderFactory.createEmptyBorder(4,4,4,4)); + button.addActionListener(action -> { + MercuryStoreCore.soundSubject.onNext(SoundType.CLICKS); + button.setBorder(BorderFactory.createEmptyBorder(4,4,4,4)); + }); button.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - if(SwingUtilities.isLeftMouseButton(e)) { - MercuryStoreCore.soundSubject.onNext(SoundType.CLICKS); - } - } + Border prevBorder; @Override public void mouseEntered(MouseEvent e) { + prevBorder = button.getBorder(); button.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(AppThemeColor.ADR_SELECTED_BORDER), BorderFactory.createEmptyBorder(3,3,3,3))); @@ -227,7 +234,7 @@ public void mouseEntered(MouseEvent e) { @Override public void mouseExited(MouseEvent e) { - button.setBorder(BorderFactory.createEmptyBorder(4,4,4,4)); + button.setBorder(prevBorder); button.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } @@ -362,6 +369,16 @@ public JLabel getIconLabel(String iconPath, int size){ } return iconLabel; } + public JLabel getIconLabel(String iconPath, int size, int aligment){ + JLabel iconLabel = new JLabel(); + try { + iconLabel.setIcon(getIcon(iconPath,(int)(scale*size))); + } catch (Exception e) { + return getTextLabel(StringUtils.substringBetween(iconPath,"/",".")); + } + iconLabel.setHorizontalAlignment(aligment); + return iconLabel; + } public JLabel getIconLabel(URL url, int size){ JLabel iconLabel = new JLabel(); try { @@ -438,14 +455,14 @@ public JCheckBox getCheckBox(String tooltip){ JCheckBox checkBox = new JCheckBox(); checkBox.setFocusPainted(false); checkBox.setBackground(AppThemeColor.TRANSPARENT); - checkBox.setUI(new WindowsButtonUI()); +// checkBox.setUI(new WindowsButtonUI()); checkBox.addMouseListener(new TooltipMouseListener(tooltip)); return checkBox; } public JCheckBox getCheckBox(boolean value){ JCheckBox checkBox = new JCheckBox(); checkBox.setSelected(value); - checkBox.setUI(new WindowsButtonUI()); +// checkBox.setUI(new WindowsButtonUI()); checkBox.setFocusPainted(false); checkBox.setBackground(AppThemeColor.TRANSPARENT); return checkBox; @@ -516,7 +533,7 @@ public JSlider getSlider(int min, int max, int value){ slider.setMajorTickSpacing(10); slider.setMinorTickSpacing(1); // slider.setPaintLabels(true); - slider.setUI(new WindowsSliderUI(slider)); +// slider.setUI(new WindowsSliderUI(slider)); slider.setForeground(AppThemeColor.TEXT_DEFAULT); slider.setFont(REGULAR_FONT.deriveFont(15f)); slider.setRequestFocusEnabled(false); @@ -650,7 +667,7 @@ private boolean matches(char c) { public JPanel getJPanel(LayoutManager layoutManager) { JPanel panel = new JPanel(layoutManager); - panel.setBackground(AppThemeColor.FRAME_RGB); + panel.setBackground(AppThemeColor.FRAME); return panel; } public JPanel getJPanel(LayoutManager layoutManager,Color bg) { @@ -691,7 +708,7 @@ public Component add(Component comp) { return panel.add(comp); } }; - wrapper.setBackground(AppThemeColor.FRAME_RGB); + wrapper.setBackground(AppThemeColor.FRAME); wrapper.setBorder(BorderFactory.createEmptyBorder(top,left,bottom,right)); wrapper.add(panel,BorderLayout.CENTER); return wrapper; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/fields/font/FontStyle.java b/app-ui/src/main/java/com/mercury/platform/ui/components/fields/font/FontStyle.java index 0015f1a0..8afeffa5 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/fields/font/FontStyle.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/fields/font/FontStyle.java @@ -4,5 +4,5 @@ * Created by Константин on 23.12.2016. */ public enum FontStyle { - ITALIC, BOLD, REGULAR, SMALLCAPS + ITALIC, BOLD, REGULAR, SMALLCAPS,DEFAULT } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/fields/style/MercuryComboBoxUI.java b/app-ui/src/main/java/com/mercury/platform/ui/components/fields/style/MercuryComboBoxUI.java index 3d59fa0d..b1aec1ac 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/fields/style/MercuryComboBoxUI.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/fields/style/MercuryComboBoxUI.java @@ -13,7 +13,7 @@ public static MercuryComboBoxUI createUI(JComponent c) { } @Override protected JButton createArrowButton() { - return new ComponentsFactory().getIconButton("app/expand-combobox.png",16, AppThemeColor.FRAME_ALPHA,"Expand."); + return new ComponentsFactory().getIconButton("app/expand-combobox.png",16, AppThemeColor.HEADER,"Expand."); } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/fields/style/MercuryScrollBarUI.java b/app-ui/src/main/java/com/mercury/platform/ui/components/fields/style/MercuryScrollBarUI.java index ffe16b0e..c37eb2c0 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/fields/style/MercuryScrollBarUI.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/fields/style/MercuryScrollBarUI.java @@ -14,7 +14,7 @@ public MercuryScrollBarUI(Color color) { this.scrollColor = color; } public MercuryScrollBarUI() { - this.scrollColor = AppThemeColor.BUTTON; + this.scrollColor = AppThemeColor.SCROLL_BAR; } @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/ItemInfoPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/ItemInfoPanel.java index 1ca355c3..c9d7dbcc 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/ItemInfoPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/ItemInfoPanel.java @@ -41,19 +41,19 @@ public void onViewInit() { this.setBackground(AppThemeColor.FRAME); JLabel nicknameLabel = componentsFactory.getTextLabel(message.getWhisperNickname()); - JPanel nicknamePanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); + JPanel nicknamePanel = componentsFactory.getJPanel(new FlowLayout(FlowLayout.CENTER)); nicknameLabel.setForeground(AppThemeColor.TEXT_NICKNAME); nicknamePanel.add(nicknameLabel); nicknamePanel.setBorder(BorderFactory.createEmptyBorder(-6,0,-6,0)); this.add(nicknamePanel,BorderLayout.CENTER); - JButton hideButton = componentsFactory.getIconButton("app/close.png", 12, AppThemeColor.FRAME_ALPHA, "Close"); + JButton hideButton = componentsFactory.getIconButton("app/close.png", 12, AppThemeColor.FRAME, "Close"); hideButton.addActionListener((action)-> { controller.hidePanel(); }); this.add(hideButton,BorderLayout.LINE_END); - JPanel tabInfoPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); + JPanel tabInfoPanel = componentsFactory.getJPanel(new FlowLayout(FlowLayout.CENTER)); JLabel tabLabel = componentsFactory.getTextLabel("Tab: " + message.getTabName()); tabInfoPanel.add(tabLabel); tabInfoPanel.setBorder(BorderFactory.createEmptyBorder(-8,0,-6,0)); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/TabInfoPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/TabInfoPanel.java index adc2d9dd..775fa19f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/TabInfoPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/TabInfoPanel.java @@ -25,12 +25,12 @@ public TabInfoPanel(@NonNull StashTabDescriptor stashTabDescriptor, @NonNull Com public void onViewInit() { this.setLayout(new BorderLayout()); this.setBackground(AppThemeColor.FRAME); - JButton hideButton = componentsFactory.getIconButton("app/close.png", 12, AppThemeColor.FRAME_ALPHA, "Dismiss"); + JButton hideButton = componentsFactory.getIconButton("app/close.png", 12, AppThemeColor.FRAME, "Dismiss"); hideButton.addActionListener((action)->{ stashTabDescriptor.setUndefined(true); MercuryStoreUI.dismissTabInfoPanelSubject.onNext(this); }); - JPanel tabInfoPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); + JPanel tabInfoPanel = componentsFactory.getJPanel(new FlowLayout(FlowLayout.CENTER)); JLabel tabLabel = componentsFactory.getTextLabel(stashTabDescriptor.getTitle()); tabLabel.setBorder(null); tabLabel.setFont(componentsFactory.getFont(FontStyle.BOLD,15f)); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/HistoryNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/HistoryNotificationPanel.java new file mode 100644 index 00000000..2167caa1 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/HistoryNotificationPanel.java @@ -0,0 +1,55 @@ +package com.mercury.platform.ui.components.panel.notification; + +import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.descriptor.HotKeyType; +import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.components.fields.font.TextAlignment; +import com.mercury.platform.ui.components.panel.notification.controller.HistoryController; +import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.TooltipConstants; + +import javax.swing.*; +import java.awt.*; + + +public class HistoryNotificationPanel extends NotificationPanel { + @Override + public void onViewInit() { + super.onViewInit(); + this.add(this.getHeader(),BorderLayout.PAGE_START); + JLabel sourceLabel = this.componentsFactory.getTextLabel(this.data.getSourceString(),FontStyle.REGULAR,17f); + sourceLabel.setBackground(AppThemeColor.FRAME); + sourceLabel.setHorizontalAlignment(SwingConstants.LEFT); + sourceLabel.setVerticalAlignment(SwingConstants.TOP); + this.add(sourceLabel,BorderLayout.CENTER); + } + private JPanel getHeader(){ + JPanel root = new JPanel(new BorderLayout()); + root.setBackground(AppThemeColor.MSG_HEADER); + root.setBorder(BorderFactory.createEmptyBorder(1,1,1,1)); + + JLabel nicknameLabel = this.componentsFactory.getTextLabel(FontStyle.BOLD,AppThemeColor.TEXT_NICKNAME, TextAlignment.LEFTOP,15f,this.data.getWhisperNickname()); + nicknameLabel.setBorder(BorderFactory.createEmptyBorder(0,4,0,5)); + root.add(nicknameLabel,BorderLayout.CENTER); + + JPanel opPanel = this.componentsFactory.getJPanel(new BorderLayout(),AppThemeColor.MSG_HEADER); + JPanel interactionPanel = new JPanel(new GridLayout(1,0,4,0)); + interactionPanel.setBackground(AppThemeColor.MSG_HEADER); + JButton reloadButton = componentsFactory.getIconButton("app/reload-history.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.INVITE); + reloadButton.addActionListener(e -> { + this.controller.reload(); + }); + JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); + openChatButton.addActionListener(e -> controller.performOpenChat()); + interactionPanel.add(reloadButton); + interactionPanel.add(openChatButton); + opPanel.add(interactionPanel,BorderLayout.CENTER); + root.add(opPanel,BorderLayout.LINE_END); + return root; + } + @Override + protected void updateHotKeyPool() { + /*NOP*/ + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/InMessagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/InMessagePanel.java index 223b1cff..503bf747 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/InMessagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/InMessagePanel.java @@ -561,12 +561,12 @@ public void setComponentsFactory(ComponentsFactory componentsFactory) { @Override public void initHotKeyListeners() { - KeyValueConfigurationService config = Configuration.get().hotKeysConfiguration(); - MercuryStoreCore.hotKeySubject.subscribe(descriptor -> { - HotKeyDescriptor hotKeyDescriptor = config.get(HotKeyType.CLOSE_NOTIFICATION.name()); - if(descriptor.equals(hotKeyDescriptor)) { - this.controller.performHide(); - } - }); +// KeyValueConfigurationService config = Configuration.get().hotKeysConfiguration(); +// MercuryStoreCore.hotKeySubject.subscribe(descriptor -> { +// HotKeyDescriptor hotKeyDescriptor = config.get(HotKeyType.N_CLOSE_NOTIFICATION.name()); +// if(descriptor.equals(hotKeyDescriptor)) { +// this.controller.performHide(); +// } +// }); } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java index b3ba2b29..f57bfa6b 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java @@ -2,12 +2,13 @@ import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.configration.KeyValueConfigurationService; import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; -import com.mercury.platform.shared.config.descriptor.ResponseButtonDescriptor; +import com.mercury.platform.shared.config.descriptor.*; import com.mercury.platform.shared.entity.message.TradeNotificationDescriptor; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; +import com.mercury.platform.ui.components.panel.VerticalScrollContainer; import com.mercury.platform.ui.components.panel.notification.controller.IncomingPanelController; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.TooltipConstants; @@ -15,8 +16,6 @@ import javax.swing.*; import javax.swing.Timer; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.*; @@ -24,28 +23,46 @@ public abstract class IncomingNotificationPanel extends NotificationPanel{ private PlainConfigurationService config; + private PlainConfigurationService hotKeysConfig; + private JPanel messagePanel; + private JPanel responseButtonsPanel; + private JPanel chatPanel; + private JPanel chatContainer; @Override public void onViewInit() { super.onViewInit(); this.config = Configuration.get().notificationConfiguration(); + this.hotKeysConfig = Configuration.get().hotKeysConfiguration(); this.add(this.getHeader(),BorderLayout.PAGE_START); - this.add(this.getMessagePanel(),BorderLayout.CENTER); - this.add(this.getResponseButtonsPanel(),BorderLayout.PAGE_END); + this.messagePanel = this.getMessagePanel(); + this.responseButtonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER,5,2)); + this.responseButtonsPanel.setBackground(AppThemeColor.FRAME); + this.chatPanel = this.getChatPanel(); + this.chatPanel.setVisible(false); + this.add(this.messagePanel,BorderLayout.CENTER); + this.add(this.responseButtonsPanel,BorderLayout.PAGE_END); + this.updateHotKeyPool(); } private JPanel getHeader(){ JPanel root = new JPanel(new BorderLayout()); root.setBackground(AppThemeColor.MSG_HEADER); + root.setBorder(BorderFactory.createEmptyBorder(1,1,1,1)); + JPanel nickNamePanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.MSG_HEADER); JLabel nicknameLabel = this.componentsFactory.getTextLabel(FontStyle.BOLD,AppThemeColor.TEXT_NICKNAME, TextAlignment.LEFTOP,15f,this.getNicknameText()); - nicknameLabel.setBorder(BorderFactory.createEmptyBorder(0,5,0,5)); - root.add(nicknameLabel,BorderLayout.CENTER); + nicknameLabel.setBorder(BorderFactory.createEmptyBorder(0,4,0,5)); + nickNamePanel.add(this.getExpandButton(),BorderLayout.LINE_START); + nickNamePanel.add(nicknameLabel,BorderLayout.CENTER); + root.add(nickNamePanel,BorderLayout.CENTER); JPanel opPanel = this.componentsFactory.getJPanel(new BorderLayout(),AppThemeColor.MSG_HEADER); JPanel interactionPanel = new JPanel(new GridLayout(1,0,4,0)); - interactionPanel.setPreferredSize(new Dimension(200,26)); interactionPanel.setBackground(AppThemeColor.MSG_HEADER); JButton inviteButton = componentsFactory.getIconButton("app/invite.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.INVITE); - inviteButton.addActionListener(e -> this.controller.performInvite()); + inviteButton.addActionListener(e -> { + this.controller.performInvite(); + root.setBorder(BorderFactory.createLineBorder(AppThemeColor.HEADER_SELECTED_BORDER)); + }); JButton kickButton = componentsFactory.getIconButton("app/kick.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.KICK); kickButton.addActionListener(e -> { this.controller.performKick(); @@ -56,7 +73,21 @@ private JPanel getHeader(){ JButton tradeButton = componentsFactory.getIconButton("app/trade.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.TRADE); tradeButton.addActionListener(e -> { this.controller.performOfferTrade(); - this.onBlur(); + }); + JButton showChatButton = componentsFactory.getIconButton("app/chat_history.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); + showChatButton.addActionListener(e -> { + if(this.chatPanel.isVisible()){ + this.chatPanel.setVisible(false); + this.remove(this.chatPanel); + this.add(this.messagePanel,BorderLayout.CENTER); + this.add(this.responseButtonsPanel,BorderLayout.PAGE_END); + }else { + this.remove(this.messagePanel); + this.remove(this.responseButtonsPanel); + this.chatPanel.setVisible(true); + this.add(this.chatPanel,BorderLayout.CENTER); + } + SwingUtilities.getWindowAncestor(IncomingNotificationPanel.this).pack(); }); JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); openChatButton.addActionListener(e -> controller.performOpenChat()); @@ -64,13 +95,23 @@ private JPanel getHeader(){ hideButton.addActionListener(action -> { this.controller.performHide(); }); + JButton stillInterestedButton = getStillInterestedButton(); interactionPanel.add(inviteButton); interactionPanel.add(tradeButton); interactionPanel.add(kickButton); - interactionPanel.add(getStillInterestedButton()); + interactionPanel.add(stillInterestedButton); + interactionPanel.add(showChatButton); interactionPanel.add(openChatButton); interactionPanel.add(hideButton); + this.interactButtonMap.put(HotKeyType.N_INVITE_PLAYER,inviteButton); + this.interactButtonMap.put(HotKeyType.N_TRADE_PLAYER,tradeButton); + this.interactButtonMap.put(HotKeyType.N_KICK_PLAYER,kickButton); + this.interactButtonMap.put(HotKeyType.N_STILL_INTERESTING,stillInterestedButton); + this.interactButtonMap.put(HotKeyType.N_SWITCH_CHAT,showChatButton); + this.interactButtonMap.put(HotKeyType.N_OPEN_CHAT,openChatButton); + this.interactButtonMap.put(HotKeyType.N_CLOSE_NOTIFICATION,hideButton); + JPanel timePanel = this.getTimePanel(); timePanel.setPreferredSize(new Dimension(50,26)); opPanel.add(timePanel,BorderLayout.CENTER); @@ -79,14 +120,42 @@ private JPanel getHeader(){ root.add(opPanel,BorderLayout.LINE_END); return root; } + @Override - public void subscribe() { + protected void updateHotKeyPool() { + this.hotKeysPool.clear(); + this.interactButtonMap.forEach((type, button) -> { + HotKeyPair hotKeyPair = this.hotKeysConfig.get() + .getIncNHotKeysList() + .stream() + .filter(it -> it.getType().equals(type)) + .findAny().orElse(null); + this.hotKeysPool.put(hotKeyPair.getDescriptor(),button); + }); + this.initResponseButtonsPanel(); + Window windowAncestor = SwingUtilities.getWindowAncestor(IncomingNotificationPanel.this); + if(windowAncestor != null) { + windowAncestor.pack(); + } + } + @Override + public void subscribe() { + super.subscribe(); } @Override public void onViewDestroy() { - + super.onViewDestroy(); + } + private JPanel getChatPanel(){ + this.chatContainer = new VerticalScrollContainer(); + this.chatContainer.setLayout(new BoxLayout(this.chatContainer,BoxLayout.Y_AXIS)); + this.chatContainer.setBackground(AppThemeColor.FRAME); + this.chatContainer.add(this.componentsFactory.getTextLabel(this.data.getSourceString())); + this.chatContainer.add(this.componentsFactory.getTextLabel(this.data.getSourceString())); + this.chatContainer.add(this.componentsFactory.getTextLabel(this.data.getSourceString())); + return this.componentsFactory.wrapToSlide(this.chatContainer,AppThemeColor.FRAME); } protected JPanel getForPanel(){ JPanel forPanel = new JPanel(new BorderLayout()); @@ -134,9 +203,8 @@ protected JLabel getOfferLabel(){ } protected abstract JPanel getMessagePanel(); protected abstract JButton getStillInterestedButton(); - private JPanel getResponseButtonsPanel(){ - JPanel root = new JPanel(new FlowLayout(FlowLayout.CENTER,5,2)); - root.setBackground(AppThemeColor.FRAME); + private void initResponseButtonsPanel(){ + this.responseButtonsPanel.removeAll(); List buttonsConfig = this.config.get().getButtons(); Collections.sort(buttonsConfig); buttonsConfig.forEach((buttonConfig)->{ @@ -161,50 +229,21 @@ public void mouseExited(MouseEvent e) { )); } }); + button.addActionListener(action -> { + button.setBorder( BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(AppThemeColor.ADR_SELECTED_BORDER, 1), + BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON, 3) + )); + }); button.addActionListener(e -> { this.controller.performResponse(buttonConfig.getResponseText()); if(buttonConfig.isClose()){ this.controller.performHide(); } }); - root.add(button); - }); - return root; - } - private JPanel getTimePanel() { - JPanel root = new JPanel(new BorderLayout()); - root.setBackground(AppThemeColor.MSG_HEADER); - JLabel timeLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MISC, TextAlignment.CENTER, 14, "0m"); - Timer timeAgo = new Timer(60000, new ActionListener() { - private int minute = 0; - private int hours = 0; - private int day = 0; - - @Override - public void actionPerformed(ActionEvent e) { - String labelText = ""; - minute++; - if (minute > 60) { - hours++; - minute = 0; - if (hours > 24) { - day++; - hours = 0; - } - } - if (hours == 0 && day == 0) { - labelText = minute + "m"; - } else if (hours > 0) { - labelText = hours + "h " + minute + "m"; - } else if (day > 0) { - labelText = day + "d " + hours + "h " + minute + "m"; - } - timeLabel.setText(labelText); - } + this.hotKeysPool.put(buttonConfig.getHotKeyDescriptor(),button); + this.responseButtonsPanel.add(button); }); - timeAgo.start(); - root.add(timeLabel,BorderLayout.CENTER); - return root; } private String getNicknameText(){ String whisperNickname = data.getWhisperNickname(); @@ -231,26 +270,19 @@ private String getNicknameText(){ return result; } private JButton getExpandButton(){ - String iconPath = "app/default-mp.png"; -// if(expanded){ -// if(style.equals(MessagePanelStyle.IN_DOWNWARDS)){ -// iconPath = "app/expand-mp.png"; -// }else { -// iconPath = "app/collapse-mp.png"; -// } -// } + String iconPath = "app/expand-mp.png"; JButton expandButton = componentsFactory.getIconButton(iconPath, 18f, AppThemeColor.MSG_HEADER,""); - expandButton.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { -// if(SwingUtilities.isLeftMouseButton(e)) { -// if (!messagePanel.isVisible()) { -// expand(); -// } else { -// collapse(); -// } -// } + expandButton.addActionListener(action -> { + if(this.messagePanel.isVisible()){ + this.messagePanel.setVisible(false); + this.responseButtonsPanel.setVisible(false); + expandButton.setIcon(this.componentsFactory.getIcon("app/default-mp.png",18f)); + }else { + this.messagePanel.setVisible(true); + this.responseButtonsPanel.setVisible(true); + expandButton.setIcon(this.componentsFactory.getIcon("app/expand-mp.png",18f)); } + SwingUtilities.getWindowAncestor(IncomingNotificationPanel.this).pack(); }); return expandButton; } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java index 1eeb3ff9..e2924542 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java @@ -2,15 +2,25 @@ import com.mercury.platform.shared.AsSubscriber; +import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; +import com.mercury.platform.shared.config.descriptor.HotKeyType; import com.mercury.platform.ui.components.ComponentsFactory; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.components.fields.font.TextAlignment; import com.mercury.platform.ui.components.panel.misc.ViewDestroy; import com.mercury.platform.ui.components.panel.misc.ViewInit; import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.MercuryStoreUI; import lombok.Getter; import lombok.Setter; +import rx.Subscription; import javax.swing.*; import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.HashMap; +import java.util.Map; public abstract class NotificationPanel extends JPanel implements AsSubscriber, ViewInit,ViewDestroy { @Setter @@ -20,12 +30,16 @@ public abstract class NotificationPanel extends JPanel implements AsSubscri protected C controller; @Setter protected ComponentsFactory componentsFactory; + protected Map hotKeysPool = new HashMap<>(); + protected Map interactButtonMap = new HashMap<>(); @Setter private float paintAlphaValue = 0f; @Setter - private float paintBorderValue = 0f; - private boolean blurEffect; - private boolean blurReverse; + protected float paintBorderValue = 0f; + protected boolean blurEffect; + protected boolean blurReverse; + + private Subscription settingsPostSubscription; @Override public void onViewInit() { @@ -36,6 +50,26 @@ public void onViewInit() { BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON_BORDER, 1))); } + public void onHotKeyPressed(HotKeyDescriptor descriptor){ + JButton button = this.hotKeysPool.get(descriptor); + if(button != null){ + button.doClick(); + } + } + + @Override + public void subscribe() { + this.settingsPostSubscription = MercuryStoreUI.settingsPostSubject.subscribe(state -> { + this.updateHotKeyPool(); + }); + } + protected abstract void updateHotKeyPool(); + + @Override + public void onViewDestroy() { + this.settingsPostSubscription.unsubscribe(); + } + @Override public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g.create(); @@ -52,6 +86,41 @@ public void paint(Graphics g) { this.repaint(); } } + protected JPanel getTimePanel() { + JPanel root = new JPanel(new BorderLayout()); + root.setBackground(AppThemeColor.MSG_HEADER); + JLabel timeLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MISC, TextAlignment.CENTER, 14, "0m"); + Timer timeAgo = new Timer(60000, new ActionListener() { + private int minute = 0; + private int hours = 0; + private int day = 0; + + @Override + public void actionPerformed(ActionEvent e) { + String labelText = ""; + minute++; + if (minute > 60) { + hours++; + minute = 0; + if (hours > 24) { + day++; + hours = 0; + } + } + if (hours == 0 && day == 0) { + labelText = minute + "m"; + } else if (hours > 0) { + labelText = hours + "h " + minute + "m"; + } else if (day > 0) { + labelText = day + "d " + hours + "h " + minute + "m"; + } + timeLabel.setText(labelText); + } + }); + timeAgo.start(); + root.add(timeLabel,BorderLayout.CENTER); + return root; + } protected void onBlur(){ this.blurEffect = true; this.setBorder(BorderFactory.createCompoundBorder( diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutgoingNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutgoingNotificationPanel.java index ab22aacc..f3ef9ed2 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutgoingNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutgoingNotificationPanel.java @@ -1,10 +1,9 @@ package com.mercury.platform.ui.components.panel.notification; import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.configration.KeyValueConfigurationService; import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; -import com.mercury.platform.shared.config.descriptor.ResponseButtonDescriptor; -import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.shared.config.descriptor.*; import com.mercury.platform.shared.entity.message.TradeNotificationDescriptor; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; @@ -21,42 +20,51 @@ public abstract class OutgoingNotificationPanel extends NotificationPanel { private PlainConfigurationService config; + private PlainConfigurationService hotKeysConfig; + private JPanel responseButtonsPanel; + private JPanel bottomPanel; @Override public void onViewInit() { super.onViewInit(); this.config = Configuration.get().notificationConfiguration(); + this.hotKeysConfig = Configuration.get().hotKeysConfiguration(); this.add(this.getHeader(),BorderLayout.PAGE_START); - JPanel bottomPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); - bottomPanel.add(this.getContentPanel(),BorderLayout.CENTER); - bottomPanel.add(this.componentsFactory.wrapToSlide(this.getResponseButtonsPanel(),AppThemeColor.FRAME),BorderLayout.LINE_END); + + this.responseButtonsPanel = new JPanel(new GridLayout(1,0,0,5)); + this.responseButtonsPanel.setBackground(AppThemeColor.FRAME); + this.bottomPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); + this.bottomPanel.add(this.getContentPanel(),BorderLayout.CENTER); + this.bottomPanel.add(this.componentsFactory.wrapToSlide(this.responseButtonsPanel,AppThemeColor.FRAME),BorderLayout.LINE_END); this.add(bottomPanel,BorderLayout.CENTER); + this.updateHotKeyPool(); } private JPanel getHeader(){ JPanel root = new JPanel(new BorderLayout()); root.setBackground(AppThemeColor.MSG_HEADER); + JPanel nickNamePanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.MSG_HEADER); JLabel nicknameLabel = this.componentsFactory.getTextLabel(FontStyle.BOLD,AppThemeColor.TEXT_NICKNAME, TextAlignment.LEFTOP,15f,this.data.getWhisperNickname()); nicknameLabel.setBorder(BorderFactory.createEmptyBorder(0,5,0,5)); + nickNamePanel.add(this.getExpandButton(),BorderLayout.LINE_START); + nickNamePanel.add(nicknameLabel,BorderLayout.CENTER); + root.add(nickNamePanel,BorderLayout.CENTER); - root.add(nicknameLabel,BorderLayout.CENTER); - - JPanel interactionPanel = new JPanel(new GridLayout(1,0,4,0)); - interactionPanel.setPreferredSize(new Dimension(200,26)); + JPanel interactionPanel = new JPanel(new GridLayout(1,0,6,0)); interactionPanel.setBackground(AppThemeColor.MSG_HEADER); JButton visiteHideout = componentsFactory.getIconButton("app/visiteHideout.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.INVITE); visiteHideout.addActionListener(e -> this.controller.visitHideout()); JButton tradeButton = componentsFactory.getIconButton("app/trade.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.TRADE); - tradeButton.addActionListener(e -> this.controller.performTrade()); + tradeButton.addActionListener(e -> this.controller.performOfferTrade()); JButton leaveButton = componentsFactory.getIconButton("app/leave.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.KICK); leaveButton.addActionListener(e -> { - this.controller.performLeave(); - if(this.config.get().isDismissAfterKick()){ + this.controller.performLeave(this.config.get().getPlayerNickname()); + if(this.config.get().isDismissAfterLeave()){ this.controller.performHide(); } }); - JButton backToHo = componentsFactory.getIconButton("app/backToHideout.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); - backToHo.addActionListener(e -> controller.backToHideout()); +// JButton backToHo = componentsFactory.getIconButton("app/backToHideout.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); +// backToHo.addActionListener(e -> controller.backToHideout()); JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); openChatButton.addActionListener(e -> controller.performOpenChat()); JButton hideButton = componentsFactory.getIconButton("app/close.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.HIDE_PANEL); @@ -66,16 +74,40 @@ private JPanel getHeader(){ interactionPanel.add(visiteHideout); interactionPanel.add(tradeButton); interactionPanel.add(leaveButton); - interactionPanel.add(backToHo); +// interactionPanel.add(backToHo); interactionPanel.add(openChatButton); interactionPanel.add(hideButton); + this.interactButtonMap.put(HotKeyType.N_VISITE_HIDEOUT,visiteHideout); + this.interactButtonMap.put(HotKeyType.N_TRADE_PLAYER,tradeButton); + this.interactButtonMap.put(HotKeyType.N_LEAVE,leaveButton); +// this.interactButtonMap.put(HotKeyType.N_BACK_TO_HIDEOUT,backToHo); + this.interactButtonMap.put(HotKeyType.N_OPEN_CHAT,openChatButton); + this.interactButtonMap.put(HotKeyType.N_CLOSE_NOTIFICATION,hideButton); root.add(interactionPanel,BorderLayout.LINE_END); return root; } - private JPanel getResponseButtonsPanel(){ - JPanel root = new JPanel(new GridLayout(1,0,0,5)); - root.setBackground(AppThemeColor.FRAME); + + @Override + protected void updateHotKeyPool() { + this.hotKeysPool.clear(); + this.interactButtonMap.forEach((type, button) -> { + HotKeyPair hotKeyPair = this.hotKeysConfig.get() + .getOutNHotKeysList() + .stream() + .filter(it -> it.getType().equals(type)) + .findAny().orElse(null); + this.hotKeysPool.put(hotKeyPair.getDescriptor(),button); + }); + this.initResponseButtonPanel(); + Window windowAncestor = SwingUtilities.getWindowAncestor(OutgoingNotificationPanel.this); + if(windowAncestor != null) { + windowAncestor.pack(); + } + } + + private void initResponseButtonPanel(){ + this.responseButtonsPanel.removeAll(); List buttonsConfig = this.config.get().getOutButtons(); Collections.sort(buttonsConfig); buttonsConfig.forEach((buttonConfig)->{ @@ -97,15 +129,21 @@ public void mouseExited(MouseEvent e) { )); } }); + button.addActionListener(action -> { + button.setBorder( BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(AppThemeColor.ADR_SELECTED_BORDER, 1), + BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON, 3) + )); + }); button.addActionListener(e -> { this.controller.performResponse(buttonConfig.getResponseText()); if(buttonConfig.isClose()){ this.controller.performHide(); } }); - root.add(button); + this.responseButtonsPanel.add(button); + this.hotKeysPool.put(buttonConfig.getHotKeyDescriptor(),button); }); - return root; } protected JPanel getFromPanel(){ JPanel forPanel = new JPanel(new BorderLayout()); @@ -144,13 +182,28 @@ protected JPanel getCurrencyPanel(Double curCount, String curIconPath){ } @Override public void subscribe() { - + super.subscribe(); } protected abstract JPanel getContentPanel(); @Override public void onViewDestroy() { - + super.onViewDestroy(); + } + private JButton getExpandButton(){ + String iconPath = "app/expand-mp.png"; + JButton expandButton = componentsFactory.getIconButton(iconPath, 18f, AppThemeColor.MSG_HEADER,""); + expandButton.addActionListener(action -> { + if(this.bottomPanel.isVisible()){ + this.bottomPanel.setVisible(false); + expandButton.setIcon(this.componentsFactory.getIcon("app/default-mp.png",18f)); + }else { + this.bottomPanel.setVisible(true); + expandButton.setIcon(this.componentsFactory.getIcon("app/expand-mp.png",18f)); + } + SwingUtilities.getWindowAncestor(OutgoingNotificationPanel.this).pack(); + }); + return expandButton; } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java index 45f7244a..9fa38652 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java @@ -1,8 +1,9 @@ package com.mercury.platform.ui.components.panel.notification; import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.configration.KeyValueConfigurationService; import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.descriptor.ScannerDescriptor; +import com.mercury.platform.shared.config.descriptor.*; import com.mercury.platform.shared.entity.message.NotificationDescriptor; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; @@ -16,44 +17,52 @@ public class ScannerNotificationPanel extends NotificationPanel { private PlainConfigurationService config; + private PlainConfigurationService nConfig; + private PlainConfigurationService hotKeysConfig; + private JPanel contentPanel; @Override public void onViewInit() { super.onViewInit(); this.config = Configuration.get().scannerConfiguration(); + this.nConfig = Configuration.get().notificationConfiguration(); + this.hotKeysConfig = Configuration.get().hotKeysConfiguration(); this.add(this.getHeader(),BorderLayout.PAGE_START); - JLabel sourceLabel = this.componentsFactory.getTextLabel(this.data.getSourceString(),FontStyle.BOLD,17f); + JLabel sourceLabel = this.componentsFactory.getTextLabel(this.data.getSourceString(),FontStyle.REGULAR,17f); sourceLabel.setBackground(AppThemeColor.FRAME); sourceLabel.setHorizontalAlignment(SwingConstants.LEFT); sourceLabel.setVerticalAlignment(SwingConstants.TOP); - this.add(this.componentsFactory.wrapToSlide(sourceLabel,AppThemeColor.FRAME,2,2,2,2),BorderLayout.CENTER); - this.validate(); + this.contentPanel = this.componentsFactory.wrapToSlide(sourceLabel,AppThemeColor.FRAME,2,2,2,2); + this.add(this.contentPanel,BorderLayout.CENTER); + this.updateHotKeyPool(); } private JPanel getHeader(){ JPanel root = new JPanel(new BorderLayout()); root.setBackground(AppThemeColor.MSG_HEADER); + JPanel nickNamePanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.MSG_HEADER); JLabel nicknameLabel = this.componentsFactory.getTextLabel(FontStyle.BOLD,AppThemeColor.TEXT_NICKNAME, TextAlignment.LEFTOP,15f,this.data.getWhisperNickname()); nicknameLabel.setBorder(BorderFactory.createEmptyBorder(0,5,0,5)); + nickNamePanel.add(this.getExpandButton(),BorderLayout.LINE_START); + nickNamePanel.add(nicknameLabel,BorderLayout.CENTER); + root.add(nickNamePanel,BorderLayout.CENTER); - root.add(nicknameLabel,BorderLayout.CENTER); - - JPanel interactionPanel = new JPanel(new GridLayout(1,0,4,0)); - interactionPanel.setPreferredSize(new Dimension(234,26)); + JPanel interactionPanel = new JPanel(new GridLayout(1,0,6,0)); interactionPanel.setBackground(AppThemeColor.MSG_HEADER); JButton inviteMeButton = componentsFactory.getIconButton("app/chat_scanner_response.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.INVITE); inviteMeButton.addActionListener(e -> this.controller.performResponse(this.config.get().getResponseMessage())); JButton visiteHideout = componentsFactory.getIconButton("app/visiteHideout.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.INVITE); visiteHideout.addActionListener(e -> this.controller.visitHideout()); JButton tradeButton = componentsFactory.getIconButton("app/trade.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.TRADE); - tradeButton.addActionListener(e -> this.controller.performTrade()); + tradeButton.addActionListener(e -> this.controller.performOfferTrade()); JButton leaveButton = componentsFactory.getIconButton("app/leave.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.KICK); leaveButton.addActionListener(e -> { - this.controller.performLeave(); + this.controller.performLeave(this.nConfig.get().getPlayerNickname()); + if(this.nConfig.get().isDismissAfterLeave()){ + this.controller.performHide(); + } }); - JButton backToHo = componentsFactory.getIconButton("app/backToHideout.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); - backToHo.addActionListener(e -> controller.backToHideout()); JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); - openChatButton.addActionListener(e -> controller.performOpenChat()); + openChatButton.addActionListener(e -> this.controller.performOpenChat()); JButton hideButton = componentsFactory.getIconButton("app/close.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.HIDE_PANEL); hideButton.addActionListener(action -> { this.controller.performHide(); @@ -62,19 +71,62 @@ private JPanel getHeader(){ interactionPanel.add(visiteHideout); interactionPanel.add(tradeButton); interactionPanel.add(leaveButton); - interactionPanel.add(backToHo); +// interactionPanel.add(backToHo); interactionPanel.add(openChatButton); interactionPanel.add(hideButton); - root.add(interactionPanel,BorderLayout.LINE_END); + this.interactButtonMap.put(HotKeyType.N_QUICK_RESPONSE,inviteMeButton); + this.interactButtonMap.put(HotKeyType.N_VISITE_HIDEOUT,visiteHideout); + this.interactButtonMap.put(HotKeyType.N_TRADE_PLAYER,tradeButton); + this.interactButtonMap.put(HotKeyType.N_LEAVE,leaveButton); +// this.interactButtonMap.put(HotKeyType.N_BACK_TO_HIDEOUT,backToHo); + this.interactButtonMap.put(HotKeyType.N_OPEN_CHAT,openChatButton); + this.interactButtonMap.put(HotKeyType.N_CLOSE_NOTIFICATION,hideButton); + + JPanel opPanel = this.componentsFactory.getJPanel(new BorderLayout(),AppThemeColor.MSG_HEADER); + JPanel timePanel = this.getTimePanel(); + timePanel.setPreferredSize(new Dimension(50,26)); + opPanel.add(timePanel,BorderLayout.CENTER); + opPanel.add(interactionPanel,BorderLayout.LINE_END); + root.add(opPanel,BorderLayout.LINE_END); return root; } @Override public void subscribe() { + super.subscribe(); + } + @Override + protected void updateHotKeyPool() { + this.hotKeysPool.clear(); + this.interactButtonMap.forEach((type, button) -> { + HotKeyPair hotKeyPair = this.hotKeysConfig.get() + .getScannerNHotKeysList() + .stream() + .filter(it -> it.getType().equals(type)) + .findAny().orElse(null); + this.hotKeysPool.put(hotKeyPair.getDescriptor(),button); + }); } + @Override public void onViewDestroy() { + super.onViewDestroy(); + } + private JButton getExpandButton(){ + String iconPath = "app/expand-mp.png"; + JButton expandButton = componentsFactory.getIconButton(iconPath, 18f, AppThemeColor.MSG_HEADER,""); + expandButton.addActionListener(action -> { + if(this.contentPanel.isVisible()){ + this.contentPanel.setVisible(false); + expandButton.setIcon(this.componentsFactory.getIcon("app/default-mp.png",18f)); + }else { + this.contentPanel.setVisible(true); + expandButton.setIcon(this.componentsFactory.getIcon("app/expand-mp.png",18f)); + } + SwingUtilities.getWindowAncestor(ScannerNotificationPanel.this).pack(); + }); + return expandButton; } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/HistoryController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/HistoryController.java new file mode 100644 index 00000000..6564dff7 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/HistoryController.java @@ -0,0 +1,7 @@ +package com.mercury.platform.ui.components.panel.notification.controller; + + +public interface HistoryController { + void reload(); + void performOpenChat(); +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/IncomingPanelController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/IncomingPanelController.java index 06e1a89e..4453ae06 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/IncomingPanelController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/IncomingPanelController.java @@ -3,13 +3,9 @@ import com.mercury.platform.ui.components.panel.notification.InMessagePanel; import lombok.NonNull; -public interface IncomingPanelController { +public interface IncomingPanelController extends NotificationController{ void performInvite(); void performKick(); - void performOfferTrade(); - void performOpenChat(); - void performResponse(@NonNull String responseText); - void performHide(); void showITH(); void reloadMessage(@NonNull InMessagePanel panel); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationController.java new file mode 100644 index 00000000..11a0728c --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationController.java @@ -0,0 +1,9 @@ +package com.mercury.platform.ui.components.panel.notification.controller; + + +public interface NotificationController { + void performOfferTrade(); + void performHide(); + void performOpenChat(); + void performResponse(String response); +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationIncomingController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationIncomingController.java index 0361bc51..707efd97 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationIncomingController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationIncomingController.java @@ -30,7 +30,6 @@ public void performInvite() { @Override public void performKick() { MercuryStoreCore.chatCommandSubject.onNext("/kick " + notificationDescriptor.getWhisperNickname()); - } @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationOutgoingController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationOutgoingController.java index 58e153ef..8bb4d1b4 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationOutgoingController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationOutgoingController.java @@ -15,22 +15,17 @@ public NotificationOutgoingController(NotificationDescriptor notificationDescrip @Override public void visitHideout() { - + MercuryStoreCore.chatCommandSubject.onNext("/hideout " + notificationDescriptor.getWhisperNickname()); } @Override - public void backToHideout() { - + public void performLeave(String nickName) { + MercuryStoreCore.chatCommandSubject.onNext("/kick " + nickName); } @Override - public void performTrade() { - - } - - @Override - public void performLeave() { - + public void performOfferTrade() { + MercuryStoreCore.chatCommandSubject.onNext("/tradewith " + notificationDescriptor.getWhisperNickname()); } @Override @@ -40,12 +35,12 @@ public void performHide() { @Override public void performOpenChat() { - + MercuryStoreCore.openChatSubject.onNext(notificationDescriptor.getWhisperNickname()); } @Override public void performResponse(String response) { - + MercuryStoreCore.chatCommandSubject.onNext("@" + notificationDescriptor.getWhisperNickname() + " " + response); } private void closeMessagePanel(){ diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationScannerController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationScannerController.java index 955ff75c..695a95dc 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationScannerController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationScannerController.java @@ -15,22 +15,17 @@ public NotificationScannerController(NotificationDescriptor notificationDescript @Override public void visitHideout() { - + MercuryStoreCore.chatCommandSubject.onNext("/hideout " + notificationDescriptor.getWhisperNickname()); } @Override - public void backToHideout() { - + public void performLeave(String nickName) { + MercuryStoreCore.chatCommandSubject.onNext("/kick " + nickName); } @Override - public void performTrade() { - - } - - @Override - public void performLeave() { - + public void performOfferTrade() { + MercuryStoreCore.chatCommandSubject.onNext("/tradewith " + notificationDescriptor.getWhisperNickname()); } @Override @@ -40,12 +35,12 @@ public void performHide() { @Override public void performOpenChat() { - + MercuryStoreCore.openChatSubject.onNext(notificationDescriptor.getWhisperNickname()); } @Override public void performResponse(String response) { - + MercuryStoreCore.chatCommandSubject.onNext("@" + notificationDescriptor.getWhisperNickname() + " " + response); } private void closeMessagePanel(){ Timer timer = new Timer(30, action -> { diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/OutgoingPanelController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/OutgoingPanelController.java index 7ece358d..61b8265c 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/OutgoingPanelController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/OutgoingPanelController.java @@ -1,12 +1,7 @@ package com.mercury.platform.ui.components.panel.notification.controller; -public interface OutgoingPanelController { +public interface OutgoingPanelController extends NotificationController{ void visitHideout(); - void backToHideout(); - void performTrade(); - void performLeave(); - void performHide(); - void performOpenChat(); - void performResponse(String response); + void performLeave(String nickName); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/ScannerPanelController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/ScannerPanelController.java index 24819fe9..8551c90f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/ScannerPanelController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/ScannerPanelController.java @@ -1,11 +1,6 @@ package com.mercury.platform.ui.components.panel.notification.controller; -public interface ScannerPanelController { +public interface ScannerPanelController extends NotificationController{ void visitHideout(); - void backToHideout(); - void performTrade(); - void performLeave(); - void performHide(); - void performOpenChat(); - void performResponse(String response); + void performLeave(String nickName); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/HistoryPanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/HistoryPanelProvider.java new file mode 100644 index 00000000..fa0e5945 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/HistoryPanelProvider.java @@ -0,0 +1,33 @@ +package com.mercury.platform.ui.components.panel.notification.factory; + +import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationType; +import com.mercury.platform.shared.store.MercuryStoreCore; +import com.mercury.platform.ui.components.panel.notification.HistoryNotificationPanel; +import com.mercury.platform.ui.components.panel.notification.NotificationPanel; +import com.mercury.platform.ui.components.panel.notification.controller.HistoryController; + + +public class HistoryPanelProvider extends NotificationPanelProvider { + @Override + public boolean isSuitable(NotificationType type) { + return type.equals(NotificationType.HISTORY); + } + + @Override + protected NotificationPanel getPanel() { + HistoryNotificationPanel panel = new HistoryNotificationPanel(); + panel.setController(new HistoryController() { + @Override + public void reload() { + MercuryStoreCore.newNotificationSubject.onNext(data); + } + + @Override + public void performOpenChat() { + MercuryStoreCore.openChatSubject.onNext(data.getWhisperNickname()); + } + }); + return panel; + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelFactory.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelFactory.java index 8a327706..08db85fc 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelFactory.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelFactory.java @@ -16,6 +16,7 @@ public NotificationPanelFactory() { this.providers.add(new ItemOutPanelProvider()); this.providers.add(new CurrencyOutPanelProvider()); this.providers.add(new ScannerPanelProvider()); + this.providers.add(new HistoryPanelProvider()); } public NotificationPanelProvider getProviderFor(NotificationType type){ diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/HotKeyPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/HotKeyPanel.java new file mode 100644 index 00000000..dd79df0b --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/HotKeyPanel.java @@ -0,0 +1,61 @@ +package com.mercury.platform.ui.components.panel.settings.page; + +import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; +import com.mercury.platform.shared.store.MercuryStoreCore; +import com.mercury.platform.ui.components.ComponentsFactory; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.misc.AppThemeColor; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + + +public class HotKeyPanel extends JPanel { + private HotKeyDescriptor descriptor; + private boolean hotKeyAllowed; + private ComponentsFactory componentsFactory = new ComponentsFactory(); + public HotKeyPanel(HotKeyDescriptor descriptor) { + super(new BorderLayout()); + this.descriptor = descriptor; + this.setPreferredSize(new Dimension(100,26)); + + JButton button = this.componentsFactory.getBorderedButton(this.descriptor.getTitle()); + button.setFont(this.componentsFactory.getFont(FontStyle.BOLD, 17f)); + MouseAdapter mouseAdapter = new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + if(SwingUtilities.isLeftMouseButton(e)) { + button.setBackground(AppThemeColor.ADR_BG); + button.setText("Press any key"); + hotKeyAllowed = true; + button.removeMouseListener(this); + } + } + }; + button.addMouseListener(mouseAdapter); + MercuryStoreCore.hotKeySubject.subscribe(hotKey -> { + if (hotKeyAllowed) { + button.setBackground(AppThemeColor.BUTTON); + if (hotKey.getVirtualKeyCode() == 27) { + this.descriptor.setTitle("..."); + this.descriptor.setVirtualKeyCode(0); + this.descriptor.setMenuPressed(false); + this.descriptor.setShiftPressed(false); + this.descriptor.setControlPressed(false); + } else { + this.descriptor.setTitle(hotKey.getTitle()); + this.descriptor.setVirtualKeyCode(hotKey.getVirtualKeyCode()); + this.descriptor.setMenuPressed(hotKey.isMenuPressed()); + this.descriptor.setShiftPressed(hotKey.isShiftPressed()); + this.descriptor.setControlPressed(hotKey.isControlPressed()); + } + button.setText(hotKey.getTitle()); + hotKeyAllowed = false; + button.addMouseListener(mouseAdapter); + } + }); + this.add(button,BorderLayout.CENTER); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java index 8f10ddfa..e593a04a 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java @@ -4,10 +4,7 @@ import com.mercury.platform.shared.config.Configuration; import com.mercury.platform.shared.config.configration.KeyValueConfigurationService; import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; -import com.mercury.platform.shared.config.descriptor.HotKeyType; -import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; -import com.mercury.platform.shared.config.descriptor.ResponseButtonDescriptor; +import com.mercury.platform.shared.config.descriptor.*; import com.mercury.platform.shared.entity.message.FlowDirections; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.ComponentsFactory; @@ -18,61 +15,59 @@ import javax.swing.*; import java.awt.*; import java.awt.event.*; -import java.util.Map; +import java.util.*; +import java.util.List; public class NotificationSettingsPagePanel extends SettingsPagePanel { private PlainConfigurationService notificationService; - private KeyValueConfigurationService hotKeyService; + private PlainConfigurationService hotKeyService; + private PlainConfigurationService scannerService; private NotificationSettingsDescriptor generalSnapshot; - private Map hotKeySnapshot; - private JPanel buttonsTable; + private HotKeysSettingsDescriptor hotKeySnapshot; + private ScannerDescriptor scannerSnapshot; @Override public void onViewInit() { super.onViewInit(); this.notificationService = Configuration.get().notificationConfiguration(); this.hotKeyService = Configuration.get().hotKeysConfiguration(); + this.scannerService = Configuration.get().scannerConfiguration(); this.generalSnapshot = CloneHelper.cloneObject(notificationService.get()); - this.hotKeySnapshot = CloneHelper.cloneObject(hotKeyService.getMap()); - + this.hotKeySnapshot = CloneHelper.cloneObject(hotKeyService.get()); + this.scannerSnapshot = CloneHelper.cloneObject(scannerService.get()); JPanel inPanel = this.adrComponentsFactory.getCounterPanel(this.getIncomingPanel(), "Incoming notification:", AppThemeColor.ADR_BG,true); inPanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); JPanel outPanel = this.adrComponentsFactory.getCounterPanel(this.getOutgoingPanel(), "Outgoing notification:", AppThemeColor.ADR_BG,true); outPanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); + JPanel scannerPanel = this.adrComponentsFactory.getCounterPanel(this.getChatScannerPanel(), "Chat scanner notification:", AppThemeColor.ADR_BG,true); + scannerPanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); + this.container.add(this.componentsFactory.wrapToSlide(this.getGeneralPanel())); this.container.add(this.componentsFactory.wrapToSlide(inPanel)); -// this.container.add(this.componentsFactory.wrapToSlide(outPanel)); + this.container.add(this.componentsFactory.wrapToSlide(outPanel)); + this.container.add(this.componentsFactory.wrapToSlide(scannerPanel)); } @Override public void onSave() { this.notificationService.set(CloneHelper.cloneObject(this.generalSnapshot)); this.hotKeyService.set(CloneHelper.cloneObject(this.hotKeySnapshot)); + this.scannerService.set(CloneHelper.cloneObject(this.scannerSnapshot)); MercuryStoreCore.buttonsChangedSubject.onNext(true); } @Override public void restore() { this.generalSnapshot = CloneHelper.cloneObject(notificationService.get()); - this.hotKeySnapshot = CloneHelper.cloneObject(hotKeyService.getMap()); + this.hotKeySnapshot = CloneHelper.cloneObject(hotKeyService.get()); + this.scannerSnapshot = CloneHelper.cloneObject(scannerService.get()); this.removeAll(); this.onViewInit(); } - private JPanel getIncomingPanel() { + private JPanel getGeneralPanel(){ JPanel root = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.ADR_BG); JPanel propertiesPanel = this.componentsFactory.getJPanel(new GridLayout(0, 2, 4, 4),AppThemeColor.ADR_BG); - JCheckBox enabled = this.componentsFactory.getCheckBox(this.generalSnapshot.isNotificationEnable()); - enabled.addActionListener(action -> { - this.generalSnapshot.setNotificationEnable(enabled.isSelected()); - }); - JCheckBox dismiss = this.componentsFactory.getCheckBox(this.generalSnapshot.isDismissAfterKick()); - dismiss.addActionListener(action -> { - this.generalSnapshot.setDismissAfterKick(dismiss.isSelected()); - }); - JCheckBox showLeague = this.componentsFactory.getCheckBox(this.generalSnapshot.isShowLeague()); - showLeague.addActionListener(action -> { - this.generalSnapshot.setShowLeague(showLeague.isSelected()); - }); + root.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); JComboBox flowDirectionPicker = componentsFactory.getComboBox(new String[]{"Upwards", "Downwards"}); flowDirectionPicker.addActionListener(e -> { switch ((String)flowDirectionPicker.getSelectedItem()){ @@ -95,26 +90,61 @@ private JPanel getIncomingPanel() { this.generalSnapshot.setUnfoldCount(unfoldSlider.getValue()); }); flowDirectionPicker.setSelectedIndex(this.generalSnapshot.getFlowDirections().ordinal()); + propertiesPanel.add(this.componentsFactory.getTextLabel("Flow direction:", FontStyle.REGULAR,16)); + propertiesPanel.add(flowDirectionPicker); + propertiesPanel.add(this.componentsFactory.getTextLabel("Pre-group limit:", FontStyle.REGULAR,16)); + propertiesPanel.add(limitSlider); + propertiesPanel.add(this.componentsFactory.getTextLabel("Unfold by default:", FontStyle.REGULAR,16)); + propertiesPanel.add(unfoldSlider); + propertiesPanel.add(this.componentsFactory.getTextLabel("Your nickname(for leave option):", FontStyle.REGULAR,16)); + JTextField nickNameField = this.componentsFactory.getTextField(this.generalSnapshot.getPlayerNickname(), FontStyle.DEFAULT, 15f); + nickNameField.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + generalSnapshot.setPlayerNickname(nickNameField.getText()); + } + }); + propertiesPanel.add(nickNameField); + root.add(this.componentsFactory.wrapToSlide(propertiesPanel,AppThemeColor.ADR_BG,2,0,2,2),BorderLayout.PAGE_START); + return root; + } + + private JPanel getIncomingPanel() { + JPanel root = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.ADR_BG); + JPanel propertiesPanel = this.componentsFactory.getJPanel(new GridLayout(0, 2, 4, 4),AppThemeColor.ADR_BG); + JCheckBox enabled = this.componentsFactory.getCheckBox(this.generalSnapshot.isIncNotificationEnable()); + enabled.addActionListener(action -> { + this.generalSnapshot.setIncNotificationEnable(enabled.isSelected()); + }); + JCheckBox dismiss = this.componentsFactory.getCheckBox(this.generalSnapshot.isDismissAfterKick()); + dismiss.addActionListener(action -> { + this.generalSnapshot.setDismissAfterKick(dismiss.isSelected()); + }); + JCheckBox showLeague = this.componentsFactory.getCheckBox(this.generalSnapshot.isShowLeague()); + showLeague.addActionListener(action -> { + this.generalSnapshot.setShowLeague(showLeague.isSelected()); + }); propertiesPanel.add(this.componentsFactory.getTextLabel("Enabled:", FontStyle.REGULAR,16)); propertiesPanel.add(enabled); propertiesPanel.add(this.componentsFactory.getTextLabel("Close panel on kick:", FontStyle.REGULAR,16)); propertiesPanel.add(dismiss); propertiesPanel.add(this.componentsFactory.getTextLabel("Show league:", FontStyle.REGULAR,16)); propertiesPanel.add(showLeague); -// propertiesPanel.add(this.componentsFactory.getTextLabel("Flow direction:", FontStyle.REGULAR,16)); -// propertiesPanel.add(flowDirectionPicker); -// propertiesPanel.add(this.componentsFactory.getTextLabel("Pre-group limit:", FontStyle.REGULAR,16)); -// propertiesPanel.add(limitSlider); -// propertiesPanel.add(this.componentsFactory.getTextLabel("Unfold by default:", FontStyle.REGULAR,16)); -// propertiesPanel.add(unfoldSlider); root.add(propertiesPanel,BorderLayout.PAGE_START); - root.add(this.componentsFactory.wrapToSlide(this.getResponseButtonsPanel(),AppThemeColor.ADR_BG),BorderLayout.CENTER); -// root.add(this.componentsFactory.wrapToSlide(this.getInNotificationHotKeysPanel(),AppThemeColor.ADR_BG),BorderLayout.PAGE_END); + + root.add(this.wrapToCounter(this.componentsFactory.wrapToSlide(this.getResponseButtonsPanel(this.generalSnapshot.getButtons()),AppThemeColor.ADR_BG),"Response buttons:"),BorderLayout.CENTER); + root.add(this.wrapToCounter(this.componentsFactory.wrapToSlide(this.getInNotificationHotKeysPanel(),AppThemeColor.ADR_BG),"Hotkeys"),BorderLayout.PAGE_END); return root; } - private JPanel getResponseButtonsPanel(){ + private JPanel wrapToCounter(JPanel inner, String title){ + JPanel root = this.adrComponentsFactory.getCounterPanel(inner, title, AppThemeColor.ADR_BG,false); + inner.setVisible(false); + root.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); + return this.componentsFactory.wrapToSlide(root,AppThemeColor.ADR_BG); + } + private JPanel getResponseButtonsPanel(List buttons){ JPanel root = this.componentsFactory.getJPanel(new BorderLayout(4,4), AppThemeColor.SETTINGS_BG); - this.buttonsTable = this.componentsFactory.getJPanel(new GridLayout(0, 1, 4, 4),AppThemeColor.SETTINGS_BG); + JPanel buttonsTable = this.componentsFactory.getJPanel(new GridLayout(0, 1, 4, 4),AppThemeColor.SETTINGS_BG); buttonsTable.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_DEFAULT_BORDER)); JPanel headerPanel = this.componentsFactory.getJPanel(new BorderLayout(),AppThemeColor.SETTINGS_BG); @@ -140,20 +170,22 @@ private JPanel getResponseButtonsPanel(){ miscPanel.add(closeLabel,BorderLayout.LINE_END); headerPanel.add(miscPanel,BorderLayout.LINE_END); - this.buttonsTable.add(headerPanel); + buttonsTable.add(headerPanel); - this.generalSnapshot.getButtons().forEach(it -> { - this.buttonsTable.add(this.getResponseRow(it)); + buttons.forEach(it -> { + buttonsTable.add(this.getResponseRow(it)); }); - root.add(this.buttonsTable,BorderLayout.CENTER); - JButton addButton = this.componentsFactory.getIconButton("app/add_button.png", 24, AppThemeColor.HEADER, "Add button"); - addButton.setBorder(BorderFactory.createLineBorder(AppThemeColor.BORDER)); + root.add(buttonsTable,BorderLayout.CENTER); + JButton addButton = this.componentsFactory.getIconButton("app/add_button.png", 22, AppThemeColor.HEADER, "Add button"); + addButton.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(AppThemeColor.BORDER), + BorderFactory.createEmptyBorder(3,3,3,3))); addButton.addActionListener(action -> { ResponseButtonDescriptor descriptor = new ResponseButtonDescriptor(); - int size = this.generalSnapshot.getButtons().size(); + int size = buttons.size(); descriptor.setId(++size); - this.generalSnapshot.getButtons().add(descriptor); - this.buttonsTable.add(this.getResponseRow(descriptor)); + buttons.add(descriptor); + buttonsTable.add(this.getResponseRow(descriptor)); MercuryStoreUI.settingsRepaintSubject.onNext(true); MercuryStoreUI.settingsPackSubject.onNext(true); }); @@ -177,8 +209,8 @@ public void focusLost(FocusEvent e) { descriptor.setResponseText(responseField.getText()); } }); - root.add(titleField,BorderLayout.LINE_START); - root.add(responseField,BorderLayout.CENTER); + root.add(this.componentsFactory.wrapToSlide(titleField,AppThemeColor.SETTINGS_BG,0,2,2,0),BorderLayout.LINE_START); + root.add(this.componentsFactory.wrapToSlide(responseField,AppThemeColor.SETTINGS_BG,0,0,2,0),BorderLayout.CENTER); JPanel miscPanel = this.componentsFactory.getJPanel(new BorderLayout(4, 4),AppThemeColor.SETTINGS_BG); JCheckBox checkBox = this.componentsFactory.getCheckBox(descriptor.isClose(),"Close notification panel after click?"); @@ -186,11 +218,11 @@ public void focusLost(FocusEvent e) { descriptor.setClose(checkBox.isSelected()); }); miscPanel.add(checkBox, BorderLayout.LINE_START); -// miscPanel.add(new HotKeyPanel(descriptor.getHotKeyDescriptor()),BorderLayout.CENTER); + miscPanel.add(this.componentsFactory.wrapToSlide(new HotKeyPanel(descriptor.getHotKeyDescriptor()),AppThemeColor.SETTINGS_BG,0,0,2,0),BorderLayout.CENTER); JButton removeButton = this.componentsFactory.getIconButton("app/adr/remove_node.png", 17, AppThemeColor.SETTINGS_BG, "Remove button"); removeButton.addActionListener(action -> { - this.buttonsTable.remove(root); + root.getParent().remove(root); this.generalSnapshot.getButtons().remove(descriptor); MercuryStoreUI.settingsPackSubject.onNext(true); MercuryStoreUI.settingsRepaintSubject.onNext(true); @@ -201,77 +233,82 @@ public void focusLost(FocusEvent e) { return root; } private JPanel getInNotificationHotKeysPanel(){ - JPanel root = this.componentsFactory.getJPanel(new GridLayout(0, 4, 4, 4),AppThemeColor.SETTINGS_BG); + JPanel root = this.componentsFactory.getJPanel(new GridLayout(0, 2, 4, 4),AppThemeColor.SETTINGS_BG); root.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_DEFAULT_BORDER)); - this.hotKeySnapshot.forEach((key, value) -> { - if(HotKeyType.contains(key)) { - JLabel iconLabel = this.componentsFactory.getIconLabel(HotKeyType.valueOf(key).getIconPath(), 18); - iconLabel.setHorizontalAlignment(SwingConstants.CENTER); - root.add(iconLabel); - root.add(this.componentsFactory.wrapToSlide(new HotKeyPanel(value),AppThemeColor.SETTINGS_BG,1,4,1,1)); - } + this.hotKeySnapshot.getIncNHotKeysList().forEach(pair -> { + root.add(this.componentsFactory.getIconLabel(pair.getType().getIconPath(), 18,SwingConstants.CENTER)); + root.add(this.componentsFactory.wrapToSlide(new HotKeyPanel(pair.getDescriptor()),AppThemeColor.SETTINGS_BG,2,4,1,1)); + + }); + return root; + } + private JPanel getOutNotificationHotKeysPanel(){ + JPanel root = this.componentsFactory.getJPanel(new GridLayout(0, 2, 4, 4),AppThemeColor.SETTINGS_BG); + root.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_DEFAULT_BORDER)); + this.hotKeySnapshot.getOutNHotKeysList().forEach(pair -> { + root.add(this.componentsFactory.getIconLabel(pair.getType().getIconPath(), 18,SwingConstants.CENTER)); + root.add(this.componentsFactory.wrapToSlide(new HotKeyPanel(pair.getDescriptor()),AppThemeColor.SETTINGS_BG,2,4,1,1)); + }); return root; } + private JPanel getScannerNotificationHotKeysPanel(){ + JPanel root = this.componentsFactory.getJPanel(new GridLayout(0, 2, 4, 4),AppThemeColor.SETTINGS_BG); + root.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_DEFAULT_BORDER)); + this.hotKeySnapshot.getScannerNHotKeysList().forEach(pair-> { + root.add(this.componentsFactory.getIconLabel(pair.getType().getIconPath(), 18,SwingConstants.CENTER)); + root.add(this.componentsFactory.wrapToSlide(new HotKeyPanel(pair.getDescriptor()),AppThemeColor.SETTINGS_BG,2,4,1,1)); + + }); + return root; + } + private JPanel getOutgoingPanel() { JPanel root = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.ADR_BG); JPanel propertiesPanel = this.componentsFactory.getJPanel(new GridLayout(0, 2, 4, 4),AppThemeColor.ADR_BG); - JCheckBox enabled = this.componentsFactory.getCheckBox(this.generalSnapshot.isNotificationEnable()); + JCheckBox enabled = this.componentsFactory.getCheckBox(this.generalSnapshot.isOutNotificationEnable()); enabled.addActionListener(action -> { - this.generalSnapshot.setNotificationEnable(enabled.isSelected()); + this.generalSnapshot.setOutNotificationEnable(enabled.isSelected()); }); propertiesPanel.add(this.componentsFactory.getTextLabel("Enabled:", FontStyle.REGULAR,16)); propertiesPanel.add(enabled); + propertiesPanel.add(this.componentsFactory.getTextLabel("Close panel after leave:", FontStyle.REGULAR,16)); + JCheckBox closeAfterLeave = this.componentsFactory.getCheckBox(this.generalSnapshot.isDismissAfterLeave()); + closeAfterLeave.addActionListener(action -> { + this.generalSnapshot.setDismissAfterLeave(closeAfterLeave.isSelected()); + }); + propertiesPanel.add(closeAfterLeave); + root.add(propertiesPanel,BorderLayout.PAGE_START); + root.add(this.wrapToCounter(this.componentsFactory.wrapToSlide(this.getResponseButtonsPanel(this.generalSnapshot.getOutButtons()),AppThemeColor.ADR_BG),"Response buttons:"),BorderLayout.CENTER); + root.add(this.wrapToCounter(this.componentsFactory.wrapToSlide(this.getOutNotificationHotKeysPanel(),AppThemeColor.ADR_BG),"Hotkeys:"),BorderLayout.PAGE_END); return root; } - - private class HotKeyPanel extends JPanel { - private HotKeyDescriptor descriptor; - private boolean hotKeyAllowed; - private ComponentsFactory componentsFactory = new ComponentsFactory(); - public HotKeyPanel(HotKeyDescriptor descriptor) { - super(new BorderLayout()); - this.descriptor = descriptor; - this.setPreferredSize(new Dimension(130,26)); - - JButton button = this.componentsFactory.getBorderedButton(this.descriptor.getTitle()); - button.setFont(this.componentsFactory.getFont(FontStyle.BOLD, 18f)); - MouseAdapter mouseAdapter = new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - if(SwingUtilities.isLeftMouseButton(e)) { - button.setBackground(AppThemeColor.ADR_BG); - button.setText("Press any key"); - hotKeyAllowed = true; - button.removeMouseListener(this); - } - } - }; - button.addMouseListener(mouseAdapter); - MercuryStoreCore.hotKeySubject.subscribe(hotKey -> { - if (hotKeyAllowed) { - button.setBackground(AppThemeColor.BUTTON); - if (hotKey.getVirtualKeyCode() == 27) { - this.descriptor.setTitle("..."); - this.descriptor.setVirtualKeyCode(0); - this.descriptor.setMenuPressed(false); - this.descriptor.setShiftPressed(false); - this.descriptor.setControlPressed(false); - } else { - this.descriptor.setTitle(hotKey.getTitle()); - this.descriptor.setVirtualKeyCode(hotKey.getVirtualKeyCode()); - this.descriptor.setMenuPressed(hotKey.isMenuPressed()); - this.descriptor.setShiftPressed(hotKey.isShiftPressed()); - this.descriptor.setControlPressed(hotKey.isControlPressed()); - this.descriptor.setKeyChar(hotKey.getKeyChar()); - } - button.setText(hotKey.getTitle()); - hotKeyAllowed = false; - button.addMouseListener(mouseAdapter); - } - }); - this.add(button,BorderLayout.CENTER); - } + private JPanel getChatScannerPanel() { + JPanel root = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.ADR_BG); + JPanel propertiesPanel = this.componentsFactory.getJPanel(new GridLayout(0, 2, 4, 4),AppThemeColor.ADR_BG); + JCheckBox enabled = this.componentsFactory.getCheckBox(this.generalSnapshot.isScannerNotificationEnable()); + enabled.addActionListener(action -> { + this.generalSnapshot.setScannerNotificationEnable(enabled.isSelected()); + }); + propertiesPanel.add(this.componentsFactory.getTextLabel("Enabled:", FontStyle.REGULAR,16)); + propertiesPanel.add(enabled); + JLabel quickResponseLabel = this.componentsFactory.getIconLabel(HotKeyType.N_QUICK_RESPONSE.getIconPath(), 18); + quickResponseLabel.setFont(this.componentsFactory.getFont(FontStyle.REGULAR,16)); + quickResponseLabel.setForeground(AppThemeColor.TEXT_DEFAULT); + quickResponseLabel.setBorder(BorderFactory.createEmptyBorder(0,4,0,0)); + quickResponseLabel.setText("Response message:"); + propertiesPanel.add(quickResponseLabel); + JTextField quickResponseField = this.componentsFactory.getTextField(this.scannerSnapshot.getResponseMessage(), FontStyle.BOLD, 15f); + quickResponseField.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + scannerSnapshot.setResponseMessage(quickResponseField.getText()); + } + }); + propertiesPanel.add(this.componentsFactory.wrapToSlide(quickResponseField,AppThemeColor.ADR_BG,0,0,0,4)); + root.add(propertiesPanel,BorderLayout.PAGE_START); + root.add(this.wrapToCounter(this.componentsFactory.wrapToSlide(this.getScannerNotificationHotKeysPanel(),AppThemeColor.ADR_BG),"Hotkeys"),BorderLayout.CENTER); + return root; } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/TaskBarSettingsPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/TaskBarSettingsPagePanel.java index f311e638..e75921de 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/TaskBarSettingsPagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/TaskBarSettingsPagePanel.java @@ -4,6 +4,7 @@ import com.mercury.platform.shared.config.Configuration; import com.mercury.platform.shared.config.configration.PlainConfigurationService; import com.mercury.platform.shared.config.descriptor.ApplicationDescriptor; +import com.mercury.platform.shared.config.descriptor.HotKeysSettingsDescriptor; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.misc.AppThemeColor; @@ -13,13 +14,17 @@ public class TaskBarSettingsPagePanel extends SettingsPagePanel { private PlainConfigurationService applicationConfig; + private PlainConfigurationService hotKeyService; + private HotKeysSettingsDescriptor hotKeySnapshot; private ApplicationDescriptor applicationSnapshot; @Override public void onViewInit() { super.onViewInit(); this.applicationConfig = Configuration.get().applicationConfiguration(); + this.hotKeyService = Configuration.get().hotKeysConfiguration(); this.applicationSnapshot = CloneHelper.cloneObject(this.applicationConfig.get()); + this.hotKeySnapshot = CloneHelper.cloneObject(hotKeyService.get()); JPanel root = componentsFactory.getJPanel(new GridLayout(0,2),AppThemeColor.ADR_BG); root.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); @@ -35,17 +40,28 @@ public void onViewInit() { root.add(inGameDND); root.add(componentsFactory.getTextLabel("DND response:", FontStyle.REGULAR)); root.add(this.componentsFactory.wrapToSlide(responseField,AppThemeColor.ADR_BG)); + + JPanel hotKeysPanel = this.componentsFactory.getJPanel(new GridLayout(0, 2, 4, 4),AppThemeColor.SETTINGS_BG); + hotKeysPanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_DEFAULT_BORDER)); + this.hotKeySnapshot.getTaskBarNHotKeysList().forEach(pair -> { + root.add(this.componentsFactory.getIconLabel(pair.getType().getIconPath(), 24,SwingConstants.CENTER)); + root.add(this.componentsFactory.wrapToSlide(new HotKeyPanel(pair.getDescriptor()),AppThemeColor.SETTINGS_BG,2,4,1,1)); + + }); this.container.add(this.componentsFactory.wrapToSlide(root)); + this.container.add(this.componentsFactory.wrapToSlide(hotKeysPanel)); } @Override public void onSave() { this.applicationConfig.set(CloneHelper.cloneObject(this.applicationSnapshot)); + this.hotKeyService.set(CloneHelper.cloneObject(this.hotKeySnapshot)); } @Override public void restore() { this.applicationSnapshot = CloneHelper.cloneObject(this.applicationConfig.get()); + this.hotKeySnapshot = CloneHelper.cloneObject(this.hotKeyService.get()); this.removeAll(); this.onViewInit(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/MercuryTaskBarController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/MercuryTaskBarController.java index 9c5c320b..f1845316 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/MercuryTaskBarController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/MercuryTaskBarController.java @@ -4,6 +4,7 @@ import com.mercury.platform.ui.frame.movable.ItemsGridFrame; import com.mercury.platform.ui.frame.movable.TaskBarFrame; import com.mercury.platform.ui.frame.titled.chat.ChatFilterFrame; +import com.mercury.platform.ui.frame.titled.chat.ChatFilterSettingsFrame; import com.mercury.platform.ui.frame.titled.container.HistoryFrame; import com.mercury.platform.ui.frame.titled.SettingsFrame; import com.mercury.platform.ui.manager.FramesManager; @@ -36,7 +37,7 @@ public void performHideout() { @Override public void showChatFiler() { - FramesManager.INSTANCE.hideOrShowFrame(ChatFilterFrame.class); + FramesManager.INSTANCE.hideOrShowFrame(ChatFilterSettingsFrame.class); } @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarPanel.java index f0e98403..1666f5f8 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarPanel.java @@ -2,6 +2,7 @@ import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.panel.misc.ViewInit; +import com.mercury.platform.ui.frame.movable.TaskBarFrame; import com.mercury.platform.ui.manager.FramesManager; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.TooltipConstants; @@ -28,13 +29,13 @@ public TaskBarPanel(@NonNull TaskBarController controller, @NonNull ComponentsFa @Override public void onViewInit() { - this.setBackground(AppThemeColor.TRANSPARENT); + this.setBackground(AppThemeColor.FRAME); this.setLayout(new BoxLayout(this,BoxLayout.X_AXIS)); JButton visibleMode = componentsFactory.getIconButton( "app/visible-always-mode.png", 24, - AppThemeColor.FRAME_ALPHA, + AppThemeColor.FRAME, TooltipConstants.VISIBLE_MODE); componentsFactory.setUpToggleCallbacks(visibleMode, () -> { @@ -51,7 +52,7 @@ public void onViewInit() { JButton itemGrid = componentsFactory.getIconButton( "app/item-grid-enable.png", 24, - AppThemeColor.FRAME_ALPHA, + AppThemeColor.FRAME, TooltipConstants.ITEM_GRID); itemGrid.addMouseListener(new MouseAdapter() { @Override @@ -65,7 +66,7 @@ public void mousePressed(MouseEvent e) { JButton toHideOut = componentsFactory.getIconButton( "app/hideout.png", 24, - AppThemeColor.FRAME_ALPHA, + AppThemeColor.FRAME, TooltipConstants.HIDEOUT); toHideOut.addActionListener(action -> { this.controller.performHideout(); @@ -74,37 +75,37 @@ public void mousePressed(MouseEvent e) { JButton adr = componentsFactory.getIconButton( "app/overseer_icon.png", 24, - AppThemeColor.FRAME_ALPHA, + AppThemeColor.FRAME, TooltipConstants.ADR_SETTINGS); adr.addActionListener(action -> { FramesManager.INSTANCE.performAdr(); - this.repaint(); + TaskBarFrame windowAncestor = (TaskBarFrame) SwingUtilities.getWindowAncestor(TaskBarPanel.this); + windowAncestor.setSize(new Dimension(windowAncestor.getMIN_WIDTH(),windowAncestor.getHeight())); + windowAncestor.pack(); }); JButton chatFilter = componentsFactory.getIconButton( "app/chat-filter.png", 24, - AppThemeColor.FRAME_ALPHA, + AppThemeColor.FRAME, TooltipConstants.CHAT_FILTER); chatFilter.addActionListener(action -> { this.controller.showChatFiler(); - this.repaint(); }); JButton historyButton = componentsFactory.getIconButton( "app/history.png", 24, - AppThemeColor.FRAME_ALPHA, + AppThemeColor.FRAME, TooltipConstants.HISTORY); historyButton.addActionListener(action -> { this.controller.showHistory(); - this.repaint(); }); JButton pinButton = componentsFactory.getIconButton( "app/drag_and_drop.png", 24, - AppThemeColor.FRAME_ALPHA, + AppThemeColor.FRAME, TooltipConstants.SETUP_FRAMES_LOCATION); pinButton.addMouseListener(new MouseAdapter() { @Override @@ -118,7 +119,7 @@ public void mouseClicked(MouseEvent e) { JButton scaleButton = componentsFactory.getIconButton( "app/scale-settings.png", 24, - AppThemeColor.FRAME_ALPHA, + AppThemeColor.FRAME, TooltipConstants.SCALE_SETTINGS); scaleButton.addMouseListener(new MouseAdapter() { @Override @@ -132,13 +133,16 @@ public void mouseClicked(MouseEvent e) { JButton settingsButton = componentsFactory.getIconButton( "app/settings.png", 26, - AppThemeColor.FRAME_ALPHA, + AppThemeColor.FRAME, ""); settingsButton.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if(SwingUtilities.isLeftMouseButton(e)) { controller.showSettings(); + TaskBarFrame windowAncestor = (TaskBarFrame) SwingUtilities.getWindowAncestor(TaskBarPanel.this); + windowAncestor.setSize(new Dimension(windowAncestor.getMIN_WIDTH(),windowAncestor.getHeight())); + windowAncestor.pack(); } } }); @@ -146,7 +150,7 @@ public void mousePressed(MouseEvent e) { JButton exitButton = componentsFactory.getIconButton( "app/exit.png", 24, - AppThemeColor.FRAME_ALPHA, + AppThemeColor.FRAME, ""); exitButton.addMouseListener(new MouseAdapter() { @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractOverlaidFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractOverlaidFrame.java index 18f4c7f7..2a7b5f50 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractOverlaidFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractOverlaidFrame.java @@ -52,7 +52,8 @@ public void mouseEntered(MouseEvent e) { } }); - MercuryStoreCore.frameVisibleSubject.subscribe(this::changeVisible); + MercuryStoreCore.frameVisibleSubject.subscribe(state -> + SwingUtilities.invokeLater(()-> this.changeVisible(state))); } protected void changeVisible(FrameVisibleState state){ if (this.processingHideEvent) { diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/AbstractMovableComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/AbstractMovableComponentFrame.java index 4775b63e..2183754f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/AbstractMovableComponentFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/AbstractMovableComponentFrame.java @@ -95,20 +95,20 @@ private JPanel setUpMoveListeners(JPanel panel){ panel.addMouseMotionListener(new DraggedFrameMotionListener()); panel.addMouseListener(new DraggedFrameMouseListener()); - if(enableMouseOverBorder) { + if(this.enableMouseOverBorder) { panel.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { + panel.setCursor(new Cursor(Cursor.MOVE_CURSOR)); getRootPane().setBorder(BorderFactory.createLineBorder(AppThemeColor.TEXT_MESSAGE, 1)); - AbstractMovableComponentFrame.this.repaint(); } @Override public void mouseExited(MouseEvent e) { + panel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); if (!AbstractMovableComponentFrame.this.getBounds().contains(e.getPoint())) { getRootPane().setBorder(BorderFactory.createLineBorder(AppThemeColor.BORDER, 1)); } - AbstractMovableComponentFrame.this.repaint(); } }); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/TaskBarFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/TaskBarFrame.java index e0a2fb9e..31e191c6 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/TaskBarFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/TaskBarFrame.java @@ -9,6 +9,7 @@ import com.mercury.platform.ui.components.panel.taskbar.TaskBarPanel; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.MercuryStoreUI; +import lombok.Getter; import org.pushingpixels.trident.Timeline; import org.pushingpixels.trident.ease.Spline; @@ -19,6 +20,7 @@ public class TaskBarFrame extends AbstractMovableComponentFrame { private Timeline collapseAnimation; + @Getter private int MIN_WIDTH; private int MAX_WIDTH; private MouseListener collapseListener; @@ -83,13 +85,12 @@ protected void onLock() { @Override protected JPanel getPanelForPINSettings() { - disableCollapseAnimation(); - JPanel panel = componentsFactory.getTransparentPanel(); - panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS)); - JPanel labelPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); - labelPanel.add(componentsFactory.getTextLabel(FontStyle.BOLD,AppThemeColor.TEXT_MESSAGE, TextAlignment.LEFTOP,20f,"Task Bar")); - panel.add(labelPanel); - panel.setBackground(AppThemeColor.ADR_BG); + this.disableCollapseAnimation(); + JPanel panel = this.componentsFactory.getJPanel(new BorderLayout(),AppThemeColor.FRAME); + JLabel textLabel = this.componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 22f, "Task Bar"); + textLabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(textLabel); + panel.setPreferredSize(this.getPreferredSize()); return panel; } @@ -119,7 +120,7 @@ public void onViewInit() { this.setWidth(MIN_WIDTH); this.setMaximumSize(taskBarPanel.getPreferredSize()); - collapseListener = new MouseAdapter() { + this.collapseListener = new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { TaskBarFrame.this.repaint(); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java index 90f73126..9f3ed731 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java @@ -250,16 +250,16 @@ protected JPanel getPanelForPINSettings() { labelPanel.setBackground(AppThemeColor.ADR_BG); JLabel headerLabel = componentsFactory.getTextLabel( FontStyle.BOLD, - this.notificationConfig.get().isNotificationEnable()?AppThemeColor.TEXT_MESSAGE:AppThemeColor.TEXT_DISABLE, + this.notificationConfig.get().isIncNotificationEnable()?AppThemeColor.TEXT_MESSAGE:AppThemeColor.TEXT_DISABLE, TextAlignment.CENTER, 18f, "Notification panel"); labelPanel.add(headerLabel,BorderLayout.CENTER); - JButton enableButton = this.componentsFactory.getBorderedButton(this.notificationConfig.get().isNotificationEnable() ? "Switch-off" : "Switch-on"); + JButton enableButton = this.componentsFactory.getBorderedButton(this.notificationConfig.get().isIncNotificationEnable() ? "Switch-off" : "Switch-on"); enableButton.addActionListener(action -> { - boolean notificationEnable = this.notificationConfig.get().isNotificationEnable(); - this.notificationConfig.get().setNotificationEnable(!notificationEnable); - if(this.notificationConfig.get().isNotificationEnable()){ + boolean notificationEnable = this.notificationConfig.get().isIncNotificationEnable(); + this.notificationConfig.get().setIncNotificationEnable(!notificationEnable); + if(this.notificationConfig.get().isIncNotificationEnable()){ headerLabel.setForeground(AppThemeColor.TEXT_MESSAGE); }else { headerLabel.setForeground(AppThemeColor.TEXT_DISABLE); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java index 6787f35c..840e048c 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java @@ -1,16 +1,23 @@ package com.mercury.platform.ui.frame.movable.container; +import com.mercury.platform.core.ProdStarter; +import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.config.Configuration; import com.mercury.platform.shared.config.configration.PlainConfigurationService; import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; +import com.mercury.platform.shared.entity.message.FlowDirections; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.ComponentsFactory; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.components.fields.font.TextAlignment; import com.mercury.platform.ui.components.panel.notification.NotificationPanel; +import com.mercury.platform.ui.components.panel.notification.ScannerNotificationPanel; import com.mercury.platform.ui.components.panel.notification.factory.NotificationPanelFactory; import com.mercury.platform.ui.frame.movable.AbstractMovableComponentFrame; import com.mercury.platform.ui.misc.AppThemeColor; import javax.swing.*; +import javax.swing.Timer; import java.awt.*; import java.util.*; import java.util.List; @@ -69,6 +76,20 @@ public void subscribe() { } this.pack(); this.repaint(); + if(this.config.get().getFlowDirections().equals(FlowDirections.UPWARDS) + && !(notificationPanel instanceof ScannerNotificationPanel)){ + this.setLocation(new Point(this.getLocation().x,this.getLocation().y - notificationPanel.getSize().height)); + } + if(notificationPanel instanceof ScannerNotificationPanel){ + Timer packTimer = new Timer(5, action -> { + this.pack(); + if(this.config.get().getFlowDirections().equals(FlowDirections.UPWARDS)){ + this.setLocation(new Point(this.getLocation().x,this.getLocation().y - notificationPanel.getSize().height)); + } + }); + packTimer.setRepeats(false); + packTimer.start(); + } }); }); MercuryStoreCore.removeNotificationSubject.subscribe(notification -> { @@ -88,13 +109,29 @@ public void subscribe() { } this.pack(); this.repaint(); + if(this.config.get().getFlowDirections().equals(FlowDirections.UPWARDS) + && this.notificationPanels.size() == 0){ + this.setLocation(this.framesConfig.get("NotificationFrame").getFrameLocation()); + } + }); + }); + MercuryStoreCore.hotKeySubject.subscribe(hotkeyDescriptor -> { + SwingUtilities.invokeLater(() -> { + if(this.notificationPanels.size() > 0 && ProdStarter.APP_STATUS.equals(FrameVisibleState.SHOW)){ + this.notificationPanels.get(0).onHotKeyPressed(hotkeyDescriptor); + } }); }); } @Override protected JPanel getPanelForPINSettings() { - return new JPanel(); + JPanel panel = this.componentsFactory.getJPanel(new BorderLayout(),AppThemeColor.FRAME); + JLabel textLabel = this.componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 22f, "Notification panel"); + textLabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(textLabel); + panel.setPreferredSize(new Dimension((int)(400 * componentsFactory.getScale()), (int)(130*componentsFactory.getScale()))); + return panel; } @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/AbstractTitledComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/AbstractTitledComponentFrame.java index 812630cc..86fc064f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/AbstractTitledComponentFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/AbstractTitledComponentFrame.java @@ -42,16 +42,10 @@ private void initHeaderPanel(){ this.headerPanel.add(appIcon,BorderLayout.LINE_START); this.headerPanel.add(this.frameTitleLabel, BorderLayout.CENTER); - this.miscPanel.setBackground(AppThemeColor.TRANSPARENT); - this.hideButton = componentsFactory.getIconButton("app/close.png", 14, AppThemeColor.FRAME_ALPHA, ""); - this.hideButton.setBorder(BorderFactory.createEmptyBorder(0,0,0,2)); - this.hideButton.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - if(SwingUtilities.isLeftMouseButton(e)) { - hideComponent(); - } - } + this.miscPanel.setBackground(AppThemeColor.HEADER); + this.hideButton = componentsFactory.getIconButton("app/close.png", 14, AppThemeColor.HEADER, ""); + this.hideButton.addActionListener(action -> { + this.hideComponent(); }); this.miscPanel.add(hideButton); this.headerPanel.add(miscPanel, BorderLayout.LINE_END); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/SettingsFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/SettingsFrame.java index ce3721e1..fb02afdc 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/SettingsFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/SettingsFrame.java @@ -96,8 +96,8 @@ private JPanel getSaveButtonPanel(){ }); saveButton.setPreferredSize(new Dimension(110, 26)); cancelButton.setPreferredSize(new Dimension(110, 26)); - root.add(this.componentsFactory.wrapToSlide(saveButton,AppThemeColor.HEADER,2,2,2,2)); root.add(this.componentsFactory.wrapToSlide(cancelButton,AppThemeColor.HEADER,2,2,2,2)); + root.add(this.componentsFactory.wrapToSlide(saveButton,AppThemeColor.HEADER,2,2,2,2)); return root; } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterFrame.java index 6dc01013..a31c95fb 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterFrame.java @@ -36,11 +36,11 @@ public ChatFilterFrame() { super(); FrameDescriptor frameDescriptor = this.framesConfig.get(this.getClass().getSimpleName()); this.setPreferredSize(frameDescriptor.getFrameSize()); - this.settingsFrame = new ChatFilterSettingsFrame(strings -> { - if(chatEnable){ - performNewStrings(strings); - } - }); +// this.settingsFrame = new ChatFilterSettingsFrame(strings -> { +// if(chatEnable){ +//// performNewStrings(strings); +// } +// }); } @Override @@ -199,10 +199,10 @@ private JPanel getToolbar(){ 17, AppThemeColor.TRANSPARENT, "Chat Scanner settings"); - edit.addActionListener( - action -> this.settingsFrame.showAuxiliaryFrame( - new Point(this.getLocation().x,this.getLocation().y), - this.getPreferredSize().height)); +// edit.addActionListener( +// action -> this.settingsFrame.showAuxiliaryFrame( +// new Point(this.getLocation().x,this.getLocation().y), +// this.getPreferredSize().height)); JButton clear = componentsFactory.getIconButton( "app/clear-history.png", 18, diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterSettingsFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterSettingsFrame.java index 2426ae14..3f49be94 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterSettingsFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterSettingsFrame.java @@ -1,27 +1,38 @@ package com.mercury.platform.ui.frame.titled.chat; +import com.mercury.platform.core.misc.SoundType; +import com.mercury.platform.core.utils.interceptor.MessageInterceptor; +import com.mercury.platform.core.utils.interceptor.filter.MessageFilter; import com.mercury.platform.shared.config.Configuration; import com.mercury.platform.shared.config.configration.PlainConfigurationService; import com.mercury.platform.shared.config.descriptor.ScannerDescriptor; +import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationType; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; +import com.mercury.platform.ui.components.panel.chat.ChatMessagePanel; +import com.mercury.platform.ui.components.panel.chat.HtmlMessageBuilder; import com.mercury.platform.ui.frame.titled.AbstractTitledComponentFrame; import com.mercury.platform.ui.misc.AppThemeColor; +import net.jodah.expiringmap.ExpiringMap; import org.apache.commons.lang3.StringUtils; import javax.swing.*; import java.awt.*; +import java.util.*; +import java.util.List; +import java.util.concurrent.TimeUnit; public class ChatFilterSettingsFrame extends AbstractTitledComponentFrame { - private ChatSettingsCallback callback; private PlainConfigurationService scannerService; private JTextField quickResponseField; + private MessageInterceptor currentInterceptor; + private Map expiresMessages; + private HtmlMessageBuilder messageBuilder; - public ChatFilterSettingsFrame(ChatSettingsCallback callback) { + public ChatFilterSettingsFrame() { super(); - this.callback = callback; - this.scannerService = Configuration.get().scannerConfiguration(); this.processingHideEvent = false; this.setFocusableWindowState(true); this.setFocusable(true); @@ -30,6 +41,11 @@ public ChatFilterSettingsFrame(ChatSettingsCallback callback) { @Override public void onViewInit() { + this.scannerService = Configuration.get().scannerConfiguration(); + this.expiresMessages = ExpiringMap.builder() + .expiration(10, TimeUnit.SECONDS) + .build(); + this.messageBuilder = new HtmlMessageBuilder(); JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); JPanel setupArea = componentsFactory.getTransparentPanel(new BorderLayout()); setupArea.setBorder(BorderFactory.createEmptyBorder(4,4,4,4)); @@ -57,8 +73,7 @@ public void onViewInit() { String chunkStr = StringUtils.deleteWhitespace(words.getText()); String[] split = chunkStr.split(","); - - this.callback.onHide(split); + this.performNewStrings(split); this.hideComponent(); }); JButton cancel = componentsFactory.getBorderedButton("Cancel"); @@ -89,6 +104,63 @@ public void onViewInit() { this.add(navBar,BorderLayout.PAGE_END); this.pack(); } + private void performNewStrings(String[] strings){ + List contains = new ArrayList<>(); + List notContains = new ArrayList<>(); + + Arrays.stream(strings).forEach(str -> { + str = str.toLowerCase().trim(); + if(!str.isEmpty()) { + if (str.contains("!")) { + notContains.add(str.replace("!", "")); + } else { + contains.add(str); + } + } + }); + if (this.currentInterceptor != null) { + MercuryStoreCore.removeInterceptorSubject.onNext(this.currentInterceptor); + } + this.currentInterceptor = new MessageInterceptor() { + @Override + protected void process(String stubMessage) { + String message = StringUtils.substringAfter(stubMessage,"] $"); + if(message.isEmpty()){ + message = StringUtils.substringAfter(stubMessage,"] #"); + } + if(!message.isEmpty()){ + String nickname = StringUtils.substringBefore(message, ":"); + String messageContent = StringUtils.substringAfter(message, nickname + ":"); + nickname = StringUtils.deleteWhitespace(nickname); + if(nickname.contains(">")) { + nickname = StringUtils.substringAfterLast(nickname, ">"); + } + if(!expiresMessages.containsValue(message)){ + NotificationDescriptor notificationDescriptor = new NotificationDescriptor(); + notificationDescriptor.setType(NotificationType.SCANNER_MESSAGE); + notificationDescriptor.setSourceString(messageBuilder.build(messageContent)); + notificationDescriptor.setWhisperNickname(nickname); + MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); + expiresMessages.put(nickname,message); + MercuryStoreCore.soundSubject.onNext(SoundType.CHAT_SCANNER); + } + } + } + + @Override + protected MessageFilter getFilter() { + return message -> { + if (!message.contains("] $") && !message.contains("] #")) { + return false; + } + message = StringUtils.substringAfter(message, ":").toLowerCase(); + return notContains.stream().noneMatch(message::contains) + && contains.stream().anyMatch(message::contains); + }; + } + }; + MercuryStoreCore.addInterceptorSubject.onNext(this.currentInterceptor); + } @Override protected void initialize() { @@ -135,14 +207,6 @@ private JPanel getMemo(){ return root; } - public void showAuxiliaryFrame(Point location, int height) { - this.setPreferredSize(new Dimension(this.getPreferredSize().width,height)); - this.setMinimumSize(new Dimension(this.getPreferredSize().width,height)); - this.setMinimumSize(new Dimension(this.getPreferredSize().width,height)); - this.setLocation(location); - this.showComponent(); - } - @Override protected String getFrameTitle() { return "Chat filter settings"; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryFrame.java index c60996cb..889140a7 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryFrame.java @@ -4,12 +4,15 @@ import com.mercury.platform.shared.MessageParser; import com.mercury.platform.shared.config.descriptor.FrameDescriptor; import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationType; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.fields.style.MercuryScrollBarUI; import com.mercury.platform.ui.components.panel.notification.InMessagePanel; import com.mercury.platform.ui.components.panel.VerticalScrollContainer; +import com.mercury.platform.ui.components.panel.notification.NotificationPanel; import com.mercury.platform.ui.components.panel.notification.controller.NotificationIncomingController; import com.mercury.platform.ui.components.panel.notification.MessagePanelStyle; +import com.mercury.platform.ui.components.panel.notification.factory.NotificationPanelFactory; import com.mercury.platform.ui.frame.titled.AbstractTitledComponentFrame; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.MercuryStoreUI; @@ -18,10 +21,14 @@ import javax.swing.*; import java.awt.*; import java.awt.event.*; +import java.util.*; +import java.util.List; -public class HistoryFrame extends AbstractTitledComponentFrame implements HistoryContainer { +public class HistoryFrame extends AbstractTitledComponentFrame{ private JPanel mainContainer; + private NotificationPanelFactory factory; + private List currentMessages; public HistoryFrame() { super(); FrameDescriptor frameDescriptor = this.framesConfig.get(this.getClass().getSimpleName()); @@ -30,8 +37,10 @@ public HistoryFrame() { } @Override public void onViewInit() { + this.factory = new NotificationPanelFactory(); + this.currentMessages = new ArrayList<>(); this.mainContainer = new VerticalScrollContainer(); - this.mainContainer.setBackground(AppThemeColor.TRANSPARENT); + this.mainContainer.setBackground(AppThemeColor.FRAME); this.mainContainer.setLayout(new BoxLayout(this.mainContainer,BoxLayout.Y_AXIS)); JScrollPane scrollPane = new JScrollPane(this.mainContainer); @@ -54,7 +63,7 @@ public void mouseWheelMoved(MouseWheelEvent e) { vBar.addAdjustmentListener(e -> repaint()); this.add(scrollPane,BorderLayout.CENTER); - mainContainer.getParent().setBackground(AppThemeColor.TRANSPARENT); + mainContainer.getParent().setBackground(AppThemeColor.FRAME); String[] messages = HistoryManager.INSTANCE.fetchNext(10); ArrayUtils.reverse(messages); @@ -62,13 +71,12 @@ public void mouseWheelMoved(MouseWheelEvent e) { MessageParser parser = new MessageParser(); NotificationDescriptor parsedNotificationDescriptor = parser.parse(message); if(parsedNotificationDescriptor != null) { - InMessagePanel inMessagePanel = new InMessagePanel( - parsedNotificationDescriptor, - MessagePanelStyle.HISTORY, - new NotificationIncomingController(parsedNotificationDescriptor), - this.componentsFactory); - inMessagePanel.disableTime(); - mainContainer.add(inMessagePanel); + NotificationPanel panel = this.factory.getProviderFor(NotificationType.HISTORY) + .setData(parsedNotificationDescriptor) + .setComponentsFactory(this.componentsFactory) + .build(); + this.currentMessages.add(parsedNotificationDescriptor); + mainContainer.add(panel); } } this.miscPanel.add(getClearButton(),0); @@ -81,13 +89,12 @@ public void mouseWheelMoved(MouseWheelEvent e) { MessageParser parser = new MessageParser(); NotificationDescriptor parsedNotificationDescriptor = parser.parse(message); if(parsedNotificationDescriptor != null) { - InMessagePanel inMessagePanel = new InMessagePanel( - parsedNotificationDescriptor, - MessagePanelStyle.HISTORY, - new NotificationIncomingController(parsedNotificationDescriptor), - this.componentsFactory); - inMessagePanel.disableTime(); - this.mainContainer.add(inMessagePanel, 0); + NotificationPanel panel = this.factory.getProviderFor(NotificationType.HISTORY) + .setData(parsedNotificationDescriptor) + .setComponentsFactory(this.componentsFactory) + .build(); + this.currentMessages.add(parsedNotificationDescriptor); + mainContainer.add(panel,0); } vBar.setValue(vBar.getValue() + 100); } @@ -98,18 +105,13 @@ private JButton getClearButton(){ JButton clearHistory = componentsFactory.getIconButton("app/clear-history.png", 13, - AppThemeColor.TRANSPARENT, + AppThemeColor.HEADER, "Clear history"); - clearHistory.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - HistoryManager.INSTANCE.clear(); - mainContainer.removeAll(); - pack(); - repaint(); - } + clearHistory.addActionListener(action -> { + HistoryManager.INSTANCE.clear(); + this.mainContainer.removeAll(); + this.pack(); }); - clearHistory.setBorder(BorderFactory.createEmptyBorder(0,0,0,10)); return clearHistory; } @@ -120,18 +122,18 @@ protected String getFrameTitle() { @Override public void subscribe() { - MercuryStoreCore.messageSubject.subscribe(message -> SwingUtilities.invokeLater(()-> { - HistoryManager.INSTANCE.add(message); - InMessagePanel inMessagePanel = new InMessagePanel( - message, - MessagePanelStyle.HISTORY, - new NotificationIncomingController(message), - this.componentsFactory); - this.mainContainer.add(inMessagePanel); - this.trimContainer(); - this.pack(); + MercuryStoreCore.newNotificationSubject.subscribe(message -> SwingUtilities.invokeLater(()-> { + if(!currentMessages.contains(message)) { + HistoryManager.INSTANCE.add(message); + NotificationPanel panel = this.factory.getProviderFor(NotificationType.HISTORY) + .setData(message) + .setComponentsFactory(this.componentsFactory) + .build(); + mainContainer.add(panel); + this.trimContainer(); + this.pack(); + } })); - MercuryStoreUI.reloadMessageSubject.subscribe(this::onReloadMessage); } private void trimContainer(){ if(mainContainer.getComponentCount() > 40){ @@ -141,12 +143,4 @@ private void trimContainer(){ this.pack(); } } - - @Override - public void onReloadMessage(InMessagePanel inMessagePanel) { - inMessagePanel.setStyle(MessagePanelStyle.RELOADED); - inMessagePanel.setPreferredSize(new Dimension(this.getWidth()-10, inMessagePanel.getPreferredSize().height)); - this.pack(); - this.repaint(); - } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java b/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java index 7cab202f..fce9e621 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java @@ -22,6 +22,7 @@ import com.mercury.platform.ui.frame.setup.location.SetUpLocationCommander; import com.mercury.platform.ui.frame.other.SetUpLocationFrame; import com.mercury.platform.ui.frame.titled.chat.ChatFilterFrame; +import com.mercury.platform.ui.frame.titled.chat.ChatFilterSettingsFrame; import com.mercury.platform.ui.frame.titled.container.HistoryFrame; import com.mercury.platform.ui.manager.routing.SettingsRoutManager; import com.mercury.platform.ui.misc.MercuryStoreUI; @@ -81,7 +82,7 @@ public void start(){ this.framesMap.put(TooltipFrame.class,new TooltipFrame()); this.framesMap.put(NotificationAlertFrame.class,new NotificationAlertFrame()); this.framesMap.put(MercuryLoadingFrame.class,new MercuryLoadingFrame()); - this.framesMap.put(ChatFilterFrame.class,new ChatFilterFrame()); + this.framesMap.put(ChatFilterSettingsFrame.class,new ChatFilterSettingsFrame()); this.framesMap.put(UpdateReadyFrame.class,new UpdateReadyFrame()); this.framesMap.put(TaskBarFrame.class,taskBarFrame); this.framesMap.put(SetUpLocationFrame.class,new SetUpLocationFrame()); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/misc/AppThemeColor.java b/app-ui/src/main/java/com/mercury/platform/ui/misc/AppThemeColor.java index a9398f91..48b7f1dd 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/misc/AppThemeColor.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/misc/AppThemeColor.java @@ -4,7 +4,7 @@ public class AppThemeColor { public static final Color BUTTON = new Color(52, 62, 61); - public static final Color SCROLL_BAR = new Color(44, 70, 80); + public static final Color SCROLL_BAR = new Color(71, 81, 80); public static final Color TEXT_DEFAULT = new Color(255,250,250); public static final Color TEXT_MESSAGE = new Color(255,250,213); public static final Color TEXT_MISC = new Color(219,158,54); @@ -14,6 +14,7 @@ public class AppThemeColor { public static final Color TEXT_DISABLE = new Color(126,130,122); public static final Color BORDER = new Color(70, 81, 80); public static final Color BORDER_DARK = new Color(62, 73, 72); + public static final Color HEADER_SELECTED_BORDER = new Color(128, 123, 95); public static final Color FRAME = new Color(42, 44, 43,254); public static final Color FRAME_RGB = new Color(42, 44, 43); public static final Color FRAME_ALPHA = new Color(42, 44, 43,1); diff --git a/app/src/main/java/com/mercury/platform/AppMain.java b/app/src/main/java/com/mercury/platform/AppMain.java index b50d3398..b9acd195 100644 --- a/app/src/main/java/com/mercury/platform/AppMain.java +++ b/app/src/main/java/com/mercury/platform/AppMain.java @@ -24,6 +24,7 @@ public class AppMain { public static void main(String[] args) { System.setProperty("sun.java2d.d3d","false"); + System.setProperty("jna.nosys","true"); new ErrorHandler(); MercuryLoadingFrame mercuryLoadingFrame = new MercuryLoadingFrame(); mercuryLoadingFrame.init(); From b27d70a8ad316c5637a5eb846ce9cbc7ef773e94 Mon Sep 17 00:00:00 2001 From: Exslims Date: Sun, 20 Aug 2017 02:11:56 +0400 Subject: [PATCH 06/17] Notification panel rework, added scale handlers --- .../impl/FramesConfigurationServiceImpl.java | 4 +- .../impl/HotKeyConfigurationService.java | 40 +-- .../NotificationConfigurationService.java | 3 +- .../CurrencyIncNotificationPanel.java | 8 +- .../ItemIncNotificationPanel.java | 4 +- .../panel/notification/NotificationPanel.java | 6 +- .../stub/HistoryStubController.java | 16 ++ .../controller/stub/IncStubController.java | 46 +++ .../controller/stub/OutStubController.java | 38 +++ .../stub/ScannerStubController.java | 38 +++ .../factory/NotificationPanelProvider.java | 3 + .../frame/AbstractScalableComponentFrame.java | 36 +-- .../AbstractMovableComponentFrame.java | 22 +- .../ui/frame/movable/ItemsGridFrame.java | 2 - .../movable/container/NotificationFrame.java | 51 +++- .../ui/frame/titled/TestCasesFrame.java | 262 +----------------- .../platform/ui/frame/titled/TestEngine.java | 204 ++++++++++++++ 17 files changed, 448 insertions(+), 335 deletions(-) create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/stub/HistoryStubController.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/stub/IncStubController.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/stub/OutStubController.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/stub/ScannerStubController.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestEngine.java diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/FramesConfigurationServiceImpl.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/FramesConfigurationServiceImpl.java index f06dd294..5ff4bb07 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/FramesConfigurationServiceImpl.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/FramesConfigurationServiceImpl.java @@ -62,7 +62,7 @@ public Dimension getMinimumSize(String frameClass) { private void initMinimumMap() { minimumFrameSize.put("TaskBarFrame",new Dimension(109,20)); - minimumFrameSize.put("NotificationFrame",new Dimension(360,10)); + minimumFrameSize.put("NotificationFrame",new Dimension(320,10)); minimumFrameSize.put("OutMessageFrame",new Dimension(280,115)); minimumFrameSize.put("TestCasesFrame",new Dimension(400,100)); minimumFrameSize.put("SettingsFrame",new Dimension(600,400)); @@ -79,7 +79,7 @@ private void initMinimumMap() { } private void initDefaultMap() { defaultFramesSettings.put("TaskBarFrame", new FrameDescriptor(new Point(400, 500), new Dimension(109, 20))); - defaultFramesSettings.put("NotificationFrame", new FrameDescriptor(new Point(700, 600), new Dimension(315, 0))); + defaultFramesSettings.put("NotificationFrame", new FrameDescriptor(new Point(700, 600), new Dimension(350, 0))); defaultFramesSettings.put("OutMessageFrame", new FrameDescriptor(new Point(200, 500), new Dimension(280, 115))); defaultFramesSettings.put("TestCasesFrame", new FrameDescriptor(new Point(1400, 500), new Dimension(400, 100))); defaultFramesSettings.put("SettingsFrame", new FrameDescriptor(new Point(600, 600), new Dimension(800,600))); diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeyConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeyConfigurationService.java index 6aa37b1a..30474ffd 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeyConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeyConfigurationService.java @@ -19,32 +19,32 @@ public HotKeyConfigurationService(ProfileDescriptor selectedProfile) { public HotKeysSettingsDescriptor getDefault() { HotKeysSettingsDescriptor hotKeysSettingsDescriptor = new HotKeysSettingsDescriptor(); List incNDataList = new ArrayList<>(); - incNDataList.add(new HotKeyPair(HotKeyType.N_INVITE_PLAYER,new HotKeyDescriptor("F1", NativeKeyEvent.VC_F1,true,false,false))); - incNDataList.add(new HotKeyPair(HotKeyType.N_TRADE_PLAYER,new HotKeyDescriptor("F2",NativeKeyEvent.VC_F2,true,false,false))); - incNDataList.add(new HotKeyPair(HotKeyType.N_KICK_PLAYER,new HotKeyDescriptor("F3",NativeKeyEvent.VC_F3,true,false,false))); - incNDataList.add(new HotKeyPair(HotKeyType.N_STILL_INTERESTING,new HotKeyDescriptor("F4",NativeKeyEvent.VC_F4,true,false,false))); - incNDataList.add(new HotKeyPair(HotKeyType.N_OPEN_CHAT,new HotKeyDescriptor("F5",NativeKeyEvent.VC_F5,true,false,false))); - incNDataList.add(new HotKeyPair(HotKeyType.N_SWITCH_CHAT,new HotKeyDescriptor("F6",NativeKeyEvent.VC_F6,true,false,false))); - incNDataList.add(new HotKeyPair(HotKeyType.N_CLOSE_NOTIFICATION,new HotKeyDescriptor("F7",NativeKeyEvent.VC_F7,true,false,false))); + incNDataList.add(new HotKeyPair(HotKeyType.N_INVITE_PLAYER,new HotKeyDescriptor("F1", NativeKeyEvent.VC_F1,false,false,false))); + incNDataList.add(new HotKeyPair(HotKeyType.N_TRADE_PLAYER,new HotKeyDescriptor("F2",NativeKeyEvent.VC_F2,false,false,false))); + incNDataList.add(new HotKeyPair(HotKeyType.N_KICK_PLAYER,new HotKeyDescriptor("F3",NativeKeyEvent.VC_F3,false,false,false))); + incNDataList.add(new HotKeyPair(HotKeyType.N_STILL_INTERESTING,new HotKeyDescriptor("F4",NativeKeyEvent.VC_F4,false,false,false))); + incNDataList.add(new HotKeyPair(HotKeyType.N_OPEN_CHAT,new HotKeyDescriptor("F5",NativeKeyEvent.VC_F5,false,false,false))); + incNDataList.add(new HotKeyPair(HotKeyType.N_SWITCH_CHAT,new HotKeyDescriptor("F6",NativeKeyEvent.VC_F6,false,false,false))); + incNDataList.add(new HotKeyPair(HotKeyType.N_CLOSE_NOTIFICATION,new HotKeyDescriptor("F7",NativeKeyEvent.VC_F7,false,false,false))); List outNDataList = new ArrayList<>(); - outNDataList.add(new HotKeyPair(HotKeyType.N_VISITE_HIDEOUT,new HotKeyDescriptor("F1", NativeKeyEvent.VC_F1,true,false,false))); - outNDataList.add(new HotKeyPair(HotKeyType.N_TRADE_PLAYER,new HotKeyDescriptor("F2",NativeKeyEvent.VC_F2,true,false,false))); - outNDataList.add(new HotKeyPair(HotKeyType.N_LEAVE,new HotKeyDescriptor("F3",NativeKeyEvent.VC_F3,true,false,false))); - outNDataList.add(new HotKeyPair(HotKeyType.N_OPEN_CHAT,new HotKeyDescriptor("F4",NativeKeyEvent.VC_F4,true,false,false))); - outNDataList.add(new HotKeyPair(HotKeyType.N_CLOSE_NOTIFICATION,new HotKeyDescriptor("F5",NativeKeyEvent.VC_F5,true,false,false))); + outNDataList.add(new HotKeyPair(HotKeyType.N_VISITE_HIDEOUT,new HotKeyDescriptor("F1", NativeKeyEvent.VC_F1,false,false,false))); + outNDataList.add(new HotKeyPair(HotKeyType.N_TRADE_PLAYER,new HotKeyDescriptor("F2",NativeKeyEvent.VC_F2,false,false,false))); + outNDataList.add(new HotKeyPair(HotKeyType.N_LEAVE,new HotKeyDescriptor("F3",NativeKeyEvent.VC_F3,false,false,false))); + outNDataList.add(new HotKeyPair(HotKeyType.N_OPEN_CHAT,new HotKeyDescriptor("F4",NativeKeyEvent.VC_F4,false,false,false))); + outNDataList.add(new HotKeyPair(HotKeyType.N_CLOSE_NOTIFICATION,new HotKeyDescriptor("F5",NativeKeyEvent.VC_F5,false,false,false))); List scannerNDataList = new ArrayList<>(); - scannerNDataList.add(new HotKeyPair(HotKeyType.N_QUICK_RESPONSE,new HotKeyDescriptor("F1", NativeKeyEvent.VC_F1,true,false,false))); - scannerNDataList.add(new HotKeyPair(HotKeyType.N_VISITE_HIDEOUT,new HotKeyDescriptor("F2", NativeKeyEvent.VC_F2,true,false,false))); - scannerNDataList.add(new HotKeyPair(HotKeyType.N_TRADE_PLAYER,new HotKeyDescriptor("F3",NativeKeyEvent.VC_F3,true,false,false))); - scannerNDataList.add(new HotKeyPair(HotKeyType.N_LEAVE,new HotKeyDescriptor("F4",NativeKeyEvent.VC_F4,true,false,false))); - scannerNDataList.add(new HotKeyPair(HotKeyType.N_OPEN_CHAT,new HotKeyDescriptor("F5",NativeKeyEvent.VC_F5,true,false,false))); - scannerNDataList.add(new HotKeyPair(HotKeyType.N_CLOSE_NOTIFICATION,new HotKeyDescriptor("F6",NativeKeyEvent.VC_F6,true,false,false))); + scannerNDataList.add(new HotKeyPair(HotKeyType.N_QUICK_RESPONSE,new HotKeyDescriptor("F1", NativeKeyEvent.VC_F1,false,false,false))); + scannerNDataList.add(new HotKeyPair(HotKeyType.N_VISITE_HIDEOUT,new HotKeyDescriptor("F2", NativeKeyEvent.VC_F2,false,false,false))); + scannerNDataList.add(new HotKeyPair(HotKeyType.N_TRADE_PLAYER,new HotKeyDescriptor("F3",NativeKeyEvent.VC_F3,false,false,false))); + scannerNDataList.add(new HotKeyPair(HotKeyType.N_LEAVE,new HotKeyDescriptor("F4",NativeKeyEvent.VC_F4,false,false,false))); + scannerNDataList.add(new HotKeyPair(HotKeyType.N_OPEN_CHAT,new HotKeyDescriptor("F5",NativeKeyEvent.VC_F5,false,false,false))); + scannerNDataList.add(new HotKeyPair(HotKeyType.N_CLOSE_NOTIFICATION,new HotKeyDescriptor("F6",NativeKeyEvent.VC_F6,false,false,false))); List taskBarNDataList = new ArrayList<>(); - taskBarNDataList.add(new HotKeyPair(HotKeyType.T_TO_HIDEOUT,new HotKeyDescriptor("F1",NativeKeyEvent.VC_F1,true,false,false))); - taskBarNDataList.add(new HotKeyPair(HotKeyType.T_DND,new HotKeyDescriptor("F2",NativeKeyEvent.VC_F2,true,false,false))); + taskBarNDataList.add(new HotKeyPair(HotKeyType.T_TO_HIDEOUT,new HotKeyDescriptor("F1",NativeKeyEvent.VC_F1,false,false,false))); + taskBarNDataList.add(new HotKeyPair(HotKeyType.T_DND,new HotKeyDescriptor("F2",NativeKeyEvent.VC_F2,false,false,false))); hotKeysSettingsDescriptor.setIncNHotKeysList(incNDataList); hotKeysSettingsDescriptor.setOutNHotKeysList(outNDataList); diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java index c3ae10f4..6d23c8bd 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java @@ -27,7 +27,8 @@ public NotificationSettingsDescriptor getDefault() { defaultButtons.add(new ResponseButtonDescriptor(3,false,"sold", "sold",new HotKeyDescriptor())); List defaultOutButtons = new ArrayList<>(); defaultOutButtons.add(new ResponseButtonDescriptor(0,false,"thanks","thanks", new HotKeyDescriptor())); - notificationSettingsDescriptor.setButtons(defaultOutButtons); + notificationSettingsDescriptor.setButtons(defaultButtons); + notificationSettingsDescriptor.setOutButtons(defaultOutButtons); return notificationSettingsDescriptor; } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyIncNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyIncNotificationPanel.java index 0ce5fb36..118841f7 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyIncNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyIncNotificationPanel.java @@ -56,13 +56,9 @@ private JPanel getCurrencyRatePanel(){ protected JButton getStillInterestedButton() { JButton stillIntButton = componentsFactory.getIconButton("app/still-interesting.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.STILL_INTERESTED); stillIntButton.addActionListener(action -> { - String curCount = this.data.getCurCount() % 1 == 0 ? - String.valueOf(this.data.getCurCount().intValue()) : - String.valueOf(this.data.getCurCount()); + String curCount = this.data.getCurCount().toString(); String responseText = "Hi, are you still interested in "; - String curForSaleCount = this.data.getCurCount() % 1 == 0 ? - String.valueOf(this.data.getCurrForSaleCount().intValue()) : - String.valueOf(this.data.getCurrForSaleCount()); + String curForSaleCount = this.data.getCurrForSaleCount().toString(); responseText += curForSaleCount + " " + this.data.getCurrForSaleTitle() + " for " + curCount + " " + this.data.getCurrency() + "?"; this.controller.performResponse(responseText); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemIncNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemIncNotificationPanel.java index 949f5da7..8c1b5f4b 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemIncNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemIncNotificationPanel.java @@ -49,9 +49,7 @@ protected JPanel getMessagePanel() { protected JButton getStillInterestedButton() { JButton stillIntButton = componentsFactory.getIconButton("app/still-interesting.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.STILL_INTERESTED); stillIntButton.addActionListener(action-> { - String curCount = this.data.getCurCount() % 1 == 0 ? - String.valueOf(this.data.getCurCount().intValue()) : - String.valueOf(this.data.getCurCount()); + String curCount = this.data.getCurCount().toString(); String responseText = "Hi, are you still interested in "; if(this.data.getCurrency().equals("???")){ responseText += this.data.getItemName() + "?"; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java index e2924542..e044665d 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java @@ -28,7 +28,6 @@ public abstract class NotificationPanel extends JPanel implements AsSubscri protected T data; @Setter protected C controller; - @Setter protected ComponentsFactory componentsFactory; protected Map hotKeysPool = new HashMap<>(); protected Map interactButtonMap = new HashMap<>(); @@ -49,6 +48,11 @@ public void onViewInit() { BorderFactory.createEmptyBorder(1,1,1,1), BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON_BORDER, 1))); } + public void setComponentsFactory(ComponentsFactory factory){ + this.componentsFactory = factory; + this.removeAll(); + this.onViewInit(); + } public void onHotKeyPressed(HotKeyDescriptor descriptor){ JButton button = this.hotKeysPool.get(descriptor); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/stub/HistoryStubController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/stub/HistoryStubController.java new file mode 100644 index 00000000..bd95b67d --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/stub/HistoryStubController.java @@ -0,0 +1,16 @@ +package com.mercury.platform.ui.components.panel.notification.controller.stub; + +import com.mercury.platform.ui.components.panel.notification.controller.HistoryController; + + +public class HistoryStubController implements HistoryController { + @Override + public void reload() { + + } + + @Override + public void performOpenChat() { + + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/stub/IncStubController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/stub/IncStubController.java new file mode 100644 index 00000000..ac786e23 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/stub/IncStubController.java @@ -0,0 +1,46 @@ +package com.mercury.platform.ui.components.panel.notification.controller.stub; + +import com.mercury.platform.ui.components.panel.notification.InMessagePanel; +import com.mercury.platform.ui.components.panel.notification.controller.IncomingPanelController; + +public class IncStubController implements IncomingPanelController { + @Override + public void performOfferTrade() { + + } + + @Override + public void performHide() { + + } + + @Override + public void performOpenChat() { + + } + + @Override + public void performResponse(String response) { + + } + + @Override + public void performInvite() { + + } + + @Override + public void performKick() { + + } + + @Override + public void showITH() { + + } + + @Override + public void reloadMessage(InMessagePanel panel) { + + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/stub/OutStubController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/stub/OutStubController.java new file mode 100644 index 00000000..07ad16bb --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/stub/OutStubController.java @@ -0,0 +1,38 @@ +package com.mercury.platform.ui.components.panel.notification.controller.stub; + +import com.mercury.platform.ui.components.panel.notification.controller.OutgoingPanelController; + +/** + * Created by Константин on 20.08.2017. + */ +public class OutStubController implements OutgoingPanelController { + @Override + public void performOfferTrade() { + + } + + @Override + public void performHide() { + + } + + @Override + public void performOpenChat() { + + } + + @Override + public void performResponse(String response) { + + } + + @Override + public void visitHideout() { + + } + + @Override + public void performLeave(String nickName) { + + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/stub/ScannerStubController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/stub/ScannerStubController.java new file mode 100644 index 00000000..2f4fea81 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/stub/ScannerStubController.java @@ -0,0 +1,38 @@ +package com.mercury.platform.ui.components.panel.notification.controller.stub; + +import com.mercury.platform.ui.components.panel.notification.controller.ScannerPanelController; + +/** + * Created by Константин on 20.08.2017. + */ +public class ScannerStubController implements ScannerPanelController { + @Override + public void performOfferTrade() { + + } + + @Override + public void performHide() { + + } + + @Override + public void performOpenChat() { + + } + + @Override + public void performResponse(String response) { + + } + + @Override + public void visitHideout() { + + } + + @Override + public void performLeave(String nickName) { + + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelProvider.java index de3eabb5..64674189 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelProvider.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelProvider.java @@ -34,6 +34,9 @@ public NotificationPanel build() { panel.setComponentsFactory(this.componentsFactory); panel.subscribe(); panel.onViewInit(); + this.componentsFactory = null; + this.controller = null; + this.data = null; return panel; } protected abstract NotificationPanel getPanel(); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractScalableComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractScalableComponentFrame.java index 47006df0..1fa2c572 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractScalableComponentFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractScalableComponentFrame.java @@ -13,7 +13,6 @@ public abstract class AbstractScalableComponentFrame extends AbstractComponentFr private ScaleState scaleState = ScaleState.DEFAULT; protected ComponentsFactory stubComponentsFactory; private ScalableFrameConstraints prevConstraints; - protected boolean sizeWasChanged = false; protected boolean inScaleSettings = false; protected AbstractScalableComponentFrame() { @@ -41,22 +40,14 @@ protected void changeScale(float scale){ this.initDefaultView(); } public void setState(ScaleState state){ + System.out.println(this.mainContainer.getPreferredSize()); switch (state){ case DEFAULT:{ this.scaleState = ScaleState.DEFAULT; this.setContentPane(mainContainer); this.setVisible(prevConstraints.visible); + this.processEResize = prevConstraints.processEResize; this.setBackground(prevConstraints.bgColor); - this.setLocation(prevConstraints.location); - if(sizeWasChanged){ - this.setPreferredSize(this.getSize()); - this.setMinimumSize(this.getSize()); - this.setMaximumSize(this.getSize()); - sizeWasChanged = false; - }else { - this.setMinimumSize(prevConstraints.minSize); - this.setMaximumSize(prevConstraints.maxSize); - } this.inScaleSettings = false; this.onScaleLock(); break; @@ -66,14 +57,10 @@ public void setState(ScaleState state){ this.scaleState = ScaleState.ENABLE; this.prevConstraints = new ScalableFrameConstraints( this.isVisible(), - this.getMinimumSize(), - this.getMaximumSize(), - this.getLocation(), - this.getBackground() + this.processEResize, this.getBackground() ); + this.processEResize = false; initDefaultView(); - this.setLocation(this.framesConfig.get(this.getClass().getSimpleName()).getFrameLocation()); - this.setMinimumSize(null); this.setVisible(true); this.onScaleUnlock(); break; @@ -92,21 +79,14 @@ private void initDefaultView(){ protected class ScalableFrameConstraints { private boolean visible; - private Dimension minSize; - private Dimension maxSize; - private Point location; + private boolean processEResize; private Color bgColor; ScalableFrameConstraints( - boolean visible, - Dimension minSize, - Dimension maxSize, - Point location, - Color bgColor) { + boolean visible, + boolean processEResize, Color bgColor) { this.visible = visible; - this.minSize = minSize; - this.maxSize = maxSize; - this.location = location; + this.processEResize = processEResize; this.bgColor = bgColor; } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/AbstractMovableComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/AbstractMovableComponentFrame.java index 2183754f..a5ef6192 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/AbstractMovableComponentFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/AbstractMovableComponentFrame.java @@ -40,9 +40,7 @@ public void setState(LocationState state){ this.isVisible(), this.getBackground(), this.getRootPane().getBorder(), - this.getLocation(), - this.getMinimumSize(), - this.getMaximumSize() + this.getLocation() ); this.processEResize = false; this.processSEResize = false; @@ -50,7 +48,6 @@ public void setState(LocationState state){ this.setBackground(panelForPin.getBackground()); this.setLocation(this.framesConfig.get(this.getClass().getSimpleName()).getFrameLocation()); this.getRootPane().setBorder(BorderFactory.createLineBorder(AppThemeColor.BORDER, 1)); - this.setMinimumSize(null); this.setContentPane(panelForPin); this.setVisible(true); this.setAlwaysOnTop(true); @@ -66,15 +63,6 @@ public void setState(LocationState state){ this.setBackground(prevConstraints.bgColor); this.getRootPane().setBorder(prevConstraints.border); this.setLocation(prevConstraints.location); - if(sizeWasChanged){ - this.setPreferredSize(this.getSize()); - this.setMinimumSize(this.getSize()); - this.setMaximumSize(this.getSize()); - sizeWasChanged = false; - }else { - this.setMinimumSize(prevConstraints.minSize); - this.setMaximumSize(prevConstraints.maxSize); - } inMoveMode = false; this.onLock(); break; @@ -126,25 +114,19 @@ protected class MovableFrameConstraints { private Color bgColor; private Border border; private Point location; - private Dimension minSize; - private Dimension maxSize; MovableFrameConstraints(boolean processSEResize, boolean processEResize, boolean visible, Color bgColor, Border border, - Point location, - Dimension minSize, - Dimension maxSize) { + Point location) { this.processSEResize = processSEResize; this.processEResize = processEResize; this.visible = visible; this.bgColor = bgColor; this.border = border; this.location = location; - this.minSize = minSize; - this.maxSize = maxSize; } public void setLocation(Point location) { diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/ItemsGridFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/ItemsGridFrame.java index 5a410279..d9e091d2 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/ItemsGridFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/ItemsGridFrame.java @@ -276,7 +276,6 @@ protected void performScaling(Map scaleData) { private class ResizeByWidthMouseMotionListener extends MouseMotionAdapter { @Override public void mouseDragged(MouseEvent e) { - sizeWasChanged = true; JPanel source = (JPanel) e.getSource(); Point frameLocation = getLocation(); setSize(new Dimension(e.getLocationOnScreen().x - frameLocation.x + source.getWidth(), getHeight())); @@ -285,7 +284,6 @@ public void mouseDragged(MouseEvent e) { private class ResizeByHeightMouseMotionListener extends MouseMotionAdapter { @Override public void mouseDragged(MouseEvent e) { - sizeWasChanged = true; JPanel source = (JPanel) e.getSource(); Point frameLocation = getLocation(); setSize(new Dimension(getWidth(),e.getLocationOnScreen().y - frameLocation.y + source.getHeight())); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java index 840e048c..bd421761 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java @@ -6,15 +6,23 @@ import com.mercury.platform.shared.config.configration.PlainConfigurationService; import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; import com.mercury.platform.shared.entity.message.FlowDirections; +import com.mercury.platform.shared.entity.message.NotificationType; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; +import com.mercury.platform.ui.components.panel.notification.InMessagePanel; import com.mercury.platform.ui.components.panel.notification.NotificationPanel; import com.mercury.platform.ui.components.panel.notification.ScannerNotificationPanel; +import com.mercury.platform.ui.components.panel.notification.controller.IncomingPanelController; +import com.mercury.platform.ui.components.panel.notification.controller.stub.IncStubController; +import com.mercury.platform.ui.components.panel.notification.controller.stub.OutStubController; +import com.mercury.platform.ui.components.panel.notification.controller.stub.ScannerStubController; import com.mercury.platform.ui.components.panel.notification.factory.NotificationPanelFactory; import com.mercury.platform.ui.frame.movable.AbstractMovableComponentFrame; +import com.mercury.platform.ui.frame.titled.TestEngine; import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.MercuryStoreUI; import javax.swing.*; import javax.swing.Timer; @@ -26,7 +34,7 @@ public class NotificationFrame extends AbstractMovableComponentFrame { private List notificationPanels; private PlainConfigurationService config; - private NotificationPanelFactory factory; + private NotificationPanelFactory providersFactory; private JPanel container; private JPanel expandPanel; private boolean expanded; @@ -38,7 +46,7 @@ protected void initialize() { this.config = Configuration.get().notificationConfiguration(); this.componentsFactory.setScale(this.scaleConfig.get("notification")); this.stubComponentsFactory.setScale(this.scaleConfig.get("notification")); - this.factory = new NotificationPanelFactory(); + this.providersFactory = new NotificationPanelFactory(); } @Override @@ -61,7 +69,7 @@ public void onViewInit() { public void subscribe() { MercuryStoreCore.newNotificationSubject.subscribe(notification -> { SwingUtilities.invokeLater(() -> { - NotificationPanel notificationPanel = this.factory.getProviderFor(notification.getType()) + NotificationPanel notificationPanel = this.providersFactory.getProviderFor(notification.getType()) .setData(notification) .setComponentsFactory(this.componentsFactory) .build(); @@ -136,14 +144,49 @@ protected JPanel getPanelForPINSettings() { @Override protected void registerDirectScaleHandler() { + MercuryStoreUI.notificationScaleSubject.subscribe(this::changeScale); } @Override protected void performScaling(Map scaleData) { + this.componentsFactory.setScale(scaleData.get("notification")); + this.notificationPanels.forEach(it -> { + it.setComponentsFactory(this.componentsFactory); + }); + this.pack(); + this.repaint(); } @Override + @SuppressWarnings("all") protected JPanel defaultView(ComponentsFactory factory) { - return null; + TestEngine testEngine = new TestEngine(); + JPanel root = factory.getJPanel(new BorderLayout()); + root.setLayout(new BoxLayout(root,BoxLayout.Y_AXIS)); + + root.add(this.providersFactory + .getProviderFor(NotificationType.INC_ITEM_MESSAGE) + .setData(testEngine.getRandomItemIncMessage()) + .setComponentsFactory(factory) + .setController(new IncStubController()) + .build()); + root.add(this.providersFactory + .getProviderFor(NotificationType.OUT_ITEM_MESSAGE) + .setData(testEngine.getRandomItemOutMessage()) + .setComponentsFactory(factory) + .setController(new OutStubController()) + .build()); + root.add(this.providersFactory + .getProviderFor(NotificationType.SCANNER_MESSAGE) + .setData(testEngine.getRandomScannerMessage()) + .setComponentsFactory(factory) + .setController(new ScannerStubController()) + .build()); + Timer packTimer = new Timer(10, action -> { + this.pack(); + }); + packTimer.start(); + + return root; } @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java index 6937894c..9ed1e152 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java @@ -1,145 +1,20 @@ package com.mercury.platform.ui.frame.titled; -import com.mercury.platform.core.misc.SoundType; -import com.mercury.platform.shared.MessageParser; -import com.mercury.platform.shared.entity.message.NotificationDescriptor; -import com.mercury.platform.shared.entity.message.NotificationType; import com.mercury.platform.shared.store.MercuryStoreCore; -import com.mercury.platform.ui.components.panel.chat.HtmlMessageBuilder; import com.mercury.platform.ui.misc.AppThemeColor; -import org.apache.commons.lang3.StringUtils; - import javax.swing.*; -import javax.swing.Timer; import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.*; -import java.util.List; public class TestCasesFrame extends AbstractTitledComponentFrame { - private List items; - private List currency; - private List nickNames; - private List offer; - private List leagues; - private HtmlMessageBuilder messageBuilder; - private String poeTradeTemplate = "%s: Hi, I would like to buy your %s listed for %d %s in %s (stash tab \"%d\"; position: left %d, top %d) %s"; - private String currencyTemplate = "%s: Hi, I'd like to buy your %d %s for my %d %s in %s. %s"; + private TestEngine testEngine; public TestCasesFrame() { super(); - items = new ArrayList<>(); - currency = new ArrayList<>(); - nickNames = new ArrayList<>(); - offer = new ArrayList<>(); - leagues = new ArrayList<>(); - this.messageBuilder = new HtmlMessageBuilder(); - this.messageBuilder.setChunkStrings(Arrays.asList("Hi","buy","listed","like")); - items.add("Wondertrap Velvet Slippers"); - items.add("Rain of Arrows"); - items.add("Dreadarc Cleaver"); - items.add("Three-step Assault Shagreen Boots"); - items.add("Thunderous Skies"); - items.add("Honourhome Soldier Helmet"); - items.add("Pain Breaker Blood Sceptre"); - items.add("Freeze Mine"); - items.add("The Lunaris Priestess"); - - currency.add("alteration"); - currency.add("alchemy"); - currency.add("apprentice sextant"); - currency.add("divine"); - currency.add("exalted"); - currency.add("blessed"); - currency.add("esh's breachstone"); - currency.add("eber's"); - currency.add("regal"); - currency.add("armourer's"); - currency.add("augmentation"); - currency.add("bauble"); - currency.add("blessing of chayula"); - currency.add("blessing of esh"); - currency.add("blessing of tul"); - currency.add("blessing of uul-netol"); - currency.add("blessing of xoph"); - currency.add("chance"); - currency.add("chaos"); - currency.add("chayula's breachstone"); - currency.add("chimera"); - currency.add("chisel"); - currency.add("chrome"); - currency.add("coin"); - currency.add("dawn"); - currency.add("dusk"); - currency.add("eternal"); - currency.add("fusing"); - currency.add("gcp"); - currency.add("grief"); - currency.add("hope"); - currency.add("hydra"); - currency.add("ignorance"); - currency.add("inya's"); - currency.add("jeweller's"); - currency.add("journeyman sextant"); - currency.add("master sextant"); - currency.add("midnight"); - currency.add("minotaur"); - currency.add("mirror"); - currency.add("mortal set"); - currency.add("noon"); - currency.add("offering"); - currency.add("pale court"); - currency.add("phoenix"); - currency.add("portal"); - currency.add("rage"); - currency.add("regret"); - currency.add("sacrifice set"); - currency.add("scouring"); - currency.add("shaper set"); - currency.add("silver"); - currency.add("splinter of chayula"); - currency.add("splinter of esh"); - currency.add("splinter of tul"); - currency.add("splinter of uul-netol"); - currency.add("splinter of xoph"); - currency.add("transmutation"); - currency.add("tul's breachstone"); - currency.add("uul-netol's breachstone"); - currency.add("vaal"); - currency.add("volkuur's"); - currency.add("wisdom"); - currency.add("xoph's breachstone"); - currency.add("yriel's"); - - nickNames.add("Example1"); - nickNames.add("Example2"); - nickNames.add("Example3"); - nickNames.add("Example4"); - nickNames.add("Example5"); - nickNames.add("Example6"); - - offer.add("offer"); - offer.add(" "); - offer.add(""); - offer.add(" "); - offer.add("offer offer offer offer offer"); - offer.add("offer offer offer offer offer offer offer offer"); - offer.add("offer offer"); - offer.add("offer"); - - leagues.add("Standard"); - leagues.add("Hardcore Legacy"); - leagues.add("Legacy"); - leagues.add("Hardcore"); - leagues.add("Beta Standard"); - leagues.add("Beta Hardcore"); - leagues.add("1 Week Legacy (JRE055)"); - leagues.add("1 Week Legacy HC (JRE055)"); } @Override public void onViewInit() { + this.testEngine = new TestEngine(); this.add(getTestCasesPanel(), BorderLayout.CENTER); this.pack(); } @@ -149,9 +24,8 @@ protected String getFrameTitle() { return "Example of usage"; } + private JPanel getTestCasesPanel(){ - MessageParser parser = new MessageParser(); - Random random = new Random(); JPanel testPanel = new JPanel(new GridBagLayout()); GridBagConstraints buttonColumn = new GridBagConstraints(); @@ -170,23 +44,10 @@ private JPanel getTestCasesPanel(){ titleColumn.insets = new Insets(3,3,3,0); JButton button = componentsFactory.getBorderedButton("Click"); - button.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - NotificationDescriptor notificationDescriptor = parser.parse(String.format(poeTradeTemplate, - nickNames.get(random.nextInt(nickNames.size())), - items.get(random.nextInt(items.size())), - random.nextInt(200), - currency.get(random.nextInt(currency.size())), - leagues.get(random.nextInt(leagues.size())), - random.nextInt(30), - random.nextInt(12) + 1, - random.nextInt(12) + 1, - offer.get(random.nextInt(offer.size())) - )); - MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); - } + button.addActionListener(action -> { + MercuryStoreCore.newNotificationSubject.onNext(this.testEngine.getRandomItemIncMessage()); }); + ; testPanel.add(button,buttonColumn); buttonColumn.gridy++; JLabel textLabel = componentsFactory.getTextLabel("Random incoming item message"); @@ -194,20 +55,8 @@ public void mousePressed(MouseEvent e) { titleColumn.gridy++; JButton button1 = componentsFactory.getBorderedButton("Click"); - button1.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - NotificationDescriptor notificationDescriptor = parser.parse(String.format(currencyTemplate, - nickNames.get(random.nextInt(nickNames.size())), - random.nextInt(200) + 1, - currency.get(random.nextInt(currency.size())), - random.nextInt(200) + 1, - currency.get(random.nextInt(currency.size())), - leagues.get(random.nextInt(leagues.size())), - offer.get(random.nextInt(offer.size())) - )); - MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); - } + button1.addActionListener(action -> { + MercuryStoreCore.newNotificationSubject.onNext(this.testEngine.getRandomCurrencyIncMessage()); }); testPanel.add(button1,buttonColumn); buttonColumn.gridy++; @@ -215,62 +64,9 @@ public void mousePressed(MouseEvent e) { testPanel.add(textLabel1,titleColumn); titleColumn.gridy++; -// JButton button2 = componentsFactory.getBorderedButton("Click"); -// button2.addMouseListener(new MouseAdapter() { -// @Override -// public void mousePressed(MouseEvent e) { -// String nickname = nickNames.get(random.nextInt(nickNames.size())); -// NotificationDescriptor notificationDescriptor = parser.parse(String.format(currencyTemplate, -// nickname, -// random.nextInt(200), -// currency.get(random.nextInt(currency.size())), -// random.nextInt(200), -// currency.get(random.nextInt(currency.size())), -// leagues.get(random.nextInt(leagues.size())), -// offer.get(random.nextInt(offer.size())) -// )); -// MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); -// MercuryStoreCore.soundSubject.onNext(SoundType.MESSAGE); -// -// Timer joinedTimer = new Timer(1000,null); -// joinedTimer.addActionListener(e1 -> { -// MercuryStoreCore.playerJoinSubject.onNext(nickname); -// joinedTimer.stop(); -// }); -// joinedTimer.start(); -// -// Timer leftTimer = new Timer(2000,null); -// leftTimer.addActionListener(e1 -> { -// MercuryStoreCore.playerLeftSubject.onNext(nickname); -// leftTimer.stop(); -// }); -// leftTimer.start(); -// } -// }); -// testPanel.add(button2,buttonColumn); -// buttonColumn.gridy++; -// JLabel textLabel2 = componentsFactory.getTextLabel("Test accessibility status"); -// testPanel.add(textLabel2,titleColumn); -// titleColumn.gridy++; - JButton outItemButton = componentsFactory.getBorderedButton("Click"); - outItemButton.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - NotificationDescriptor notificationDescriptor = parser.parse(String.format(poeTradeTemplate, - nickNames.get(random.nextInt(nickNames.size())), - items.get(random.nextInt(items.size())), - random.nextInt(200), - currency.get(random.nextInt(currency.size())), - leagues.get(random.nextInt(leagues.size())), - random.nextInt(30), - random.nextInt(12) + 1, - random.nextInt(12) + 1, - offer.get(random.nextInt(offer.size())) - )); - notificationDescriptor.setType(NotificationType.OUT_ITEM_MESSAGE); - MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); - } + outItemButton.addActionListener(action -> { + MercuryStoreCore.newNotificationSubject.onNext(this.testEngine.getRandomItemOutMessage()); }); testPanel.add(outItemButton,buttonColumn); buttonColumn.gridy++; @@ -279,21 +75,8 @@ public void mousePressed(MouseEvent e) { titleColumn.gridy++; JButton outCurrencyButton = componentsFactory.getBorderedButton("Click"); - outCurrencyButton.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - NotificationDescriptor notificationDescriptor = parser.parse(String.format(currencyTemplate, - nickNames.get(random.nextInt(nickNames.size())), - random.nextInt(200) + 1, - currency.get(random.nextInt(currency.size())), - random.nextInt(200) + 1, - currency.get(random.nextInt(currency.size())), - leagues.get(random.nextInt(leagues.size())), - offer.get(random.nextInt(offer.size())) - )); - notificationDescriptor.setType(NotificationType.OUT_CURRENCY_MESSAGE); - MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); - } + outCurrencyButton.addActionListener(action -> { + MercuryStoreCore.newNotificationSubject.onNext(this.testEngine.getRandomCurrencyOutMessage()); }); testPanel.add(outCurrencyButton,buttonColumn); buttonColumn.gridy++; @@ -303,25 +86,8 @@ public void mousePressed(MouseEvent e) { testPanel.setBackground(AppThemeColor.TRANSPARENT); JButton chatScannerButton = componentsFactory.getBorderedButton("Click"); - chatScannerButton.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - NotificationDescriptor notificationDescriptor = parser.parse(String.format(poeTradeTemplate, - nickNames.get(random.nextInt(nickNames.size())), - items.get(random.nextInt(items.size())), - random.nextInt(200), - currency.get(random.nextInt(currency.size())), - leagues.get(random.nextInt(leagues.size())), - random.nextInt(30), - random.nextInt(12) + 1, - random.nextInt(12) + 1, - offer.get(random.nextInt(offer.size())) - )); - String source = StringUtils.substringAfter(notificationDescriptor.getSourceString(), ": "); - notificationDescriptor.setSourceString(messageBuilder.build(source)); - notificationDescriptor.setType(NotificationType.SCANNER_MESSAGE); - MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); - } + chatScannerButton.addActionListener(action -> { + MercuryStoreCore.newNotificationSubject.onNext(this.testEngine.getRandomScannerMessage()); }); testPanel.add(chatScannerButton,buttonColumn); buttonColumn.gridy++; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestEngine.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestEngine.java new file mode 100644 index 00000000..636901f5 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestEngine.java @@ -0,0 +1,204 @@ +package com.mercury.platform.ui.frame.titled; + + +import com.mercury.platform.shared.MessageParser; +import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationType; +import com.mercury.platform.ui.components.panel.chat.HtmlMessageBuilder; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Random; + +public class TestEngine { + private List items = new ArrayList<>(); + private List currency= new ArrayList<>(); + private List nickNames= new ArrayList<>(); + private List offer= new ArrayList<>(); + private List leagues= new ArrayList<>(); + private HtmlMessageBuilder messageBuilder = new HtmlMessageBuilder(); + private MessageParser parser = new MessageParser(); + private Random random = new Random(); + private String poeTradeTemplate = "%s: Hi, I would like to buy your %s listed for %d %s in %s (stash tab \"%d\"; position: left %d, top %d) %s"; + private String currencyTemplate = "%s: Hi, I'd like to buy your %d %s for my %d %s in %s. %s"; + + public TestEngine() { + this.messageBuilder.setChunkStrings(Arrays.asList("Hi","buy","listed","like")); + + items.add("Wondertrap Velvet Slippers"); + items.add("Rain of Arrows"); + items.add("Dreadarc Cleaver"); + items.add("Three-step Assault Shagreen Boots"); + items.add("Thunderous Skies"); + items.add("Honourhome Soldier Helmet"); + items.add("Pain Breaker Blood Sceptre"); + items.add("Freeze Mine"); + items.add("The Lunaris Priestess"); + + currency.add("alteration"); + currency.add("alchemy"); + currency.add("apprentice sextant"); + currency.add("divine"); + currency.add("exalted"); + currency.add("blessed"); + currency.add("esh's breachstone"); + currency.add("eber's"); + currency.add("regal"); + currency.add("armourer's"); + currency.add("augmentation"); + currency.add("bauble"); + currency.add("blessing of chayula"); + currency.add("blessing of esh"); + currency.add("blessing of tul"); + currency.add("blessing of uul-netol"); + currency.add("blessing of xoph"); + currency.add("chance"); + currency.add("chaos"); + currency.add("chayula's breachstone"); + currency.add("chimera"); + currency.add("chisel"); + currency.add("chrome"); + currency.add("coin"); + currency.add("dawn"); + currency.add("dusk"); + currency.add("eternal"); + currency.add("fusing"); + currency.add("gcp"); + currency.add("grief"); + currency.add("hope"); + currency.add("hydra"); + currency.add("ignorance"); + currency.add("inya's"); + currency.add("jeweller's"); + currency.add("journeyman sextant"); + currency.add("master sextant"); + currency.add("midnight"); + currency.add("minotaur"); + currency.add("mirror"); + currency.add("mortal set"); + currency.add("noon"); + currency.add("offering"); + currency.add("pale court"); + currency.add("phoenix"); + currency.add("portal"); + currency.add("rage"); + currency.add("regret"); + currency.add("sacrifice set"); + currency.add("scouring"); + currency.add("shaper set"); + currency.add("silver"); + currency.add("splinter of chayula"); + currency.add("splinter of esh"); + currency.add("splinter of tul"); + currency.add("splinter of uul-netol"); + currency.add("splinter of xoph"); + currency.add("transmutation"); + currency.add("tul's breachstone"); + currency.add("uul-netol's breachstone"); + currency.add("vaal"); + currency.add("volkuur's"); + currency.add("wisdom"); + currency.add("xoph's breachstone"); + currency.add("yriel's"); + + nickNames.add("Example1"); + nickNames.add("Example2"); + nickNames.add("Example3"); + nickNames.add("Example4"); + nickNames.add("Example5"); + nickNames.add("Example6"); + + offer.add("offer"); + offer.add(" "); + offer.add(""); + offer.add(" "); + offer.add("offer offer offer offer offer"); + offer.add("offer offer offer offer offer offer offer offer"); + offer.add("offer offer"); + offer.add("offer"); + + leagues.add("Standard"); + leagues.add("Hardcore Legacy"); + leagues.add("Legacy"); + leagues.add("Hardcore"); + leagues.add("Beta Standard"); + leagues.add("Beta Hardcore"); + leagues.add("1 Week Legacy (JRE055)"); + leagues.add("1 Week Legacy HC (JRE055)"); + } + public NotificationDescriptor getRandomItemIncMessage(){ + NotificationDescriptor notificationDescriptor = parser.parse(String.format(poeTradeTemplate, + nickNames.get(random.nextInt(nickNames.size())), + items.get(random.nextInt(items.size())), + random.nextInt(200), + currency.get(random.nextInt(currency.size())), + leagues.get(random.nextInt(leagues.size())), + random.nextInt(30), + random.nextInt(12) + 1, + random.nextInt(12) + 1, + offer.get(random.nextInt(offer.size())) + )); + return notificationDescriptor; + } + public NotificationDescriptor getRandomCurrencyIncMessage(){ + NotificationDescriptor notificationDescriptor = parser.parse(String.format(currencyTemplate, + nickNames.get(random.nextInt(nickNames.size())), + random.nextInt(200) + 1, + currency.get(random.nextInt(currency.size())), + random.nextInt(200) + 1, + currency.get(random.nextInt(currency.size())), + leagues.get(random.nextInt(leagues.size())), + offer.get(random.nextInt(offer.size())) + )); + return notificationDescriptor; + } + + public NotificationDescriptor getRandomItemOutMessage(){ + NotificationDescriptor notificationDescriptor = parser.parse(String.format(poeTradeTemplate, + nickNames.get(random.nextInt(nickNames.size())), + items.get(random.nextInt(items.size())), + random.nextInt(200), + currency.get(random.nextInt(currency.size())), + leagues.get(random.nextInt(leagues.size())), + random.nextInt(30), + random.nextInt(12) + 1, + random.nextInt(12) + 1, + offer.get(random.nextInt(offer.size())) + )); + notificationDescriptor.setType(NotificationType.OUT_ITEM_MESSAGE); + return notificationDescriptor; + } + public NotificationDescriptor getRandomCurrencyOutMessage(){ + NotificationDescriptor notificationDescriptor = parser.parse(String.format(currencyTemplate, + nickNames.get(random.nextInt(nickNames.size())), + random.nextInt(200) + 1, + currency.get(random.nextInt(currency.size())), + random.nextInt(200) + 1, + currency.get(random.nextInt(currency.size())), + leagues.get(random.nextInt(leagues.size())), + offer.get(random.nextInt(offer.size())) + )); + notificationDescriptor.setType(NotificationType.OUT_CURRENCY_MESSAGE); + return notificationDescriptor; + } + public NotificationDescriptor getRandomScannerMessage(){ + NotificationDescriptor notificationDescriptor = parser.parse(String.format(poeTradeTemplate, + nickNames.get(random.nextInt(nickNames.size())), + items.get(random.nextInt(items.size())), + random.nextInt(200), + currency.get(random.nextInt(currency.size())), + leagues.get(random.nextInt(leagues.size())), + random.nextInt(30), + random.nextInt(12) + 1, + random.nextInt(12) + 1, + offer.get(random.nextInt(offer.size())) + )); + String source = StringUtils.substringAfter(notificationDescriptor.getSourceString(), ": "); + notificationDescriptor.setSourceString(messageBuilder.build(source)); + notificationDescriptor.setType(NotificationType.SCANNER_MESSAGE); + return notificationDescriptor; + } + +} From 9077f2d7c21c9aa87496ff4a954cfd4b215202a8 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sun, 20 Aug 2017 02:49:03 +0400 Subject: [PATCH 07/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 428c5b04..9fa12793 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Overseer is essentially "a customizable and nicely looking set of overlay timers   *Major feature:* **Notification**

- +

When you receive a trade related message this notification panel pops up. It contains all the information you need to make a decision. It offers a set of fully customizable "quick response buttons" - such as "Sold" / "No" / "Wait 3m" / etc - as well as buttons to invite, kick and trade with the person who made the offer. From d3f019e90abba3147620e752c2d6f647e3c204cd Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sun, 20 Aug 2017 02:56:51 +0400 Subject: [PATCH 08/17] Update README.md --- README.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/README.md b/README.md index 9fa12793..9b9cac79 100644 --- a/README.md +++ b/README.md @@ -61,15 +61,9 @@ If you've received multiple notifications before dismissing your current one, th

The box on the left - "Group" - will appear if "Pre-group limit" is exceeded (this limit is also customizable). All consecutive notifications will be grouped together to save screen space. Toggling this button will expand the whole group.

-

- -

- -

Notification Panel settings (unlocked mode)

-

- +

Response buttons are fully customizable

From 535c8816e261f83894da37d9ed69339fb4c744f0 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sun, 20 Aug 2017 03:00:18 +0400 Subject: [PATCH 09/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b9cac79..17834ada 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Overseer is essentially "a customizable and nicely looking set of overlay timers When you receive a trade related message this notification panel pops up. It contains all the information you need to make a decision. It offers a set of fully customizable "quick response buttons" - such as "Sold" / "No" / "Wait 3m" / etc - as well as buttons to invite, kick and trade with the person who made the offer.

- +

Multiple notifications

From ed0a20d9ad81074b033c512d7a4e4754e78ef721 Mon Sep 17 00:00:00 2001 From: Exslims Date: Sun, 20 Aug 2017 15:24:45 +0400 Subject: [PATCH 10/17] Notification panel rework, scanner refactoring and bug fixes --- .../core/utils/MessageFileHandler.java | 4 +- .../interceptor/PlainMessageInterceptor.java | 190 +++++ .../TradeIncMessagesInterceptor.java | 204 +++++ .../interceptor/TradeMessagesInterceptor.java | 102 --- .../shared/config/descriptor/HotKeyType.java | 3 +- .../message/PlainMessageDescriptor.java | 10 + .../shared/store/MercuryStoreCore.java | 4 + .../panel/chat/ChatFilterPanel.java | 138 --- .../panel/chat/HtmlMessageBuilder.java | 22 +- .../notification/HistoryMessagePanel.java | 7 - .../HistoryNotificationPanel.java | 5 +- .../panel/notification/InMessagePanel.java | 572 ------------- .../IncomingNotificationPanel.java | 15 +- .../panel/notification/MessagePanelStyle.java | 5 - .../ScannerNotificationPanel.java | 7 +- .../controller/IncomingPanelController.java | 3 - .../NotificationIncomingController.java | 6 - .../NotificationScannerController.java | 16 +- .../controller/stub/IncStubController.java | 6 - .../factory/NotificationPanelProvider.java | 3 +- .../factory/ScannerPanelProvider.java | 5 +- .../page/NotificationSettingsPagePanel.java | 52 +- .../page/TaskBarSettingsPagePanel.java | 13 +- .../taskbar/MercuryTaskBarController.java | 5 +- .../frame/AbstractScalableComponentFrame.java | 1 - .../{container => }/NotificationFrame.java | 114 ++- .../frame/movable/container/MessageFrame.java | 783 ------------------ .../movable/container/MessagesContainer.java | 9 - .../titled/AbstractTitledComponentFrame.java | 5 +- .../{chat => }/ChatFilterSettingsFrame.java | 169 ++-- .../titled/{container => }/HistoryFrame.java | 10 +- .../ui/frame/titled/TestCasesFrame.java | 2 +- .../platform/ui/frame/titled/TestEngine.java | 11 +- .../ui/frame/titled/chat/ChatFilterFrame.java | 267 ------ .../titled/chat/ChatSettingsCallback.java | 6 - .../titled/container/HistoryContainer.java | 7 - .../platform/ui/manager/FramesManager.java | 8 +- .../platform/ui/misc/MercuryStoreUI.java | 2 - 38 files changed, 670 insertions(+), 2121 deletions(-) create mode 100644 app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlainMessageInterceptor.java create mode 100644 app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeIncMessagesInterceptor.java delete mode 100644 app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeMessagesInterceptor.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/entity/message/PlainMessageDescriptor.java delete mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/chat/ChatFilterPanel.java delete mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/HistoryMessagePanel.java delete mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/InMessagePanel.java delete mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/MessagePanelStyle.java rename app-ui/src/main/java/com/mercury/platform/ui/frame/movable/{container => }/NotificationFrame.java (69%) delete mode 100644 app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java delete mode 100644 app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessagesContainer.java rename app-ui/src/main/java/com/mercury/platform/ui/frame/titled/{chat => }/ChatFilterSettingsFrame.java (53%) rename app-ui/src/main/java/com/mercury/platform/ui/frame/titled/{container => }/HistoryFrame.java (92%) delete mode 100644 app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterFrame.java delete mode 100644 app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatSettingsCallback.java delete mode 100644 app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryContainer.java diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/MessageFileHandler.java b/app-core/src/main/java/com/mercury/platform/core/utils/MessageFileHandler.java index 13e59383..4f4357a3 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/MessageFileHandler.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/MessageFileHandler.java @@ -10,7 +10,6 @@ import java.io.File; import java.io.RandomAccessFile; import java.util.*; -import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -27,7 +26,8 @@ public MessageFileHandler(String logFilePath) { this.logFilePath = logFilePath; this.datePattern = Pattern.compile(dateRGPattern); - this.interceptors.add(new TradeMessagesInterceptor()); + this.interceptors.add(new TradeIncMessagesInterceptor()); + this.interceptors.add(new PlainMessageInterceptor()); this.interceptors.add(new PlayerJoinInterceptor()); this.interceptors.add(new PlayerLeftInterceptor()); diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlainMessageInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlainMessageInterceptor.java new file mode 100644 index 00000000..9d0d51af --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlainMessageInterceptor.java @@ -0,0 +1,190 @@ +package com.mercury.platform.core.utils.interceptor; + + +import com.mercury.platform.core.utils.interceptor.filter.MessageFilter; +import com.mercury.platform.shared.entity.message.PlainMessageDescriptor; +import com.mercury.platform.shared.store.MercuryStoreCore; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class PlainMessageInterceptor extends MessageInterceptor{ + private List clients = new ArrayList<>(); + + public PlainMessageInterceptor() { + this.clients.add(new EngIncLocalizationMatcher()); + this.clients.add(new EngOutLocalizationMatcher()); + this.clients.add(new RuIncLocalizationMatcher()); + this.clients.add(new RuOutLocalizationMatcher()); + this.clients.add(new ArabicInLocalizationMatcher()); + this.clients.add(new ArabicOutLocalizationMatcher()); + this.clients.add(new BZIncLocalizationMatcher()); + this.clients.add(new BZOutLocalizationMatcher()); + } + + @Override + protected void process(String message) { + LocalizationMatcher localizationMatcher = this.clients.stream() + .filter(matcher -> matcher.isSuitableFor(message)) + .findAny().orElse(null); + if(localizationMatcher != null){ + localizationMatcher.processMessage(message); + } + } + + @Override + protected MessageFilter getFilter() { + return message -> + this.clients.stream() + .filter(matcher -> matcher.isSuitableFor(message)) + .findAny().orElse(null) != null; + } + private abstract class LocalizationMatcher { + public abstract boolean isSuitableFor(String message); + public abstract boolean isIncoming(); + public abstract String trimString(String message); + public void processMessage(String message){ + Pattern pattern = Pattern.compile("^(\\<.+?\\>)?\\s?(.+?):(.+)$"); + Matcher matcher = pattern.matcher(this.trimString(message)); + if(matcher.find()){ + PlainMessageDescriptor descriptor = new PlainMessageDescriptor(); + descriptor.setNickName(matcher.group(2)); + descriptor.setMessage(matcher.group(3)); + descriptor.setIncoming(this.isIncoming()); + MercuryStoreCore.plainMessageSubject.onNext(descriptor); + } + } + } + private class EngIncLocalizationMatcher extends LocalizationMatcher { + @Override + public boolean isSuitableFor(String message) { + return message.contains("@From"); + } + + @Override + public boolean isIncoming() { + return true; + } + + @Override + public String trimString(String message) { + return StringUtils.substringAfter(message,"@From "); + } + } + private class EngOutLocalizationMatcher extends LocalizationMatcher{ + @Override + public boolean isSuitableFor(String message) { + return message.contains("@To"); + } + + @Override + public boolean isIncoming() { + return false; + } + + @Override + public String trimString(String message) { + return StringUtils.substringAfter(message,"@To "); + } + } + private class RuIncLocalizationMatcher extends LocalizationMatcher{ + @Override + public boolean isSuitableFor(String message) { + return message.contains("@От кого"); + } + + @Override + public boolean isIncoming() { + return true; + } + + @Override + public String trimString(String message) { + return StringUtils.substringAfter(message,"@От кого "); + } + } + private class RuOutLocalizationMatcher extends LocalizationMatcher{ + @Override + public boolean isSuitableFor(String message) { + return message.contains("@Кому"); + } + + @Override + public boolean isIncoming() { + return false; + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@Кому "); + } + + } + private class ArabicInLocalizationMatcher extends LocalizationMatcher{ + @Override + public boolean isSuitableFor(String message) { + return message.contains("@จาก"); + } + + @Override + public boolean isIncoming() { + return true; + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@จาก"); + } + } + private class ArabicOutLocalizationMatcher extends LocalizationMatcher{ + @Override + public boolean isSuitableFor(String message) { + return message.contains("@ถึง"); + } + + @Override + public boolean isIncoming() { + return false; + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@ถึง"); + } + } + private class BZIncLocalizationMatcher extends LocalizationMatcher{ + @Override + public boolean isSuitableFor(String message) { + return message.contains("@De"); + } + + @Override + public boolean isIncoming() { + return true; + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@De"); + } + } + private class BZOutLocalizationMatcher extends LocalizationMatcher{ + @Override + public boolean isSuitableFor(String message) { + return message.contains("@Para"); + } + + @Override + public boolean isIncoming() { + return false; + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@Para"); + } + } +} diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeIncMessagesInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeIncMessagesInterceptor.java new file mode 100644 index 00000000..200f9b3f --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeIncMessagesInterceptor.java @@ -0,0 +1,204 @@ +package com.mercury.platform.core.utils.interceptor; + +import com.mercury.platform.core.misc.SoundType; +import com.mercury.platform.core.utils.interceptor.filter.MessageFilter; +import com.mercury.platform.shared.MessageParser; +import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.configration.PlainConfigurationService; +import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; +import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationType; +import com.mercury.platform.shared.store.MercuryStoreCore; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +public class TradeIncMessagesInterceptor extends MessageInterceptor { + private MessageParser messageParser = new MessageParser(); + private PlainConfigurationService config; + private List clients = new ArrayList<>(); + + public TradeIncMessagesInterceptor() { + this.config = Configuration.get().notificationConfiguration(); + this.clients.add(new EngIncLocalizationMatcher()); + this.clients.add(new EngOutLocalizationMatcher()); + this.clients.add(new RuIncLocalizationMatcher()); + this.clients.add(new RuOutLocalizationMatcher()); + this.clients.add(new ArabicInLocalizationMatcher()); + this.clients.add(new ArabicOutLocalizationMatcher()); + this.clients.add(new BZIncLocalizationMatcher()); + this.clients.add(new BZOutLocalizationMatcher()); + } + + @Override + protected void process(String message) { + if(this.config.get().isIncNotificationEnable()) { + LocalizationMatcher localizationMatcher = this.clients.stream() + .filter(matcher -> matcher.isSuitableFor(message)) + .findAny().orElse(null); + if(localizationMatcher != null){ + localizationMatcher.processMessage(message); + } + } + } + + @Override + protected MessageFilter getFilter() { + return message -> + this.clients.stream() + .filter(matcher -> matcher.isSuitableFor(message)) + .findAny().orElse(null) != null; + } + private abstract class LocalizationMatcher { + public boolean isSuitableFor(String message){ + return message.contains("Hi, I would like") || + message.contains("Hi, I'd like") || + (message.contains("wtb") && message.contains("(stash")); + } + public abstract String trimString(String src); + public NotificationDescriptor getDescriptor(String message){ + return messageParser.parse(this.trimString(message)); + } + public void processMessage(String message){ + NotificationDescriptor notificationDescriptor = this.getDescriptor(message); + if (notificationDescriptor != null) { + MercuryStoreCore.soundSubject.onNext(SoundType.MESSAGE); + MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); + } + } + } + private class EngIncLocalizationMatcher extends LocalizationMatcher { + @Override + public boolean isSuitableFor(String message) { + return message.contains("@From") && super.isSuitableFor(message); + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@From"); + } + } + private class EngOutLocalizationMatcher extends LocalizationMatcher{ + @Override + public boolean isSuitableFor(String message) { + return message.contains("@To") && super.isSuitableFor(message); + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@To"); + } + + @Override + public NotificationDescriptor getDescriptor(String message) { + NotificationDescriptor descriptor = messageParser.parse(this.trimString(message)); + if(descriptor instanceof ItemTradeNotificationDescriptor){ + descriptor.setType(NotificationType.OUT_ITEM_MESSAGE); + }else { + descriptor.setType(NotificationType.OUT_CURRENCY_MESSAGE); + } + return descriptor; + } + } + private class RuIncLocalizationMatcher extends LocalizationMatcher{ + @Override + public boolean isSuitableFor(String message) { + return message.contains("@От кого") && super.isSuitableFor(message); + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@От кого"); + } + } + private class RuOutLocalizationMatcher extends LocalizationMatcher{ + @Override + public boolean isSuitableFor(String message) { + return message.contains("@Кому") && super.isSuitableFor(message); + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@Кому"); + } + + @Override + public NotificationDescriptor getDescriptor(String message) { + NotificationDescriptor descriptor = messageParser.parse(this.trimString(message)); + if(descriptor instanceof ItemTradeNotificationDescriptor){ + descriptor.setType(NotificationType.OUT_ITEM_MESSAGE); + }else { + descriptor.setType(NotificationType.OUT_CURRENCY_MESSAGE); + } + return descriptor; + } + } + private class ArabicInLocalizationMatcher extends LocalizationMatcher{ + @Override + public boolean isSuitableFor(String message) { + return message.contains("@จาก") && super.isSuitableFor(message); + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@จาก"); + } + } + private class ArabicOutLocalizationMatcher extends LocalizationMatcher{ + @Override + public boolean isSuitableFor(String message) { + return message.contains("@ถึง") && super.isSuitableFor(message); + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@ถึง"); + } + + @Override + public NotificationDescriptor getDescriptor(String message) { + NotificationDescriptor descriptor = messageParser.parse(this.trimString(message)); + if(descriptor instanceof ItemTradeNotificationDescriptor){ + descriptor.setType(NotificationType.OUT_ITEM_MESSAGE); + }else { + descriptor.setType(NotificationType.OUT_CURRENCY_MESSAGE); + } + return descriptor; + } + } + private class BZIncLocalizationMatcher extends LocalizationMatcher{ + @Override + public boolean isSuitableFor(String message) { + return message.contains("@De") && super.isSuitableFor(message); + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@De"); + } + } + private class BZOutLocalizationMatcher extends LocalizationMatcher{ + @Override + public boolean isSuitableFor(String message) { + return message.contains("@Para") && super.isSuitableFor(message); + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@Para"); + } + + @Override + public NotificationDescriptor getDescriptor(String message) { + NotificationDescriptor descriptor = messageParser.parse(this.trimString(message)); + if(descriptor instanceof ItemTradeNotificationDescriptor){ + descriptor.setType(NotificationType.OUT_ITEM_MESSAGE); + }else { + descriptor.setType(NotificationType.OUT_CURRENCY_MESSAGE); + } + return descriptor; + } + } +} diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeMessagesInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeMessagesInterceptor.java deleted file mode 100644 index 280e59d2..00000000 --- a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeMessagesInterceptor.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.mercury.platform.core.utils.interceptor; - -import com.mercury.platform.core.misc.SoundType; -import com.mercury.platform.core.utils.interceptor.filter.MessageFilter; -import com.mercury.platform.shared.MessageParser; -import com.mercury.platform.shared.config.Configuration; -import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; -import com.mercury.platform.shared.entity.message.NotificationDescriptor; -import com.mercury.platform.shared.store.MercuryStoreCore; -import org.apache.commons.lang3.StringUtils; - -import java.util.ArrayList; -import java.util.List; - -public class TradeMessagesInterceptor extends MessageInterceptor { - private MessageParser messageParser = new MessageParser(); - private PlainConfigurationService config; - private List clients = new ArrayList<>(); - - public TradeMessagesInterceptor() { - this.config = Configuration.get().notificationConfiguration(); - this.clients.add(new EngLocalizationMatcher()); - this.clients.add(new RuLocalizationMatcher()); - this.clients.add(new ArabicLocalizationMatcher()); - this.clients.add(new BZLocalizationMatcher()); - } - - @Override - protected void process(String message) { - if(this.config.get().isIncNotificationEnable()) { - LocalizationMatcher localizationMatcher = this.clients.stream() - .filter(matcher -> matcher.isSuitableFor(message)) - .findAny().orElse(null); - NotificationDescriptor notificationDescriptor = messageParser.parse(localizationMatcher.trimString(message)); - if (notificationDescriptor != null) { - MercuryStoreCore.soundSubject.onNext(SoundType.MESSAGE); - MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); - } - } - } - - @Override - protected MessageFilter getFilter() { - return message -> - this.clients.stream() - .filter(matcher -> matcher.isSuitableFor(message)) - .findAny().orElse(null) != null; - } - private abstract class LocalizationMatcher { - public boolean isSuitableFor(String message){ - return message.contains("Hi, I would like") || - message.contains("Hi, I'd like") || - (message.contains("wtb") && message.contains("(stash")); - } - public abstract String trimString(String src); - } - private class EngLocalizationMatcher extends LocalizationMatcher{ - @Override - public boolean isSuitableFor(String message) { - return message.contains("@From") && super.isSuitableFor(message); - } - - @Override - public String trimString(String src) { - return StringUtils.substringAfter(src, "@From"); - } - } - private class RuLocalizationMatcher extends LocalizationMatcher{ - @Override - public boolean isSuitableFor(String message) { - return message.contains("@От кого") && super.isSuitableFor(message); - } - - @Override - public String trimString(String src) { - return StringUtils.substringAfter(src, "@От кого"); - } - } - private class ArabicLocalizationMatcher extends LocalizationMatcher{ - @Override - public boolean isSuitableFor(String message) { - return message.contains("@จาก") && super.isSuitableFor(message); - } - - @Override - public String trimString(String src) { - return StringUtils.substringAfter(src, "@จาก"); - } - } - private class BZLocalizationMatcher extends LocalizationMatcher{ - @Override - public boolean isSuitableFor(String message) { - return message.contains("@De") && super.isSuitableFor(message); - } - - @Override - public String trimString(String src) { - return StringUtils.substringAfter(src, "@De"); - } - } -} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyType.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyType.java index a5c106f8..6fa12bb9 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyType.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyType.java @@ -1,10 +1,11 @@ package com.mercury.platform.shared.config.descriptor; +import java.io.Serializable; import java.util.Arrays; import java.util.stream.Collectors; -public enum HotKeyType { +public enum HotKeyType implements Serializable{ N_TRADE_PLAYER { @Override public String getIconPath() { diff --git a/app-core/src/main/java/com/mercury/platform/shared/entity/message/PlainMessageDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/entity/message/PlainMessageDescriptor.java new file mode 100644 index 00000000..2e2db477 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/message/PlainMessageDescriptor.java @@ -0,0 +1,10 @@ +package com.mercury.platform.shared.entity.message; + +import lombok.Data; + +@Data +public class PlainMessageDescriptor { + boolean incoming; + String nickName; + String message; +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java index 00a7ae85..e972e922 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java +++ b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java @@ -10,6 +10,7 @@ import com.mercury.platform.shared.entity.message.NotificationDescriptor; import com.mercury.platform.shared.config.descriptor.SoundDescriptor; import com.mercury.platform.shared.entity.message.NotificationDefinition; +import com.mercury.platform.shared.entity.message.PlainMessageDescriptor; import rx.subjects.PublishSubject; @@ -54,4 +55,7 @@ public class MercuryStoreCore { public static final PublishSubject newNotificationSubject = PublishSubject.create(); public static final PublishSubject removeNotificationSubject = PublishSubject.create(); + public static final PublishSubject plainMessageSubject = PublishSubject.create(); + public static final PublishSubject newScannerMessageSubject = PublishSubject.create(); + public static final PublishSubject removeScannerNotificationSubject = PublishSubject.create(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/chat/ChatFilterPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/chat/ChatFilterPanel.java deleted file mode 100644 index 9a83b5c0..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/chat/ChatFilterPanel.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.mercury.platform.ui.components.panel.chat; - -import com.mercury.platform.core.misc.SoundType; -import com.mercury.platform.shared.entity.message.NotificationDescriptor; -import com.mercury.platform.shared.entity.message.NotificationType; -import com.mercury.platform.shared.store.MercuryStoreCore; -import com.mercury.platform.ui.components.ComponentsFactory; -import com.mercury.platform.ui.components.fields.style.MercuryScrollBarUI; -import com.mercury.platform.ui.components.panel.VerticalScrollContainer; -import com.mercury.platform.ui.frame.titled.chat.ChatFilterFrame; -import com.mercury.platform.ui.misc.AppThemeColor; -import com.mercury.platform.ui.misc.MercuryStoreUI; -import net.jodah.expiringmap.ExpiringMap; -import org.apache.commons.lang3.StringUtils; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseWheelEvent; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -public class ChatFilterPanel extends JPanel { - private Map expiresMessages; - private ComponentsFactory componentsFactory; - private HtmlMessageBuilder messageBuilder; - - private boolean scrollToBottom = true; - private boolean soundEnable = false; - private JPanel container; - public ChatFilterPanel() { - this.componentsFactory = new ComponentsFactory(); - this.messageBuilder = new HtmlMessageBuilder(); - this.expiresMessages = ExpiringMap.builder() - .expiration(10, TimeUnit.SECONDS) - .build(); - container = new VerticalScrollContainer(); - container.setBackground(AppThemeColor.TRANSPARENT); - container.setLayout(new BoxLayout(container,BoxLayout.Y_AXIS)); - - this.setBackground(AppThemeColor.TRANSPARENT); - this.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createEmptyBorder(2,2,2,0), - BorderFactory.createLineBorder(AppThemeColor.HEADER) - )); - - JScrollPane scrollPane = new JScrollPane(container); - scrollPane.setBorder(null); - scrollPane.setBackground(AppThemeColor.FRAME); - scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); - scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - scrollPane.addMouseWheelListener(new MouseAdapter() { - @Override - public void mouseWheelMoved(MouseWheelEvent e) { - MercuryStoreUI.repaintSubject.onNext(ChatFilterFrame.class); - } - }); - scrollPane.addMouseWheelListener(e -> MercuryStoreUI.scrollToEndSubject.onNext(false)); - - container.getParent().setBackground(AppThemeColor.TRANSPARENT); - JScrollBar vBar = scrollPane.getVerticalScrollBar(); - vBar.setBackground(AppThemeColor.SLIDE_BG); - vBar.setUI(new MercuryScrollBarUI()); - vBar.setPreferredSize(new Dimension(15, Integer.MAX_VALUE)); - vBar.setUnitIncrement(3); - vBar.setBorder(BorderFactory.createEmptyBorder(1,1,1,1)); - vBar.addAdjustmentListener(e -> { - MercuryStoreUI.repaintSubject.onNext(ChatFilterFrame.class); - }); - - this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); - this.add(scrollPane); - } - public void addMessage(String stubMessage){ - String message = StringUtils.substringAfter(stubMessage,"] $"); - if(message.isEmpty()){ - message = StringUtils.substringAfter(stubMessage,"] #"); - } - - this.addMessageToFilter(message); - MercuryStoreUI.repaintSubject.onNext(ChatFilterFrame.class); - } - - public void scrollToBottom(boolean value) { - this.scrollToBottom = value; - if (scrollToBottom) { - container.scrollRectToVisible(new Rectangle(0, container.getHeight() - 1, 1, 1)); - } - } - - public void sound(boolean enable){ - this.soundEnable = enable; - } - - private void addMessageToFilter(String message) { - if(!message.isEmpty()){ - String nickname = StringUtils.substringBefore(message, ":"); - String messageContent = StringUtils.substringAfter(message, nickname + ":"); - nickname = StringUtils.deleteWhitespace(nickname); - if(nickname.contains(">")) { - nickname = StringUtils.substringAfterLast(nickname, ">"); - } - if(!expiresMessages.containsValue(message)){ - ChatMessagePanel chatMessagePanel = new ChatMessagePanel( - this.componentsFactory, - nickname, - messageBuilder.build(messageContent)); - NotificationDescriptor notificationDescriptor = new NotificationDescriptor(); - notificationDescriptor.setType(NotificationType.SCANNER_MESSAGE); - notificationDescriptor.setSourceString(messageBuilder.build(messageContent)); - notificationDescriptor.setWhisperNickname(nickname); - MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); - container.add(chatMessagePanel); - trimContainer(); - expiresMessages.put(nickname,message); - MercuryStoreUI.packSubject.onNext(ChatFilterFrame.class); - if(soundEnable){ - MercuryStoreCore.soundSubject.onNext(SoundType.CHAT_SCANNER); - } - if(scrollToBottom) { - container.scrollRectToVisible(new Rectangle(0, container.getHeight() - 1, 1, 1)); - } - } - } - } - private void trimContainer(){ - if(container.getComponentCount() > 30){ - container.remove(0); - } - } - public void clear(){ - container.removeAll(); - } - public void setNewChunks(List chunks){ - this.messageBuilder.setChunkStrings(chunks); - } -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/chat/HtmlMessageBuilder.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/chat/HtmlMessageBuilder.java index 2ab32b73..914e55ab 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/chat/HtmlMessageBuilder.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/chat/HtmlMessageBuilder.java @@ -1,12 +1,15 @@ package com.mercury.platform.ui.components.panel.chat; +import org.apache.commons.lang3.StringUtils; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class HtmlMessageBuilder { private List chunkStrings; + private String stubMessage; public HtmlMessageBuilder() { this.chunkStrings = new ArrayList<>(); @@ -18,18 +21,17 @@ public HtmlMessageBuilder() { * @return html equivalent */ public String build(String message) { - List resultStrs = new ArrayList<>(); - resultStrs.add(""); - String[] words = message.split("((?<=\\s)|(?=\\s)|(?<=\\.)|(?=\\.)|(?<=,)|(?<=\\?)|(?=\\?)|(?=,)|(?<=!)|(?=!)|(?<=/)|(?=/)|(?<=>)|(?=>))"); - Arrays.stream(words).forEach(word -> { - if(chunkStrings.stream().noneMatch(word::equalsIgnoreCase)){ - resultStrs.add(word); - }else { - resultStrs.add("" + word + ""); + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(""); + this.stubMessage = message; + this.chunkStrings.forEach(it -> { + if(StringUtils.containsIgnoreCase(message,it)){ + this.stubMessage = stubMessage.replaceAll("(?i)" + it,"" + it + ""); } }); - resultStrs.add(""); - return String.join("",resultStrs); + stringBuilder.append(this.stubMessage); + stringBuilder.append(""); + return stringBuilder.toString(); } public List getChunkStrings() { diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/HistoryMessagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/HistoryMessagePanel.java deleted file mode 100644 index 2dd9e901..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/HistoryMessagePanel.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.mercury.platform.ui.components.panel.notification; - -/** - * Created by Константин on 10.08.2017. - */ -public class HistoryMessagePanel { -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/HistoryNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/HistoryNotificationPanel.java index 2167caa1..97e817ae 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/HistoryNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/HistoryNotificationPanel.java @@ -1,13 +1,12 @@ package com.mercury.platform.ui.components.panel.notification; -import com.mercury.platform.shared.config.Configuration; -import com.mercury.platform.shared.config.descriptor.HotKeyType; import com.mercury.platform.shared.entity.message.NotificationDescriptor; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; import com.mercury.platform.ui.components.panel.notification.controller.HistoryController; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.TooltipConstants; +import org.apache.commons.lang3.StringUtils; import javax.swing.*; import java.awt.*; @@ -18,7 +17,7 @@ public class HistoryNotificationPanel extends NotificationPanel notificationService; - private IncomingPanelController controller; - private MessagePanelStyle style; - - private String whisper; - private JLabel whisperLabel; - private JButton tradeButton; - private JButton expandButton; - - @Getter - private NotificationDescriptor notificationDescriptor; - - private Timer timeAgo; - private String cachedTime = "0m"; - private JLabel timeLabel; - private Color cachedWhisperColor = AppThemeColor.TEXT_NICKNAME; - private JPanel whisperPanel; - private JPanel messagePanel; - private JPanel customButtonsPanel; - - private boolean expanded = false; - - private InMessagePanel(NotificationDescriptor notificationDescriptor, MessagePanelStyle style) { - super(new BorderLayout()); - this.notificationDescriptor = notificationDescriptor; - this.style = style; - this.whisper = notificationDescriptor.getWhisperNickname(); - this.notificationService = Configuration.get().notificationConfiguration(); - if(!style.equals(MessagePanelStyle.HISTORY)) { - this.initHotKeyListeners(); - } - } - public InMessagePanel(NotificationDescriptor notificationDescriptor, MessagePanelStyle style, IncomingPanelController controller, ComponentsFactory componentsFactory){ - this(notificationDescriptor,style); - this.componentsFactory = componentsFactory; - this.controller = controller; - onViewInit(); - } - - @Override - public void onViewInit() { - this.setBackground(AppThemeColor.FRAME); - this.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,1), - BorderFactory.createLineBorder(AppThemeColor.BORDER, 1))); - init(); - subscribe(); - setMaximumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); - setMinimumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); - } - private void init(){ - this.removeAll(); - this.whisperPanel = getWhisperPanel(); - this.messagePanel = getFormattedMessagePanel(); - this.customButtonsPanel = getButtonsPanel(); - whisperPanel.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createMatteBorder(1, 0, 1, 0, AppThemeColor.MSG_HEADER_BORDER), - BorderFactory.createEmptyBorder(-6, 0, -6, 0))); - if(style.equals(MessagePanelStyle.IN_DOWNWARDS) || - style.equals(MessagePanelStyle.HISTORY) || style.equals(MessagePanelStyle.RELOADED)) { - this.add(whisperPanel,BorderLayout.PAGE_START); - this.add(messagePanel,BorderLayout.CENTER); - this.add(customButtonsPanel,BorderLayout.PAGE_END); - }else { - this.add(customButtonsPanel,BorderLayout.PAGE_START); - this.add(messagePanel,BorderLayout.CENTER); - this.add(whisperPanel,BorderLayout.PAGE_END); - } - switch (style){ - case IN_DOWNWARDS:{ - messagePanel.setVisible(expanded); - customButtonsPanel.setVisible(expanded); - break; - } - case IN_UPWARDS:{ - messagePanel.setVisible(expanded); - customButtonsPanel.setVisible(expanded); - break; - } - case HISTORY:{ - messagePanel.setVisible(true); - customButtonsPanel.setVisible(false); - break; - } - case RELOADED:{ - messagePanel.setVisible(true); - customButtonsPanel.setVisible(true); - } - } - this.repaint(); - } - - private JPanel getFormattedMessagePanel(){ - JPanel labelsPanel = new JPanel(); - labelsPanel.setLayout(new BoxLayout(labelsPanel,BoxLayout.Y_AXIS)); - labelsPanel.setBackground(AppThemeColor.TRANSPARENT); - - JPanel tradePanel = new JPanel(new BorderLayout()); - tradePanel.setBackground(AppThemeColor.TRANSPARENT); - tradePanel.setBorder(BorderFactory.createEmptyBorder(-11,2,-11,0)); - if(notificationDescriptor instanceof ItemTradeNotificationDescriptor) { - JButton itemButton = componentsFactory.getButton( - FontStyle.BOLD, - AppThemeColor.BUTTON, - BorderFactory.createEmptyBorder(0,4,0,2), - ((ItemTradeNotificationDescriptor) notificationDescriptor).getItemName(), 17f); - - itemButton.setForeground(AppThemeColor.TEXT_IMPORTANT); - itemButton.setBackground(AppThemeColor.TRANSPARENT); - itemButton.setHorizontalAlignment(SwingConstants.LEFT); - itemButton.setContentAreaFilled(false); - itemButton.setRolloverEnabled(false); - itemButton.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - controller.showITH(); - } - - @Override - public void mouseReleased(MouseEvent e) { - MercuryStoreUI.repaintSubject.onNext(MessageFrame.class); - } - - @Override - public void mouseEntered(MouseEvent e) { - itemButton.setBorder(new CompoundBorder( - BorderFactory.createMatteBorder(0,1,0,1,AppThemeColor.BORDER), - BorderFactory.createEmptyBorder(0,3,0,1))); - MercuryStoreUI.repaintSubject.onNext(MessageFrame.class); - } - - @Override - public void mouseExited(MouseEvent e) { - itemButton.setBorder(BorderFactory.createEmptyBorder(0,4,0,2)); - MercuryStoreUI.repaintSubject.onNext(MessageFrame.class); - } - }); - tradePanel.add(itemButton,BorderLayout.CENTER); - }else if(notificationDescriptor instanceof CurrencyTradeNotificationDescriptor){ - JPanel fromPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); - fromPanel.setBackground(AppThemeColor.TRANSPARENT); - CurrencyTradeNotificationDescriptor message = (CurrencyTradeNotificationDescriptor) this.notificationDescriptor; - - String curCount = message.getCurrForSaleCount() % 1 == 0 ? - String.valueOf(message.getCurrForSaleCount().intValue()) : - String.valueOf(message.getCurrForSaleCount()); - JPanel curCountPanel = getCurrencyPanel(curCount); - JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + message.getCurrForSaleTitle() + ".png", 26); - JPanel curPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); - curPanel.setBackground(AppThemeColor.TRANSPARENT); - curPanel.add(curCountPanel); - curPanel.add(currencyLabel); - curPanel.add(getCurrencyRatePanel()); - fromPanel.add(curPanel); - tradePanel.add(fromPanel,BorderLayout.CENTER); - } - - JPanel forPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - forPanel.setBackground(AppThemeColor.TRANSPARENT); - - JLabel separator = componentsFactory.getTextLabel( - FontStyle.BOLD, - AppThemeColor.TEXT_MESSAGE, - TextAlignment.CENTER, - 18f, - "=>"); - separator.setHorizontalAlignment(SwingConstants.CENTER); - String curCount = " "; -// if(notificationDescriptor.getCurCount() > 0) { -// curCount = notificationDescriptor.getCurCount() % 1 == 0 ? -// String.valueOf(notificationDescriptor.getCurCount().intValue()) : -// String.valueOf(notificationDescriptor.getCurCount()); -// } -// String currency = notificationDescriptor.getCurrency(); -// if(!Objects.equals(curCount, "") && currency != null) { -// JPanel curCountPanel = getCurrencyPanel(curCount); -// JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + currency + ".png", 26); -// JPanel curPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); -// curPanel.setBackground(AppThemeColor.TRANSPARENT); -// curPanel.add(separator); -// curPanel.add(curCountPanel); -// curPanel.add(currencyLabel); -// forPanel.add(curPanel); -// } -// tradePanel.add(forPanel,BorderLayout.LINE_END); -// labelsPanel.add(tradePanel); -// String offer = notificationDescriptor.getOffer(); -// if(offer != null && offer.trim().length() > 0) { -// JLabel offerLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 17f, offer); -// offerLabel.setAlignmentY(Component.TOP_ALIGNMENT); -// labelsPanel.add(offerLabel); -// } - return labelsPanel; - } - private JPanel getCurrencyPanel(String curCount){ - JPanel curCountPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); - curCountPanel.setBackground(AppThemeColor.TRANSPARENT); - - JLabel priceLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER,17f,null, curCount); - curCountPanel.add(priceLabel); - curCountPanel.setPreferredSize(new Dimension((int)(componentsFactory.getScale() * 40),curCountPanel.getPreferredSize().height)); - return curCountPanel; - } - private JPanel getCurrencyRatePanel(){ - CurrencyTradeNotificationDescriptor message = (CurrencyTradeNotificationDescriptor) this.notificationDescriptor; - Double currForSaleCount = message.getCurrForSaleCount(); - Double curCount = message.getCurCount(); - double rate = curCount / currForSaleCount; - DecimalFormat decimalFormat = new DecimalFormat("#.####"); - JPanel ratePanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); - ratePanel.add(componentsFactory. - getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 18f, null,"(")); - JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + message.getCurrency() + ".png", 26); - currencyLabel.setBorder(null); - ratePanel.add(currencyLabel); - ratePanel.add(componentsFactory. - getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 18f, null,decimalFormat.format(rate))); - ratePanel.add(componentsFactory. - getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 18f, null,")")); - ratePanel.setBorder(BorderFactory.createEmptyBorder(-5,0,-5,0)); - return ratePanel; - } - private JPanel getWhisperPanel(){ - JPanel topPanel = new JPanel(new BorderLayout()); - topPanel.setBackground(AppThemeColor.MSG_HEADER); - - whisperLabel = componentsFactory.getTextLabel(FontStyle.BOLD,cachedWhisperColor, TextAlignment.LEFTOP,15f,getNicknameLabel()); - Border border = whisperLabel.getBorder(); - whisperLabel.setBorder(new CompoundBorder(border,new EmptyBorder(0,0,0,5))); - whisperLabel.setVerticalAlignment(SwingConstants.CENTER); - - JPanel nickNamePanel = componentsFactory.getTransparentPanel(new BorderLayout()); - if(style.equals(MessagePanelStyle.HISTORY)){ - nickNamePanel.add(whisperLabel,BorderLayout.CENTER); - }else { - JPanel buttonWrapper = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); - buttonWrapper.setBorder(BorderFactory.createEmptyBorder(2,0,0,0)); - buttonWrapper.add(getExpandButton()); - if(!style.equals(MessagePanelStyle.RELOADED)) { - nickNamePanel.add(buttonWrapper, BorderLayout.LINE_START); - } - nickNamePanel.add(whisperLabel,BorderLayout.CENTER); - } - topPanel.add(nickNamePanel,BorderLayout.CENTER); - - JPanel interactionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); - interactionPanel.setBorder(BorderFactory.createEmptyBorder(1,0,1,0)); - interactionPanel.setBackground(AppThemeColor.TRANSPARENT); - interactionPanel.add(getTimePanel()); - if(!style.equals(MessagePanelStyle.HISTORY)) { - JButton inviteButton = componentsFactory.getIconButton("app/invite.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.INVITE); - inviteButton.addActionListener(e -> controller.performInvite()); - JButton kickButton = componentsFactory.getIconButton("app/kick.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.KICK); - kickButton.addActionListener(e -> { - controller.performKick(); - if(this.notificationService.get().isDismissAfterKick() && !style.equals(MessagePanelStyle.RELOADED)){ - controller.performHide(); - } - }); - tradeButton = componentsFactory.getIconButton("app/trade.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.TRADE); - tradeButton.addActionListener(e -> controller.performOfferTrade()); - interactionPanel.add(inviteButton); - interactionPanel.add(kickButton); - interactionPanel.add(tradeButton); - interactionPanel.add(getStillInterestedButton()); - }else { - JButton reloadButton = componentsFactory.getIconButton("app/reload-history.png", 14, AppThemeColor.MSG_HEADER, "Restore"); - reloadButton.addActionListener(e -> controller.reloadMessage(this)); - interactionPanel.add(reloadButton); - } - JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); - openChatButton.setToolTipText("Open chat"); - openChatButton.addActionListener(e -> controller.performOpenChat()); - - interactionPanel.add(openChatButton); - JButton hideButton = componentsFactory.getIconButton("app/close.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.HIDE_PANEL); - hideButton.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - if(SwingUtilities.isLeftMouseButton(e)) { - controller.performHide(); - } - } - }); - if(!style.equals(MessagePanelStyle.HISTORY) && !style.equals(MessagePanelStyle.RELOADED)) { - interactionPanel.add(hideButton); - } - - topPanel.add(interactionPanel,BorderLayout.LINE_END); - return topPanel; - } - private String getNicknameLabel(){ - String whisperNickname = notificationDescriptor.getWhisperNickname(); - String result = whisperNickname + ":"; -// if(this.notificationService.get().isShowLeague()) { -// if (notificationDescriptor.getLeague() != null) { -// String league = notificationDescriptor.getLeague().trim(); -// if (league.length() == 0) { -// return result; -// } -// if (league.contains("Hardcore")) { -// if (league.equals("Hardcore")) { -// result = "HC " + result; -// } else { -// result = String.valueOf(league.split(" ")[1].charAt(0)) + "HC " + result; -// } -// } else if (league.contains("Standard")) { -// result = "Standard " + result; -// } else { -// result = String.valueOf(league.charAt(0)) + "SC " + result; -// } -// } -// } - return result; - } - private JPanel getTimePanel(){ - JPanel panel = new JPanel(); - panel.setBackground(AppThemeColor.TRANSPARENT); - timeLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MISC, TextAlignment.CENTER, 14, cachedTime); - if(timeAgo == null) { - timeAgo = new Timer(60000, new ActionListener() { - private int minute = 0; - private int hours = 0; - private int day = 0; - - @Override - public void actionPerformed(ActionEvent e) { - String labelText = ""; - minute++; - if (minute > 60) { - hours++; - minute = 0; - if (hours > 24) { - day++; - hours = 0; - } - } - if (hours == 0 && day == 0) { - labelText = minute + "m"; - } else if (hours > 0) { - labelText = hours + "h " + minute + "m"; - } else if (day > 0) { - labelText = day + "d " + hours + "h " + minute + "m"; - } - timeLabel.setText(labelText); - MercuryStoreUI.repaintSubject.onNext(MessageFrame.class); - } - }); - timeAgo.start(); - } - panel.add(timeLabel); - return panel; - } - public void disableTime(){ - if(timeAgo != null) { - timeAgo.stop(); - timeLabel.setText(""); - } - } - private JButton getExpandButton(){ - String iconPath = "app/default-mp.png"; - if(expanded){ - if(style.equals(MessagePanelStyle.IN_DOWNWARDS)){ - iconPath = "app/expand-mp.png"; - }else { - iconPath = "app/collapse-mp.png"; - } - } - expandButton = componentsFactory.getIconButton(iconPath, 18f, AppThemeColor.MSG_HEADER,""); - expandButton.setBorder(BorderFactory.createEmptyBorder(4,4,4,0)); - expandButton.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - if(SwingUtilities.isLeftMouseButton(e)) { - if (!messagePanel.isVisible()) { - expand(); - } else { - collapse(); - } - } - } - }); - return expandButton; - } - public void expand(){ - expanded = true; - if(style.equals(MessagePanelStyle.IN_DOWNWARDS)) { - expandButton.setIcon(componentsFactory.getIcon("app/expand-mp.png", 18f)); - messagePanel.setVisible(true); - customButtonsPanel.setVisible(true); - }else { - expandButton.setIcon(componentsFactory.getIcon("app/collapse-mp.png", 18f)); - messagePanel.setVisible(true); - customButtonsPanel.setVisible(true); - } - setMaximumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); - setMinimumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); - MercuryStoreUI.expandMessageSubject.onNext(true); - MercuryStoreUI.packSubject.onNext(MessageFrame.class); - } - public void collapse(){ - expanded = false; - if(style.equals(MessagePanelStyle.IN_DOWNWARDS)) { - expandButton.setIcon(componentsFactory.getIcon("app/default-mp.png", 18)); - messagePanel.setVisible(false); - customButtonsPanel.setVisible(false); - }else { - expandButton.setIcon(componentsFactory.getIcon("app/default-mp.png", 18)); - messagePanel.setVisible(false); - customButtonsPanel.setVisible(false); - } - setMaximumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); - setMinimumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); - MercuryStoreUI.collapseMessageSubject.onNext(true); - MercuryStoreUI.packSubject.onNext(MessageFrame.class); - } - - public boolean isExpanded() { - return expanded; - } - - public void setStyle(MessagePanelStyle style) { - this.style = style; - this.cachedTime = timeLabel.getText(); - init(); - setMaximumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); - setMinimumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); - } - - public MessagePanelStyle getStyle() { - return style; - } - private JPanel getButtonsPanel(){ - JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER)); - panel.setBackground(AppThemeColor.TRANSPARENT); - initResponseButtons(panel); - return panel; - } - @Override - public void subscribe() { - MercuryStoreCore.playerJoinSubject.subscribe(nickname -> { - if(nickname.equals(whisper)){ - whisperLabel.setForeground(AppThemeColor.TEXT_SUCCESS); - cachedWhisperColor = AppThemeColor.TEXT_SUCCESS; - if(!style.equals(MessagePanelStyle.HISTORY)) { - tradeButton.setEnabled(true); - } - MercuryStoreUI.repaintSubject.onNext(MessageFrame.class); - } - }); - MercuryStoreCore.playerLeftSubject.subscribe(nickname -> { - if (nickname.equals(whisper)) { - whisperLabel.setForeground(AppThemeColor.TEXT_DISABLE); - cachedWhisperColor = AppThemeColor.TEXT_DISABLE; - if (!style.equals(MessagePanelStyle.HISTORY)) { - tradeButton.setEnabled(false); - } - MercuryStoreUI.repaintSubject.onNext(MessageFrame.class); - } - }); - MercuryStoreCore.buttonsChangedSubject.subscribe(state -> { - this.customButtonsPanel.removeAll(); - initResponseButtons(customButtonsPanel); - MercuryStoreUI.repaintSubject.onNext(MessageFrame.class); - }); - } - private void initResponseButtons(JPanel panel){ - List buttonsConfig = this.notificationService.get().getButtons(); - Collections.sort(buttonsConfig); - buttonsConfig.forEach((buttonConfig)->{ - JButton button = componentsFactory.getBorderedButton(buttonConfig.getTitle(),15f); - button.addActionListener(e -> { - controller.performResponse(buttonConfig.getResponseText()); - if(buttonConfig.isClose() && !style.equals(MessagePanelStyle.RELOADED)){ - controller.performHide(); - } - }); - panel.add(button); - }); - } - private JButton getStillInterestedButton(){ - JButton stillIntButton = componentsFactory.getIconButton("app/still-interesting.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.STILL_INTERESTED); -// -// String curCount = notificationDescriptor.getCurCount() % 1 == 0 ? -// String.valueOf(notificationDescriptor.getCurCount().intValue()) : -// String.valueOf(notificationDescriptor.getCurCount()); -// String responseText = "Hi, are you still interested in "; -// if(notificationDescriptor instanceof ItemTradeNotificationDescriptor){ -// ItemTradeNotificationDescriptor message = (ItemTradeNotificationDescriptor) this.notificationDescriptor; -// if(message.getCurrency().equals("???")){ -// responseText += message.getItemName() + "?"; -// }else { -// responseText += message.getItemName() + -// " for " + curCount + " " + message.getCurrency() + "?"; -// } -// }else { -// CurrencyTradeNotificationDescriptor message = (CurrencyTradeNotificationDescriptor) this.notificationDescriptor; -// String curForSaleCount = message.getCurCount() % 1 == 0 ? -// String.valueOf(message.getCurrForSaleCount().intValue()) : -// String.valueOf(message.getCurrForSaleCount()); -// responseText += curForSaleCount + " " + message.getCurrForSaleTitle() + " for " + -// curCount + " " + message.getCurrency() + "?"; -// } -// String finalResponseText = responseText; // hate java -// stillIntButton.addActionListener( -// (action)->controller.performResponse(finalResponseText) -// ); - return stillIntButton; - } - - public void setComponentsFactory(ComponentsFactory componentsFactory) { - this.componentsFactory = componentsFactory; - } - - @Override - public void initHotKeyListeners() { -// KeyValueConfigurationService config = Configuration.get().hotKeysConfiguration(); -// MercuryStoreCore.hotKeySubject.subscribe(descriptor -> { -// HotKeyDescriptor hotKeyDescriptor = config.get(HotKeyType.N_CLOSE_NOTIFICATION.name()); -// if(descriptor.equals(hotKeyDescriptor)) { -// this.controller.performHide(); -// } -// }); - } -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java index f57bfa6b..3a8b599e 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java @@ -6,12 +6,15 @@ import com.mercury.platform.shared.config.configration.PlainConfigurationService; import com.mercury.platform.shared.config.descriptor.*; import com.mercury.platform.shared.entity.message.TradeNotificationDescriptor; +import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; import com.mercury.platform.ui.components.panel.VerticalScrollContainer; import com.mercury.platform.ui.components.panel.notification.controller.IncomingPanelController; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.TooltipConstants; +import org.apache.commons.lang3.StringUtils; +import rx.Subscription; import javax.swing.*; import javax.swing.Timer; @@ -28,6 +31,7 @@ public abstract class IncomingNotificationPanel { + if(this.data.getWhisperNickname().equals(message.getNickName())){ + this.chatContainer.add(this.componentsFactory.getTextLabel((message.isIncoming()? "From: ":"To: ") + message.getMessage())); + SwingUtilities.getWindowAncestor(IncomingNotificationPanel.this).pack(); + } + }); } @Override public void onViewDestroy() { super.onViewDestroy(); + this.chatSubscription.unsubscribe(); } private JPanel getChatPanel(){ this.chatContainer = new VerticalScrollContainer(); this.chatContainer.setLayout(new BoxLayout(this.chatContainer,BoxLayout.Y_AXIS)); this.chatContainer.setBackground(AppThemeColor.FRAME); - this.chatContainer.add(this.componentsFactory.getTextLabel(this.data.getSourceString())); - this.chatContainer.add(this.componentsFactory.getTextLabel(this.data.getSourceString())); - this.chatContainer.add(this.componentsFactory.getTextLabel(this.data.getSourceString())); + this.chatContainer.add(this.componentsFactory.getTextLabel("From:" + StringUtils.substringAfter(this.data.getSourceString(),this.data.getWhisperNickname() +":"))); return this.componentsFactory.wrapToSlide(this.chatContainer,AppThemeColor.FRAME); } protected JPanel getForPanel(){ diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/MessagePanelStyle.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/MessagePanelStyle.java deleted file mode 100644 index cdfaccf6..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/MessagePanelStyle.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.mercury.platform.ui.components.panel.notification; - -public enum MessagePanelStyle { - OUT_MESSAGE, IN_DOWNWARDS, IN_UPWARDS,HISTORY, RELOADED -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java index 9fa38652..7e79bd19 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java @@ -5,6 +5,7 @@ import com.mercury.platform.shared.config.configration.PlainConfigurationService; import com.mercury.platform.shared.config.descriptor.*; import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.shared.entity.message.PlainMessageDescriptor; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; import com.mercury.platform.ui.components.panel.notification.controller.ScannerPanelController; @@ -15,7 +16,7 @@ import java.awt.*; -public class ScannerNotificationPanel extends NotificationPanel { +public class ScannerNotificationPanel extends NotificationPanel { private PlainConfigurationService config; private PlainConfigurationService nConfig; private PlainConfigurationService hotKeysConfig; @@ -27,7 +28,7 @@ public void onViewInit() { this.nConfig = Configuration.get().notificationConfiguration(); this.hotKeysConfig = Configuration.get().hotKeysConfiguration(); this.add(this.getHeader(),BorderLayout.PAGE_START); - JLabel sourceLabel = this.componentsFactory.getTextLabel(this.data.getSourceString(),FontStyle.REGULAR,17f); + JLabel sourceLabel = this.componentsFactory.getTextLabel(this.data.getMessage(),FontStyle.REGULAR,17f); sourceLabel.setBackground(AppThemeColor.FRAME); sourceLabel.setHorizontalAlignment(SwingConstants.LEFT); sourceLabel.setVerticalAlignment(SwingConstants.TOP); @@ -40,7 +41,7 @@ private JPanel getHeader(){ root.setBackground(AppThemeColor.MSG_HEADER); JPanel nickNamePanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.MSG_HEADER); - JLabel nicknameLabel = this.componentsFactory.getTextLabel(FontStyle.BOLD,AppThemeColor.TEXT_NICKNAME, TextAlignment.LEFTOP,15f,this.data.getWhisperNickname()); + JLabel nicknameLabel = this.componentsFactory.getTextLabel(FontStyle.BOLD,AppThemeColor.TEXT_NICKNAME, TextAlignment.LEFTOP,15f,this.data.getNickName()); nicknameLabel.setBorder(BorderFactory.createEmptyBorder(0,5,0,5)); nickNamePanel.add(this.getExpandButton(),BorderLayout.LINE_START); nickNamePanel.add(nicknameLabel,BorderLayout.CENTER); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/IncomingPanelController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/IncomingPanelController.java index 4453ae06..0c1ba966 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/IncomingPanelController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/IncomingPanelController.java @@ -1,11 +1,8 @@ package com.mercury.platform.ui.components.panel.notification.controller; -import com.mercury.platform.ui.components.panel.notification.InMessagePanel; -import lombok.NonNull; public interface IncomingPanelController extends NotificationController{ void performInvite(); void performKick(); void showITH(); - void reloadMessage(@NonNull InMessagePanel panel); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationIncomingController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationIncomingController.java index 707efd97..8e094d7f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationIncomingController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationIncomingController.java @@ -3,7 +3,6 @@ import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; import com.mercury.platform.shared.entity.message.NotificationDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; -import com.mercury.platform.ui.components.panel.notification.InMessagePanel; import com.mercury.platform.ui.misc.MercuryStoreUI; import lombok.NonNull; import org.apache.logging.log4j.LogManager; @@ -62,11 +61,6 @@ public void showITH() { } } - @Override - public void reloadMessage(InMessagePanel panel) { - MercuryStoreUI.reloadMessageSubject.onNext(panel); - } - private void copyItemNameToClipboard(@NonNull String itemName){ Timer timer = new Timer(30, action -> { StringSelection selection = new StringSelection(itemName); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationScannerController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationScannerController.java index 695a95dc..050f6abc 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationScannerController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationScannerController.java @@ -1,21 +1,21 @@ package com.mercury.platform.ui.components.panel.notification.controller; -import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.shared.entity.message.PlainMessageDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; import javax.swing.*; public class NotificationScannerController implements ScannerPanelController { - private NotificationDescriptor notificationDescriptor; + private PlainMessageDescriptor notificationDescriptor; - public NotificationScannerController(NotificationDescriptor notificationDescriptor) { + public NotificationScannerController(PlainMessageDescriptor notificationDescriptor) { this.notificationDescriptor = notificationDescriptor; } @Override public void visitHideout() { - MercuryStoreCore.chatCommandSubject.onNext("/hideout " + notificationDescriptor.getWhisperNickname()); + MercuryStoreCore.chatCommandSubject.onNext("/hideout " + notificationDescriptor.getNickName()); } @Override @@ -25,7 +25,7 @@ public void performLeave(String nickName) { @Override public void performOfferTrade() { - MercuryStoreCore.chatCommandSubject.onNext("/tradewith " + notificationDescriptor.getWhisperNickname()); + MercuryStoreCore.chatCommandSubject.onNext("/tradewith " + notificationDescriptor.getNickName()); } @Override @@ -35,16 +35,16 @@ public void performHide() { @Override public void performOpenChat() { - MercuryStoreCore.openChatSubject.onNext(notificationDescriptor.getWhisperNickname()); + MercuryStoreCore.openChatSubject.onNext(notificationDescriptor.getNickName()); } @Override public void performResponse(String response) { - MercuryStoreCore.chatCommandSubject.onNext("@" + notificationDescriptor.getWhisperNickname() + " " + response); + MercuryStoreCore.chatCommandSubject.onNext("@" + notificationDescriptor.getNickName() + " " + response); } private void closeMessagePanel(){ Timer timer = new Timer(30, action -> { - MercuryStoreCore.removeNotificationSubject.onNext(notificationDescriptor); + MercuryStoreCore.removeScannerNotificationSubject.onNext(notificationDescriptor); }); timer.setRepeats(false); timer.start(); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/stub/IncStubController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/stub/IncStubController.java index ac786e23..070e2552 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/stub/IncStubController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/stub/IncStubController.java @@ -1,6 +1,5 @@ package com.mercury.platform.ui.components.panel.notification.controller.stub; -import com.mercury.platform.ui.components.panel.notification.InMessagePanel; import com.mercury.platform.ui.components.panel.notification.controller.IncomingPanelController; public class IncStubController implements IncomingPanelController { @@ -38,9 +37,4 @@ public void performKick() { public void showITH() { } - - @Override - public void reloadMessage(InMessagePanel panel) { - - } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelProvider.java index 64674189..71ef7fcd 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelProvider.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/NotificationPanelProvider.java @@ -6,7 +6,7 @@ import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.panel.notification.NotificationPanel; -public abstract class NotificationPanelProvider { +public abstract class NotificationPanelProvider { protected T data; protected C controller; protected ComponentsFactory componentsFactory; @@ -36,7 +36,6 @@ public NotificationPanel build() { panel.onViewInit(); this.componentsFactory = null; this.controller = null; - this.data = null; return panel; } protected abstract NotificationPanel getPanel(); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ScannerPanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ScannerPanelProvider.java index f562e0a1..7a1235df 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ScannerPanelProvider.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ScannerPanelProvider.java @@ -2,19 +2,20 @@ import com.mercury.platform.shared.entity.message.NotificationDescriptor; import com.mercury.platform.shared.entity.message.NotificationType; +import com.mercury.platform.shared.entity.message.PlainMessageDescriptor; import com.mercury.platform.ui.components.panel.notification.NotificationPanel; import com.mercury.platform.ui.components.panel.notification.ScannerNotificationPanel; import com.mercury.platform.ui.components.panel.notification.controller.NotificationScannerController; import com.mercury.platform.ui.components.panel.notification.controller.ScannerPanelController; -public class ScannerPanelProvider extends NotificationPanelProvider { +public class ScannerPanelProvider extends NotificationPanelProvider { @Override public boolean isSuitable(NotificationType type) { return type.equals(NotificationType.SCANNER_MESSAGE); } @Override - protected NotificationPanel getPanel() { + protected NotificationPanel getPanel() { ScannerNotificationPanel panel = new ScannerNotificationPanel(); panel.setController(new NotificationScannerController(this.data)); return panel; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java index e593a04a..7e460c7a 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java @@ -23,7 +23,9 @@ public class NotificationSettingsPagePanel extends SettingsPagePanel { private PlainConfigurationService hotKeyService; private PlainConfigurationService scannerService; private NotificationSettingsDescriptor generalSnapshot; - private HotKeysSettingsDescriptor hotKeySnapshot; + private List incHotKeySnapshot; + private List outHotKeySnapshot; + private List scannerHotKeySnapshot; private ScannerDescriptor scannerSnapshot; @Override @@ -33,7 +35,9 @@ public void onViewInit() { this.hotKeyService = Configuration.get().hotKeysConfiguration(); this.scannerService = Configuration.get().scannerConfiguration(); this.generalSnapshot = CloneHelper.cloneObject(notificationService.get()); - this.hotKeySnapshot = CloneHelper.cloneObject(hotKeyService.get()); + this.incHotKeySnapshot = CloneHelper.cloneObject(hotKeyService.get().getIncNHotKeysList()); + this.outHotKeySnapshot = CloneHelper.cloneObject(hotKeyService.get().getOutNHotKeysList()); + this.scannerHotKeySnapshot = CloneHelper.cloneObject(hotKeyService.get().getScannerNHotKeysList()); this.scannerSnapshot = CloneHelper.cloneObject(scannerService.get()); JPanel inPanel = this.adrComponentsFactory.getCounterPanel(this.getIncomingPanel(), "Incoming notification:", AppThemeColor.ADR_BG,true); inPanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); @@ -42,24 +46,30 @@ public void onViewInit() { JPanel scannerPanel = this.adrComponentsFactory.getCounterPanel(this.getChatScannerPanel(), "Chat scanner notification:", AppThemeColor.ADR_BG,true); scannerPanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); this.container.add(this.componentsFactory.wrapToSlide(this.getGeneralPanel())); - this.container.add(this.componentsFactory.wrapToSlide(inPanel)); - this.container.add(this.componentsFactory.wrapToSlide(outPanel)); - this.container.add(this.componentsFactory.wrapToSlide(scannerPanel)); + this.container.add(this.componentsFactory.wrapToSlide(inPanel,2,4,2,4)); + this.container.add(this.componentsFactory.wrapToSlide(outPanel,2,4,2,4)); + this.container.add(this.componentsFactory.wrapToSlide(scannerPanel,2,4,2,4)); } @Override public void onSave() { this.notificationService.set(CloneHelper.cloneObject(this.generalSnapshot)); - this.hotKeyService.set(CloneHelper.cloneObject(this.hotKeySnapshot)); + this.hotKeyService.get().setIncNHotKeysList(CloneHelper.cloneObject(this.incHotKeySnapshot)); + this.hotKeyService.get().setOutNHotKeysList(CloneHelper.cloneObject(this.outHotKeySnapshot)); + this.hotKeyService.get().setScannerNHotKeysList(CloneHelper.cloneObject(this.scannerHotKeySnapshot)); this.scannerService.set(CloneHelper.cloneObject(this.scannerSnapshot)); + + //protect + this.scannerSnapshot = CloneHelper.cloneObject(scannerService.get()); + MercuryStoreCore.buttonsChangedSubject.onNext(true); } @Override public void restore() { - this.generalSnapshot = CloneHelper.cloneObject(notificationService.get()); - this.hotKeySnapshot = CloneHelper.cloneObject(hotKeyService.get()); - this.scannerSnapshot = CloneHelper.cloneObject(scannerService.get()); + this.incHotKeySnapshot = CloneHelper.cloneObject(hotKeyService.get().getIncNHotKeysList()); + this.outHotKeySnapshot = CloneHelper.cloneObject(hotKeyService.get().getOutNHotKeysList()); + this.scannerHotKeySnapshot = CloneHelper.cloneObject(hotKeyService.get().getScannerNHotKeysList()); this.removeAll(); this.onViewInit(); } @@ -81,21 +91,21 @@ private JPanel getGeneralPanel(){ } } }); + JLabel limitLabel = this.componentsFactory.getTextLabel(String.valueOf(this.generalSnapshot.getLimitCount()), FontStyle.REGULAR, 16); + limitLabel.setPreferredSize(new Dimension(30,26)); JSlider limitSlider = componentsFactory.getSlider(2, 20, this.generalSnapshot.getLimitCount(),AppThemeColor.ADR_BG); limitSlider.addChangeListener(e -> { + limitLabel.setText(String.valueOf(limitSlider.getValue())); this.generalSnapshot.setLimitCount(limitSlider.getValue()); }); - JSlider unfoldSlider = componentsFactory.getSlider(0, 20, this.generalSnapshot.getUnfoldCount(),AppThemeColor.ADR_BG); - unfoldSlider.addChangeListener(e -> { - this.generalSnapshot.setUnfoldCount(unfoldSlider.getValue()); - }); flowDirectionPicker.setSelectedIndex(this.generalSnapshot.getFlowDirections().ordinal()); propertiesPanel.add(this.componentsFactory.getTextLabel("Flow direction:", FontStyle.REGULAR,16)); propertiesPanel.add(flowDirectionPicker); propertiesPanel.add(this.componentsFactory.getTextLabel("Pre-group limit:", FontStyle.REGULAR,16)); - propertiesPanel.add(limitSlider); - propertiesPanel.add(this.componentsFactory.getTextLabel("Unfold by default:", FontStyle.REGULAR,16)); - propertiesPanel.add(unfoldSlider); + JPanel limitPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.ADR_BG); + limitPanel.add(limitLabel,BorderLayout.LINE_START); + limitPanel.add(limitSlider,BorderLayout.CENTER); + propertiesPanel.add(limitPanel); propertiesPanel.add(this.componentsFactory.getTextLabel("Your nickname(for leave option):", FontStyle.REGULAR,16)); JTextField nickNameField = this.componentsFactory.getTextField(this.generalSnapshot.getPlayerNickname(), FontStyle.DEFAULT, 15f); nickNameField.addFocusListener(new FocusAdapter() { @@ -134,6 +144,7 @@ private JPanel getIncomingPanel() { root.add(this.wrapToCounter(this.componentsFactory.wrapToSlide(this.getResponseButtonsPanel(this.generalSnapshot.getButtons()),AppThemeColor.ADR_BG),"Response buttons:"),BorderLayout.CENTER); root.add(this.wrapToCounter(this.componentsFactory.wrapToSlide(this.getInNotificationHotKeysPanel(),AppThemeColor.ADR_BG),"Hotkeys"),BorderLayout.PAGE_END); + root.setVisible(false); return root; } private JPanel wrapToCounter(JPanel inner, String title){ @@ -235,7 +246,7 @@ public void focusLost(FocusEvent e) { private JPanel getInNotificationHotKeysPanel(){ JPanel root = this.componentsFactory.getJPanel(new GridLayout(0, 2, 4, 4),AppThemeColor.SETTINGS_BG); root.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_DEFAULT_BORDER)); - this.hotKeySnapshot.getIncNHotKeysList().forEach(pair -> { + this.incHotKeySnapshot.forEach(pair -> { root.add(this.componentsFactory.getIconLabel(pair.getType().getIconPath(), 18,SwingConstants.CENTER)); root.add(this.componentsFactory.wrapToSlide(new HotKeyPanel(pair.getDescriptor()),AppThemeColor.SETTINGS_BG,2,4,1,1)); @@ -245,17 +256,16 @@ private JPanel getInNotificationHotKeysPanel(){ private JPanel getOutNotificationHotKeysPanel(){ JPanel root = this.componentsFactory.getJPanel(new GridLayout(0, 2, 4, 4),AppThemeColor.SETTINGS_BG); root.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_DEFAULT_BORDER)); - this.hotKeySnapshot.getOutNHotKeysList().forEach(pair -> { + this.outHotKeySnapshot.forEach(pair -> { root.add(this.componentsFactory.getIconLabel(pair.getType().getIconPath(), 18,SwingConstants.CENTER)); root.add(this.componentsFactory.wrapToSlide(new HotKeyPanel(pair.getDescriptor()),AppThemeColor.SETTINGS_BG,2,4,1,1)); - }); return root; } private JPanel getScannerNotificationHotKeysPanel(){ JPanel root = this.componentsFactory.getJPanel(new GridLayout(0, 2, 4, 4),AppThemeColor.SETTINGS_BG); root.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_DEFAULT_BORDER)); - this.hotKeySnapshot.getScannerNHotKeysList().forEach(pair-> { + this.scannerHotKeySnapshot.forEach(pair-> { root.add(this.componentsFactory.getIconLabel(pair.getType().getIconPath(), 18,SwingConstants.CENTER)); root.add(this.componentsFactory.wrapToSlide(new HotKeyPanel(pair.getDescriptor()),AppThemeColor.SETTINGS_BG,2,4,1,1)); @@ -282,6 +292,7 @@ private JPanel getOutgoingPanel() { root.add(propertiesPanel,BorderLayout.PAGE_START); root.add(this.wrapToCounter(this.componentsFactory.wrapToSlide(this.getResponseButtonsPanel(this.generalSnapshot.getOutButtons()),AppThemeColor.ADR_BG),"Response buttons:"),BorderLayout.CENTER); root.add(this.wrapToCounter(this.componentsFactory.wrapToSlide(this.getOutNotificationHotKeysPanel(),AppThemeColor.ADR_BG),"Hotkeys:"),BorderLayout.PAGE_END); + root.setVisible(false); return root; } private JPanel getChatScannerPanel() { @@ -309,6 +320,7 @@ public void focusLost(FocusEvent e) { propertiesPanel.add(this.componentsFactory.wrapToSlide(quickResponseField,AppThemeColor.ADR_BG,0,0,0,4)); root.add(propertiesPanel,BorderLayout.PAGE_START); root.add(this.wrapToCounter(this.componentsFactory.wrapToSlide(this.getScannerNotificationHotKeysPanel(),AppThemeColor.ADR_BG),"Hotkeys"),BorderLayout.CENTER); + root.setVisible(false); return root; } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/TaskBarSettingsPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/TaskBarSettingsPagePanel.java index e75921de..87633d7d 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/TaskBarSettingsPagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/TaskBarSettingsPagePanel.java @@ -4,18 +4,21 @@ import com.mercury.platform.shared.config.Configuration; import com.mercury.platform.shared.config.configration.PlainConfigurationService; import com.mercury.platform.shared.config.descriptor.ApplicationDescriptor; +import com.mercury.platform.shared.config.descriptor.HotKeyPair; import com.mercury.platform.shared.config.descriptor.HotKeysSettingsDescriptor; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.misc.AppThemeColor; import javax.swing.*; import java.awt.*; +import java.util.*; +import java.util.List; public class TaskBarSettingsPagePanel extends SettingsPagePanel { private PlainConfigurationService applicationConfig; private PlainConfigurationService hotKeyService; - private HotKeysSettingsDescriptor hotKeySnapshot; + private List hotKeySnapshot; private ApplicationDescriptor applicationSnapshot; @Override @@ -24,7 +27,7 @@ public void onViewInit() { this.applicationConfig = Configuration.get().applicationConfiguration(); this.hotKeyService = Configuration.get().hotKeysConfiguration(); this.applicationSnapshot = CloneHelper.cloneObject(this.applicationConfig.get()); - this.hotKeySnapshot = CloneHelper.cloneObject(hotKeyService.get()); + this.hotKeySnapshot = CloneHelper.cloneObject(hotKeyService.get().getTaskBarNHotKeysList()); JPanel root = componentsFactory.getJPanel(new GridLayout(0,2),AppThemeColor.ADR_BG); root.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); @@ -43,7 +46,7 @@ public void onViewInit() { JPanel hotKeysPanel = this.componentsFactory.getJPanel(new GridLayout(0, 2, 4, 4),AppThemeColor.SETTINGS_BG); hotKeysPanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_DEFAULT_BORDER)); - this.hotKeySnapshot.getTaskBarNHotKeysList().forEach(pair -> { + this.hotKeySnapshot.forEach(pair -> { root.add(this.componentsFactory.getIconLabel(pair.getType().getIconPath(), 24,SwingConstants.CENTER)); root.add(this.componentsFactory.wrapToSlide(new HotKeyPanel(pair.getDescriptor()),AppThemeColor.SETTINGS_BG,2,4,1,1)); @@ -55,13 +58,13 @@ public void onViewInit() { @Override public void onSave() { this.applicationConfig.set(CloneHelper.cloneObject(this.applicationSnapshot)); - this.hotKeyService.set(CloneHelper.cloneObject(this.hotKeySnapshot)); + this.hotKeyService.get().setTaskBarNHotKeysList(CloneHelper.cloneObject(this.hotKeySnapshot)); } @Override public void restore() { this.applicationSnapshot = CloneHelper.cloneObject(this.applicationConfig.get()); - this.hotKeySnapshot = CloneHelper.cloneObject(this.hotKeyService.get()); + this.hotKeySnapshot = CloneHelper.cloneObject(this.hotKeyService.get().getTaskBarNHotKeysList()); this.removeAll(); this.onViewInit(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/MercuryTaskBarController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/MercuryTaskBarController.java index f1845316..e212e553 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/MercuryTaskBarController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/MercuryTaskBarController.java @@ -3,9 +3,8 @@ import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.frame.movable.ItemsGridFrame; import com.mercury.platform.ui.frame.movable.TaskBarFrame; -import com.mercury.platform.ui.frame.titled.chat.ChatFilterFrame; -import com.mercury.platform.ui.frame.titled.chat.ChatFilterSettingsFrame; -import com.mercury.platform.ui.frame.titled.container.HistoryFrame; +import com.mercury.platform.ui.frame.titled.ChatFilterSettingsFrame; +import com.mercury.platform.ui.frame.titled.HistoryFrame; import com.mercury.platform.ui.frame.titled.SettingsFrame; import com.mercury.platform.ui.manager.FramesManager; import com.mercury.platform.ui.misc.MercuryStoreUI; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractScalableComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractScalableComponentFrame.java index 1fa2c572..b9ce1a2b 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractScalableComponentFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractScalableComponentFrame.java @@ -40,7 +40,6 @@ protected void changeScale(float scale){ this.initDefaultView(); } public void setState(ScaleState state){ - System.out.println(this.mainContainer.getPreferredSize()); switch (state){ case DEFAULT:{ this.scaleState = ScaleState.DEFAULT; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/NotificationFrame.java similarity index 69% rename from app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java rename to app-ui/src/main/java/com/mercury/platform/ui/frame/movable/NotificationFrame.java index bd421761..df551794 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/NotificationFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/NotificationFrame.java @@ -1,4 +1,4 @@ -package com.mercury.platform.ui.frame.movable.container; +package com.mercury.platform.ui.frame.movable; import com.mercury.platform.core.ProdStarter; import com.mercury.platform.shared.FrameVisibleState; @@ -11,15 +11,12 @@ import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.components.panel.notification.InMessagePanel; import com.mercury.platform.ui.components.panel.notification.NotificationPanel; import com.mercury.platform.ui.components.panel.notification.ScannerNotificationPanel; -import com.mercury.platform.ui.components.panel.notification.controller.IncomingPanelController; import com.mercury.platform.ui.components.panel.notification.controller.stub.IncStubController; import com.mercury.platform.ui.components.panel.notification.controller.stub.OutStubController; import com.mercury.platform.ui.components.panel.notification.controller.stub.ScannerStubController; import com.mercury.platform.ui.components.panel.notification.factory.NotificationPanelFactory; -import com.mercury.platform.ui.frame.movable.AbstractMovableComponentFrame; import com.mercury.platform.ui.frame.titled.TestEngine; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.MercuryStoreUI; @@ -73,31 +70,29 @@ public void subscribe() { .setData(notification) .setComponentsFactory(this.componentsFactory) .build(); - this.notificationPanels.add(notificationPanel); - this.container.add(notificationPanel); - if(this.notificationPanels.size() > this.config.get().getLimitCount()){ - if(!this.expanded) { - notificationPanel.setPaintAlphaValue(1f); - notificationPanel.setVisible(false); - } - this.expandPanel.setVisible(true); - } - this.pack(); - this.repaint(); - if(this.config.get().getFlowDirections().equals(FlowDirections.UPWARDS) + this.addNotification(notificationPanel); + if(this.notificationPanels.size() > 1 + && this.config.get().getFlowDirections().equals(FlowDirections.UPWARDS) && !(notificationPanel instanceof ScannerNotificationPanel)){ this.setLocation(new Point(this.getLocation().x,this.getLocation().y - notificationPanel.getSize().height)); } - if(notificationPanel instanceof ScannerNotificationPanel){ - Timer packTimer = new Timer(5, action -> { - this.pack(); - if(this.config.get().getFlowDirections().equals(FlowDirections.UPWARDS)){ - this.setLocation(new Point(this.getLocation().x,this.getLocation().y - notificationPanel.getSize().height)); - } - }); - packTimer.setRepeats(false); - packTimer.start(); - } + }); + }); + MercuryStoreCore.newScannerMessageSubject.subscribe(message -> { + SwingUtilities.invokeLater(()-> { + NotificationPanel notificationPanel = this.providersFactory.getProviderFor(NotificationType.SCANNER_MESSAGE) + .setData(message) + .setComponentsFactory(this.componentsFactory) + .build(); + this.addNotification(notificationPanel); + Timer packTimer = new Timer(5, action -> { + this.pack(); + if(this.notificationPanels.size() > 1 && this.config.get().getFlowDirections().equals(FlowDirections.UPWARDS)){ + this.setLocation(new Point(this.getLocation().x,this.getLocation().y - notificationPanel.getSize().height)); + } + }); + packTimer.setRepeats(false); + packTimer.start(); }); }); MercuryStoreCore.removeNotificationSubject.subscribe(notification -> { @@ -105,22 +100,15 @@ public void subscribe() { NotificationPanel notificationPanel = this.notificationPanels.stream() .filter(it -> it.getData().equals(notification)) .findAny().orElse(null); - notificationPanel.onViewDestroy(); - int limitCount = this.config.get().getLimitCount(); - if(!this.expanded && this.notificationPanels.size() > limitCount){ - this.notificationPanels.get(limitCount).setVisible(true); - } - this.container.remove(notificationPanel); - this.notificationPanels.remove(notificationPanel); - if(this.notificationPanels.size() - 1 < this.config.get().getLimitCount()){ - this.expandPanel.setVisible(false); - } - this.pack(); - this.repaint(); - if(this.config.get().getFlowDirections().equals(FlowDirections.UPWARDS) - && this.notificationPanels.size() == 0){ - this.setLocation(this.framesConfig.get("NotificationFrame").getFrameLocation()); - } + this.removeNotification(notificationPanel); + }); + }); + MercuryStoreCore.removeScannerNotificationSubject.subscribe(message -> { + SwingUtilities.invokeLater(() -> { + NotificationPanel notificationPanel = this.notificationPanels.stream() + .filter(it -> it.getData().equals(message)) + .findAny().orElse(null); + this.removeNotification(notificationPanel); }); }); MercuryStoreCore.hotKeySubject.subscribe(hotkeyDescriptor -> { @@ -130,6 +118,48 @@ public void subscribe() { } }); }); + MercuryStoreUI.settingsPostSubject.subscribe(state -> { + if(this.config.get().getFlowDirections().equals(FlowDirections.DOWNWARDS)){ + this.setLocation(this.framesConfig.get("NotificationFrame").getFrameLocation()); + } + }); + } + + private void addNotification(NotificationPanel notificationPanel){ + this.notificationPanels.add(notificationPanel); + this.container.add(notificationPanel); + if(this.notificationPanels.size() > this.config.get().getLimitCount()){ + if(!this.expanded) { + notificationPanel.setPaintAlphaValue(1f); + notificationPanel.setVisible(false); + } + this.expandPanel.setVisible(true); + } + this.pack(); + this.repaint(); + if(this.notificationPanels.size() > 1 + && this.config.get().getFlowDirections().equals(FlowDirections.UPWARDS) + && !(notificationPanel instanceof ScannerNotificationPanel)){ + this.setLocation(new Point(this.getLocation().x,this.getLocation().y - notificationPanel.getSize().height)); + } + } + private void removeNotification(NotificationPanel notificationPanel){ + notificationPanel.onViewDestroy(); + int limitCount = this.config.get().getLimitCount(); + if(!this.expanded && this.notificationPanels.size() > limitCount){ + this.notificationPanels.get(limitCount).setVisible(true); + } + this.container.remove(notificationPanel); + this.notificationPanels.remove(notificationPanel); + if(this.notificationPanels.size() - 1 < this.config.get().getLimitCount()){ + this.expandPanel.setVisible(false); + } + this.pack(); + this.repaint(); + if(this.config.get().getFlowDirections().equals(FlowDirections.UPWARDS) + && this.notificationPanels.size() == 0){ + this.setLocation(this.framesConfig.get("NotificationFrame").getFrameLocation()); + } } @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java deleted file mode 100644 index 9f3ed731..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java +++ /dev/null @@ -1,783 +0,0 @@ -package com.mercury.platform.ui.frame.movable.container; - -import com.mercury.platform.core.ProdStarter; -import com.mercury.platform.shared.FrameVisibleState; -import com.mercury.platform.shared.config.Configuration; -import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; -import com.mercury.platform.shared.entity.message.FlowDirections; -import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; -import com.mercury.platform.shared.entity.message.NotificationDescriptor; -import com.mercury.platform.shared.entity.message.NotificationType; -import com.mercury.platform.shared.store.MercuryStoreCore; -import com.mercury.platform.ui.components.ComponentsFactory; -import com.mercury.platform.ui.components.fields.font.FontStyle; -import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.components.panel.notification.*; -import com.mercury.platform.ui.components.panel.notification.controller.IncomingPanelController; -import com.mercury.platform.ui.components.panel.notification.factory.NotificationPanelFactory; -import com.mercury.platform.ui.frame.movable.AbstractMovableComponentFrame; -import com.mercury.platform.ui.frame.AbstractOverlaidFrame; -import com.mercury.platform.ui.frame.setup.location.LocationState; -import com.mercury.platform.ui.frame.setup.scale.ScaleState; -import com.mercury.platform.ui.misc.AppThemeColor; -import com.mercury.platform.ui.misc.MercuryStoreUI; -import com.mercury.platform.ui.misc.TooltipConstants; - -import javax.swing.*; -import javax.swing.border.Border; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.*; -import java.util.List; - -public class MessageFrame extends AbstractMovableComponentFrame implements MessagesContainer { - private List currentMessages = new ArrayList<>(); - private PlainConfigurationService notificationConfig; - private boolean wasVisible; - private FlowDirections flowDirections; - private FlowDirections pikerDirection; - private boolean expanded = false; - private JPanel buffer; - private JSlider limitSlider; - private int limitMsgCount; - private JSlider unfoldSlider; - private int unfoldCount; - private int currentUnfoldCount; - - private ExpandAllFrame expandAllFrame; - - private boolean dnd = false; - public MessageFrame(){ - super(); - this.componentsFactory.setScale(this.scaleConfig.get("notification")); - this.stubComponentsFactory.setScale(this.scaleConfig.get("notification")); - this.notificationConfig = Configuration.get().notificationConfiguration(); - this.processSEResize = false; - this.flowDirections = this.notificationConfig.get().getFlowDirections(); - this.pikerDirection = this.notificationConfig.get().getFlowDirections(); - this.limitMsgCount = this.notificationConfig.get().getLimitCount(); - this.unfoldCount = this.notificationConfig.get().getUnfoldCount(); - this.currentUnfoldCount = 0; - this.expandAllFrame = new ExpandAllFrame(); - this.buffer = new JPanel(new FlowLayout(FlowLayout.CENTER)); - this.buffer.setMinimumSize(new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE)); - this.buffer.setBackground(AppThemeColor.TRANSPARENT); - } - - @Override - protected void initialize() { - super.initialize(); - } - - @Override - public void onViewInit() { - this.setBackground(AppThemeColor.TRANSPARENT); - this.getRootPane().setBorder(null); - if(this.currentMessages.size() > 0){ - this.currentMessages.forEach(panel -> this.mainContainer.add(panel)); - this.setVisible(true); - } - if(this.flowDirections.equals(FlowDirections.UPWARDS)){ - this.changeDirectionTo(FlowDirections.UPWARDS); - this.locationWasChanged = true; - this.changeLocation(); - } - this.expandAllFrame.init(); - } - - @Override - protected LayoutManager getFrameLayout() { - return new BoxLayout(mainContainer,BoxLayout.Y_AXIS); - } - - @Override - public void subscribe() { - MercuryStoreCore.dndSubject.subscribe(state -> { - this.dnd = state; - if(dnd){ - this.setVisible(false); - expandAllFrame.setVisible(false); - }else if(flowDirections.equals(FlowDirections.UPWARDS)){ - if(mainContainer.getComponentCount() > 1){ - this.setVisible(true); - setUpExpandButton(); - } - }else if(mainContainer.getComponentCount() > 0){ - this.setVisible(true); - setUpExpandButton(); - } - }); - MercuryStoreCore.messageSubject.subscribe(message -> SwingUtilities.invokeLater(()-> { -// List collect = this.currentMessages.stream() -// .filter(panel -> panel.getMessage().equals(message)) -// .collect(Collectors.toList()); -// if(collect.size() == 0) { - this.addMessage(message); -// } - })); -// MercuryStoreUI.closeMessage.subscribe(message -> { -// List panels = this.currentMessages.stream() -// .filter(panel -> panel.getMessage().equals(message)) -// .collect(Collectors.toList()); -// if(panels.size() > 0) { -// InMessagePanel inMessagePanel = panels.get(0); -// if (inMessagePanel.isExpanded()) { -// this.currentUnfoldCount--; -// if (this.currentUnfoldCount < 0) { -// this.currentUnfoldCount = 0; -// } -// } -// this.remove(inMessagePanel); -// this.currentMessages.remove(inMessagePanel); -// -// if (this.currentMessages.size() == 0) { -// this.setVisible(false); -// } else if (this.currentMessages.size() >= this.limitMsgCount) { -// if (this.currentMessages.size() == this.limitMsgCount) { -// this.expandAllFrame.setVisible(false); -// } -// this.currentMessages.get(this.limitMsgCount - 1).setVisible(true); -// this.expandAllFrame.decMessageCount(); -// } -// this.pack(); -// this.repaint(); -// this.setUpExpandButton(); -// } -// }); - MercuryStoreUI.expandMessageSubject.subscribe(state -> this.onExpandMessage()); - MercuryStoreUI.collapseMessageSubject.subscribe(state -> this.onCollapseMessage()); - } - - private void addMessage(NotificationDescriptor notificationDescriptor){ - MessagePanelStyle style = flowDirections.equals(FlowDirections.DOWNWARDS)? - MessagePanelStyle.IN_DOWNWARDS : MessagePanelStyle.IN_UPWARDS; - NotificationPanelFactory factory = new NotificationPanelFactory(); - NotificationPanel inMessagePanel = factory.getProviderFor(NotificationType.INC_ITEM_MESSAGE) - .setData(notificationDescriptor) - .setComponentsFactory(this.componentsFactory) - .build(); -// InMessagePanel inMessagePanel = new InMessagePanel( -// message, -// style, -// new NotificationMessageController(message), -// this.componentsFactory); - if (!dnd && !this.isVisible() && ProdStarter.APP_STATUS == FrameVisibleState.SHOW) { - this.showComponent(); - } else { - this.prevState = FrameVisibleState.SHOW; - } - if (flowDirections.equals(FlowDirections.UPWARDS)) { - this.mainContainer.add(inMessagePanel, 1); - } else { - this.mainContainer.add(inMessagePanel); - } - this.currentMessages.add(inMessagePanel); - this.pack(); - this.repaint(); - if (this.currentUnfoldCount < this.unfoldCount) { -// inMessagePanel.expand(); - } - if(this.currentMessages.size() > this.limitMsgCount){ - if(!expanded) { - inMessagePanel.setVisible(false); - } - if(ProdStarter.APP_STATUS == FrameVisibleState.SHOW) { - this.setUpExpandButton(); - } - this.expandAllFrame.incMessageCount(); - } - } - - @Override - protected void changeVisible(FrameVisibleState state) { - super.changeVisible(state); - if(state.equals(FrameVisibleState.SHOW)) { - this.setUpExpandButton(); - } - } - - private void setUpExpandButton(){ - if(!inScaleSettings && !inMoveMode && !dnd) { - switch (flowDirections) { - case DOWNWARDS: { - if(this.mainContainer.getComponentCount() >= (limitMsgCount + 1)) { - if (this.mainContainer.getComponentCount() > limitMsgCount) { - Component[] components = mainContainer.getComponents(); - int height = 0; - for (int i = 0; i < limitMsgCount; i++) { - height += components[i].getPreferredSize().height; - } - this.expandAllFrame.setMinimumSize(new Dimension((int)(20 * componentsFactory.getScale()), height)); - this.expandAllFrame.setLocation(new Point(this.getLocation().x - expandAllFrame.getPreferredSize().width, - this.getLocation().y)); - this.expandAllFrame.pack(); - } - this.expandAllFrame.changeArrowDirection(); - this.expandAllFrame.setVisible(true); - } - break; - } - case UPWARDS: { - if(this.mainContainer.getComponentCount() >= (limitMsgCount + 2)) { - if (this.mainContainer.getComponentCount() > (limitMsgCount + 1)) { - Component[] components = mainContainer.getComponents(); - int height = 0; - for (int i = components.length - 1; i > components.length - (limitMsgCount + 1); i--) { - height += components[i].getPreferredSize().height; - } - Point location = mainContainer.getComponent(components.length - limitMsgCount).getLocationOnScreen(); - this.expandAllFrame.setMinimumSize(new Dimension((int)(20 * componentsFactory.getScale()), height)); - this.expandAllFrame.setLocation(new Point(this.getLocation().x - expandAllFrame.getPreferredSize().width, - location.y)); - this.expandAllFrame.pack(); - } - this.expandAllFrame.changeArrowDirection(); - this.expandAllFrame.setVisible(true); - } - break; - } - } - } - } - - @Override - protected JPanel getPanelForPINSettings() { - JPanel panel = componentsFactory.getTransparentPanel(new GridLayout(4,1)); - panel.setBackground(AppThemeColor.ADR_BG); - JPanel labelPanel = componentsFactory.getTransparentPanel(new BorderLayout()); - labelPanel.setBackground(AppThemeColor.ADR_BG); - JLabel headerLabel = componentsFactory.getTextLabel( - FontStyle.BOLD, - this.notificationConfig.get().isIncNotificationEnable()?AppThemeColor.TEXT_MESSAGE:AppThemeColor.TEXT_DISABLE, - TextAlignment.CENTER, - 18f, - "Notification panel"); - labelPanel.add(headerLabel,BorderLayout.CENTER); - JButton enableButton = this.componentsFactory.getBorderedButton(this.notificationConfig.get().isIncNotificationEnable() ? "Switch-off" : "Switch-on"); - enableButton.addActionListener(action -> { - boolean notificationEnable = this.notificationConfig.get().isIncNotificationEnable(); - this.notificationConfig.get().setIncNotificationEnable(!notificationEnable); - if(this.notificationConfig.get().isIncNotificationEnable()){ - headerLabel.setForeground(AppThemeColor.TEXT_MESSAGE); - }else { - headerLabel.setForeground(AppThemeColor.TEXT_DISABLE); - } - enableButton.setText(!notificationEnable ? "Switch-off" : "Switch-on"); - MercuryStoreCore.saveConfigSubject.onNext(true); - }); - enableButton.setFont(this.componentsFactory.getFont(FontStyle.BOLD,18f)); - enableButton.setPreferredSize(new Dimension(100,26)); - labelPanel.add(this.componentsFactory.wrapToSlide(enableButton,AppThemeColor.ADR_BG),BorderLayout.LINE_END); - panel.add(labelPanel); - JComboBox flowDirectionPicker = componentsFactory.getComboBox(new String[]{"Upwards", "Downwards"}); - flowDirectionPicker.setSelectedIndex(FlowDirections.valueOf(flowDirections.toString()).ordinal()); - flowDirectionPicker.addActionListener(e -> { - switch ((String)flowDirectionPicker.getSelectedItem()){ - case "Upwards":{ - pikerDirection = FlowDirections.UPWARDS; - break; - } - case "Downwards":{ - pikerDirection = FlowDirections.DOWNWARDS; - break; - } - } - }); - flowDirectionPicker.setSelectedIndex(flowDirections.ordinal()); - panel.add(componentsFactory.getSettingsPanel( - componentsFactory.getTextLabel("Flow direction:"),flowDirectionPicker)); - JLabel limitCount = componentsFactory.getTextLabel(String.valueOf(limitMsgCount)); - this.limitSlider = componentsFactory.getSlider(2, 20, limitMsgCount,AppThemeColor.ADR_BG); - this.limitSlider.addChangeListener(e -> { - limitCount.setText(String.valueOf(limitSlider.getValue())); - }); - panel.add(componentsFactory.getSliderSettingsPanel( - componentsFactory.getTextLabel("Pre-group limit:"), - limitCount, - limitSlider - )); - JLabel unfoldCount = componentsFactory.getTextLabel(String.valueOf(this.unfoldCount)); - this.unfoldSlider = componentsFactory.getSlider(0, 20, this.unfoldCount,AppThemeColor.ADR_BG); - this.unfoldSlider.addChangeListener(e -> { - unfoldCount.setText(String.valueOf(unfoldSlider.getValue())); - }); - panel.add(componentsFactory.getSliderSettingsPanel( - this.componentsFactory.getTextLabel("Unfold by default:"), - unfoldCount, - this.unfoldSlider - )); - panel.setPreferredSize(new Dimension((int)(400 * componentsFactory.getScale()), (int)(130*componentsFactory.getScale()))); - this.setMaximumSize(panel.getPreferredSize()); - return panel; - } - - private void onLimitCountChange(){ - this.expandAllFrame.resetMessageCount(); - Arrays.stream(mainContainer.getComponents()) - .forEach(component -> component.setVisible(true)); - this.currentMessages.stream().skip(this.limitMsgCount).forEach(panel -> { - panel.setVisible(false); - this.expandAllFrame.incMessageCount(); - }); - if(this.currentMessages.size() < this.limitMsgCount){ - this.expandAllFrame.setVisible(false); - } - } - - private void onExpandedCountChange(){ - this.currentUnfoldCount = 0; -// this.currentMessages.forEach(InMessagePanel::collapse); - this.currentUnfoldCount = 0; - this.currentMessages.stream().limit(this.unfoldCount).forEach(panel -> { -// panel.expand(); - this.currentUnfoldCount++; - }); - } - - @Override - public void setOpacity(float opacity) { - super.setOpacity(opacity); - this.expandAllFrame.setOpacity(opacity); - } - @Override - protected void onLock() { - this.expandAllFrame.setLocationState(LocationState.DEFAULT); - if(!this.flowDirections.equals(pikerDirection)){ - this.notificationConfig.get().setFlowDirections(this.pikerDirection); - this.changeDirectionTo(pikerDirection); - this.locationWasChanged = true; - } - if(this.limitMsgCount != this.limitSlider.getValue()) { - this.limitMsgCount = this.limitSlider.getValue(); - this.notificationConfig.get().setLimitCount(this.limitMsgCount); - this.onLimitCountChange(); - } - if(this.unfoldCount != this.unfoldSlider.getValue()) { - this.unfoldCount = this.unfoldSlider.getValue(); - this.notificationConfig.get().setUnfoldCount(this.unfoldCount); - this.onExpandedCountChange(); - } - MercuryStoreCore.saveConfigSubject.onNext(true); - this.changeLocation(); - super.onLock(); - this.setUpExpandButton(); - if(currentMessages.size() > 0){ - this.setVisible(true); - } - } - @Override - protected void onUnlock() { - super.onUnlock(); - this.setUpExpandButton(); - this.expandAllFrame.setLocationState(LocationState.MOVING); - } - - @Override - protected void onScaleLock() { - if(currentMessages.size() > 0){ - this.setVisible(true); - this.expandAllFrame.setScaleState(ScaleState.DEFAULT); - this.changeLocation(); - this.setUpExpandButton(); - this.pack(); - this.repaint(); - } - } - - @Override - protected void onScaleUnlock() { - if(currentMessages.size() > 0) { - this.setVisible(true); - } - this.expandAllFrame.setScaleState(ScaleState.ENABLE); - this.pack(); - this.repaint(); - } - - @Override - protected void onFrameDragged(Point location) { - super.onFrameDragged(location); - this.expandAllFrame.setLocation(location.x - expandAllFrame.getPreferredSize().width - 2,location.y); - } - - @Override - public void onLocationChange(Point location) { - super.onLocationChange(location); - if(this.expandAllFrame.isVisible()) { - this.expandAllFrame.setLocation(location.x - expandAllFrame.getPreferredSize().width - 2, location.y); - } - } - - private void changeDirectionTo(FlowDirections direction){ - this.wasVisible = isVisible(); - this.hideComponent(); - switch (direction) { - case DOWNWARDS:{ - this.mainContainer.remove(this.buffer); - Component[] components = this.mainContainer.getComponents(); - for (Component component : components) { - ((InMessagePanel) component).setStyle(MessagePanelStyle.IN_DOWNWARDS); - this.mainContainer.remove(component); - this.mainContainer.add(component, 0); - } - break; - } - case UPWARDS: { - this.mainContainer.add(buffer,0); - Component[] components = this.mainContainer.getComponents(); - for (int i = 1; i < components.length; i++) { - ((InMessagePanel) components[i]).setStyle(MessagePanelStyle.IN_UPWARDS); - this.mainContainer.remove(components[i]); - this.mainContainer.add(components[i], 1); - } - break; - } - } - if(this.wasVisible) { - this.showComponent(); - } - this.flowDirections = direction; - } - private void changeLocation(){ - this.wasVisible = isVisible(); - this.hideComponent(); - switch (flowDirections){ - case DOWNWARDS:{ - this.setLocation(this.framesConfig.get(this.getClass().getSimpleName()).getFrameLocation()); - break; - } - case UPWARDS:{ - if(this.locationWasChanged) { - int height = this.getLocation().y; - this.setLocation(this.getLocation().x, -1000); - this.setMinimumSize(new Dimension(this.getWidth(), height + 1000 + (int)(130*componentsFactory.getScale()))); - this.setMaximumSize(new Dimension(this.getWidth(), height + 1000 + (int)(130*componentsFactory.getScale()))); - this.locationWasChanged = false; - } - break; - } - } - if(this.wasVisible) { - this.showComponent(); - } - } - - @Override - protected Point getFrameLocation() { - if(this.flowDirections.equals(FlowDirections.UPWARDS)){ - return new Point(this.getLocationOnScreen().x,this.getLocationOnScreen().y + this.getHeight()); - } - return super.getFrameLocation(); - } - - @Override - public void onExpandMessage() { - this.pack(); - if(this.expandAllFrame.isVisible()) { - this.setUpExpandButton(); - } - this.currentUnfoldCount++; - } - - @Override - public void onCollapseMessage() { - this.pack(); - if(this.expandAllFrame.isVisible()) { - this.setUpExpandButton(); - } - this.currentUnfoldCount--; - } - - @Override - protected void performScaling(Map scaleData) { - this.wasVisible = isVisible(); - this.hideComponent(); - this.componentsFactory.setScale(scaleData.get("notification")); - this.currentMessages.forEach(panel -> { - panel.setComponentsFactory(this.componentsFactory); -// panel.setStyle(panel.getStyle()); - }); - if(this.wasVisible) { - this.showComponent(); - } - this.expandAllFrame.processNewScale(); - this.changeLocation(); - this.setUpExpandButton(); - this.pack(); - this.repaint(); - } - - @Override - protected void registerDirectScaleHandler() { - MercuryStoreUI.notificationScaleSubject.subscribe(this::changeScale); - } - - @Override - protected JPanel defaultView(ComponentsFactory factory) { - ItemTradeNotificationDescriptor message = new ItemTradeNotificationDescriptor(); - message.setWhisperNickname("Example1"); - message.setItemName("Example example example"); - message.setCurrency("chaos"); - message.setCurCount(1000d); - message.setLeague("Standard"); - message.setOffer("Offer offer offer"); - - JPanel panel = factory.getTransparentPanel(); - panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS)); - panel.setBackground(AppThemeColor.FRAME); - IncomingPanelController stubController = new IncomingPanelController() { - @Override - public void performInvite() {} - @Override - public void performKick() {} - @Override - public void performOfferTrade() {} - @Override - public void performOpenChat() {} - @Override - public void performResponse(String responseText) {} - @Override - public void performHide() {} - @Override - public void showITH() {} - @Override - public void reloadMessage(InMessagePanel panel1) {} - }; - InMessagePanel inMessagePanel = new InMessagePanel(message, MessagePanelStyle.IN_DOWNWARDS, stubController, factory); - inMessagePanel.expand(); - panel.add(inMessagePanel); - return panel; - } - - private class ExpandAllFrame extends AbstractOverlaidFrame { - private int messageCount = 0; - private JLabel msgCountLabel; - private JButton expandButton; - private JPanel labelPanel; - private Container rootContainer; - private ExpandAllFrameConstraints prevContraints; - private boolean wasVisible; - - ExpandAllFrame() { - super(); - } - @Override - protected void initialize() { - this.rootContainer = this.getContentPane(); - this.componentsFactory = MessageFrame.this.componentsFactory; - this.setBackground(AppThemeColor.MSG_HEADER); - this.getRootPane().setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createMatteBorder(1,1,1,0,AppThemeColor.TRANSPARENT), - BorderFactory.createMatteBorder(1,1,1,1,AppThemeColor.BORDER))); - - labelPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); - labelPanel.setBackground(AppThemeColor.MSG_HEADER); - labelPanel.setPreferredSize(new Dimension((int)(10 * componentsFactory.getScale()),(int)(22 * componentsFactory.getScale()))); - labelPanel.setBorder(BorderFactory.createEmptyBorder(-4,0,0,0)); - msgCountLabel = componentsFactory.getTextLabel("+" + String.valueOf(messageCount)); - String iconPath = (flowDirections.equals(FlowDirections.DOWNWARDS))? "app/collapse-all.png" : "app/expand-all.png"; - expandButton = componentsFactory.getIconButton(iconPath,22,AppThemeColor.MSG_HEADER,""); - expandButton.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - if(SwingUtilities.isLeftMouseButton(e)){ - String iconPath; - if(!expanded){ - Arrays.stream(mainContainer.getComponents()).forEach(panel ->{ - if(!panel.isVisible()){ - panel.setVisible(true); - } - }); - if(flowDirections.equals(FlowDirections.DOWNWARDS)){ - iconPath = "app/expand-all.png"; - }else { - iconPath = "app/collapse-all.png"; - } - msgCountLabel.setText(""); - expanded = true; - }else { - if(flowDirections.equals(FlowDirections.DOWNWARDS)){ - iconPath = "app/collapse-all.png"; - }else { - iconPath = "app/expand-all.png"; - } - Component[] components = mainContainer.getComponents(); - if(flowDirections.equals(FlowDirections.UPWARDS)){ - for (int i = 1; i < mainContainer.getComponentCount() - limitMsgCount; i++) { - components[i].setVisible(false); - } - }else { - for (int i = 0; i < components.length; i++) { - if(i > (limitMsgCount-1)){ - components[i].setVisible(false); - } - } - } - msgCountLabel.setText("+"+String.valueOf(messageCount)); - expanded = false; - } - expandButton.setIcon(componentsFactory.getIcon(iconPath,22)); - MessageFrame.this.pack(); - } - } - }); - expandButton.setAlignmentY(SwingConstants.CENTER); - labelPanel.add(msgCountLabel); - if(flowDirections.equals(FlowDirections.DOWNWARDS)){ - rootContainer.add(expandButton,BorderLayout.CENTER); - rootContainer.add(labelPanel,BorderLayout.PAGE_END); - }else { - rootContainer.add(labelPanel, BorderLayout.PAGE_START); - rootContainer.add(expandButton, BorderLayout.CENTER); - } - this.pack(); - } - void processNewScale(){ - labelPanel.setPreferredSize(new Dimension((int)(10 * componentsFactory.getScale()),(int)(22 * componentsFactory.getScale()))); - msgCountLabel.setFont(componentsFactory.getFont(FontStyle.BOLD,15f)); - changeArrowDirection(); - } - - void incMessageCount(){ - messageCount++; - if(!expanded) { - msgCountLabel.setText("+" + String.valueOf(messageCount)); - rootContainer.repaint(); - } - - } - void decMessageCount(){ - messageCount--; - if(!expanded) { - msgCountLabel.setText("+" + String.valueOf(messageCount)); - rootContainer.repaint(); - } - } - void resetMessageCount(){ - messageCount = 0; - } - void changeArrowDirection(){ - String iconPath = ""; - if(flowDirections.equals(FlowDirections.DOWNWARDS)){ - if(!expanded){ - iconPath = "app/collapse-all.png"; - }else { - iconPath = "app/expand-all.png"; - } - }else { - if(!expanded){ - iconPath = "app/expand-all.png"; - }else { - iconPath = "app/collapse-all.png"; - } - } - expandButton.setIcon(componentsFactory.getIcon(iconPath,22)); - rootContainer.remove(labelPanel); - if(pikerDirection.equals(FlowDirections.DOWNWARDS)){ - rootContainer.add(labelPanel,BorderLayout.PAGE_END); - }else { - rootContainer.add(labelPanel, BorderLayout.PAGE_START); - } - this.pack(); - } - @Override - public void subscribe() { - - } - - void setLocationState(LocationState state){ - switch (state){ - case DEFAULT:{ - toDefaultState(); - break; - } - case MOVING:{ - prevContraints = new ExpandAllFrameConstraints( - this.isVisible(), - this.getRootPane().getBorder(), - this.getBackground() - ); - this.getRootPane().setBorder(null); - this.setBackground(AppThemeColor.FRAME); - this.setMinimumSize(null); - this.setVisible(true); - JPanel panel = componentsFactory.getTransparentPanel(new BorderLayout()); - panel.setBackground(AppThemeColor.ADR_BG); - panel.setBorder(BorderFactory.createLineBorder(AppThemeColor.BORDER)); - JLabel infoLabel = componentsFactory.getTextLabel(FontStyle.BOLD,AppThemeColor.TEXT_DEFAULT,TextAlignment.LEFTOP,29f,"?"); - infoLabel.setOpaque(true); - infoLabel.setBackground(AppThemeColor.ADR_BG); - infoLabel.setBorder(BorderFactory.createEmptyBorder(0,3,0,0)); - infoLabel.addMouseListener(new MouseAdapter() { - @Override - public void mouseEntered(MouseEvent e) { - MercuryStoreCore.tooltipSubject.onNext(TooltipConstants.NOTIFICATION_SETTINGS); - } - - @Override - public void mouseExited(MouseEvent e) { - MercuryStoreCore.tooltipSubject.onNext(null); - } - }); - panel.add(infoLabel,BorderLayout.CENTER); - panel.setPreferredSize(new Dimension(this.getPreferredSize().width,MessageFrame.this.getPreferredSize().height)); - this.setLocation(MessageFrame.this.getLocation().x - this.getPreferredSize().width - 2, MessageFrame.this.getLocation().y); - this.setContentPane(panel); - this.pack(); - break; - } - } - } - private void toDefaultState(){ - this.setContentPane(rootContainer); - this.setVisible(prevContraints.visible); - this.getRootPane().setBorder(prevContraints.border); - this.setBackground(prevContraints.bgColor); - prevContraints = null; - setUpExpandButton(); - this.pack(); - } - - void setScaleState(ScaleState state){ - switch (state){ - case DEFAULT: { - toDefaultState(); - break; - } - case ENABLE:{ - prevContraints = new ExpandAllFrameConstraints( - this.isVisible(), - this.getRootPane().getBorder(), - this.getBackground() - ); - this.setVisible(false); - break; - } - } - } - - @Override - protected LayoutManager getFrameLayout() { - return new BorderLayout(); - } - - @Override - public void onViewInit() { - - } - - private class ExpandAllFrameConstraints { - private boolean visible; - private Border border; - private Color bgColor; - - public ExpandAllFrameConstraints(boolean visible, Border border, Color bgColor) { - this.visible = visible; - this.border = border; - this.bgColor = bgColor; - } - } - } -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessagesContainer.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessagesContainer.java deleted file mode 100644 index f512976e..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessagesContainer.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.mercury.platform.ui.frame.movable.container; - -/** - * Created by Константин on 25.02.2017. - */ -public interface MessagesContainer { - void onExpandMessage(); - void onCollapseMessage(); -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/AbstractTitledComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/AbstractTitledComponentFrame.java index 86fc064f..ed307257 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/AbstractTitledComponentFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/AbstractTitledComponentFrame.java @@ -25,7 +25,6 @@ protected void initialize() { private void initHeaderPanel(){ if(layout instanceof BorderLayout) { - this.miscPanel = new JPanel(new GridLayout(1,0,5,0)); this.headerPanel = new JPanel(new BorderLayout()); this.headerPanel.setBackground(AppThemeColor.HEADER); this.headerPanel.setPreferredSize(new Dimension(100,26)); @@ -42,12 +41,12 @@ private void initHeaderPanel(){ this.headerPanel.add(appIcon,BorderLayout.LINE_START); this.headerPanel.add(this.frameTitleLabel, BorderLayout.CENTER); - this.miscPanel.setBackground(AppThemeColor.HEADER); + this.miscPanel = this.componentsFactory.getJPanel(new BorderLayout(),AppThemeColor.HEADER); this.hideButton = componentsFactory.getIconButton("app/close.png", 14, AppThemeColor.HEADER, ""); this.hideButton.addActionListener(action -> { this.hideComponent(); }); - this.miscPanel.add(hideButton); + this.miscPanel.add(hideButton,BorderLayout.LINE_END); this.headerPanel.add(miscPanel, BorderLayout.LINE_END); this.add(headerPanel, BorderLayout.PAGE_START); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterSettingsFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/ChatFilterSettingsFrame.java similarity index 53% rename from app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterSettingsFrame.java rename to app-ui/src/main/java/com/mercury/platform/ui/frame/titled/ChatFilterSettingsFrame.java index 3f49be94..22a3eb27 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterSettingsFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/ChatFilterSettingsFrame.java @@ -1,4 +1,4 @@ -package com.mercury.platform.ui.frame.titled.chat; +package com.mercury.platform.ui.frame.titled; import com.mercury.platform.core.misc.SoundType; import com.mercury.platform.core.utils.interceptor.MessageInterceptor; @@ -6,14 +6,11 @@ import com.mercury.platform.shared.config.Configuration; import com.mercury.platform.shared.config.configration.PlainConfigurationService; import com.mercury.platform.shared.config.descriptor.ScannerDescriptor; -import com.mercury.platform.shared.entity.message.NotificationDescriptor; -import com.mercury.platform.shared.entity.message.NotificationType; +import com.mercury.platform.shared.entity.message.PlainMessageDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.components.panel.chat.ChatMessagePanel; import com.mercury.platform.ui.components.panel.chat.HtmlMessageBuilder; -import com.mercury.platform.ui.frame.titled.AbstractTitledComponentFrame; import com.mercury.platform.ui.misc.AppThemeColor; import net.jodah.expiringmap.ExpiringMap; import org.apache.commons.lang3.StringUtils; @@ -23,13 +20,15 @@ import java.util.*; import java.util.List; import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class ChatFilterSettingsFrame extends AbstractTitledComponentFrame { private PlainConfigurationService scannerService; - private JTextField quickResponseField; private MessageInterceptor currentInterceptor; private Map expiresMessages; private HtmlMessageBuilder messageBuilder; + private boolean running; public ChatFilterSettingsFrame() { super(); @@ -46,6 +45,7 @@ public void onViewInit() { .expiration(10, TimeUnit.SECONDS) .build(); this.messageBuilder = new HtmlMessageBuilder(); + this.initHeaderBar(); JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); JPanel setupArea = componentsFactory.getTransparentPanel(new BorderLayout()); setupArea.setBorder(BorderFactory.createEmptyBorder(4,4,4,4)); @@ -63,16 +63,14 @@ public void onViewInit() { words.setBorder(BorderFactory.createLineBorder(AppThemeColor.HEADER)); words.setBackground(AppThemeColor.SLIDE_BG); - JPanel navBar = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); + JPanel navBar = componentsFactory.getJPanel(new FlowLayout(FlowLayout.CENTER),AppThemeColor.FRAME); Dimension buttonSize = new Dimension(90, 24); JButton save = componentsFactory.getBorderedButton("Save"); save.addActionListener(action -> { this.scannerService.get().setWords(words.getText()); - this.scannerService.get().setResponseMessage(quickResponseField.getText()); MercuryStoreCore.saveConfigSubject.onNext(true); - String chunkStr = StringUtils.deleteWhitespace(words.getText()); - String[] split = chunkStr.split(","); + String[] split = words.getText().split(","); this.performNewStrings(split); this.hideComponent(); }); @@ -96,70 +94,97 @@ public void onViewInit() { root.add(setupArea,BorderLayout.CENTER); root.add(getMemo(),BorderLayout.LINE_END); - JPanel padding = componentsFactory.getTransparentPanel(new BorderLayout()); - padding.setBorder(BorderFactory.createEmptyBorder(0,4,4,4)); - padding.add(getResponsePanel(),BorderLayout.CENTER); - root.add(padding,BorderLayout.PAGE_END); this.add(root,BorderLayout.CENTER); this.add(navBar,BorderLayout.PAGE_END); this.pack(); } - private void performNewStrings(String[] strings){ - List contains = new ArrayList<>(); - List notContains = new ArrayList<>(); - - Arrays.stream(strings).forEach(str -> { - str = str.toLowerCase().trim(); - if(!str.isEmpty()) { - if (str.contains("!")) { - notContains.add(str.replace("!", "")); - } else { - contains.add(str); + + private void initHeaderBar(){ + JPanel root = this.componentsFactory.getJPanel(new GridLayout(1, 0, 4, 0),AppThemeColor.HEADER); + JLabel statusLabel = componentsFactory.getTextLabel( + FontStyle.BOLD, + AppThemeColor.TEXT_DEFAULT, + TextAlignment.LEFTOP, + 16f, + "Status: stopped"); + + JButton processButton = componentsFactory.getBorderedButton("Start"); + processButton.setFont(this.componentsFactory.getFont(FontStyle.BOLD,16f)); + processButton.setPreferredSize(new Dimension(80,20)); + processButton.addActionListener(action -> { + if(this.running){ + this.running = false; + processButton.setText("Start"); + statusLabel.setText("Status: stopped"); + if (this.currentInterceptor != null) { + MercuryStoreCore.removeInterceptorSubject.onNext(this.currentInterceptor); } + }else { + this.running = true; + processButton.setText("Stop"); + statusLabel.setText("Status: running"); + this.performNewStrings(this.scannerService.get().getWords().split(",")); } }); - if (this.currentInterceptor != null) { - MercuryStoreCore.removeInterceptorSubject.onNext(this.currentInterceptor); - } - this.currentInterceptor = new MessageInterceptor() { - @Override - protected void process(String stubMessage) { - String message = StringUtils.substringAfter(stubMessage,"] $"); - if(message.isEmpty()){ - message = StringUtils.substringAfter(stubMessage,"] #"); + root.add(statusLabel); + root.add(processButton); + this.miscPanel.add(root,BorderLayout.CENTER); + } + private void performNewStrings(String[] strings){ + if(this.running) { + List contains = new ArrayList<>(); + List notContains = new ArrayList<>(); + + Arrays.stream(strings).forEach(str -> { + str = str.toLowerCase().trim(); + if (!str.isEmpty()) { + if (str.contains("!")) { + notContains.add(str.replace("!", "")); + } else { + contains.add(str); + } } - if(!message.isEmpty()){ - String nickname = StringUtils.substringBefore(message, ":"); - String messageContent = StringUtils.substringAfter(message, nickname + ":"); - nickname = StringUtils.deleteWhitespace(nickname); - if(nickname.contains(">")) { - nickname = StringUtils.substringAfterLast(nickname, ">"); + }); + if (this.currentInterceptor != null) { + MercuryStoreCore.removeInterceptorSubject.onNext(this.currentInterceptor); + } + this.currentInterceptor = new MessageInterceptor() { + @Override + protected void process(String stubMessage) { + messageBuilder.setChunkStrings(Arrays.asList(strings)); + String message = StringUtils.substringAfter(stubMessage, "] $"); + if (message.isEmpty()) { + message = StringUtils.substringAfter(stubMessage, "] #"); } - if(!expiresMessages.containsValue(message)){ - NotificationDescriptor notificationDescriptor = new NotificationDescriptor(); - notificationDescriptor.setType(NotificationType.SCANNER_MESSAGE); - notificationDescriptor.setSourceString(messageBuilder.build(messageContent)); - notificationDescriptor.setWhisperNickname(nickname); - MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); - expiresMessages.put(nickname,message); - MercuryStoreCore.soundSubject.onNext(SoundType.CHAT_SCANNER); + if (!message.isEmpty()) { + Pattern pattern = Pattern.compile("^(\\<.+?\\>)?\\s?(.+?):(.+)$"); + Matcher matcher = pattern.matcher(message); + if (matcher.find() && !expiresMessages.containsValue(message)) { + PlainMessageDescriptor descriptor = new PlainMessageDescriptor(); + descriptor.setNickName(matcher.group(2)); + descriptor.setMessage(messageBuilder.build(matcher.group(3))); + + expiresMessages.put(descriptor.getNickName(), message); + MercuryStoreCore.newScannerMessageSubject.onNext(descriptor); + MercuryStoreCore.soundSubject.onNext(SoundType.CHAT_SCANNER); + } } } - } - @Override - protected MessageFilter getFilter() { - return message -> { - if (!message.contains("] $") && !message.contains("] #")) { - return false; - } - message = StringUtils.substringAfter(message, ":").toLowerCase(); - return notContains.stream().noneMatch(message::contains) - && contains.stream().anyMatch(message::contains); - }; - } - }; - MercuryStoreCore.addInterceptorSubject.onNext(this.currentInterceptor); + @Override + protected MessageFilter getFilter() { + return message -> { + if (!message.contains("] $") && !message.contains("] #")) { + return false; + } + message = StringUtils.substringAfter(message, ":").toLowerCase(); + return notContains.stream().noneMatch(message::contains) + && contains.stream().anyMatch(message::contains); + }; + } + }; + MercuryStoreCore.addInterceptorSubject.onNext(this.currentInterceptor); + } } @Override @@ -167,26 +192,6 @@ protected void initialize() { super.initialize(); this.setPreferredSize(new Dimension(350,300)); } - private JPanel getResponsePanel(){ - JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); - JPanel setupArea = componentsFactory.getTransparentPanel(new BorderLayout()); - setupArea.setBorder(BorderFactory.createEmptyBorder(4,4,4,4)); - - root.setBorder(BorderFactory.createLineBorder(AppThemeColor.HEADER)); - root.setBackground(AppThemeColor.SLIDE_BG); - - JButton quickResponse = componentsFactory.getIconButton("app/chat_scanner_response.png", 18f, AppThemeColor.SLIDE_BG, "Quick response"); - this.quickResponseField = componentsFactory.getTextField(this.scannerService.get().getResponseMessage(),FontStyle.REGULAR,16f); - this.quickResponseField.setBackground(AppThemeColor.SLIDE_BG); - this.quickResponseField.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createLineBorder(AppThemeColor.HEADER,1), - BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,3) - )); - setupArea.add(quickResponse,BorderLayout.LINE_START); - setupArea.add(this.quickResponseField,BorderLayout.CENTER); - root.add(setupArea,BorderLayout.CENTER); - return root; - } private JPanel getMemo(){ JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/HistoryFrame.java similarity index 92% rename from app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryFrame.java rename to app-ui/src/main/java/com/mercury/platform/ui/frame/titled/HistoryFrame.java index 889140a7..dc6b149e 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/HistoryFrame.java @@ -1,4 +1,4 @@ -package com.mercury.platform.ui.frame.titled.container; +package com.mercury.platform.ui.frame.titled; import com.mercury.platform.shared.HistoryManager; import com.mercury.platform.shared.MessageParser; @@ -7,15 +7,10 @@ import com.mercury.platform.shared.entity.message.NotificationType; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.fields.style.MercuryScrollBarUI; -import com.mercury.platform.ui.components.panel.notification.InMessagePanel; import com.mercury.platform.ui.components.panel.VerticalScrollContainer; import com.mercury.platform.ui.components.panel.notification.NotificationPanel; -import com.mercury.platform.ui.components.panel.notification.controller.NotificationIncomingController; -import com.mercury.platform.ui.components.panel.notification.MessagePanelStyle; import com.mercury.platform.ui.components.panel.notification.factory.NotificationPanelFactory; -import com.mercury.platform.ui.frame.titled.AbstractTitledComponentFrame; import com.mercury.platform.ui.misc.AppThemeColor; -import com.mercury.platform.ui.misc.MercuryStoreUI; import org.apache.commons.lang3.ArrayUtils; import javax.swing.*; @@ -57,7 +52,7 @@ public void mouseWheelMoved(MouseWheelEvent e) { JScrollBar vBar = scrollPane.getVerticalScrollBar(); vBar.setBackground(AppThemeColor.SLIDE_BG); vBar.setUI(new MercuryScrollBarUI()); - vBar.setPreferredSize(new Dimension(14, Integer.MAX_VALUE)); + vBar.setPreferredSize(new Dimension(16, Integer.MAX_VALUE)); vBar.setUnitIncrement(3); vBar.setBorder(BorderFactory.createEmptyBorder(1,1,1,2)); vBar.addAdjustmentListener(e -> repaint()); @@ -130,6 +125,7 @@ public void subscribe() { .setComponentsFactory(this.componentsFactory) .build(); mainContainer.add(panel); + this.currentMessages.add(message); this.trimContainer(); this.pack(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java index 9ed1e152..cb7d9a5c 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java @@ -87,7 +87,7 @@ private JPanel getTestCasesPanel(){ JButton chatScannerButton = componentsFactory.getBorderedButton("Click"); chatScannerButton.addActionListener(action -> { - MercuryStoreCore.newNotificationSubject.onNext(this.testEngine.getRandomScannerMessage()); + MercuryStoreCore.newScannerMessageSubject.onNext(this.testEngine.getRandomScannerMessage()); }); testPanel.add(chatScannerButton,buttonColumn); buttonColumn.gridy++; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestEngine.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestEngine.java index 636901f5..fa935869 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestEngine.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestEngine.java @@ -4,6 +4,7 @@ import com.mercury.platform.shared.MessageParser; import com.mercury.platform.shared.entity.message.NotificationDescriptor; import com.mercury.platform.shared.entity.message.NotificationType; +import com.mercury.platform.shared.entity.message.PlainMessageDescriptor; import com.mercury.platform.ui.components.panel.chat.HtmlMessageBuilder; import org.apache.commons.lang3.StringUtils; @@ -183,7 +184,7 @@ public NotificationDescriptor getRandomCurrencyOutMessage(){ notificationDescriptor.setType(NotificationType.OUT_CURRENCY_MESSAGE); return notificationDescriptor; } - public NotificationDescriptor getRandomScannerMessage(){ + public PlainMessageDescriptor getRandomScannerMessage(){ NotificationDescriptor notificationDescriptor = parser.parse(String.format(poeTradeTemplate, nickNames.get(random.nextInt(nickNames.size())), items.get(random.nextInt(items.size())), @@ -195,10 +196,10 @@ public NotificationDescriptor getRandomScannerMessage(){ random.nextInt(12) + 1, offer.get(random.nextInt(offer.size())) )); - String source = StringUtils.substringAfter(notificationDescriptor.getSourceString(), ": "); - notificationDescriptor.setSourceString(messageBuilder.build(source)); - notificationDescriptor.setType(NotificationType.SCANNER_MESSAGE); - return notificationDescriptor; + PlainMessageDescriptor descriptor = new PlainMessageDescriptor(); + descriptor.setMessage(messageBuilder.build(StringUtils.substringAfter(notificationDescriptor.getSourceString(),notificationDescriptor.getWhisperNickname()+":"))); + descriptor.setNickName(notificationDescriptor.getWhisperNickname()); + return descriptor; } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterFrame.java deleted file mode 100644 index a31c95fb..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatFilterFrame.java +++ /dev/null @@ -1,267 +0,0 @@ -package com.mercury.platform.ui.frame.titled.chat; - -import com.mercury.platform.core.utils.interceptor.MessageInterceptor; -import com.mercury.platform.core.utils.interceptor.filter.MessageFilter; -import com.mercury.platform.shared.config.Configuration; -import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.descriptor.FrameDescriptor; -import com.mercury.platform.shared.config.descriptor.ScannerDescriptor; -import com.mercury.platform.shared.store.MercuryStoreCore; -import com.mercury.platform.ui.components.fields.font.FontStyle; -import com.mercury.platform.ui.components.panel.chat.ChatFilterPanel; -import com.mercury.platform.ui.frame.titled.AbstractTitledComponentFrame; -import com.mercury.platform.ui.misc.AppThemeColor; -import com.mercury.platform.ui.misc.MercuryStoreUI; -import org.apache.commons.lang3.StringUtils; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.util.*; -import java.util.List; - -public class ChatFilterFrame extends AbstractTitledComponentFrame { - private ChatFilterSettingsFrame settingsFrame; - private PlainConfigurationService scannerService; - private ChatFilterPanel msgContainer; - private MessageInterceptor interceptor; - private JPanel toolbar; - private boolean soundEnable = false; - private boolean scrollToBottom = true; - private boolean chatEnable = false; - private JButton scrollEnd; - - public ChatFilterFrame() { - super(); - FrameDescriptor frameDescriptor = this.framesConfig.get(this.getClass().getSimpleName()); - this.setPreferredSize(frameDescriptor.getFrameSize()); -// this.settingsFrame = new ChatFilterSettingsFrame(strings -> { -// if(chatEnable){ -//// performNewStrings(strings); -// } -// }); - } - - @Override - protected void initialize() { - super.initialize(); - this.scannerService = Configuration.get().scannerConfiguration(); - } - - @Override - public void onViewInit() { - this.addComponentListener(new ComponentAdapter() { - @Override - public void componentResized(ComponentEvent e) { - setPreferredSize(getSize()); - } - }); - this.hideButton.setIcon(componentsFactory.getIcon("app/hide.png",14)); - this.hideButton.setBorder(BorderFactory.createEmptyBorder(0,2,0,2)); - this.headerPanel.add(getMenuButton(),BorderLayout.LINE_START); - this.miscPanel.add(getEnableButton(),0); -// this.miscPanel.add(getMinimizeButton(),1); - this.miscPanel.setBorder(BorderFactory.createEmptyBorder(-4,0,0,0)); - this.settingsFrame.init(); - this.msgContainer = new ChatFilterPanel(); - this.toolbar = getToolbar(); - toolbar.setVisible(false); - this.add(toolbar,BorderLayout.LINE_START); - this.add(msgContainer,BorderLayout.CENTER); - this.pack(); - } - - private JButton getEnableButton() { - JButton enableButton = componentsFactory.getBorderedButton("Start"); - enableButton.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createLineBorder(AppThemeColor.BORDER, 1), - BorderFactory.createMatteBorder(1,5,1,5,AppThemeColor.TRANSPARENT) - )); - enableButton.setFont(componentsFactory.getFont(FontStyle.BOLD,16f)); - enableButton.setPreferredSize(new Dimension(90,23)); - enableButton.setBackground(AppThemeColor.TRANSPARENT); - enableButton.setForeground(AppThemeColor.TEXT_SUCCESS); - - componentsFactory.setUpToggleCallbacks(enableButton, - () -> { - chatEnable = false; - if (interceptor != null) { - MercuryStoreCore.removeInterceptorSubject.onNext(interceptor); - } - enableButton.setText("Start"); - enableButton.setForeground(AppThemeColor.TEXT_SUCCESS); - repaint(); - }, - () -> { - chatEnable = true; - String chunkStr = StringUtils.deleteWhitespace(this.scannerService.get().getWords()); - String[] split = chunkStr.split(","); - performNewStrings(split); - enableButton.setText("Stop"); - enableButton.setForeground(AppThemeColor.TEXT_IMPORTANT); - repaint(); - }, false); - return enableButton; - } - private JButton getMinimizeButton() { - JButton minimizer = componentsFactory.getIconButton("app/minimize.png", 14, AppThemeColor.FRAME_ALPHA, ""); - minimizer.addActionListener(action -> { - //todo - }); - return minimizer; - } - private JButton getMenuButton() { - JButton menu = componentsFactory.getIconButton("app/menu.png", 18, AppThemeColor.FRAME_ALPHA, "Menu"); - menu.setBorder(BorderFactory.createEmptyBorder(4,6,4,4)); - componentsFactory.setUpToggleCallbacks(menu, - () -> { - this.toolbar.setVisible(true); - repaint(); - }, - () -> { - this.toolbar.setVisible(false); - repaint(); - }, true); - return menu; - } - private void performNewStrings(String[] strings){ - List contains = new ArrayList<>(); - List notContains = new ArrayList<>(); - - Arrays.stream(strings).forEach(str -> { - str = str.toLowerCase().trim(); - if(!str.isEmpty()) { - if (str.contains("!")) { - notContains.add(str.replace("!", "")); - } else { - contains.add(str); - } - } - }); - - msgContainer.setNewChunks(Arrays.asList(strings)); - if (interceptor != null) { - MercuryStoreCore.removeInterceptorSubject.onNext(interceptor); - } - interceptor = new MessageInterceptor() { - @Override - protected void process(String message) { - msgContainer.addMessage(message); - ChatFilterFrame.this.pack(); - if(scrollToBottom){ - msgContainer.scrollToBottom(true); - } - } - - @Override - protected MessageFilter getFilter() { - return message -> { - if (!message.contains("] $") && !message.contains("] #")) { - return false; - } - message = StringUtils.substringAfter(message, ":").toLowerCase(); - return notContains.stream().noneMatch(message::contains) - && contains.stream().anyMatch(message::contains); - }; - } - }; - MercuryStoreCore.addInterceptorSubject.onNext(interceptor); - } - - @Override - protected String getFrameTitle() { - return "Mercury: Chat scanner"; - } - - @Override - public void subscribe() { - MercuryStoreUI.scrollToEndSubject.subscribe(value -> { - this.scrollToBottom = value; - if (!this.scrollToBottom) { - this.scrollEnd.setIcon(componentsFactory.getIcon("app/scroll-end-r.png", 18)); - this.msgContainer.scrollToBottom(false); - } - }); - } - - private JPanel getToolbar(){ - JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); - root.setBorder(BorderFactory.createEmptyBorder(2,2,2,2)); - - JPanel panel = componentsFactory.getTransparentPanel(); - panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS)); - panel.setBorder(BorderFactory.createLineBorder(AppThemeColor.HEADER)); - panel.setBackground(AppThemeColor.SLIDE_BG); - - JButton edit = componentsFactory.getIconButton( - "app/edit.png", - 17, - AppThemeColor.TRANSPARENT, - "Chat Scanner settings"); -// edit.addActionListener( -// action -> this.settingsFrame.showAuxiliaryFrame( -// new Point(this.getLocation().x,this.getLocation().y), -// this.getPreferredSize().height)); - JButton clear = componentsFactory.getIconButton( - "app/clear-history.png", - 18, - AppThemeColor.TRANSPARENT, - "Clear all"); - clear.addActionListener(action -> { - this.msgContainer.clear(); - this.pack(); - this.repaint(); - }); - JButton sound = componentsFactory.getIconButton( - "app/sound-disable.png", - 18, - AppThemeColor.TRANSPARENT, - "Sound alert"); - sound.addActionListener(action -> { - if (soundEnable) { - sound.setIcon(componentsFactory.getIcon("app/sound-disable.png", 18)); - msgContainer.sound(false); - this.soundEnable = false; - this.repaint(); - } else { - sound.setIcon(componentsFactory.getIcon("app/sound-enable.png", 18)); - msgContainer.sound(true); - this.soundEnable = true; - this.repaint(); - } - }); - - this.scrollEnd = componentsFactory.getIconButton( - "app/scroll-end.png", - 18, - AppThemeColor.TRANSPARENT, - "Automatically scroll down"); - this.scrollEnd.addActionListener(action -> { - if (scrollToBottom) { - this.scrollEnd.setIcon(componentsFactory.getIcon("app/scroll-end-r.png", 18)); - this.scrollToBottom = false; - this.msgContainer.scrollToBottom(false); - this.repaint(); - } else { - this.scrollEnd.setIcon(componentsFactory.getIcon("app/scroll-end.png", 18)); - this.scrollToBottom = true; - this.msgContainer.scrollToBottom(true); - this.repaint(); - } - }); - - panel.add(edit); - panel.add(sound); - panel.add(this.scrollEnd); - panel.add(clear); - - root.add(panel,BorderLayout.CENTER); - return root; - } - - @Override - protected LayoutManager getFrameLayout() { - return new BorderLayout(); - } -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatSettingsCallback.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatSettingsCallback.java deleted file mode 100644 index 530e4f7f..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/chat/ChatSettingsCallback.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.mercury.platform.ui.frame.titled.chat; - - -public interface ChatSettingsCallback { - void onHide(String[] strings); -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryContainer.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryContainer.java deleted file mode 100644 index e2d45e42..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryContainer.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.mercury.platform.ui.frame.titled.container; - -import com.mercury.platform.ui.components.panel.notification.InMessagePanel; - -public interface HistoryContainer { - void onReloadMessage(InMessagePanel inMessagePanel); -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java b/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java index fce9e621..c20ea5f4 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java @@ -11,8 +11,7 @@ import com.mercury.platform.ui.frame.AbstractScalableComponentFrame; import com.mercury.platform.ui.frame.movable.ItemsGridFrame; import com.mercury.platform.ui.frame.movable.AbstractMovableComponentFrame; -import com.mercury.platform.ui.frame.movable.container.MessageFrame; -import com.mercury.platform.ui.frame.movable.container.NotificationFrame; +import com.mercury.platform.ui.frame.movable.NotificationFrame; import com.mercury.platform.ui.frame.other.*; import com.mercury.platform.ui.frame.movable.TaskBarFrame; import com.mercury.platform.ui.adr.AdrState; @@ -21,9 +20,8 @@ import com.mercury.platform.ui.frame.AbstractOverlaidFrame; import com.mercury.platform.ui.frame.setup.location.SetUpLocationCommander; import com.mercury.platform.ui.frame.other.SetUpLocationFrame; -import com.mercury.platform.ui.frame.titled.chat.ChatFilterFrame; -import com.mercury.platform.ui.frame.titled.chat.ChatFilterSettingsFrame; -import com.mercury.platform.ui.frame.titled.container.HistoryFrame; +import com.mercury.platform.ui.frame.titled.ChatFilterSettingsFrame; +import com.mercury.platform.ui.frame.titled.HistoryFrame; import com.mercury.platform.ui.manager.routing.SettingsRoutManager; import com.mercury.platform.ui.misc.MercuryStoreUI; import com.mercury.platform.ui.misc.note.Note; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java b/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java index e121e797..d6c3b4ce 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java @@ -9,7 +9,6 @@ import com.mercury.platform.ui.adr.routing.AdrPageDefinition; import com.mercury.platform.ui.components.panel.grid.ItemInfoPanel; import com.mercury.platform.ui.components.panel.grid.TabInfoPanel; -import com.mercury.platform.ui.components.panel.notification.InMessagePanel; import com.mercury.platform.ui.dialog.DialogCallback; import com.mercury.platform.ui.manager.routing.SettingsPage; import rx.subjects.PublishSubject; @@ -23,7 +22,6 @@ public class MercuryStoreUI { public static final PublishSubject dismissTabInfoPanelSubject = PublishSubject.create(); public static final PublishSubject expandMessageSubject = PublishSubject.create(); public static final PublishSubject itemCellStateSubject = PublishSubject.create(); - public static final PublishSubject reloadMessageSubject = PublishSubject.create(); //Scale public static final PublishSubject> saveScaleSubject = PublishSubject.create(); public static final PublishSubject notificationScaleSubject = PublishSubject.create(); From d909d50eea870c3d83127ff70f86071236b91187 Mon Sep 17 00:00:00 2001 From: Exslims Date: Sun, 20 Aug 2017 16:26:13 +0400 Subject: [PATCH 11/17] Notification panel rework, bug fixes --- .../core/utils/MessageFileHandler.java | 1 + .../TradeIncMessagesInterceptor.java | 92 ----------- .../TradeOutMessagesInterceptor.java | 156 ++++++++++++++++++ .../impl/HotKeyConfigurationService.java | 2 +- .../mercury/platform/ui/adr/AdrManager.java | 1 + .../adr/components/AdrComponentsFactory.java | 18 +- .../components/AdrSingleComponentFrame.java | 1 + .../components/panel/AdrCaptureOutPanel.java | 2 +- .../panel/page/AdrCapturePagePanel.java | 14 +- .../panel/page/AdrMainPagePanel.java | 20 ++- .../IncomingNotificationPanel.java | 2 +- .../OutgoingNotificationPanel.java | 4 +- .../ScannerNotificationPanel.java | 6 +- .../page/NotificationSettingsPagePanel.java | 8 +- .../panel/taskbar/TaskBarPanel.java | 54 +++++- .../ui/frame/other/MercuryLoadingFrame.java | 2 +- .../frame/titled/ChatFilterSettingsFrame.java | 7 +- .../platform/ui/frame/titled/NotesFrame.java | 12 +- .../platform/ui/misc/AppThemeColor.java | 1 + .../platform/ui/misc/TooltipConstants.java | 4 + 20 files changed, 267 insertions(+), 140 deletions(-) create mode 100644 app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeOutMessagesInterceptor.java diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/MessageFileHandler.java b/app-core/src/main/java/com/mercury/platform/core/utils/MessageFileHandler.java index 4f4357a3..c2d511c2 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/MessageFileHandler.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/MessageFileHandler.java @@ -27,6 +27,7 @@ public MessageFileHandler(String logFilePath) { this.datePattern = Pattern.compile(dateRGPattern); this.interceptors.add(new TradeIncMessagesInterceptor()); + this.interceptors.add(new TradeOutMessagesInterceptor()); this.interceptors.add(new PlainMessageInterceptor()); this.interceptors.add(new PlayerJoinInterceptor()); this.interceptors.add(new PlayerLeftInterceptor()); diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeIncMessagesInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeIncMessagesInterceptor.java index 200f9b3f..ec604b24 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeIncMessagesInterceptor.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeIncMessagesInterceptor.java @@ -23,13 +23,9 @@ public class TradeIncMessagesInterceptor extends MessageInterceptor { public TradeIncMessagesInterceptor() { this.config = Configuration.get().notificationConfiguration(); this.clients.add(new EngIncLocalizationMatcher()); - this.clients.add(new EngOutLocalizationMatcher()); this.clients.add(new RuIncLocalizationMatcher()); - this.clients.add(new RuOutLocalizationMatcher()); this.clients.add(new ArabicInLocalizationMatcher()); - this.clients.add(new ArabicOutLocalizationMatcher()); this.clients.add(new BZIncLocalizationMatcher()); - this.clients.add(new BZOutLocalizationMatcher()); } @Override @@ -80,28 +76,6 @@ public String trimString(String src) { return StringUtils.substringAfter(src, "@From"); } } - private class EngOutLocalizationMatcher extends LocalizationMatcher{ - @Override - public boolean isSuitableFor(String message) { - return message.contains("@To") && super.isSuitableFor(message); - } - - @Override - public String trimString(String src) { - return StringUtils.substringAfter(src, "@To"); - } - - @Override - public NotificationDescriptor getDescriptor(String message) { - NotificationDescriptor descriptor = messageParser.parse(this.trimString(message)); - if(descriptor instanceof ItemTradeNotificationDescriptor){ - descriptor.setType(NotificationType.OUT_ITEM_MESSAGE); - }else { - descriptor.setType(NotificationType.OUT_CURRENCY_MESSAGE); - } - return descriptor; - } - } private class RuIncLocalizationMatcher extends LocalizationMatcher{ @Override public boolean isSuitableFor(String message) { @@ -113,28 +87,6 @@ public String trimString(String src) { return StringUtils.substringAfter(src, "@От кого"); } } - private class RuOutLocalizationMatcher extends LocalizationMatcher{ - @Override - public boolean isSuitableFor(String message) { - return message.contains("@Кому") && super.isSuitableFor(message); - } - - @Override - public String trimString(String src) { - return StringUtils.substringAfter(src, "@Кому"); - } - - @Override - public NotificationDescriptor getDescriptor(String message) { - NotificationDescriptor descriptor = messageParser.parse(this.trimString(message)); - if(descriptor instanceof ItemTradeNotificationDescriptor){ - descriptor.setType(NotificationType.OUT_ITEM_MESSAGE); - }else { - descriptor.setType(NotificationType.OUT_CURRENCY_MESSAGE); - } - return descriptor; - } - } private class ArabicInLocalizationMatcher extends LocalizationMatcher{ @Override public boolean isSuitableFor(String message) { @@ -146,28 +98,6 @@ public String trimString(String src) { return StringUtils.substringAfter(src, "@จาก"); } } - private class ArabicOutLocalizationMatcher extends LocalizationMatcher{ - @Override - public boolean isSuitableFor(String message) { - return message.contains("@ถึง") && super.isSuitableFor(message); - } - - @Override - public String trimString(String src) { - return StringUtils.substringAfter(src, "@ถึง"); - } - - @Override - public NotificationDescriptor getDescriptor(String message) { - NotificationDescriptor descriptor = messageParser.parse(this.trimString(message)); - if(descriptor instanceof ItemTradeNotificationDescriptor){ - descriptor.setType(NotificationType.OUT_ITEM_MESSAGE); - }else { - descriptor.setType(NotificationType.OUT_CURRENCY_MESSAGE); - } - return descriptor; - } - } private class BZIncLocalizationMatcher extends LocalizationMatcher{ @Override public boolean isSuitableFor(String message) { @@ -179,26 +109,4 @@ public String trimString(String src) { return StringUtils.substringAfter(src, "@De"); } } - private class BZOutLocalizationMatcher extends LocalizationMatcher{ - @Override - public boolean isSuitableFor(String message) { - return message.contains("@Para") && super.isSuitableFor(message); - } - - @Override - public String trimString(String src) { - return StringUtils.substringAfter(src, "@Para"); - } - - @Override - public NotificationDescriptor getDescriptor(String message) { - NotificationDescriptor descriptor = messageParser.parse(this.trimString(message)); - if(descriptor instanceof ItemTradeNotificationDescriptor){ - descriptor.setType(NotificationType.OUT_ITEM_MESSAGE); - }else { - descriptor.setType(NotificationType.OUT_CURRENCY_MESSAGE); - } - return descriptor; - } - } } diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeOutMessagesInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeOutMessagesInterceptor.java new file mode 100644 index 00000000..447d94c7 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeOutMessagesInterceptor.java @@ -0,0 +1,156 @@ +package com.mercury.platform.core.utils.interceptor; + +import com.mercury.platform.core.misc.SoundType; +import com.mercury.platform.core.utils.interceptor.filter.MessageFilter; +import com.mercury.platform.shared.MessageParser; +import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.configration.PlainConfigurationService; +import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; +import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationType; +import com.mercury.platform.shared.store.MercuryStoreCore; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +public class TradeOutMessagesInterceptor extends MessageInterceptor { + private MessageParser messageParser = new MessageParser(); + private PlainConfigurationService config; + private List clients = new ArrayList<>(); + + public TradeOutMessagesInterceptor() { + this.config = Configuration.get().notificationConfiguration(); + this.clients.add(new EngOutLocalizationMatcher()); + this.clients.add(new RuOutLocalizationMatcher()); + this.clients.add(new ArabicOutLocalizationMatcher()); + this.clients.add(new BZOutLocalizationMatcher()); + } + + @Override + protected void process(String message) { + if(this.config.get().isOutNotificationEnable()) { + LocalizationMatcher localizationMatcher = this.clients.stream() + .filter(matcher -> matcher.isSuitableFor(message)) + .findAny().orElse(null); + if(localizationMatcher != null){ + localizationMatcher.processMessage(message); + } + } + } + + @Override + protected MessageFilter getFilter() { + return message -> + this.clients.stream() + .filter(matcher -> matcher.isSuitableFor(message)) + .findAny().orElse(null) != null; + } + private abstract class LocalizationMatcher { + public boolean isSuitableFor(String message){ + return message.contains("Hi, I would like") || + message.contains("Hi, I'd like") || + (message.contains("wtb") && message.contains("(stash")); + } + public abstract String trimString(String src); + public NotificationDescriptor getDescriptor(String message){ + return messageParser.parse(this.trimString(message)); + } + public void processMessage(String message){ + NotificationDescriptor notificationDescriptor = this.getDescriptor(message); + if (notificationDescriptor != null) { + MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); + } + } + } + + private class EngOutLocalizationMatcher extends LocalizationMatcher{ + @Override + public boolean isSuitableFor(String message) { + return message.contains("@To") && super.isSuitableFor(message); + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@To"); + } + + @Override + public NotificationDescriptor getDescriptor(String message) { + NotificationDescriptor descriptor = messageParser.parse(this.trimString(message)); + if(descriptor instanceof ItemTradeNotificationDescriptor){ + descriptor.setType(NotificationType.OUT_ITEM_MESSAGE); + }else { + descriptor.setType(NotificationType.OUT_CURRENCY_MESSAGE); + } + return descriptor; + } + } + private class RuOutLocalizationMatcher extends LocalizationMatcher{ + @Override + public boolean isSuitableFor(String message) { + return message.contains("@Кому") && super.isSuitableFor(message); + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@Кому"); + } + + @Override + public NotificationDescriptor getDescriptor(String message) { + NotificationDescriptor descriptor = messageParser.parse(this.trimString(message)); + if(descriptor instanceof ItemTradeNotificationDescriptor){ + descriptor.setType(NotificationType.OUT_ITEM_MESSAGE); + }else { + descriptor.setType(NotificationType.OUT_CURRENCY_MESSAGE); + } + return descriptor; + } + } + private class ArabicOutLocalizationMatcher extends LocalizationMatcher{ + @Override + public boolean isSuitableFor(String message) { + return message.contains("@ถึง") && super.isSuitableFor(message); + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@ถึง"); + } + + @Override + public NotificationDescriptor getDescriptor(String message) { + NotificationDescriptor descriptor = messageParser.parse(this.trimString(message)); + if(descriptor instanceof ItemTradeNotificationDescriptor){ + descriptor.setType(NotificationType.OUT_ITEM_MESSAGE); + }else { + descriptor.setType(NotificationType.OUT_CURRENCY_MESSAGE); + } + return descriptor; + } + } + private class BZOutLocalizationMatcher extends LocalizationMatcher{ + @Override + public boolean isSuitableFor(String message) { + return message.contains("@Para") && super.isSuitableFor(message); + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@Para"); + } + + @Override + public NotificationDescriptor getDescriptor(String message) { + NotificationDescriptor descriptor = messageParser.parse(this.trimString(message)); + if(descriptor instanceof ItemTradeNotificationDescriptor){ + descriptor.setType(NotificationType.OUT_ITEM_MESSAGE); + }else { + descriptor.setType(NotificationType.OUT_CURRENCY_MESSAGE); + } + return descriptor; + } + } +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeyConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeyConfigurationService.java index 30474ffd..3b8ce102 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeyConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeyConfigurationService.java @@ -44,7 +44,7 @@ public HotKeysSettingsDescriptor getDefault() { List taskBarNDataList = new ArrayList<>(); taskBarNDataList.add(new HotKeyPair(HotKeyType.T_TO_HIDEOUT,new HotKeyDescriptor("F1",NativeKeyEvent.VC_F1,false,false,false))); - taskBarNDataList.add(new HotKeyPair(HotKeyType.T_DND,new HotKeyDescriptor("F2",NativeKeyEvent.VC_F2,false,false,false))); +// taskBarNDataList.add(new HotKeyPair(HotKeyType.T_DND,new HotKeyDescriptor("F2",NativeKeyEvent.VC_F2,false,false,false))); hotKeysSettingsDescriptor.setIncNHotKeysList(incNDataList); hotKeysSettingsDescriptor.setOutNHotKeysList(outNDataList); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/AdrManager.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/AdrManager.java index c8204d7c..a506954c 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/AdrManager.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/AdrManager.java @@ -202,6 +202,7 @@ public void subscribe() { this.selectedProfile.getContents().remove(descriptor); targetFrame.dispose(); }); + this.mainPanel.setFromGroup(false); this.mainPanel.setPayload(null); this.adrManagerFrame.removeNode(descriptor); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrComponentsFactory.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrComponentsFactory.java index 76f4d383..b0199c2f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrComponentsFactory.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrComponentsFactory.java @@ -402,17 +402,23 @@ public void mouseReleased(MouseEvent e) { }); return opacitySlider; } - public JSlider getFpsSlider(AdrCaptureDescriptor descriptor){ - JSlider opacitySlider = this.componentsFactory.getSlider(1,60, descriptor.getFps()); - opacitySlider.setBackground(AppThemeColor.SLIDE_BG); - opacitySlider.addMouseListener(new MouseAdapter() { + public JPanel getFpsSliderPanel(AdrCaptureDescriptor descriptor){ + JPanel fpsPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.ADR_BG); + JLabel fpsCountLabel = this.componentsFactory.getTextLabel(String.valueOf(descriptor.getFps())); + fpsCountLabel.setPreferredSize(new Dimension(30,26)); + JSlider fpsSlider = this.componentsFactory.getSlider(1,60, descriptor.getFps()); + fpsSlider.setBackground(AppThemeColor.SLIDE_BG); + fpsSlider.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { - descriptor.setFps(opacitySlider.getValue()); + descriptor.setFps(fpsSlider.getValue()); + fpsCountLabel.setText(String.valueOf(fpsSlider.getValue())); MercuryStoreUI.adrReloadSubject.onNext(descriptor); } }); - return opacitySlider; + fpsPanel.add(fpsCountLabel,BorderLayout.LINE_START); + fpsPanel.add(fpsSlider,BorderLayout.CENTER); + return fpsPanel; } public JTextField getFontSizeField(AdrDurationComponentDescriptor descriptor){ return this.getSmartField(descriptor.getFontSize(), new IntegerFieldValidator(4, 1000), value -> { diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrSingleComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrSingleComponentFrame.java index 1aa7edbf..fc64a639 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrSingleComponentFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrSingleComponentFrame.java @@ -70,6 +70,7 @@ public void onDestroy() { super.onDestroy(); this.adrReloadSubscription.unsubscribe(); this.component.onDestroy(); + this.setVisible(false); } @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrCaptureOutPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrCaptureOutPanel.java index e9e3f0be..1585f3d0 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrCaptureOutPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrCaptureOutPanel.java @@ -19,7 +19,7 @@ public void onViewInit() { this.setLayout(new GridLayout(1,1)); this.setPreferredSize(this.descriptor.getCaptureSize()); this.setBackground(AppThemeColor.ADR_CAPTURE_BG); - this.setBorder(BorderFactory.createLineBorder(AppThemeColor.BORDER,4)); + this.setBorder(BorderFactory.createLineBorder(AppThemeColor.BORDER_GREEN,4)); MercuryStoreUI.adrRepaintSubject.onNext(true); } @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrCapturePagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrCapturePagePanel.java index 7cff5d34..01687e9d 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrCapturePagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrCapturePagePanel.java @@ -34,7 +34,7 @@ protected void init() { JPanel locationPanel = this.adrComponentsFactory.getLocationPanel(this.payload, false); JPanel sectorSizePanel = this.adrComponentsFactory.getCaptureSizePanel(this.payload); JPanel sectorLocationPanel = this.adrComponentsFactory.getCaptureLocationPanel(this.payload); - JSlider fpsSlider = this.adrComponentsFactory.getFpsSlider(this.payload); + JPanel fpsPanel = this.adrComponentsFactory.getFpsSliderPanel(this.payload); JPanel generalPanel = this.componentsFactory.getJPanel(new GridLayout(0, 2,0,6)); JPanel specPanel = this.componentsFactory.getJPanel(new GridLayout(0, 2,0,6)); @@ -50,17 +50,17 @@ protected void init() { generalPanel.add(titleField); generalPanel.add(sizeLabel); generalPanel.add(componentSizePanel); - generalPanel.add(locationLabel); - generalPanel.add(locationPanel); generalPanel.add(sectorSizeLabel); generalPanel.add(sectorSizePanel); + generalPanel.add(locationLabel); + generalPanel.add(locationPanel); generalPanel.add(sectorLocationLabel); generalPanel.add(sectorLocationPanel); generalPanel.add(fpsLabel); - generalPanel.add(fpsSlider); + generalPanel.add(fpsPanel); - specPanel.add(opacityLabel); - specPanel.add(opacitySlider); + generalPanel.add(opacityLabel); + generalPanel.add(opacitySlider); specPanel.setVisible(this.advancedExpanded); @@ -80,7 +80,7 @@ public void componentHidden(ComponentEvent e) { advancedPanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); container.add(this.componentsFactory.wrapToSlide(generalPanel)); - container.add(this.componentsFactory.wrapToSlide(advancedPanel)); +// container.add(this.componentsFactory.wrapToSlide(advancedPanel)); container.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrMainPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrMainPagePanel.java index bc8cc5b5..6cad9e0e 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrMainPagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrMainPagePanel.java @@ -61,7 +61,7 @@ public void mouseClicked(MouseEvent e) { } }); JPanel createCaptureComponent = this.getButton( - "app/adr/create_pb_group.png", + "app/adr/capture_icon.png", "Capture"); createCaptureComponent.addMouseListener(new MouseAdapter() { @Override @@ -108,27 +108,29 @@ public void mouseClicked(MouseEvent e) { new AdrImportDialog(importButton).setVisible(true); } }); + JPanel root = this.componentsFactory.getJPanel(new GridLayout(0, 1), AppThemeColor.FRAME); if(this.fromGroup) { switch (((AdrTrackerGroupDescriptor) this.payload).getContentType()){ case ICONS:{ - container.add(this.componentsFactory.wrapToSlide(createIcon)); + root.add(this.componentsFactory.wrapToSlide(createIcon)); break; } case PROGRESS_BARS:{ - container.add(this.componentsFactory.wrapToSlide(createPb)); + root.add(this.componentsFactory.wrapToSlide(createPb)); break; } } }else { - container.add(this.componentsFactory.wrapToSlide(createIcon)); - container.add(this.componentsFactory.wrapToSlide(createPb)); + root.add(this.componentsFactory.wrapToSlide(createIcon)); + root.add(this.componentsFactory.wrapToSlide(createPb)); } if(!this.fromGroup) { - container.add(this.componentsFactory.wrapToSlide(createIconsGroup)); - container.add(this.componentsFactory.wrapToSlide(createPbGroup)); + root.add(this.componentsFactory.wrapToSlide(createCaptureComponent)); + root.add(this.componentsFactory.wrapToSlide(createIconsGroup)); + root.add(this.componentsFactory.wrapToSlide(createPbGroup)); } - container.add(this.componentsFactory.wrapToSlide(createCaptureComponent)); - container.add(this.componentsFactory.wrapToSlide(importButton)); + root.add(this.componentsFactory.wrapToSlide(importButton)); + container.add(root); this.add(verticalContainer,BorderLayout.CENTER); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java index 3a8b599e..d5d98a54 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java @@ -78,7 +78,7 @@ private JPanel getHeader(){ tradeButton.addActionListener(e -> { this.controller.performOfferTrade(); }); - JButton showChatButton = componentsFactory.getIconButton("app/chat_history.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); + JButton showChatButton = componentsFactory.getIconButton("app/chat_history.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.SWITCH_CHAT); showChatButton.addActionListener(e -> { if(this.chatPanel.isVisible()){ this.chatPanel.setVisible(false); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutgoingNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutgoingNotificationPanel.java index f3ef9ed2..ad301615 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutgoingNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutgoingNotificationPanel.java @@ -52,11 +52,11 @@ private JPanel getHeader(){ JPanel interactionPanel = new JPanel(new GridLayout(1,0,6,0)); interactionPanel.setBackground(AppThemeColor.MSG_HEADER); - JButton visiteHideout = componentsFactory.getIconButton("app/visiteHideout.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.INVITE); + JButton visiteHideout = componentsFactory.getIconButton("app/visiteHideout.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.VISIT_HO); visiteHideout.addActionListener(e -> this.controller.visitHideout()); JButton tradeButton = componentsFactory.getIconButton("app/trade.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.TRADE); tradeButton.addActionListener(e -> this.controller.performOfferTrade()); - JButton leaveButton = componentsFactory.getIconButton("app/leave.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.KICK); + JButton leaveButton = componentsFactory.getIconButton("app/leave.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.LEAVE); leaveButton.addActionListener(e -> { this.controller.performLeave(this.config.get().getPlayerNickname()); if(this.config.get().isDismissAfterLeave()){ diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java index 7e79bd19..1a63361e 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java @@ -49,13 +49,13 @@ private JPanel getHeader(){ JPanel interactionPanel = new JPanel(new GridLayout(1,0,6,0)); interactionPanel.setBackground(AppThemeColor.MSG_HEADER); - JButton inviteMeButton = componentsFactory.getIconButton("app/chat_scanner_response.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.INVITE); + JButton inviteMeButton = componentsFactory.getIconButton("app/chat_scanner_response.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.QUICK_RESPONSE); inviteMeButton.addActionListener(e -> this.controller.performResponse(this.config.get().getResponseMessage())); - JButton visiteHideout = componentsFactory.getIconButton("app/visiteHideout.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.INVITE); + JButton visiteHideout = componentsFactory.getIconButton("app/visiteHideout.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.VISIT_HO); visiteHideout.addActionListener(e -> this.controller.visitHideout()); JButton tradeButton = componentsFactory.getIconButton("app/trade.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.TRADE); tradeButton.addActionListener(e -> this.controller.performOfferTrade()); - JButton leaveButton = componentsFactory.getIconButton("app/leave.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.KICK); + JButton leaveButton = componentsFactory.getIconButton("app/leave.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.LEAVE); leaveButton.addActionListener(e -> { this.controller.performLeave(this.nConfig.get().getPlayerNickname()); if(this.nConfig.get().isDismissAfterLeave()){ diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java index 7e460c7a..7f68637e 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java @@ -39,13 +39,13 @@ public void onViewInit() { this.outHotKeySnapshot = CloneHelper.cloneObject(hotKeyService.get().getOutNHotKeysList()); this.scannerHotKeySnapshot = CloneHelper.cloneObject(hotKeyService.get().getScannerNHotKeysList()); this.scannerSnapshot = CloneHelper.cloneObject(scannerService.get()); - JPanel inPanel = this.adrComponentsFactory.getCounterPanel(this.getIncomingPanel(), "Incoming notification:", AppThemeColor.ADR_BG,true); + JPanel inPanel = this.adrComponentsFactory.getCounterPanel(this.getIncomingPanel(), "Incoming notification:", AppThemeColor.ADR_BG,false); inPanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); - JPanel outPanel = this.adrComponentsFactory.getCounterPanel(this.getOutgoingPanel(), "Outgoing notification:", AppThemeColor.ADR_BG,true); + JPanel outPanel = this.adrComponentsFactory.getCounterPanel(this.getOutgoingPanel(), "Outgoing notification:", AppThemeColor.ADR_BG,false); outPanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); - JPanel scannerPanel = this.adrComponentsFactory.getCounterPanel(this.getChatScannerPanel(), "Chat scanner notification:", AppThemeColor.ADR_BG,true); + JPanel scannerPanel = this.adrComponentsFactory.getCounterPanel(this.getChatScannerPanel(), "Chat scanner notification:", AppThemeColor.ADR_BG,false); scannerPanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); - this.container.add(this.componentsFactory.wrapToSlide(this.getGeneralPanel())); + this.container.add(this.componentsFactory.wrapToSlide(this.getGeneralPanel(),4,4,2,4)); this.container.add(this.componentsFactory.wrapToSlide(inPanel,2,4,2,4)); this.container.add(this.componentsFactory.wrapToSlide(outPanel,2,4,2,4)); this.container.add(this.componentsFactory.wrapToSlide(scannerPanel,2,4,2,4)); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarPanel.java index 1666f5f8..17270229 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarPanel.java @@ -1,10 +1,20 @@ package com.mercury.platform.ui.components.panel.taskbar; +import com.mercury.platform.core.ProdStarter; +import com.mercury.platform.shared.FrameVisibleState; +import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.configration.PlainConfigurationService; +import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; +import com.mercury.platform.shared.config.descriptor.HotKeyPair; +import com.mercury.platform.shared.config.descriptor.HotKeyType; +import com.mercury.platform.shared.config.descriptor.HotKeysSettingsDescriptor; +import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.panel.misc.ViewInit; import com.mercury.platform.ui.frame.movable.TaskBarFrame; import com.mercury.platform.ui.manager.FramesManager; import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.MercuryStoreUI; import com.mercury.platform.ui.misc.TooltipConstants; import lombok.NonNull; @@ -12,23 +22,49 @@ import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.util.HashMap; +import java.util.Map; public class TaskBarPanel extends JPanel implements ViewInit { private ComponentsFactory componentsFactory; private TaskBarController controller; - public TaskBarPanel(@NonNull TaskBarController controller){ - this.controller = controller; - this.componentsFactory = new ComponentsFactory(); - onViewInit(); - } + private Map interactButtonMap = new HashMap<>(); + private Map hotKeysPool = new HashMap<>(); + private PlainConfigurationService hotKeysConfig; public TaskBarPanel(@NonNull TaskBarController controller, @NonNull ComponentsFactory factory){ this.controller = controller; this.componentsFactory = factory; - onViewInit(); - } + this.onViewInit(); + MercuryStoreCore.hotKeySubject.subscribe(hotkeyDescriptor -> { + SwingUtilities.invokeLater(() -> { + if(ProdStarter.APP_STATUS.equals(FrameVisibleState.SHOW)){ + JButton button = this.hotKeysPool.get(hotkeyDescriptor); + if(button != null){ + button.doClick(); + } + } + }); + }); + MercuryStoreUI.settingsPostSubject.subscribe(state -> { + this.updateHotKeyPool(); + }); + } + private void updateHotKeyPool(){ + this.hotKeysPool.clear(); + this.interactButtonMap.forEach((type, button) -> { + HotKeyPair hotKeyPair = this.hotKeysConfig.get() + .getTaskBarNHotKeysList() + .stream() + .filter(it -> it.getType().equals(type)) + .findAny().orElse(null); + this.hotKeysPool.put(hotKeyPair.getDescriptor(),button); + }); + } @Override public void onViewInit() { + this.hotKeysConfig = Configuration.get().hotKeysConfiguration(); + this.setBackground(AppThemeColor.FRAME); this.setLayout(new BoxLayout(this,BoxLayout.X_AXIS)); @@ -181,6 +217,10 @@ public void mousePressed(MouseEvent e) { this.add(Box.createRigidArea(new Dimension(3, 4))); this.add(exitButton); this.add(Box.createRigidArea(new Dimension(3, 4))); + + this.interactButtonMap.put(HotKeyType.T_TO_HIDEOUT,toHideOut); +// this.interactButtonMap.put(HotKeyType.T_DND,visibleMode); + this.updateHotKeyPool(); } public int getWidthOf(int elementCount){ diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/other/MercuryLoadingFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/MercuryLoadingFrame.java index 77574b70..83428987 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/other/MercuryLoadingFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/MercuryLoadingFrame.java @@ -54,7 +54,7 @@ public void onViewInit() { this.loadingTracker.setLoadingUI(new MercuryAppLoadingUI(this.loadingTracker)); this.loadingTracker.playLoop(); this.loadingTracker.setForeground(AppThemeColor.ADR_FOOTER_BG); - this.loadingTracker.setBackground(AppThemeColor.BORDER_DARK); + this.loadingTracker.setBackground(AppThemeColor.BORDER_GREEN); this.loadingTracker.setPreferredSize(new Dimension(200,200)); hideAnimation = new Timeline(this); hideAnimation.setDuration(400); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/ChatFilterSettingsFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/ChatFilterSettingsFrame.java index 22a3eb27..d4bcfed2 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/ChatFilterSettingsFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/ChatFilterSettingsFrame.java @@ -5,6 +5,7 @@ import com.mercury.platform.core.utils.interceptor.filter.MessageFilter; import com.mercury.platform.shared.config.Configuration; import com.mercury.platform.shared.config.configration.PlainConfigurationService; +import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; import com.mercury.platform.shared.config.descriptor.ScannerDescriptor; import com.mercury.platform.shared.entity.message.PlainMessageDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; @@ -25,6 +26,7 @@ public class ChatFilterSettingsFrame extends AbstractTitledComponentFrame { private PlainConfigurationService scannerService; + private PlainConfigurationService notificationConfig; private MessageInterceptor currentInterceptor; private Map expiresMessages; private HtmlMessageBuilder messageBuilder; @@ -41,6 +43,7 @@ public ChatFilterSettingsFrame() { @Override public void onViewInit() { this.scannerService = Configuration.get().scannerConfiguration(); + this.notificationConfig = Configuration.get().notificationConfiguration(); this.expiresMessages = ExpiringMap.builder() .expiration(10, TimeUnit.SECONDS) .build(); @@ -165,7 +168,9 @@ protected void process(String stubMessage) { descriptor.setMessage(messageBuilder.build(matcher.group(3))); expiresMessages.put(descriptor.getNickName(), message); - MercuryStoreCore.newScannerMessageSubject.onNext(descriptor); + if(notificationConfig.get().isScannerNotificationEnable()) { + MercuryStoreCore.newScannerMessageSubject.onNext(descriptor); + } MercuryStoreCore.soundSubject.onNext(SoundType.CHAT_SCANNER); } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/NotesFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/NotesFrame.java index 48d4221f..bd626745 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/NotesFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/NotesFrame.java @@ -51,9 +51,12 @@ public void onViewInit() { rootPanel.add(contentPanel,BorderLayout.CENTER); JPanel miscPanel = componentsFactory.getTransparentPanel(new BorderLayout()); - showOnStartUp = new JCheckBox(); - showOnStartUp.setBackground(AppThemeColor.TRANSPARENT); - showOnStartUp.setSelected(this.applicationConfig.get().isShowOnStartUp()); + this.showOnStartUp = new JCheckBox(); + this.showOnStartUp.setBackground(AppThemeColor.TRANSPARENT); + this.showOnStartUp.setSelected(this.applicationConfig.get().isShowOnStartUp()); + this.showOnStartUp.addActionListener(action -> { + this.applicationConfig.get().setShowOnStartUp(showOnStartUp.isSelected()); + }); JPanel showOnStartPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); showOnStartPanel.add(showOnStartUp); @@ -146,12 +149,11 @@ public void mousePressed(MouseEvent e) { if(SwingUtilities.isLeftMouseButton(e)) { NotesFrame.this.setVisible(false); if (type.equals(NotesType.INFO)) { - applicationConfig.get().setShowOnStartUp(showOnStartUp.isSelected()); - MercuryStoreCore.saveConfigSubject.onNext(true); FramesManager.INSTANCE.enableMovementExclude(ItemsGridFrame.class); } prevState = FrameVisibleState.HIDE; } + MercuryStoreCore.saveConfigSubject.onNext(true); } }); close.setBackground(AppThemeColor.FRAME); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/misc/AppThemeColor.java b/app-ui/src/main/java/com/mercury/platform/ui/misc/AppThemeColor.java index 48b7f1dd..acd6fc2e 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/misc/AppThemeColor.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/misc/AppThemeColor.java @@ -13,6 +13,7 @@ public class AppThemeColor { public static final Color TEXT_SUCCESS = new Color(111, 173, 39); public static final Color TEXT_DISABLE = new Color(126,130,122); public static final Color BORDER = new Color(70, 81, 80); + public static final Color BORDER_GREEN = new Color(20, 113, 122); public static final Color BORDER_DARK = new Color(62, 73, 72); public static final Color HEADER_SELECTED_BORDER = new Color(128, 123, 95); public static final Color FRAME = new Color(42, 44, 43,254); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/misc/TooltipConstants.java b/app-ui/src/main/java/com/mercury/platform/ui/misc/TooltipConstants.java index 2bdb3469..8ba1ce4b 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/misc/TooltipConstants.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/misc/TooltipConstants.java @@ -30,6 +30,10 @@ public class TooltipConstants { public static final String TRADE = "Offer Trade"; public static final String EXPAND_COLLAPSE = "Expand / collapse"; public static final String OPEN_CHAT = "Message this player"; + public static final String SWITCH_CHAT = "Show chat history"; + public static final String VISIT_HO = "Visit player's hideout"; + public static final String LEAVE = "Leave from party"; + public static final String QUICK_RESPONSE = "Quick response"; public static final String HIDE_PANEL = "Close"; //OutMessage tooltips From c2735c4622aef31eb715a087f89a410397ce4f41 Mon Sep 17 00:00:00 2001 From: etofok Date: Sun, 20 Aug 2017 16:48:00 +0300 Subject: [PATCH 12/17] Update README.md --- README.md | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 17834ada..86f0a9a1 100644 --- a/README.md +++ b/README.md @@ -37,13 +37,25 @@ Feedback and suggestions: [Github](https://github.com/Exslims/MercuryTrade/issue Overseer is essentially "a customizable and nicely looking set of overlay timers": you press a button and it tracks the time since - that's it. It's obviously 100% legit as there is no interaction with the game whatsoever. It's basically a clever trick, but gets the job done. +Recently Overseer has got a new component: **Capture** - allows you to literally duplicate a part of your screen to display it somewhere else. This feature is especially neat for Vaal Skills for more convenient tracking. Also flasks, charge based abilities, UI counters etc. +   *Major feature:* **Notification**

-When you receive a trade related message this notification panel pops up. It contains all the information you need to make a decision. It offers a set of fully customizable "quick response buttons" - such as "Sold" / "No" / "Wait 3m" / etc - as well as buttons to invite, kick and trade with the person who made the offer. +When you receive a trade related message this notification panel pops up. It contains all the information you need to make a decision. It offers a set of fully customizable "quick response buttons" - such as "Sold" / "No" / "Wait 3m" / etc - as well as buttons to invite, kick and trade with the person who made the offer. There are also "?" - "Still Interested?" and a chat-history button. + +**All the buttons are hotkeyable!** + +You can ignore an item: sold an item 5 hours ago yet people are still spamming you with trade offers? We can't filter out this from chat, but we can make MercuryTrade ignore it! Notifications for ignored items won't appear. + + +Players can enable outgoing trade offers to be diplayed as notifications as well. It has a different panel layout for the essentials such as "Visit Hideout" and "Leave" buttons. + + +

@@ -66,7 +78,7 @@ If you've received multiple notifications before dismissing your current one, th

-

Response buttons are fully customizable

+

Not only Response buttons are fully customizable, look how many things you can actually tweak to your taste!

@@ -83,6 +95,8 @@ If you've received multiple notifications before dismissing your current one, th Each notification you receive is stored in a separate file by **MercuryTrade**. History allows you to access that file in a useful way to interact with customers. Comes in handy if you want to reach a person you traded with some time ago or in case your client has crashed - your in-game chat will be lost, but History will not. +Use "Restore" button to bring back related notification. + #   *Major feature:* **Chat scanner** @@ -90,7 +104,7 @@ Each notification you receive is stored in a separate file by **MercuryTrade**.

-Set up words to look for (or not!) in chat. Extremely useful for when buying something specific from chat. +Set up words to look for (or not!) in chat. Extremely useful for when buying something specific from chat, looking for Trials, specific challenged and other things you might be interested in. # @@ -190,5 +204,5 @@ After you go through the overview, panels will be in "Unlocked" mode. This will - +[![Donate](https://www.paypalobjects.com/webstatic/en_US/i/buttons/PP_logo_h_150x38.png)](https://www.paypal.me/mercurytrade) From d3c3abe67423b90d2b96a93b6ff7578cadbc63e3 Mon Sep 17 00:00:00 2001 From: Exslims Date: Sun, 20 Aug 2017 18:51:25 +0400 Subject: [PATCH 13/17] Notification panel rework, added ignore item --- app-core/pom.xml | 4 ++++ .../TradeIncMessagesInterceptor.java | 17 +++++++++++-- .../shared/store/MercuryStoreCore.java | 1 + .../ItemIncNotificationPanel.java | 24 +++++++++++++++---- .../panel/notification/NotificationPanel.java | 2 ++ .../ui/frame/movable/NotificationFrame.java | 16 +++++++++++++ 6 files changed, 57 insertions(+), 7 deletions(-) diff --git a/app-core/pom.xml b/app-core/pom.xml index 93bd7f86..5dc20f6f 100644 --- a/app-core/pom.xml +++ b/app-core/pom.xml @@ -19,6 +19,10 @@ app-shared 1.0.0.5 + + net.jodah + expiringmap + com.1stleg jnativehook diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeIncMessagesInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeIncMessagesInterceptor.java index ec604b24..d3126b63 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeIncMessagesInterceptor.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeIncMessagesInterceptor.java @@ -10,15 +10,20 @@ import com.mercury.platform.shared.entity.message.NotificationDescriptor; import com.mercury.platform.shared.entity.message.NotificationType; import com.mercury.platform.shared.store.MercuryStoreCore; +import net.jodah.expiringmap.ExpiringMap; import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.TimeUnit; public class TradeIncMessagesInterceptor extends MessageInterceptor { private MessageParser messageParser = new MessageParser(); private PlainConfigurationService config; private List clients = new ArrayList<>(); + private Map expiresMessages; public TradeIncMessagesInterceptor() { this.config = Configuration.get().notificationConfiguration(); @@ -26,6 +31,12 @@ public TradeIncMessagesInterceptor() { this.clients.add(new RuIncLocalizationMatcher()); this.clients.add(new ArabicInLocalizationMatcher()); this.clients.add(new BZIncLocalizationMatcher()); + this.expiresMessages = ExpiringMap.builder() + .expiration(1, TimeUnit.HOURS) + .build(); + MercuryStoreCore.expiredNotificationSubject.subscribe(notificationDescriptor -> { + this.expiresMessages.put(UUID.randomUUID().toString(),StringUtils.substringAfter(notificationDescriptor.getSourceString(),":")); + }); } @Override @@ -60,8 +71,10 @@ public NotificationDescriptor getDescriptor(String message){ public void processMessage(String message){ NotificationDescriptor notificationDescriptor = this.getDescriptor(message); if (notificationDescriptor != null) { - MercuryStoreCore.soundSubject.onNext(SoundType.MESSAGE); - MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); + if(!expiresMessages.containsValue(StringUtils.substringAfter(notificationDescriptor.getSourceString(),":"))) { + MercuryStoreCore.soundSubject.onNext(SoundType.MESSAGE); + MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); + } } } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java index e972e922..8b72d5e8 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java +++ b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java @@ -58,4 +58,5 @@ public class MercuryStoreCore { public static final PublishSubject plainMessageSubject = PublishSubject.create(); public static final PublishSubject newScannerMessageSubject = PublishSubject.create(); public static final PublishSubject removeScannerNotificationSubject = PublishSubject.create(); + public static final PublishSubject expiredNotificationSubject = PublishSubject.create(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemIncNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemIncNotificationPanel.java index 8c1b5f4b..19b2d2a1 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemIncNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemIncNotificationPanel.java @@ -1,6 +1,7 @@ package com.mercury.platform.ui.components.panel.notification; import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; +import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; import com.mercury.platform.ui.misc.AppThemeColor; @@ -12,11 +13,12 @@ public class ItemIncNotificationPanel extends IncomingNotificationPanel { + private JPanel labelsPanel; @Override protected JPanel getMessagePanel() { - JPanel labelsPanel = new JPanel(); - labelsPanel.setLayout(new BorderLayout()); - labelsPanel.setBackground(AppThemeColor.FRAME); + this.labelsPanel = new JPanel(); + this.labelsPanel.setLayout(new BorderLayout()); + this.labelsPanel.setBackground(AppThemeColor.FRAME); JPanel tradePanel = new JPanel(new BorderLayout()); tradePanel.setBackground(AppThemeColor.FRAME); @@ -37,14 +39,26 @@ protected JPanel getMessagePanel() { tradePanel.add(itemButton,BorderLayout.CENTER); tradePanel.add(this.getForPanel(),BorderLayout.LINE_END); - labelsPanel.add(tradePanel,BorderLayout.CENTER); + this.labelsPanel.add(tradePanel,BorderLayout.CENTER); JLabel offerLabel = this.getOfferLabel(); if(offerLabel != null) { - labelsPanel.add(offerLabel, BorderLayout.PAGE_END); + this.labelsPanel.add(offerLabel, BorderLayout.PAGE_END); } return labelsPanel; } + @Override + public void setDuplicate(boolean duplicate) { + if(duplicate){ + JButton ignoreButton = componentsFactory.getIconButton("app/adr/visible_node_off.png", 15, AppThemeColor.FRAME, "Ignore item 1 hour"); + ignoreButton.addActionListener(e -> { + MercuryStoreCore.expiredNotificationSubject.onNext(this.data); + this.controller.performHide(); + }); + this.labelsPanel.add(ignoreButton, BorderLayout.LINE_START); + } + } + @Override protected JButton getStillInterestedButton() { JButton stillIntButton = componentsFactory.getIconButton("app/still-interesting.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.STILL_INTERESTED); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java index e044665d..6124fe46 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java @@ -37,6 +37,8 @@ public abstract class NotificationPanel extends JPanel implements AsSubscri protected float paintBorderValue = 0f; protected boolean blurEffect; protected boolean blurReverse; + @Setter + protected boolean duplicate; private Subscription settingsPostSubscription; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/NotificationFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/NotificationFrame.java index df551794..5a0231b9 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/NotificationFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/NotificationFrame.java @@ -1,12 +1,15 @@ package com.mercury.platform.ui.frame.movable; import com.mercury.platform.core.ProdStarter; +import com.mercury.platform.core.utils.interceptor.TradeIncMessagesInterceptor; import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.config.Configuration; import com.mercury.platform.shared.config.configration.PlainConfigurationService; import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; import com.mercury.platform.shared.entity.message.FlowDirections; +import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; import com.mercury.platform.shared.entity.message.NotificationType; +import com.mercury.platform.shared.entity.message.TradeNotificationDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.fields.font.FontStyle; @@ -20,16 +23,21 @@ import com.mercury.platform.ui.frame.titled.TestEngine; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.MercuryStoreUI; +import net.jodah.expiringmap.ExpiringMap; +import net.jodah.expiringmap.ExpiringValue; +import org.apache.commons.lang3.StringUtils; import javax.swing.*; import javax.swing.Timer; import java.awt.*; import java.util.*; import java.util.List; +import java.util.concurrent.TimeUnit; public class NotificationFrame extends AbstractMovableComponentFrame { private List notificationPanels; + private List currentOffers; private PlainConfigurationService config; private NotificationPanelFactory providersFactory; private JPanel container; @@ -50,6 +58,7 @@ protected void initialize() { public void onViewInit() { this.getRootPane().setBorder(null); this.setBackground(AppThemeColor.TRANSPARENT); + this.currentOffers = new ArrayList<>(); this.container = new JPanel(); this.container.setBackground(AppThemeColor.TRANSPARENT); this.container.setLayout(new BoxLayout(container,BoxLayout.Y_AXIS)); @@ -70,6 +79,12 @@ public void subscribe() { .setData(notification) .setComponentsFactory(this.componentsFactory) .build(); + String message = StringUtils.substringAfter(notification.getSourceString(), ":"); + if(this.currentOffers.contains(message)){ + notificationPanel.setDuplicate(true); + }else { + this.currentOffers.add(message); + } this.addNotification(notificationPanel); if(this.notificationPanels.size() > 1 && this.config.get().getFlowDirections().equals(FlowDirections.UPWARDS) @@ -100,6 +115,7 @@ public void subscribe() { NotificationPanel notificationPanel = this.notificationPanels.stream() .filter(it -> it.getData().equals(notification)) .findAny().orElse(null); + this.currentOffers.remove(StringUtils.substringAfter(notification.getSourceString(), ":")); this.removeNotification(notificationPanel); }); }); From a670a7f54c06c7d98c288517523cd3a86f908d61 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sun, 20 Aug 2017 19:01:17 +0400 Subject: [PATCH 14/17] Update README.md --- README.md | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 86f0a9a1..34f08785 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Recently Overseer has got a new component: **Capture** - allows you to literally

-When you receive a trade related message this notification panel pops up. It contains all the information you need to make a decision. It offers a set of fully customizable "quick response buttons" - such as "Sold" / "No" / "Wait 3m" / etc - as well as buttons to invite, kick and trade with the person who made the offer. There are also "?" - "Still Interested?" and a chat-history button. +When you receive a trade related message or scanner message this notification panel pops up. It contains all the information you need to make a decision. It offers a set of fully customizable "quick response buttons" - such as "Sold" / "No" / "Wait 3m" / etc - as well as buttons to invite, kick and trade with the person who made the offer. There are also "?" - "Still Interested?" and a chat-history button. **All the buttons are hotkeyable!** @@ -54,23 +54,13 @@ You can ignore an item: sold an item 5 hours ago yet people are still spamming y Players can enable outgoing trade offers to be diplayed as notifications as well. It has a different panel layout for the essentials such as "Visit Hideout" and "Leave" buttons. - - -

Multiple notifications

-If you've received multiple notifications before dismissing your current one, they will stack up like a deck of cards underneath (or on top) of each other and won't clutter the screen. Notification panels can be set up to fade out after X seconds - a customizable option. - -

- -

- -

"Group" showcase: you received 5 notifications

- +If you've received multiple notifications before dismissing your current one, they will stack up like a deck of cards underneath (or on top) of each other and won't clutter the screen.

The box on the left - "Group" - will appear if "Pre-group limit" is exceeded (this limit is also customizable). All consecutive notifications will be grouped together to save screen space. Toggling this button will expand the whole group.

@@ -88,7 +78,7 @@ If you've received multiple notifications before dismissing your current one, th   *Minor feature:* **History**

- +

History

@@ -101,10 +91,10 @@ Use "Restore" button to bring back related notification.   *Major feature:* **Chat scanner**

- +

-Set up words to look for (or not!) in chat. Extremely useful for when buying something specific from chat, looking for Trials, specific challenged and other things you might be interested in. +Set up words to look for (or not!) in chat. Extremely useful for when buying something specific from chat, looking for Trials, specific challenged and other things you might be interested in. Works in conjunction with the notification panel. # From b2e2895664508291c328f171f055b29181078b59 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sun, 20 Aug 2017 19:03:42 +0400 Subject: [PATCH 15/17] Update README.md --- README.md | 61 ------------------------------------------------------- 1 file changed, 61 deletions(-) diff --git a/README.md b/README.md index 34f08785..bd027107 100644 --- a/README.md +++ b/README.md @@ -116,22 +116,6 @@ Mercury can highlight the stash location of the item somebody's buying. You will

Item Grid set up.

- -# - -  *Minor feature:* **Accessibility status** -

- -

- -

Name will change its color accordingly

- - -**MercuryTrade** notifications have an **indication for when a person comes in or leaves your hideout** - that way you can offer a trade as soon as possible and keep track of all the people without even closing your stash. Especially useful for SuperTrade mode. - - -Important to mention: in Path of Exile when you use your stash you can't click on party frames, because they're hidden behind the stash window. **MercuryTrade** solves this inconvenience as you can interact with the person through a related notification panel. - #   *Minor feature:* **Do not Disturb** @@ -151,48 +135,3 @@ Activate this mode if you don't want to see (and hear!) anything from the applic Download and install Java on your computer, then open MercuryTrade.jar. Because the program operates on top of a Path of Exile window as an overlay, **make sure your client is not in fullscreen mode**. Upon launch you'll be greeted with a short overview of the application (identical to this ReadMe) and patch notes. Afterwards you should see **Task Panel** and **Notification Panel**. - - -
- -**Task panel**: - -

- -

- - -* (1) **Travel to Hideout**. - -* (2) **Do Not Disturb** mode button switch. - -* (3) **Chat scanner**. - -* (4) **History**. - -* (5) **Item Grid** set up. - -* (6) **Panel unlock**. - -* (7) **Scale setting**. - -* (8) **Settings**. - -* (9) **Exit**. - -
- -**Notification panel** *(unlocked mode)* - -

- -

- -
- -After you go through the overview, panels will be in "Unlocked" mode. This will allow you to reposition them to your taste. - - - -[![Donate](https://www.paypalobjects.com/webstatic/en_US/i/buttons/PP_logo_h_150x38.png)](https://www.paypal.me/mercurytrade) - From 58da88791f0f2301c0121f448fee66be4a0e711b Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sun, 20 Aug 2017 19:05:24 +0400 Subject: [PATCH 16/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bd027107..aba04137 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ When you receive a trade related message or scanner message this notification pa You can ignore an item: sold an item 5 hours ago yet people are still spamming you with trade offers? We can't filter out this from chat, but we can make MercuryTrade ignore it! Notifications for ignored items won't appear. -Players can enable outgoing trade offers to be diplayed as notifications as well. It has a different panel layout for the essentials such as "Visit Hideout" and "Leave" buttons. +Outgoing trade offers and messages from chat scanner to be diplayed as notifications as well. It has a different panel layout for the essentials such as "Visit Hideout" and "Leave" buttons.

From ff2f654f966d33665ea02c95be1c0ac2200761d9 Mon Sep 17 00:00:00 2001 From: Exslims Date: Sun, 20 Aug 2017 19:40:11 +0400 Subject: [PATCH 17/17] 1.0.1.8 release commit --- .../java/com/mercury/platform/core/MercuryConstants.java | 2 +- .../configration/impl/FramesConfigurationServiceImpl.java | 4 ++-- .../components/panel/taskbar/MercuryTaskBarController.java | 4 ++-- .../{ChatFilterSettingsFrame.java => ChatScannerFrame.java} | 6 +++--- .../com/mercury/platform/ui/frame/titled/NotesFrame.java | 2 +- .../java/com/mercury/platform/ui/manager/FramesManager.java | 4 ++-- app-ui/src/main/resources/notes/patch/patch-notes.json | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) rename app-ui/src/main/java/com/mercury/platform/ui/frame/titled/{ChatFilterSettingsFrame.java => ChatScannerFrame.java} (98%) diff --git a/app-core/src/main/java/com/mercury/platform/core/MercuryConstants.java b/app-core/src/main/java/com/mercury/platform/core/MercuryConstants.java index 5d560e0f..ae012210 100644 --- a/app-core/src/main/java/com/mercury/platform/core/MercuryConstants.java +++ b/app-core/src/main/java/com/mercury/platform/core/MercuryConstants.java @@ -1,7 +1,7 @@ package com.mercury.platform.core; public class MercuryConstants { - public static final String APP_VERSION = "1.0.1.7.0"; + public static final String APP_VERSION = "1.0.1.8.0"; public static final String SERVER_HOST = "exslims.ddns.net"; public static final int PORT = 5555; } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/FramesConfigurationServiceImpl.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/FramesConfigurationServiceImpl.java index 5ff4bb07..9cd009df 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/FramesConfigurationServiceImpl.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/FramesConfigurationServiceImpl.java @@ -68,7 +68,7 @@ private void initMinimumMap() { minimumFrameSize.put("SettingsFrame",new Dimension(600,400)); minimumFrameSize.put("HistoryFrame",new Dimension(280,400)); minimumFrameSize.put("TimerFrame",new Dimension(240,102)); - minimumFrameSize.put("ChatFilterFrame",new Dimension(400,100)); + minimumFrameSize.put("ChatScannerFrame",new Dimension(450,100)); minimumFrameSize.put("ItemsGridFrame",new Dimension(150,150)); minimumFrameSize.put("NotesFrame",new Dimension(540,100)); minimumFrameSize.put("ChatFilterSettingsFrame",new Dimension(300,200)); @@ -85,7 +85,7 @@ private void initDefaultMap() { defaultFramesSettings.put("SettingsFrame", new FrameDescriptor(new Point(600, 600), new Dimension(800,600))); defaultFramesSettings.put("HistoryFrame", new FrameDescriptor(new Point(600, 500), new Dimension(280, 400))); defaultFramesSettings.put("TimerFrame", new FrameDescriptor(new Point(400, 600), new Dimension(240, 102))); - defaultFramesSettings.put("ChatFilterFrame", new FrameDescriptor(new Point(400, 600), new Dimension(500, 300))); + defaultFramesSettings.put("ChatScannerFrame", new FrameDescriptor(new Point(400, 600), new Dimension(550, 220))); defaultFramesSettings.put("ItemsGridFrame", new FrameDescriptor(new Point(12, 79), new Dimension(641, 718))); defaultFramesSettings.put("NotesFrame", new FrameDescriptor(new Point(400, 600), new Dimension(540, 100))); defaultFramesSettings.put("ChatFilterSettingsFrame", new FrameDescriptor(new Point(400, 600), new Dimension(320, 200))); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/MercuryTaskBarController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/MercuryTaskBarController.java index e212e553..c5961698 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/MercuryTaskBarController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/MercuryTaskBarController.java @@ -3,7 +3,7 @@ import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.frame.movable.ItemsGridFrame; import com.mercury.platform.ui.frame.movable.TaskBarFrame; -import com.mercury.platform.ui.frame.titled.ChatFilterSettingsFrame; +import com.mercury.platform.ui.frame.titled.ChatScannerFrame; import com.mercury.platform.ui.frame.titled.HistoryFrame; import com.mercury.platform.ui.frame.titled.SettingsFrame; import com.mercury.platform.ui.manager.FramesManager; @@ -36,7 +36,7 @@ public void performHideout() { @Override public void showChatFiler() { - FramesManager.INSTANCE.hideOrShowFrame(ChatFilterSettingsFrame.class); + FramesManager.INSTANCE.hideOrShowFrame(ChatScannerFrame.class); } @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/ChatFilterSettingsFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/ChatScannerFrame.java similarity index 98% rename from app-ui/src/main/java/com/mercury/platform/ui/frame/titled/ChatFilterSettingsFrame.java rename to app-ui/src/main/java/com/mercury/platform/ui/frame/titled/ChatScannerFrame.java index d4bcfed2..a575b510 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/ChatFilterSettingsFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/ChatScannerFrame.java @@ -24,7 +24,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -public class ChatFilterSettingsFrame extends AbstractTitledComponentFrame { +public class ChatScannerFrame extends AbstractTitledComponentFrame { private PlainConfigurationService scannerService; private PlainConfigurationService notificationConfig; private MessageInterceptor currentInterceptor; @@ -32,7 +32,7 @@ public class ChatFilterSettingsFrame extends AbstractTitledComponentFrame { private HtmlMessageBuilder messageBuilder; private boolean running; - public ChatFilterSettingsFrame() { + public ChatScannerFrame() { super(); this.processingHideEvent = false; this.setFocusableWindowState(true); @@ -219,7 +219,7 @@ private JPanel getMemo(){ @Override protected String getFrameTitle() { - return "Chat filter settings"; + return "Chat scanner"; } @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/NotesFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/NotesFrame.java index bd626745..b234f17d 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/NotesFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/NotesFrame.java @@ -93,7 +93,7 @@ private JPanel getNavBar(){ JButton donate = componentsFactory.getBorderedButton("Donate"); donate.addActionListener(action -> { try { - Desktop.getDesktop().browse(new URI("https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=HJVSYP4YR7V88&lc=US&item_name=MercuryTrade¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted")); + Desktop.getDesktop().browse(new URI("https://www.paypal.me/mercurytrade")); } catch (Exception e1) { e1.printStackTrace(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java b/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java index c20ea5f4..1000f988 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java @@ -20,7 +20,7 @@ import com.mercury.platform.ui.frame.AbstractOverlaidFrame; import com.mercury.platform.ui.frame.setup.location.SetUpLocationCommander; import com.mercury.platform.ui.frame.other.SetUpLocationFrame; -import com.mercury.platform.ui.frame.titled.ChatFilterSettingsFrame; +import com.mercury.platform.ui.frame.titled.ChatScannerFrame; import com.mercury.platform.ui.frame.titled.HistoryFrame; import com.mercury.platform.ui.manager.routing.SettingsRoutManager; import com.mercury.platform.ui.misc.MercuryStoreUI; @@ -80,7 +80,7 @@ public void start(){ this.framesMap.put(TooltipFrame.class,new TooltipFrame()); this.framesMap.put(NotificationAlertFrame.class,new NotificationAlertFrame()); this.framesMap.put(MercuryLoadingFrame.class,new MercuryLoadingFrame()); - this.framesMap.put(ChatFilterSettingsFrame.class,new ChatFilterSettingsFrame()); + this.framesMap.put(ChatScannerFrame.class,new ChatScannerFrame()); this.framesMap.put(UpdateReadyFrame.class,new UpdateReadyFrame()); this.framesMap.put(TaskBarFrame.class,taskBarFrame); this.framesMap.put(SetUpLocationFrame.class,new SetUpLocationFrame()); diff --git a/app-ui/src/main/resources/notes/patch/patch-notes.json b/app-ui/src/main/resources/notes/patch/patch-notes.json index dc762584..9e37d271 100644 --- a/app-ui/src/main/resources/notes/patch/patch-notes.json +++ b/app-ui/src/main/resources/notes/patch/patch-notes.json @@ -1,9 +1,9 @@ { - "version":"1.0.1.7.0", + "version":"1.0.1.8.0", "notes":[ { "title" : "Update", - "text" : "More than 5000 unique users this week! Here is an update for you!\n-Completely reworked Settings GUI.\n-All the issues with non-English keyboard layouts should be gone. Also now you can bind absolutely any mouse / keyboard button you have.\n-Fixed an issue when you couldn't close Notification panel.\n-Now components are cleaned up properly on a profile switch.\nCheck out the Overseer channel on Discord - post your setups, share profiles and converse!\n\nStay with us as there are more mind-blowing features to come. And don't forget to support the app, judging from all the activity looks like it's probably worth some!", + "text" : "Just this week we've got more than 6000 new users which is insane. The update we're rolling out today affects every aspect of the application - basically a big rework of the core systems.\n\n- Notification panel rework (more info on reddit)\n- Overseer: new component \"Capture\".\n- All the buttons are now hotkeyable.\n- Chat scanner and history rework.\n- More responsive interface.\n\nA lot of work has been done, but that's it for today. Stay with us!", "image" : "", "layout" : "VERTICAL" }