From a48773b04712bd3664bb8d05a4faf92267b6cb5c Mon Sep 17 00:00:00 2001 From: Exslims Date: Tue, 4 Apr 2017 19:09:47 +0400 Subject: [PATCH 01/15] Added sound tab to settings, added volume settings, refactoring SoundNotifier --- .../platform/core/misc/SoundNotifier.java | 24 ++--- .../IncTradeMessagesInterceptor.java | 4 +- .../events/custom/ButtonPressedEvent.java | 9 -- .../events/custom/ChatFilterMessageEvent.java | 7 -- .../events/custom/SoundNotificationEvent.java | 33 +++++++ .../custom/WhisperNotificationEvent.java | 8 -- .../ui/components/ComponentsFactory.java | 29 +++++- .../panel/chat/ChatFilterPanel.java | 4 +- .../panel/settings/SoundSettingsPanel.java | 94 +++++++++++++++++++ .../ui/frame/titled/SettingsFrame.java | 3 + .../ui/frame/titled/TestCasesFrame.java | 2 +- .../ui/frame/titled/chat/ChatFilterFrame.java | 1 - 12 files changed, 174 insertions(+), 44 deletions(-) delete mode 100644 app-core/src/main/java/com/mercury/platform/shared/events/custom/ButtonPressedEvent.java delete mode 100644 app-core/src/main/java/com/mercury/platform/shared/events/custom/ChatFilterMessageEvent.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/events/custom/SoundNotificationEvent.java delete mode 100644 app-core/src/main/java/com/mercury/platform/shared/events/custom/WhisperNotificationEvent.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java diff --git a/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java b/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java index b69d2a76..14e0e1ba 100644 --- a/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java +++ b/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java @@ -18,40 +18,42 @@ public class SoundNotifier { private final Logger logger = LogManager.getLogger(SoundNotifier.class); private boolean dnd = false; public SoundNotifier() { - EventRouter.CORE.registerHandler(WhisperNotificationEvent.class, event -> { + EventRouter.CORE.registerHandler(SoundNotificationEvent.WhisperSoundNotificationEvent.class, event -> { WhisperNotifierStatus status = ConfigManager.INSTANCE.getWhisperNotifier(); if (status == WhisperNotifierStatus.ALWAYS || ((status == WhisperNotifierStatus.ALTAB) && (AppStarter.APP_STATUS == FrameStates.HIDE))) { - play("app/notification.wav"); + play("app/notification.wav",((SoundNotificationEvent.WhisperSoundNotificationEvent)event).getDb()); } }); EventRouter.CORE.registerHandler(UpdateInfoEvent.class, event -> { - play("app/patch_tone.wav"); + play("app/patch_tone.wav",0); }); - EventRouter.CORE.registerHandler(ChatFilterMessageEvent.class, event -> { - play("app/chat-filter.wav"); + EventRouter.CORE.registerHandler(SoundNotificationEvent.ChatScannerSoundNotificationEvent.class, event -> { + play("app/chat-filter.wav",((SoundNotificationEvent.ChatScannerSoundNotificationEvent)event).getDb()); }); EventRouter.CORE.registerHandler(DndModeEvent.class, event -> { this.dnd = ((DndModeEvent)event).isDnd(); }); - EventRouter.CORE.registerHandler(ButtonPressedEvent.class, event -> { + EventRouter.CORE.registerHandler(SoundNotificationEvent.ClicksSoundNotificationEvent.class, event -> { String[] clicks = { "app/sounds/click1/button-pressed-10.wav", "app/sounds/click1/button-pressed-20.wav", "app/sounds/click1/button-pressed-30.wav"}; - play(clicks[new Random().nextInt(3)]); + play(clicks[new Random().nextInt(3)],((SoundNotificationEvent.ClicksSoundNotificationEvent)event).getDb()); }); } - private void play(String wavPath){ + private void play(String wavPath, float db){ if(!dnd) { ClassLoader classLoader = getClass().getClassLoader(); try (AudioInputStream stream = AudioSystem.getAudioInputStream(classLoader.getResource(wavPath))) { Clip clip = AudioSystem.getClip(); clip.open(stream); - FloatControl gainControl = - (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN); - gainControl.setValue(-5.0f); + if(db != 0.0) { + FloatControl gainControl = + (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN); + gainControl.setValue(db); + } clip.start(); } catch (Exception e) { logger.error("Cannot start playing wav file: ",e); diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/IncTradeMessagesInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/IncTradeMessagesInterceptor.java index e1534595..a40d551b 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/IncTradeMessagesInterceptor.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/IncTradeMessagesInterceptor.java @@ -4,7 +4,7 @@ import com.mercury.platform.shared.MessageParser; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.NewWhispersEvent; -import com.mercury.platform.shared.events.custom.WhisperNotificationEvent; +import com.mercury.platform.shared.events.custom.SoundNotificationEvent; import com.mercury.platform.shared.pojo.Message; import org.apache.commons.lang3.StringUtils; @@ -18,7 +18,7 @@ public class IncTradeMessagesInterceptor extends MessageInterceptor { protected void process(String message) { Message parsedMessage = messageParser.parse(StringUtils.substringAfter(message,"@")); if(parsedMessage != null) { - EventRouter.CORE.fireEvent(new WhisperNotificationEvent()); + EventRouter.CORE.fireEvent(new SoundNotificationEvent.WhisperSoundNotificationEvent()); EventRouter.CORE.fireEvent(new NewWhispersEvent(parsedMessage)); } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/events/custom/ButtonPressedEvent.java b/app-core/src/main/java/com/mercury/platform/shared/events/custom/ButtonPressedEvent.java deleted file mode 100644 index 889bedc0..00000000 --- a/app-core/src/main/java/com/mercury/platform/shared/events/custom/ButtonPressedEvent.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.mercury.platform.shared.events.custom; - -import com.mercury.platform.shared.events.MercuryEvent; - -/** - * Created by Константин on 01.03.2017. - */ -public class ButtonPressedEvent implements MercuryEvent { -} diff --git a/app-core/src/main/java/com/mercury/platform/shared/events/custom/ChatFilterMessageEvent.java b/app-core/src/main/java/com/mercury/platform/shared/events/custom/ChatFilterMessageEvent.java deleted file mode 100644 index 5568ca6b..00000000 --- a/app-core/src/main/java/com/mercury/platform/shared/events/custom/ChatFilterMessageEvent.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.mercury.platform.shared.events.custom; - -import com.mercury.platform.shared.events.MercuryEvent; - - -public class ChatFilterMessageEvent implements MercuryEvent { -} diff --git a/app-core/src/main/java/com/mercury/platform/shared/events/custom/SoundNotificationEvent.java b/app-core/src/main/java/com/mercury/platform/shared/events/custom/SoundNotificationEvent.java new file mode 100644 index 00000000..645728fb --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/events/custom/SoundNotificationEvent.java @@ -0,0 +1,33 @@ +package com.mercury.platform.shared.events.custom; + +import com.mercury.platform.shared.events.MercuryEvent; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SoundNotificationEvent implements MercuryEvent { + private Float db = 0f; + + @NoArgsConstructor + public static class WhisperSoundNotificationEvent extends SoundNotificationEvent { + public WhisperSoundNotificationEvent(Float db) { + super(db); + } + } + @NoArgsConstructor + public static class ChatScannerSoundNotificationEvent extends SoundNotificationEvent { + public ChatScannerSoundNotificationEvent(Float db) { + super(db); + } + } + @NoArgsConstructor + public static class ClicksSoundNotificationEvent extends SoundNotificationEvent { + public ClicksSoundNotificationEvent(Float db) { + super(db); + } + } +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/events/custom/WhisperNotificationEvent.java b/app-core/src/main/java/com/mercury/platform/shared/events/custom/WhisperNotificationEvent.java deleted file mode 100644 index 75569302..00000000 --- a/app-core/src/main/java/com/mercury/platform/shared/events/custom/WhisperNotificationEvent.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.mercury.platform.shared.events.custom; - - -import com.mercury.platform.shared.events.MercuryEvent; - - -public class WhisperNotificationEvent implements MercuryEvent { -} 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 5c1fd2d3..bcd6f7ee 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 @@ -1,8 +1,8 @@ package com.mercury.platform.ui.components; import com.mercury.platform.shared.events.EventRouter; -import com.mercury.platform.shared.events.custom.ButtonPressedEvent; import com.mercury.platform.shared.events.custom.HideTooltipEvent; +import com.mercury.platform.shared.events.custom.SoundNotificationEvent; import com.mercury.platform.ui.misc.event.ShowTooltipEvent; import com.mercury.platform.ui.components.fields.style.MercuryComboBoxUI; import com.mercury.platform.ui.components.fields.font.FontStyle; @@ -21,6 +21,7 @@ import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; import java.awt.image.BufferedImage; import java.io.IOException; @@ -83,7 +84,7 @@ protected void paintBorder(Graphics g) { @Override public void mousePressed(MouseEvent e) { if(SwingUtilities.isLeftMouseButton(e)) { - EventRouter.CORE.fireEvent(new ButtonPressedEvent()); + EventRouter.CORE.fireEvent(new SoundNotificationEvent.ClicksSoundNotificationEvent()); } } }); @@ -196,7 +197,7 @@ public void mousePressed(MouseEvent e) { @Override public void mousePressed(MouseEvent e) { if(SwingUtilities.isLeftMouseButton(e)) { - EventRouter.CORE.fireEvent(new ButtonPressedEvent()); + EventRouter.CORE.fireEvent(new SoundNotificationEvent.ClicksSoundNotificationEvent()); } } }); @@ -475,6 +476,28 @@ public JSlider getSlider(int min, int max, int value){ JSlider slider = new JSlider(JSlider.HORIZONTAL,min,max,value); slider.setMajorTickSpacing(10); slider.setMinorTickSpacing(1); + slider.addMouseMotionListener(new MouseMotionAdapter() { + @Override + public void mouseDragged(MouseEvent e) { + slider.getParent().repaint(); + } + }); + slider.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + slider.getParent().repaint(); + } + + @Override + public void mousePressed(MouseEvent e) { + slider.getParent().repaint(); + } + + @Override + public void mouseReleased(MouseEvent e) { + slider.getParent().repaint(); + } + }); slider.setBackground(AppThemeColor.TRANSPARENT); return slider; } 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 9609d663..a8c52646 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,7 +1,7 @@ package com.mercury.platform.ui.components.panel.chat; import com.mercury.platform.shared.events.EventRouter; -import com.mercury.platform.shared.events.custom.ChatFilterMessageEvent; +import com.mercury.platform.shared.events.custom.SoundNotificationEvent; import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.fields.style.MercuryScrollBarUI; import com.mercury.platform.ui.components.panel.VerticalScrollContainer; @@ -112,7 +112,7 @@ private void addMessageToFilter(String message) { expiresMessages.put(nickname,message); EventRouter.UI.fireEvent(new PackEvent.PackChatFilter()); if(soundEnable){ - EventRouter.CORE.fireEvent(new ChatFilterMessageEvent()); + EventRouter.CORE.fireEvent(new SoundNotificationEvent.ChatScannerSoundNotificationEvent()); } if(scrollToBottom) { container.scrollRectToVisible(new Rectangle(0, container.getHeight() - 1, 1, 1)); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java new file mode 100644 index 00000000..c4639da2 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java @@ -0,0 +1,94 @@ +package com.mercury.platform.ui.components.panel.settings; + +import com.mercury.platform.shared.events.EventRouter; +import com.mercury.platform.shared.events.custom.SoundNotificationEvent; +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 javax.swing.border.CompoundBorder; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +public class SoundSettingsPanel extends ConfigurationPanel { + + public SoundSettingsPanel() { + super(); + this.createUI(); + } + + @Override + public void createUI() { + verticalScrollContainer.add(getVolumePanel(),BorderLayout.CENTER); + } + + private JPanel getVolumePanel(){ + JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); + + JLabel volumeLabel = componentsFactory.getTextLabel(FontStyle.REGULAR, AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP, 17f, "Volume"); + volumeLabel.setBorder( + new CompoundBorder( + BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), + BorderFactory.createEmptyBorder(3,5,3,5))); + + + JPanel container = componentsFactory.getTransparentPanel(new GridLayout(3, 2)); + container.setBackground(AppThemeColor.SETTINGS_BG); + container.setBorder(new CompoundBorder( + BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), + BorderFactory.createEmptyBorder(3,0,3,0))); + + JSlider notificationSlider = componentsFactory.getSlider(-40, 6, 0); + notificationSlider.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + EventRouter.CORE.fireEvent( + new SoundNotificationEvent.WhisperSoundNotificationEvent( + notificationSlider.getValue() == -40 ? -80f : (float)notificationSlider.getValue()) + ); + } + }); + JSlider chatScannerSlider = componentsFactory.getSlider(-40, 6, 0); + chatScannerSlider.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + EventRouter.CORE.fireEvent( + new SoundNotificationEvent.ChatScannerSoundNotificationEvent( + chatScannerSlider.getValue() == -40 ? -80f : (float)chatScannerSlider.getValue()) + ); + } + }); + JSlider clicksSlider = componentsFactory.getSlider(-40, 6, 0); + clicksSlider.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + EventRouter.CORE.fireEvent( + new SoundNotificationEvent.ClicksSoundNotificationEvent( + clicksSlider.getValue() == -40 ? -80f : (float)clicksSlider.getValue()) + ); + } + }); + container.add(componentsFactory.getTextLabel("Notification:")); + container.add(notificationSlider); + container.add(componentsFactory.getTextLabel("Chat Scanner")); + container.add(chatScannerSlider); + container.add(componentsFactory.getTextLabel("Clicks")); + container.add(clicksSlider); + + root.add(volumeLabel,BorderLayout.PAGE_START); + root.add(container,BorderLayout.CENTER); + return root; + } + + @Override + public boolean processAndSave() { + return true; + } + + @Override + public void restore() { + + } +} 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 0d94008c..dba7ae6c 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 @@ -43,8 +43,11 @@ private void initContainer() { innerPanels.add(cbSettings); ConfigurationPanel taskBarSettings = new TaskBarSettingsPanel(); innerPanels.add(taskBarSettings); + ConfigurationPanel soundSettings = new SoundSettingsPanel(); + innerPanels.add(soundSettings); tabbedPane.addTab("General",generalSettings); + tabbedPane.addTab("Sound",soundSettings); tabbedPane.addTab("Notification panel",cbSettings); tabbedPane.addTab("Task panel",taskBarSettings); // tabbedPane.addTab("Help",new HelpPanel()); 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 47a24816..d4f717fe 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 @@ -214,7 +214,7 @@ public void mousePressed(MouseEvent e) { button2.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { - EventRouter.CORE.fireEvent(new WhisperNotificationEvent()); + EventRouter.CORE.fireEvent(new SoundNotificationEvent.WhisperSoundNotificationEvent()); String nickname = nickNames.get(random.nextInt(nickNames.size())); Message message = parser.parse(String.format(currencyTemplate, nickname, 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 d5a2b095..5139c6c5 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 @@ -4,7 +4,6 @@ import com.mercury.platform.core.utils.interceptor.filter.MessageFilter; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.AddInterceptorEvent; -import com.mercury.platform.shared.events.custom.ChatFilterMessageEvent; import com.mercury.platform.shared.events.custom.RemoveInterceptorEvent; import com.mercury.platform.shared.pojo.FrameSettings; import com.mercury.platform.ui.components.panel.chat.ChatFilterPanel; From f878c4cedb8b2829d3d4c4fa1333d6aafc7e06dd Mon Sep 17 00:00:00 2001 From: Exslims Date: Tue, 4 Apr 2017 19:15:14 +0400 Subject: [PATCH 02/15] Pack test --- .../test/java/com/mercury/platform/PackTesting.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/app-ui/src/test/java/com/mercury/platform/PackTesting.java b/app-ui/src/test/java/com/mercury/platform/PackTesting.java index 757e720c..84204a5c 100644 --- a/app-ui/src/test/java/com/mercury/platform/PackTesting.java +++ b/app-ui/src/test/java/com/mercury/platform/PackTesting.java @@ -1,17 +1,12 @@ package com.mercury.platform; -import com.mercury.platform.core.User32; import com.mercury.platform.ui.misc.AppThemeColor; -import com.sun.jna.Native; import javax.swing.*; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -/** - * Created by Константин on 23.12.2016. - */ public class PackTesting { private static void createAndShowGUI() { final JFrame frame = new JFrame("HelloWorldSwing"); @@ -19,10 +14,9 @@ private static void createAndShowGUI() { frame.setMinimumSize(new Dimension(400,400)); frame.setMaximumSize(new Dimension(400,400)); frame.setLocationRelativeTo(null); - frame.setFocusable(false); - frame.setFocusableWindowState(false); frame.setLayout(new BoxLayout(frame.getContentPane(),BoxLayout.Y_AXIS)); - + frame.setType(Window.Type.UTILITY); + frame.setUndecorated(true); JPanel buffer = new JPanel(new FlowLayout(FlowLayout.CENTER)); buffer.setMinimumSize(new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE)); buffer.setBorder(BorderFactory.createLineBorder(AppThemeColor.TEXT_IMPORTANT)); @@ -41,6 +35,7 @@ public void mouseClicked(MouseEvent e) { } }); frame.add(buffer); + frame.add(new JTextField()); frame.add(button); frame.setVisible(true); frame.pack(); From 0d9b6edc74538b9468a0996b3c6b5e92ed052f0d Mon Sep 17 00:00:00 2001 From: Exslims Date: Fri, 7 Apr 2017 01:40:52 +0400 Subject: [PATCH 03/15] Updated support panel, added sound settings --- .../platform/core/misc/SoundNotifier.java | 4 +- .../core/handlers/ResponseDispatcher.java | 5 +- .../events/custom/SoundNotificationEvent.java | 6 + .../panel/settings/SoundSettingsPanel.java | 70 +++++++++++- .../panel/settings/SupportPanel.java | 108 +++++++++++++++--- 5 files changed, 170 insertions(+), 23 deletions(-) diff --git a/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java b/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java index 14e0e1ba..1d49fb7d 100644 --- a/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java +++ b/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java @@ -25,8 +25,8 @@ public SoundNotifier() { play("app/notification.wav",((SoundNotificationEvent.WhisperSoundNotificationEvent)event).getDb()); } }); - EventRouter.CORE.registerHandler(UpdateInfoEvent.class, event -> { - play("app/patch_tone.wav",0); + EventRouter.CORE.registerHandler(SoundNotificationEvent.UpdateSoundNotificationEvent.class, event -> { + play("app/patch_tone.wav",((SoundNotificationEvent.UpdateSoundNotificationEvent)event).getDb()); }); EventRouter.CORE.registerHandler(SoundNotificationEvent.ChatScannerSoundNotificationEvent.class, event -> { play("app/chat-filter.wav",((SoundNotificationEvent.ChatScannerSoundNotificationEvent)event).getDb()); diff --git a/app-core/src/main/java/com/mercury/platform/core/update/core/handlers/ResponseDispatcher.java b/app-core/src/main/java/com/mercury/platform/core/update/core/handlers/ResponseDispatcher.java index 1315b6d9..505d2b01 100644 --- a/app-core/src/main/java/com/mercury/platform/core/update/core/handlers/ResponseDispatcher.java +++ b/app-core/src/main/java/com/mercury/platform/core/update/core/handlers/ResponseDispatcher.java @@ -4,6 +4,7 @@ import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.AlertEvent; import com.mercury.platform.shared.events.custom.ShowPatchNotesEvent; +import com.mercury.platform.shared.events.custom.SoundNotificationEvent; import com.mercury.platform.shared.events.custom.UpdateInfoEvent; import com.mercury.platform.update.AlreadyLatestUpdateMessage; import com.mercury.platform.update.PatchNotesDescriptor; @@ -19,8 +20,8 @@ public void process(Object object){ EventRouter.CORE.fireEvent(new ShowPatchNotesEvent(notes)); } if(object instanceof UpdateDescriptor){ - int nextVersion = ((UpdateDescriptor) object).getVersion(); - EventRouter.CORE.fireEvent(new UpdateInfoEvent(nextVersion)); + EventRouter.CORE.fireEvent(new SoundNotificationEvent.UpdateSoundNotificationEvent()); + EventRouter.CORE.fireEvent(new UpdateInfoEvent(((UpdateDescriptor) object).getVersion())); } if(object instanceof AlreadyLatestUpdateMessage){ if(ApplicationHolder.getInstance().isManualRequest()) { diff --git a/app-core/src/main/java/com/mercury/platform/shared/events/custom/SoundNotificationEvent.java b/app-core/src/main/java/com/mercury/platform/shared/events/custom/SoundNotificationEvent.java index 645728fb..eca514ef 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/events/custom/SoundNotificationEvent.java +++ b/app-core/src/main/java/com/mercury/platform/shared/events/custom/SoundNotificationEvent.java @@ -30,4 +30,10 @@ public ClicksSoundNotificationEvent(Float db) { super(db); } } + @NoArgsConstructor + public static class UpdateSoundNotificationEvent extends SoundNotificationEvent { + public UpdateSoundNotificationEvent(Float db) { + super(db); + } + } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java index c4639da2..9b17dce4 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java @@ -8,7 +8,10 @@ import javax.swing.*; import javax.swing.border.CompoundBorder; +import javax.swing.filechooser.FileNameExtensionFilter; import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -21,7 +24,8 @@ public SoundSettingsPanel() { @Override public void createUI() { - verticalScrollContainer.add(getVolumePanel(),BorderLayout.CENTER); + verticalScrollContainer.add(getVolumePanel()); + verticalScrollContainer.add(getSoundPickerPanel()); } private JPanel getVolumePanel(){ @@ -34,7 +38,7 @@ private JPanel getVolumePanel(){ BorderFactory.createEmptyBorder(3,5,3,5))); - JPanel container = componentsFactory.getTransparentPanel(new GridLayout(3, 2)); + JPanel container = componentsFactory.getTransparentPanel(new GridLayout(4, 2)); container.setBackground(AppThemeColor.SETTINGS_BG); container.setBorder(new CompoundBorder( BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), @@ -70,18 +74,74 @@ public void mouseReleased(MouseEvent e) { ); } }); - container.add(componentsFactory.getTextLabel("Notification:")); + JSlider update = componentsFactory.getSlider(-40, 6, 0); + update.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + EventRouter.CORE.fireEvent( + new SoundNotificationEvent.UpdateSoundNotificationEvent( + clicksSlider.getValue() == -40 ? -80f : (float)update.getValue()) + ); + } + }); + container.add(componentsFactory.getTextLabel("Notification:",FontStyle.REGULAR)); container.add(notificationSlider); - container.add(componentsFactory.getTextLabel("Chat Scanner")); + container.add(componentsFactory.getTextLabel("Chat Scanner",FontStyle.REGULAR)); container.add(chatScannerSlider); - container.add(componentsFactory.getTextLabel("Clicks")); + container.add(componentsFactory.getTextLabel("Clicks",FontStyle.REGULAR)); container.add(clicksSlider); + container.add(componentsFactory.getTextLabel("Update notification",FontStyle.REGULAR)); + container.add(update); root.add(volumeLabel,BorderLayout.PAGE_START); root.add(container,BorderLayout.CENTER); return root; } + private JPanel getSoundPickerPanel(){ + JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); + + JLabel soundLabel = componentsFactory.getTextLabel(FontStyle.REGULAR, AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP, 17f, "Sound"); + soundLabel.setBorder( + new CompoundBorder( + BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), + BorderFactory.createEmptyBorder(3,5,3,5))); + + JPanel container = componentsFactory.getTransparentPanel(new GridLayout(2, 2,0,1)); + container.setBackground(AppThemeColor.SETTINGS_BG); + container.setBorder(new CompoundBorder( + BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), + BorderFactory.createEmptyBorder(3,0,3,0))); + + JComboBox notificationComboBox = componentsFactory.getComboBox(new String[]{"Mercury Notification", "Mercury Chat Scanner", "Browse"}); + notificationComboBox.addItemListener(e -> { + switch (e.getStateChange()){ + case ItemEvent.SELECTED: { + if(notificationComboBox.getSelectedItem().equals("Browse")){ + JFileChooser fileChooser = new JFileChooser(); + fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("*.wav","wav")); + + } + break; + } + } + }); + + + JComboBox chatScannerComboBox = componentsFactory.getComboBox(new String[]{"Mercury Notification", "Mercury Chat Scanner", "Browse"}); + + + container.add(componentsFactory.getTextLabel("Notification:",FontStyle.REGULAR)); + container.add(notificationComboBox); + container.add(componentsFactory.getTextLabel("Chat Scanner",FontStyle.REGULAR)); + container.add(chatScannerComboBox); + root.add(soundLabel,BorderLayout.PAGE_START); + root.add(container,BorderLayout.CENTER); + + return root; + } + + @Override public boolean processAndSave() { return true; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SupportPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SupportPanel.java index 813cc64d..0321bf38 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SupportPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SupportPanel.java @@ -1,53 +1,133 @@ package com.mercury.platform.ui.components.panel.settings; +import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.ui.components.ComponentsFactory; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.components.fields.style.MercuryScrollBarUI; +import com.mercury.platform.ui.components.panel.VerticalScrollContainer; import com.mercury.platform.ui.components.panel.misc.HasUI; import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.event.RepaintEvent; import javax.swing.*; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.io.IOException; +import java.awt.event.MouseWheelEvent; import java.net.URI; -import java.net.URISyntaxException; +import java.util.*; +import java.util.List; -/** - * Created by Константин on 11.02.2017. - */ public class SupportPanel extends JPanel implements HasUI{ private ComponentsFactory componentsFactory; public SupportPanel() { super(); componentsFactory = new ComponentsFactory(); - this.setBackground(AppThemeColor.TRANSPARENT); + this.setBackground(AppThemeColor.SLIDE_BG); createUI(); } @Override public void createUI() { - this.setLayout(new FlowLayout(FlowLayout.CENTER)); - JPanel donatePanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); + this.setLayout(new BorderLayout()); + + JPanel donatePanel = componentsFactory.getTransparentPanel(); + donatePanel.setLayout(new BoxLayout(donatePanel,BoxLayout.Y_AXIS)); + donatePanel.setBackground(AppThemeColor.SLIDE_BG); + JButton donate = componentsFactory.getIconifiedTransparentButton("app/paypal.png","Donate"); + donate.setBorder(BorderFactory.createEmptyBorder(1,1,1,1)); donate.setBackground(AppThemeColor.SLIDE_BG); donate.addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + donate.setBorder(BorderFactory.createLineBorder(AppThemeColor.BORDER)); + } + + @Override + public void mouseExited(MouseEvent e) { + donate.setBorder(BorderFactory.createEmptyBorder(1,1,1,1)); + } + @Override public void mousePressed(MouseEvent e) { 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")); - } catch (IOException e1) { - e1.printStackTrace(); - } catch (URISyntaxException e1) { + } catch (Exception e1) { e1.printStackTrace(); } } }); - donatePanel.add(donate); - this.add(donatePanel); JTextArea donateText = componentsFactory.getSimpleTextAre("We aimed to create a convenience tool in form of an easy-to-use application, primarily for trading purposes. If MercuryTrade successfully managed to save your time or improve your experience, you can thank us by donating and telling your friends."); donateText.setPreferredSize(new Dimension(300,150)); JPanel donateTextPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); + JPanel donateButtonPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); + donateButtonPanel.setBorder(BorderFactory.createEmptyBorder(30,0,0,0)); donateTextPanel.add(donateText); - this.add(donateTextPanel); + donateButtonPanel.add(donate); + donatePanel.add(donateButtonPanel); + donatePanel.add(donateTextPanel); + this.add(donatePanel,BorderLayout.CENTER); + this.add(getDonationsPanel(),BorderLayout.LINE_END); + } + private JPanel getDonationsPanel() { + JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); + root.setBorder(BorderFactory.createEmptyBorder(20,0,10,20)); + root.add(componentsFactory.getTextLabel("Thanks a lot for support: "),BorderLayout.PAGE_START); + + JPanel donationsList = new VerticalScrollContainer(); + donationsList.setBackground(AppThemeColor.TRANSPARENT); + donationsList.setLayout(new BoxLayout(donationsList,BoxLayout.Y_AXIS)); + + JScrollPane scrollPane = new JScrollPane(donationsList); + 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) { + EventRouter.UI.fireEvent(new RepaintEvent.RepaintSettingFrame()); + } + }); + JScrollBar vBar = scrollPane.getVerticalScrollBar(); + vBar.setBackground(AppThemeColor.SLIDE_BG); + vBar.setUI(new MercuryScrollBarUI()); + vBar.setPreferredSize(new Dimension(14, Integer.MAX_VALUE)); + vBar.setUnitIncrement(3); + vBar.setBorder(BorderFactory.createEmptyBorder(1,1,1,2)); + vBar.addAdjustmentListener(e -> repaint()); + donationsList.getParent().setBackground(AppThemeColor.TRANSPARENT); + + getDonations().forEach(pair -> { + JPanel item = componentsFactory.getTransparentPanel(new BorderLayout()); + item.add(componentsFactory.getTextLabel(pair.name, FontStyle.REGULAR),BorderLayout.CENTER); + item.add(componentsFactory.getTextLabel(pair.value.intValue() + "$", FontStyle.REGULAR),BorderLayout.LINE_END); + donationsList.add(item); + }); + + root.add(scrollPane,BorderLayout.CENTER); + return root; + } + private List getDonations(){ + List donations = new ArrayList<>(); + donations.add(new DonationPair("Anonymus",15d)); + donations.add(new DonationPair("Anonymus",10d)); + donations.add(new DonationPair("Anonymus",10d)); + donations.add(new DonationPair("Anonymus",10d)); + donations.add(new DonationPair("Anonymus",5d)); + donations.add(new DonationPair("Anonymus",5d)); + donations.add(new DonationPair("Anonymus",2d)); + return donations; + } + + private class DonationPair{ + private String name; + private Double value; + + DonationPair(String name, Double value) { + this.name = name; + this.value = value; + } } } From fccce43482556a90e96d96642af378a55cdf1776 Mon Sep 17 00:00:00 2001 From: Exslims Date: Sat, 8 Apr 2017 03:25:05 +0400 Subject: [PATCH 04/15] Refactoring, testing RxJava --- app-core/pom.xml | 4 ++ .../com/mercury/platform/core/AppStarter.java | 19 +++--- .../platform/core/misc/SoundNotifier.java | 12 +++- .../mercury/platform/core/misc/SoundType.java | 6 ++ .../IncTradeMessagesInterceptor.java | 5 +- .../OutTradeMessagesInterceptor.java | 2 +- .../platform/experimental/RxJavaBasic.java | 61 +++++++++++++++++++ .../experimental/RxJavaOperators.java | 22 +++++++ .../platform/shared/ConfigManager.java | 22 +++---- ...rameStates.java => FrameVisibleState.java} | 2 +- .../platform/shared/HistoryManager.java | 6 +- .../platform/shared/MessageParser.java | 6 +- .../platform/shared/UpdateManager.java | 5 -- .../{pojo => entity}/CurrencyMessage.java | 2 +- .../{pojo => entity}/FrameSettings.java | 2 +- .../shared/{pojo => entity}/ItemMessage.java | 3 +- .../shared/{pojo => entity}/Message.java | 2 +- .../{pojo => entity}/ResponseButton.java | 2 +- .../shared/{pojo => entity}/ScaleData.java | 2 +- .../shared/{pojo => entity}/StashTab.java | 2 +- .../custom/ChangeFrameVisibleEvent.java | 4 +- .../events/custom/NewWhispersEvent.java | 2 +- .../events/custom/OutTradeMessageEvent.java | 2 +- .../platform/shared/http/ItemGuard.java | 4 ++ .../platform/shared/http/RequestBuilder.java | 7 +++ .../shared/store/DataTransformers.java | 33 ++++++++++ .../platform/shared/store/MercuryStore.java | 13 ++++ .../platform/shared/store/Reducer.java | 16 +++++ .../platform/shared/MessageParserTest.java | 4 +- .../shared/store/MercuryStoreTest.java | 17 ++++++ .../components/panel/grid/ItemInfoPanel.java | 6 +- .../grid/ItemInfoPanelControllerImpl.java | 2 +- .../components/panel/grid/ItemsGridPanel.java | 4 +- .../panel/grid/StashTabsContainer.java | 2 +- .../components/panel/grid/TabInfoPanel.java | 2 +- .../panel/message/MessagePanel.java | 8 +-- .../NotificationMessageController.java | 8 +-- .../panel/settings/CustomButtonSettings.java | 2 +- .../panel/settings/GeneralSettings.java | 6 +- .../components/panel/settings/HelpPanel.java | 2 +- .../panel/settings/SoundSettingsPanel.java | 7 ++- ...Frame.java => AbstractComponentFrame.java} | 59 +++++++++--------- ...dFrame.java => AbstractOverlaidFrame.java} | 24 ++++---- ...va => AbstractScalableComponentFrame.java} | 5 +- ...ava => AbstractMovableComponentFrame.java} | 12 ++-- .../ui/frame/movable/CurrencySearchFrame.java | 7 +-- .../ui/frame/movable/ItemsGridFrame.java | 8 +-- .../ui/frame/movable/TaskBarFrame.java | 7 +-- .../movable/container/IncMessageFrame.java | 18 +++--- .../platform/ui/frame/other/AlertFrame.java | 4 +- .../ui/frame/other/MercuryLoadingFrame.java | 4 +- .../ui/frame/other/NotificationFrame.java | 4 +- .../ui/frame/other/OutMessageFrame.java | 16 ++--- .../ui/frame/other/SetUpLocationFrame.java | 4 +- .../ui/frame/other/SetUpScaleFrame.java | 5 +- .../platform/ui/frame/other/TooltipFrame.java | 4 +- .../ui/frame/other/UpdateReadyFrame.java | 12 ++-- .../location/SetUpLocationCommander.java | 14 ++--- .../setup/scale/SetUpScaleCommander.java | 4 +- ...java => AbstractTitledComponentFrame.java} | 8 +-- .../ui/frame/titled/GamePathChooser.java | 2 +- .../platform/ui/frame/titled/NotesFrame.java | 14 ++--- .../ui/frame/titled/SettingsFrame.java | 2 +- .../ui/frame/titled/TestCasesFrame.java | 5 +- .../platform/ui/frame/titled/TimerFrame.java | 2 +- .../ui/frame/titled/chat/ChatFilterFrame.java | 6 +- .../titled/chat/ChatFilterSettingsFrame.java | 4 +- .../frame/titled/container/HistoryFrame.java | 8 +-- .../platform/ui/manager/FramesManager.java | 54 ++++++++-------- .../ui/manager/HideSettingsManager.java | 6 +- .../ui/misc/event/CloseGridItemEvent.java | 2 +- .../ui/misc/event/CloseMessagePanelEvent.java | 6 +- .../ui/misc/event/SaveScaleEvent.java | 3 - .../ui/misc/event/ShowItemGridEvent.java | 2 +- pom.xml | 7 ++- 75 files changed, 424 insertions(+), 256 deletions(-) create mode 100644 app-core/src/main/java/com/mercury/platform/core/misc/SoundType.java create mode 100644 app-core/src/main/java/com/mercury/platform/experimental/RxJavaBasic.java create mode 100644 app-core/src/main/java/com/mercury/platform/experimental/RxJavaOperators.java rename app-core/src/main/java/com/mercury/platform/shared/{FrameStates.java => FrameVisibleState.java} (77%) rename app-core/src/main/java/com/mercury/platform/shared/{pojo => entity}/CurrencyMessage.java (83%) rename app-core/src/main/java/com/mercury/platform/shared/{pojo => entity}/FrameSettings.java (81%) rename app-core/src/main/java/com/mercury/platform/shared/{pojo => entity}/ItemMessage.java (76%) rename app-core/src/main/java/com/mercury/platform/shared/{pojo => entity}/Message.java (86%) rename app-core/src/main/java/com/mercury/platform/shared/{pojo => entity}/ResponseButton.java (92%) rename app-core/src/main/java/com/mercury/platform/shared/{pojo => entity}/ScaleData.java (82%) rename app-core/src/main/java/com/mercury/platform/shared/{pojo => entity}/StashTab.java (81%) create mode 100644 app-core/src/main/java/com/mercury/platform/shared/http/ItemGuard.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/http/RequestBuilder.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/store/DataTransformers.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/store/Reducer.java create mode 100644 app-core/src/test/java/com/mercury/platform/shared/store/MercuryStoreTest.java rename app-ui/src/main/java/com/mercury/platform/ui/frame/{ComponentFrame.java => AbstractComponentFrame.java} (75%) rename app-ui/src/main/java/com/mercury/platform/ui/frame/{OverlaidFrame.java => AbstractOverlaidFrame.java} (79%) rename app-ui/src/main/java/com/mercury/platform/ui/frame/{ScalableComponentFrame.java => AbstractScalableComponentFrame.java} (95%) rename app-ui/src/main/java/com/mercury/platform/ui/frame/movable/{MovableComponentFrame.java => AbstractMovableComponentFrame.java} (92%) rename app-ui/src/main/java/com/mercury/platform/ui/frame/titled/{TitledComponentFrame.java => AbstractTitledComponentFrame.java} (90%) diff --git a/app-core/pom.xml b/app-core/pom.xml index e6f06c66..78d3e29c 100644 --- a/app-core/pom.xml +++ b/app-core/pom.xml @@ -39,6 +39,10 @@ commons-io commons-io + + io.reactivex + rxjava + junit junit diff --git a/app-core/src/main/java/com/mercury/platform/core/AppStarter.java b/app-core/src/main/java/com/mercury/platform/core/AppStarter.java index 00e4d658..a5ee4008 100644 --- a/app-core/src/main/java/com/mercury/platform/core/AppStarter.java +++ b/app-core/src/main/java/com/mercury/platform/core/AppStarter.java @@ -4,7 +4,7 @@ import com.mercury.platform.core.update.UpdateClientStarter; import com.mercury.platform.core.utils.error.ErrorHandler; import com.mercury.platform.shared.ConfigManager; -import com.mercury.platform.shared.FrameStates; +import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.HistoryManager; import com.mercury.platform.shared.UpdateManager; import com.mercury.platform.shared.events.EventRouter; @@ -24,7 +24,7 @@ */ public class AppStarter { private static final Logger logger = LogManager.getLogger(AppStarter.class.getSimpleName()); - public static FrameStates APP_STATUS = FrameStates.HIDE; + public static FrameVisibleState APP_STATUS = FrameVisibleState.HIDE; private User32 user32 = User32.INSTANCE; private boolean shutdown = false; private volatile int delay = 100; @@ -40,6 +40,7 @@ public void startApplication(){ UpdateClientStarter updateClientStarter = new UpdateClientStarter(); executor.execute(updateClientStarter); HistoryManager.INSTANCE.load(); + UpdateManager updateManager = new UpdateManager(); EventRouter.CORE.registerHandler(UILoadedEvent.class, event -> { Timer timer = new Timer(); @@ -50,7 +51,7 @@ public void run() { timer.cancel(); updateClientStarter.shutdown(); if(updating){ - UpdateManager.INSTANCE.doUpdate(); + updateManager.doUpdate(); } System.exit(0); } @@ -58,19 +59,19 @@ public void run() { PointerType hwnd = user32.GetForegroundWindow(); User32.INSTANCE.GetWindowTextA(hwnd, windowText, 512); if(!Native.toString(windowText).equals("Path of Exile")){ - if(APP_STATUS == FrameStates.SHOW) { - APP_STATUS = FrameStates.HIDE; - EventRouter.CORE.fireEvent(new ChangeFrameVisibleEvent(FrameStates.HIDE)); + if(APP_STATUS == FrameVisibleState.SHOW) { + APP_STATUS = FrameVisibleState.HIDE; + EventRouter.CORE.fireEvent(new ChangeFrameVisibleEvent(FrameVisibleState.HIDE)); } }else{ - if(APP_STATUS == FrameStates.HIDE) { + if(APP_STATUS == FrameVisibleState.HIDE) { try { Thread.sleep(delay); delay = 100; } catch (InterruptedException e) { } - APP_STATUS = FrameStates.SHOW; - EventRouter.CORE.fireEvent(new ChangeFrameVisibleEvent(FrameStates.SHOW)); + APP_STATUS = FrameVisibleState.SHOW; + EventRouter.CORE.fireEvent(new ChangeFrameVisibleEvent(FrameVisibleState.SHOW)); } } } diff --git a/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java b/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java index 1d49fb7d..4a730d90 100644 --- a/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java +++ b/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java @@ -2,9 +2,11 @@ import com.mercury.platform.core.AppStarter; import com.mercury.platform.shared.ConfigManager; -import com.mercury.platform.shared.FrameStates; +import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.*; +import com.mercury.platform.shared.store.DataTransformers; +import com.mercury.platform.shared.store.MercuryStore; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -18,10 +20,16 @@ public class SoundNotifier { private final Logger logger = LogManager.getLogger(SoundNotifier.class); private boolean dnd = false; public SoundNotifier() { + + MercuryStore.INSTANCE.soundSubject. + compose(DataTransformers.transformSoundData()) + .subscribe( + data -> play(data.get("path"), Float.valueOf(data.get("db")))); + EventRouter.CORE.registerHandler(SoundNotificationEvent.WhisperSoundNotificationEvent.class, event -> { WhisperNotifierStatus status = ConfigManager.INSTANCE.getWhisperNotifier(); if (status == WhisperNotifierStatus.ALWAYS || - ((status == WhisperNotifierStatus.ALTAB) && (AppStarter.APP_STATUS == FrameStates.HIDE))) { + ((status == WhisperNotifierStatus.ALTAB) && (AppStarter.APP_STATUS == FrameVisibleState.HIDE))) { play("app/notification.wav",((SoundNotificationEvent.WhisperSoundNotificationEvent)event).getDb()); } }); diff --git a/app-core/src/main/java/com/mercury/platform/core/misc/SoundType.java b/app-core/src/main/java/com/mercury/platform/core/misc/SoundType.java new file mode 100644 index 00000000..72d214e0 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/core/misc/SoundType.java @@ -0,0 +1,6 @@ +package com.mercury.platform.core.misc; + + +public enum SoundType { + MESSAGE,UPDATE,CHAT_SCANNER,CLICKS +} diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/IncTradeMessagesInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/IncTradeMessagesInterceptor.java index a40d551b..f1d08690 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/IncTradeMessagesInterceptor.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/IncTradeMessagesInterceptor.java @@ -1,11 +1,13 @@ 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.events.EventRouter; import com.mercury.platform.shared.events.custom.NewWhispersEvent; import com.mercury.platform.shared.events.custom.SoundNotificationEvent; -import com.mercury.platform.shared.pojo.Message; +import com.mercury.platform.shared.entity.Message; +import com.mercury.platform.shared.store.MercuryStore; import org.apache.commons.lang3.StringUtils; /** @@ -19,6 +21,7 @@ protected void process(String message) { Message parsedMessage = messageParser.parse(StringUtils.substringAfter(message,"@")); if(parsedMessage != null) { EventRouter.CORE.fireEvent(new SoundNotificationEvent.WhisperSoundNotificationEvent()); +// MercuryStore.INSTANCE.soundSubject.onNext(SoundType.MESSAGE); EventRouter.CORE.fireEvent(new NewWhispersEvent(parsedMessage)); } } diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/OutTradeMessagesInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/OutTradeMessagesInterceptor.java index 93f5126e..22c562a2 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/OutTradeMessagesInterceptor.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/OutTradeMessagesInterceptor.java @@ -4,7 +4,7 @@ import com.mercury.platform.shared.MessageParser; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.OutTradeMessageEvent; -import com.mercury.platform.shared.pojo.Message; +import com.mercury.platform.shared.entity.Message; /** * Created by Константин on 12.01.2017. diff --git a/app-core/src/main/java/com/mercury/platform/experimental/RxJavaBasic.java b/app-core/src/main/java/com/mercury/platform/experimental/RxJavaBasic.java new file mode 100644 index 00000000..570e012f --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/experimental/RxJavaBasic.java @@ -0,0 +1,61 @@ +package com.mercury.platform.experimental; + +import rx.Observable; +import rx.Subscriber; +import rx.functions.Action1; + +/** + * Created by Константин on 07.04.2017. + */ +public class RxJavaBasic { + public static void main(String[] args) { + method5(); + } + public static void method1(){ + Observable observable = Observable.create(subscriber -> { + subscriber.onNext("Hello World!"); + subscriber.onCompleted(); + }); + + Subscriber subscriber = new Subscriber() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable throwable) { + + } + + @Override + public void onNext(String s) { + System.out.println(s); + } + }; + observable.subscribe(subscriber); + } + public static void method2(){ + Observable observable = Observable.just("Hello world"); + Action1 onNextAction = System.out::println; + observable.subscribe(onNextAction); + } + public static void method3(){ + Observable.just("Hello world").subscribe(System.out::println); + } + + //Operators + public static void method4(){ + Observable.just("Hello world").map(s -> s + " -Dan").subscribe(System.out::println); + } + public static void method5(){ + Observable.just("Hello world") + .map(s -> s + " -Dan") + .map(String::hashCode) + .map(i -> Integer.toString(i)) + .subscribe(System.out::println); + } + public static void method6(){ + Observable.just("Hello world").subscribe(System.out::println); + } +} diff --git a/app-core/src/main/java/com/mercury/platform/experimental/RxJavaOperators.java b/app-core/src/main/java/com/mercury/platform/experimental/RxJavaOperators.java new file mode 100644 index 00000000..3a7b1077 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/experimental/RxJavaOperators.java @@ -0,0 +1,22 @@ +package com.mercury.platform.experimental; + +/** + * Created by Константин on 07.04.2017. + */ +public class RxJavaOperators { + public static void main(String[] args) { + + } + public static void method1(){ + + } + public static void method2(){ + + } + public static void method3(){ + + } + public static void method4(){ + + } +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java b/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java index 1dde8c05..8cf36a76 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java +++ b/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java @@ -1,10 +1,9 @@ package com.mercury.platform.shared; import com.mercury.platform.core.misc.WhisperNotifierStatus; -import com.mercury.platform.shared.pojo.FrameSettings; -import com.mercury.platform.shared.pojo.ResponseButton; -import com.mercury.platform.shared.pojo.ScaleData; -import com.mercury.platform.shared.pojo.StashTab; +import com.mercury.platform.shared.entity.FrameSettings; +import com.mercury.platform.shared.entity.ResponseButton; +import com.mercury.platform.shared.entity.StashTab; import lombok.Getter; import org.apache.commons.io.FileUtils; import org.apache.logging.log4j.LogManager; @@ -38,7 +37,6 @@ private static class ConfigManagerHolder { private List cachedButtonsConfig; private Map cachedFramesSettings; private Map minimumFrameSize; - private Map defaultFramesSettings; private Map defaultAppSettings; @Getter @@ -159,7 +157,7 @@ public void load() { saveProperty("dndResponseText", defaultAppSettings.get("dndResponseText")); saveProperty("defaultWords", defaultAppSettings.get("defaultWords")); saveProperty("scaleData", defaultAppSettings.get("scaleData")); - saveProperty("showLeague", defaultAppSettings.get("showLeague")); + saveProperty("showLeague", String.valueOf(defaultAppSettings.get("showLeague"))); } catch (Exception e) { logger.error(e); @@ -257,8 +255,9 @@ private String loadProperty(String key){ } }catch (Exception e){ logger.error("Error while loading property: " + key,e); + saveProperty(key,String.valueOf(defaultAppSettings.get(key))); + return String.valueOf(defaultAppSettings.get(key)); } - return null; } private void saveProperty(String token, T object){ JSONParser parser = new JSONParser(); @@ -275,7 +274,7 @@ private void saveProperty(String token, T object){ fileWriter.flush(); fileWriter.close(); } catch (Exception e) { - logger.error("Error in ConfigManager.saveProperty",e); + logger.error("Error in ConfigManager.saveProperty with \"" + token + "\" token.",e); } } @@ -394,7 +393,6 @@ public Map getScaleData(){ return scaleData; } - public void setCheckUpdateOnStartUp(boolean checkUpdateOnStartUp) { this.checkUpdateOnStartUp = checkUpdateOnStartUp; saveProperty("checkUpdateOnStartUp", String.valueOf(this.checkUpdateOnStartUp)); @@ -436,10 +434,6 @@ public void setFlowDirection(String flowDirection) { this.flowDirection = flowDirection; saveProperty("flowDirection",flowDirection); } - public void setTradeMode(String tradeMode) { - this.tradeMode = tradeMode; - saveProperty("tradeMode",tradeMode); - } public void setLimitMsgCount(int limitMsgCount) { this.limitMsgCount = limitMsgCount; saveProperty("limitMsgCount",String.valueOf(this.limitMsgCount)); @@ -480,7 +474,7 @@ private List getDefaultButtons(){ return defaultButtons; } public Map getDefaultFramesSettings(){ - defaultFramesSettings = new HashMap<>(); + Map defaultFramesSettings = new HashMap<>(); defaultFramesSettings.put("TaskBarFrame",new FrameSettings(new Point(400, 500),new Dimension(109,20))); defaultFramesSettings.put("IncMessageFrame",new FrameSettings(new Point(700, 600),new Dimension(315,0))); defaultFramesSettings.put("OutMessageFrame",new FrameSettings(new Point(200, 500),new Dimension(280,115))); diff --git a/app-core/src/main/java/com/mercury/platform/shared/FrameStates.java b/app-core/src/main/java/com/mercury/platform/shared/FrameVisibleState.java similarity index 77% rename from app-core/src/main/java/com/mercury/platform/shared/FrameStates.java rename to app-core/src/main/java/com/mercury/platform/shared/FrameVisibleState.java index 468805a8..d5286d9f 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/FrameStates.java +++ b/app-core/src/main/java/com/mercury/platform/shared/FrameVisibleState.java @@ -3,6 +3,6 @@ /** * Created by Константин on 09.12.2016. */ -public enum FrameStates { +public enum FrameVisibleState { SHOW,HIDE } 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 2d5716ff..93f3fcef 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,21 +1,17 @@ package com.mercury.platform.shared; -import com.mercury.platform.shared.pojo.Message; +import com.mercury.platform.shared.entity.Message; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; -import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; -import java.util.List; /** * Created by Константин on 11.02.2017. 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 8965983e..fa47eb48 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,8 +1,8 @@ package com.mercury.platform.shared; -import com.mercury.platform.shared.pojo.CurrencyMessage; -import com.mercury.platform.shared.pojo.ItemMessage; -import com.mercury.platform.shared.pojo.Message; +import com.mercury.platform.shared.entity.CurrencyMessage; +import com.mercury.platform.shared.entity.ItemMessage; +import com.mercury.platform.shared.entity.Message; import org.apache.commons.lang3.StringUtils; import java.util.regex.Matcher; diff --git a/app-core/src/main/java/com/mercury/platform/shared/UpdateManager.java b/app-core/src/main/java/com/mercury/platform/shared/UpdateManager.java index a6f726e7..4cc6f42c 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/UpdateManager.java +++ b/app-core/src/main/java/com/mercury/platform/shared/UpdateManager.java @@ -13,11 +13,6 @@ public class UpdateManager { private final static Logger logger = LogManager.getLogger(UpdateManager.class.getSimpleName()); private final static String LOCAL_UPDATER_PATH = System.getenv("USERPROFILE") + "\\AppData\\Local\\MercuryTrade\\local-updater.jar"; private static final String JAR_FILE_PATH = System.getenv("USERPROFILE") + "\\AppData\\Local\\MercuryTrade\\temp\\MercuryTrade.jar"; - private static class UpdateManagerHolder { - static final UpdateManager HOLDER_INSTANCE = new UpdateManager(); - } - public static UpdateManager INSTANCE = UpdateManagerHolder.HOLDER_INSTANCE; - public void doUpdate(){ try { String path = StringUtils.substringAfter(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI().getPath(), "/"); diff --git a/app-core/src/main/java/com/mercury/platform/shared/pojo/CurrencyMessage.java b/app-core/src/main/java/com/mercury/platform/shared/entity/CurrencyMessage.java similarity index 83% rename from app-core/src/main/java/com/mercury/platform/shared/pojo/CurrencyMessage.java rename to app-core/src/main/java/com/mercury/platform/shared/entity/CurrencyMessage.java index f25382f6..fbb34569 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/pojo/CurrencyMessage.java +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/CurrencyMessage.java @@ -1,4 +1,4 @@ -package com.mercury.platform.shared.pojo; +package com.mercury.platform.shared.entity; import lombok.Data; import lombok.EqualsAndHashCode; diff --git a/app-core/src/main/java/com/mercury/platform/shared/pojo/FrameSettings.java b/app-core/src/main/java/com/mercury/platform/shared/entity/FrameSettings.java similarity index 81% rename from app-core/src/main/java/com/mercury/platform/shared/pojo/FrameSettings.java rename to app-core/src/main/java/com/mercury/platform/shared/entity/FrameSettings.java index e6331416..93a0cff9 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/pojo/FrameSettings.java +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/FrameSettings.java @@ -1,4 +1,4 @@ -package com.mercury.platform.shared.pojo; +package com.mercury.platform.shared.entity; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/app-core/src/main/java/com/mercury/platform/shared/pojo/ItemMessage.java b/app-core/src/main/java/com/mercury/platform/shared/entity/ItemMessage.java similarity index 76% rename from app-core/src/main/java/com/mercury/platform/shared/pojo/ItemMessage.java rename to app-core/src/main/java/com/mercury/platform/shared/entity/ItemMessage.java index c9c08832..421fb760 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/pojo/ItemMessage.java +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/ItemMessage.java @@ -1,6 +1,5 @@ -package com.mercury.platform.shared.pojo; +package com.mercury.platform.shared.entity; -import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; diff --git a/app-core/src/main/java/com/mercury/platform/shared/pojo/Message.java b/app-core/src/main/java/com/mercury/platform/shared/entity/Message.java similarity index 86% rename from app-core/src/main/java/com/mercury/platform/shared/pojo/Message.java rename to app-core/src/main/java/com/mercury/platform/shared/entity/Message.java index 011813ba..73f31b21 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/pojo/Message.java +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/Message.java @@ -1,4 +1,4 @@ -package com.mercury.platform.shared.pojo; +package com.mercury.platform.shared.entity; import lombok.Data; diff --git a/app-core/src/main/java/com/mercury/platform/shared/pojo/ResponseButton.java b/app-core/src/main/java/com/mercury/platform/shared/entity/ResponseButton.java similarity index 92% rename from app-core/src/main/java/com/mercury/platform/shared/pojo/ResponseButton.java rename to app-core/src/main/java/com/mercury/platform/shared/entity/ResponseButton.java index 181caa92..a540cd9f 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/pojo/ResponseButton.java +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/ResponseButton.java @@ -1,4 +1,4 @@ -package com.mercury.platform.shared.pojo; +package com.mercury.platform.shared.entity; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/app-core/src/main/java/com/mercury/platform/shared/pojo/ScaleData.java b/app-core/src/main/java/com/mercury/platform/shared/entity/ScaleData.java similarity index 82% rename from app-core/src/main/java/com/mercury/platform/shared/pojo/ScaleData.java rename to app-core/src/main/java/com/mercury/platform/shared/entity/ScaleData.java index 10748c6a..13f0107f 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/pojo/ScaleData.java +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/ScaleData.java @@ -1,4 +1,4 @@ -package com.mercury.platform.shared.pojo; +package com.mercury.platform.shared.entity; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/app-core/src/main/java/com/mercury/platform/shared/pojo/StashTab.java b/app-core/src/main/java/com/mercury/platform/shared/entity/StashTab.java similarity index 81% rename from app-core/src/main/java/com/mercury/platform/shared/pojo/StashTab.java rename to app-core/src/main/java/com/mercury/platform/shared/entity/StashTab.java index c5adc82f..a852b2ee 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/pojo/StashTab.java +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/StashTab.java @@ -1,4 +1,4 @@ -package com.mercury.platform.shared.pojo; +package com.mercury.platform.shared.entity; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/app-core/src/main/java/com/mercury/platform/shared/events/custom/ChangeFrameVisibleEvent.java b/app-core/src/main/java/com/mercury/platform/shared/events/custom/ChangeFrameVisibleEvent.java index 5b32efaa..e3a68b83 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/events/custom/ChangeFrameVisibleEvent.java +++ b/app-core/src/main/java/com/mercury/platform/shared/events/custom/ChangeFrameVisibleEvent.java @@ -1,6 +1,6 @@ package com.mercury.platform.shared.events.custom; -import com.mercury.platform.shared.FrameStates; +import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.events.MercuryEvent; import lombok.AllArgsConstructor; import lombok.Data; @@ -8,5 +8,5 @@ @Data @AllArgsConstructor public class ChangeFrameVisibleEvent implements MercuryEvent { - private FrameStates states; + private FrameVisibleState states; } diff --git a/app-core/src/main/java/com/mercury/platform/shared/events/custom/NewWhispersEvent.java b/app-core/src/main/java/com/mercury/platform/shared/events/custom/NewWhispersEvent.java index 05c87f81..4570b331 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/events/custom/NewWhispersEvent.java +++ b/app-core/src/main/java/com/mercury/platform/shared/events/custom/NewWhispersEvent.java @@ -1,7 +1,7 @@ package com.mercury.platform.shared.events.custom; import com.mercury.platform.shared.events.MercuryEvent; -import com.mercury.platform.shared.pojo.Message; +import com.mercury.platform.shared.entity.Message; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/app-core/src/main/java/com/mercury/platform/shared/events/custom/OutTradeMessageEvent.java b/app-core/src/main/java/com/mercury/platform/shared/events/custom/OutTradeMessageEvent.java index c1bf0762..43a5ef17 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/events/custom/OutTradeMessageEvent.java +++ b/app-core/src/main/java/com/mercury/platform/shared/events/custom/OutTradeMessageEvent.java @@ -1,7 +1,7 @@ package com.mercury.platform.shared.events.custom; import com.mercury.platform.shared.events.MercuryEvent; -import com.mercury.platform.shared.pojo.Message; +import com.mercury.platform.shared.entity.Message; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/app-core/src/main/java/com/mercury/platform/shared/http/ItemGuard.java b/app-core/src/main/java/com/mercury/platform/shared/http/ItemGuard.java new file mode 100644 index 00000000..be255c2f --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/http/ItemGuard.java @@ -0,0 +1,4 @@ +package com.mercury.platform.shared.http; + +public class ItemGuard { +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/http/RequestBuilder.java b/app-core/src/main/java/com/mercury/platform/shared/http/RequestBuilder.java new file mode 100644 index 00000000..58f4786c --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/http/RequestBuilder.java @@ -0,0 +1,7 @@ +package com.mercury.platform.shared.http; + +/** + * Created by Константин on 07.04.2017. + */ +public class RequestBuilder { +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/store/DataTransformers.java b/app-core/src/main/java/com/mercury/platform/shared/store/DataTransformers.java new file mode 100644 index 00000000..09489cf5 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/store/DataTransformers.java @@ -0,0 +1,33 @@ +package com.mercury.platform.shared.store; + +import com.mercury.platform.core.misc.SoundType; +import rx.Observable; + +import java.util.HashMap; +import java.util.Map; + + +public class DataTransformers { + public static Observable.Transformer> transformSoundData() { + return obs -> obs.map(soundType -> { + Map data = new HashMap<>(); + switch (soundType){ + case MESSAGE:{ + data.put("path","app/notification.wav"); + data.put("db","-10"); + break; + } + case CHAT_SCANNER: { + break; + } + case CLICKS: { + break; + } + case UPDATE: { + break; + } + } + return data; + }); + } +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java new file mode 100644 index 00000000..617fa545 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java @@ -0,0 +1,13 @@ +package com.mercury.platform.shared.store; + +import com.mercury.platform.core.misc.SoundType; +import rx.subjects.PublishSubject; + +public class MercuryStore { + private static class MercuryStoreHolder { + static final MercuryStore HOLDER_INSTANCE = new MercuryStore(); + } + public static MercuryStore INSTANCE = MercuryStoreHolder.HOLDER_INSTANCE; + + public final PublishSubject soundSubject = PublishSubject.create(); +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/store/Reducer.java b/app-core/src/main/java/com/mercury/platform/shared/store/Reducer.java new file mode 100644 index 00000000..4fe761d1 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/store/Reducer.java @@ -0,0 +1,16 @@ +package com.mercury.platform.shared.store; + +import lombok.Getter; +import rx.subjects.PublishSubject; + + +public class Reducer { + @Getter + private String key; + @Getter + private PublishSubject subject; + protected Reducer(String key){ + this.key = key; + this.subject = 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/MessageParserTest.java index 28970bae..6f11b6d7 100644 --- a/app-core/src/test/java/com/mercury/platform/shared/MessageParserTest.java +++ b/app-core/src/test/java/com/mercury/platform/shared/MessageParserTest.java @@ -1,7 +1,7 @@ package com.mercury.platform.shared; -import com.mercury.platform.shared.pojo.CurrencyMessage; -import com.mercury.platform.shared.pojo.ItemMessage; +import com.mercury.platform.shared.entity.CurrencyMessage; +import com.mercury.platform.shared.entity.ItemMessage; import org.junit.Before; import org.junit.Test; diff --git a/app-core/src/test/java/com/mercury/platform/shared/store/MercuryStoreTest.java b/app-core/src/test/java/com/mercury/platform/shared/store/MercuryStoreTest.java new file mode 100644 index 00000000..489a6562 --- /dev/null +++ b/app-core/src/test/java/com/mercury/platform/shared/store/MercuryStoreTest.java @@ -0,0 +1,17 @@ +package com.mercury.platform.shared.store; + +import com.mercury.platform.core.misc.SoundType; +import org.junit.Test; + + +public class MercuryStoreTest { + @Test + public void testSoundReducer(){ + MercuryStore.INSTANCE.soundSubject + .compose(DataTransformers.transformSoundData()) + .subscribe(System.out::println); + + MercuryStore.INSTANCE.soundSubject.onNext(SoundType.MESSAGE); + + } +} \ No newline at end of file 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 274acada..cc7a69b1 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 @@ -1,14 +1,12 @@ package com.mercury.platform.ui.components.panel.grid; import com.mercury.platform.shared.events.EventRouter; -import com.mercury.platform.shared.pojo.StashTab; +import com.mercury.platform.shared.entity.StashTab; import com.mercury.platform.ui.misc.TooltipConstants; -import com.mercury.platform.ui.misc.event.CloseGridItemEvent; -import com.mercury.platform.shared.pojo.ItemMessage; +import com.mercury.platform.shared.entity.ItemMessage; import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.panel.misc.HasUI; import com.mercury.platform.ui.misc.AppThemeColor; -import com.mercury.platform.ui.misc.event.ItemCellStateChangedEvent; import com.mercury.platform.ui.misc.event.RepaintEvent; import javax.swing.*; 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 09d6c088..e972c3db 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,7 +1,7 @@ package com.mercury.platform.ui.components.panel.grid; import com.mercury.platform.shared.events.EventRouter; -import com.mercury.platform.shared.pojo.ItemMessage; +import com.mercury.platform.shared.entity.ItemMessage; import com.mercury.platform.ui.misc.event.CloseGridItemEvent; import com.mercury.platform.ui.misc.event.ItemCellStateChangedEvent; import lombok.NonNull; 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 d4d7141b..5f73c512 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,8 +1,8 @@ package com.mercury.platform.ui.components.panel.grid; import com.mercury.platform.shared.events.EventRouter; -import com.mercury.platform.shared.pojo.ItemMessage; -import com.mercury.platform.shared.pojo.StashTab; +import com.mercury.platform.shared.entity.ItemMessage; +import com.mercury.platform.shared.entity.StashTab; import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.panel.misc.HasUI; import com.mercury.platform.ui.misc.AppThemeColor; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/StashTabsContainer.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/StashTabsContainer.java index 92febb66..1ea98da6 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/StashTabsContainer.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/grid/StashTabsContainer.java @@ -1,7 +1,7 @@ package com.mercury.platform.ui.components.panel.grid; import com.mercury.platform.shared.ConfigManager; -import com.mercury.platform.shared.pojo.StashTab; +import com.mercury.platform.shared.entity.StashTab; import java.util.List; public class StashTabsContainer { 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 6a63f11c..a519ff8c 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 @@ -1,7 +1,7 @@ package com.mercury.platform.ui.components.panel.grid; import com.mercury.platform.shared.events.EventRouter; -import com.mercury.platform.shared.pojo.StashTab; +import com.mercury.platform.shared.entity.StashTab; 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; 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 index e029a27c..7cee0408 100644 --- 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 @@ -5,10 +5,10 @@ import com.mercury.platform.shared.HasEventHandlers; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.*; -import com.mercury.platform.shared.pojo.CurrencyMessage; -import com.mercury.platform.shared.pojo.ItemMessage; -import com.mercury.platform.shared.pojo.Message; -import com.mercury.platform.shared.pojo.ResponseButton; +import com.mercury.platform.shared.entity.CurrencyMessage; +import com.mercury.platform.shared.entity.ItemMessage; +import com.mercury.platform.shared.entity.Message; +import com.mercury.platform.shared.entity.ResponseButton; 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; 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/message/NotificationMessageController.java index 72bb1cd7..80377135 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/message/NotificationMessageController.java @@ -3,8 +3,8 @@ import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.ChatCommandEvent; import com.mercury.platform.shared.events.custom.OpenChatEvent; -import com.mercury.platform.shared.pojo.ItemMessage; -import com.mercury.platform.shared.pojo.Message; +import com.mercury.platform.shared.entity.ItemMessage; +import com.mercury.platform.shared.entity.Message; import com.mercury.platform.ui.misc.event.*; import lombok.NonNull; import org.apache.logging.log4j.LogManager; @@ -13,10 +13,8 @@ import javax.swing.*; import java.awt.*; import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.StringSelection; -import java.awt.datatransfer.UnsupportedFlavorException; -import java.io.IOException; + //todo proxy public class NotificationMessageController implements MessagePanelController { private static final Logger log = LogManager.getLogger(NotificationMessageController.class); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/CustomButtonSettings.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/CustomButtonSettings.java index fb194483..985b50ec 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/CustomButtonSettings.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/CustomButtonSettings.java @@ -3,7 +3,7 @@ import com.mercury.platform.shared.ConfigManager; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.CustomButtonsChangedEvent; -import com.mercury.platform.shared.pojo.ResponseButton; +import com.mercury.platform.shared.entity.ResponseButton; 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; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/GeneralSettings.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/GeneralSettings.java index 9dae7cb4..6584553f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/GeneralSettings.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/GeneralSettings.java @@ -6,7 +6,7 @@ import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.*; import com.mercury.platform.ui.components.fields.font.FontStyle; -import com.mercury.platform.ui.frame.ComponentFrame; +import com.mercury.platform.ui.frame.AbstractComponentFrame; import com.mercury.platform.ui.frame.titled.NotesFrame; import com.mercury.platform.ui.frame.titled.SettingsFrame; import com.mercury.platform.ui.frame.titled.TestCasesFrame; @@ -29,11 +29,11 @@ public class GeneralSettings extends ConfigurationPanel { private JSlider fadeTimeSlider; //private JComboBox secondsPicker; private JComboBox notifierStatusPicker; - private ComponentFrame owner; + private AbstractComponentFrame owner; private JCheckBox checkEnable; private JTextField gamePathField; private WrongGamePathListener poeFolderTooltipListener; - public GeneralSettings(ComponentFrame owner) { + public GeneralSettings(AbstractComponentFrame owner) { super(); this.owner = owner; createUI(); 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 44ad6e24..b33cebe2 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 @@ -60,7 +60,7 @@ public void mouseClicked(MouseEvent e) { NotesLoader notesLoader = new NotesLoader(); java.util.List patchNotes = notesLoader.getPatchNotes(); if(patchNotes.size() != 0){ - NotesFrame patchNotesFrame = new NotesFrame(patchNotes,NotesFrame.NotesType.PATCH); + NotesFrame patchNotesFrame = new NotesFrame(patchNotes, NotesFrame.NotesType.PATCH); patchNotesFrame.init(); patchNotesFrame.showComponent(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java index 9b17dce4..244a84fb 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java @@ -119,8 +119,11 @@ private JPanel getSoundPickerPanel(){ case ItemEvent.SELECTED: { if(notificationComboBox.getSelectedItem().equals("Browse")){ JFileChooser fileChooser = new JFileChooser(); - fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("*.wav","wav")); - + fileChooser.setFileFilter(new FileNameExtensionFilter("*.wav","wav")); + int returnVal = fileChooser.showOpenDialog(null); + if(returnVal == JFileChooser.APPROVE_OPTION) { + System.out.println(fileChooser.getSelectedFile().getPath()); + } } break; } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/ComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractComponentFrame.java similarity index 75% rename from app-ui/src/main/java/com/mercury/platform/ui/frame/ComponentFrame.java rename to app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractComponentFrame.java index 9056d9ea..2501bf49 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/ComponentFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractComponentFrame.java @@ -1,7 +1,6 @@ package com.mercury.platform.ui.frame; -import com.mercury.platform.shared.pojo.FrameSettings; -import com.mercury.platform.ui.frame.movable.TaskBarFrame; +import com.mercury.platform.shared.entity.FrameSettings; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.manager.HideSettingsManager; import org.pushingpixels.trident.Timeline; @@ -13,7 +12,7 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; -public abstract class ComponentFrame extends OverlaidFrame{ +public abstract class AbstractComponentFrame extends AbstractOverlaidFrame { private final int HIDE_TIME = 200; private final int SHOW_TIME = 150; private final int BORDER_THICKNESS = 1; @@ -36,7 +35,7 @@ public abstract class ComponentFrame extends OverlaidFrame{ protected boolean processEResize = true; protected boolean processHideEffect = true; - protected ComponentFrame(String title) { + protected AbstractComponentFrame(String title) { super(title); } @@ -105,25 +104,25 @@ public void onLocationChange(Point location){ configManager.saveFrameLocation(this.getClass().getSimpleName(),location); } protected void onFrameDragged(Point location){ - ComponentFrame.this.setLocation(location); + AbstractComponentFrame.this.setLocation(location); } private class ResizeByWidthMouseMotionListener extends MouseMotionAdapter{ @Override public void mouseDragged(MouseEvent e) { if(EResizeSpace) { - Point frameLocation = ComponentFrame.this.getLocation(); - ComponentFrame.this.setSize(new Dimension(e.getLocationOnScreen().x - frameLocation.x, ComponentFrame.this.getHeight())); + Point frameLocation = AbstractComponentFrame.this.getLocation(); + AbstractComponentFrame.this.setSize(new Dimension(e.getLocationOnScreen().x - frameLocation.x, AbstractComponentFrame.this.getHeight())); }else if(SEResizeSpace){ - Point frameLocation = ComponentFrame.this.getLocation(); - ComponentFrame.this.setSize(new Dimension(e.getLocationOnScreen().x - frameLocation.x, e.getLocationOnScreen().y - frameLocation.y)); + Point frameLocation = AbstractComponentFrame.this.getLocation(); + AbstractComponentFrame.this.setSize(new Dimension(e.getLocationOnScreen().x - frameLocation.x, e.getLocationOnScreen().y - frameLocation.y)); } } @Override public void mouseMoved(MouseEvent e) { - int frameWidth = ComponentFrame.this.getWidth(); - int frameHeight = ComponentFrame.this.getHeight(); - Point frameLocation = ComponentFrame.this.getLocation(); + int frameWidth = AbstractComponentFrame.this.getWidth(); + int frameHeight = AbstractComponentFrame.this.getHeight(); + Point frameLocation = AbstractComponentFrame.this.getLocation(); Rectangle ERect = new Rectangle( frameLocation.x + frameWidth - (BORDER_THICKNESS + 8), frameLocation.y,BORDER_THICKNESS+8,frameHeight); @@ -133,18 +132,18 @@ public void mouseMoved(MouseEvent e) { if(processEResize && ERect.getBounds().contains(e.getLocationOnScreen())) { if(processSEResize && SERect.getBounds().contains(e.getLocationOnScreen())){ - ComponentFrame.this.setCursor(new Cursor(Cursor.SE_RESIZE_CURSOR)); + AbstractComponentFrame.this.setCursor(new Cursor(Cursor.SE_RESIZE_CURSOR)); SEResizeSpace = true; EResizeSpace = false; }else { - ComponentFrame.this.setCursor(new Cursor(Cursor.W_RESIZE_CURSOR)); + AbstractComponentFrame.this.setCursor(new Cursor(Cursor.W_RESIZE_CURSOR)); EResizeSpace = true; SEResizeSpace = false; } }else { EResizeSpace = false; SEResizeSpace = false; - ComponentFrame.this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + AbstractComponentFrame.this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } } @@ -154,19 +153,19 @@ public void mouseReleased(MouseEvent e) { if(hideAnimationEnable && !isMouseWithInFrame()) { hideTimer.start(); } - Dimension size = ComponentFrame.this.getSize(); + Dimension size = AbstractComponentFrame.this.getSize(); if(EResizeSpace){ - ComponentFrame.this.setMaximumSize(size); - ComponentFrame.this.setMinimumSize(size); - if(ComponentFrame.this.getClass().getSimpleName().equals("IncMessageFrame")){ - configManager.saveFrameSize(ComponentFrame.this.getClass().getSimpleName(),new Dimension(size.width,0)); + AbstractComponentFrame.this.setMaximumSize(size); + AbstractComponentFrame.this.setMinimumSize(size); + if(AbstractComponentFrame.this.getClass().getSimpleName().equals("IncMessageFrame")){ + configManager.saveFrameSize(AbstractComponentFrame.this.getClass().getSimpleName(),new Dimension(size.width,0)); }else { - configManager.saveFrameSize(ComponentFrame.this.getClass().getSimpleName(), size); + configManager.saveFrameSize(AbstractComponentFrame.this.getClass().getSimpleName(), size); } }else if(SEResizeSpace){ - ComponentFrame.this.setMinimumSize(size); - ComponentFrame.this.setMaximumSize(size); - configManager.saveFrameSize(ComponentFrame.this.getClass().getSimpleName(),ComponentFrame.this.getSize()); + AbstractComponentFrame.this.setMinimumSize(size); + AbstractComponentFrame.this.setMaximumSize(size); + configManager.saveFrameSize(AbstractComponentFrame.this.getClass().getSimpleName(),AbstractComponentFrame.this.getSize()); } EResizeSpace = false; SEResizeSpace = false; @@ -174,14 +173,14 @@ public void mouseReleased(MouseEvent e) { @Override public void mouseExited(MouseEvent e) { - ComponentFrame.this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + AbstractComponentFrame.this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } @Override public void mousePressed(MouseEvent e) { if(EResizeSpace || SEResizeSpace) { - Dimension size = configManager.getMinimumFrameSize(ComponentFrame.this.getClass().getSimpleName()); - ComponentFrame.this.setMinimumSize(size); + Dimension size = configManager.getMinimumFrameSize(AbstractComponentFrame.this.getClass().getSimpleName()); + AbstractComponentFrame.this.setMinimumSize(size); } } } @@ -199,9 +198,9 @@ public HideEffectListener(){ } @Override public void mouseEntered(MouseEvent e) { - ComponentFrame.this.repaint(); + AbstractComponentFrame.this.repaint(); hideTimer.stop(); - if(ComponentFrame.this.getOpacity() < maxOpacity) { + if(AbstractComponentFrame.this.getOpacity() < maxOpacity) { showAnimation.play(); } } @@ -220,7 +219,7 @@ public void mouseExited(MouseEvent e) { public class DraggedFrameMotionListener extends MouseAdapter { @Override public void mouseDragged(MouseEvent e) { - e.translatePoint(ComponentFrame.this.getLocation().x - x,ComponentFrame.this.getLocation().y - y); + e.translatePoint(AbstractComponentFrame.this.getLocation().x - x,AbstractComponentFrame.this.getLocation().y - y); onFrameDragged(new Point(e.getX(),e.getY())); } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/OverlaidFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractOverlaidFrame.java similarity index 79% rename from app-ui/src/main/java/com/mercury/platform/ui/frame/OverlaidFrame.java rename to app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractOverlaidFrame.java index 934cee86..4e54cc5e 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/OverlaidFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractOverlaidFrame.java @@ -1,7 +1,7 @@ package com.mercury.platform.ui.frame; import com.mercury.platform.shared.ConfigManager; -import com.mercury.platform.shared.FrameStates; +import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.HasEventHandlers; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.MercuryEventHandler; @@ -14,15 +14,15 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -public abstract class OverlaidFrame extends JFrame implements HasEventHandlers{ - protected FrameStates prevState; +public abstract class AbstractOverlaidFrame extends JFrame implements HasEventHandlers{ + protected FrameVisibleState prevState; protected boolean processingHideEvent = true; protected ComponentsFactory componentsFactory; protected ConfigManager configManager = ConfigManager.INSTANCE; protected LayoutManager layout; - protected OverlaidFrame(String title){ + protected AbstractOverlaidFrame(String title){ super(title); this.componentsFactory = new ComponentsFactory(); getRootPane().setOpaque(false); @@ -34,11 +34,11 @@ protected OverlaidFrame(String title){ setFocusable(false); setAlwaysOnTop(true); setVisible(false); - this.prevState = FrameStates.HIDE; + this.prevState = FrameVisibleState.HIDE; this.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { - OverlaidFrame.this.repaint(); + AbstractOverlaidFrame.this.repaint(); } }); @@ -51,20 +51,20 @@ public void handle(ChangeFrameVisibleEvent event) { changeVisible(event.getStates()); } } - private void changeVisible(FrameStates state){ + private void changeVisible(FrameVisibleState state){ if (processingHideEvent) { switch (state) { case SHOW: { - if (prevState.equals(FrameStates.SHOW)) { + if (prevState.equals(FrameVisibleState.SHOW)) { showComponent(); } } break; case HIDE: { - if (OverlaidFrame.this.isVisible()) { - prevState = FrameStates.SHOW; + if (AbstractOverlaidFrame.this.isVisible()) { + prevState = FrameVisibleState.SHOW; }else { - prevState = FrameStates.HIDE; + prevState = FrameVisibleState.HIDE; } hideComponent(); } @@ -94,7 +94,7 @@ public void hideComponent(){ this.setVisible(false); } - public void setPrevState(FrameStates prevState) { + public void setPrevState(FrameVisibleState prevState) { this.prevState = prevState; } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/ScalableComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractScalableComponentFrame.java similarity index 95% rename from app-ui/src/main/java/com/mercury/platform/ui/frame/ScalableComponentFrame.java rename to app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractScalableComponentFrame.java index 37ae41f5..e4fbc515 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/ScalableComponentFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractScalableComponentFrame.java @@ -4,7 +4,6 @@ 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.shared.pojo.ScaleData; import com.mercury.platform.ui.misc.event.SaveScaleEvent; import com.mercury.platform.ui.misc.event.ScaleChangeEvent; @@ -12,7 +11,7 @@ import java.awt.*; import java.util.Map; //todo need generalization -public abstract class ScalableComponentFrame extends ComponentFrame implements HasUI{ +public abstract class AbstractScalableComponentFrame extends AbstractComponentFrame implements HasUI{ protected Container mainContainer; private ScaleState scaleState = ScaleState.DEFAULT; protected ComponentsFactory stubComponentsFactory; @@ -20,7 +19,7 @@ public abstract class ScalableComponentFrame extends ComponentFrame implements H protected boolean sizeWasChanged = false; protected boolean inScaleSettings = false; - protected ScalableComponentFrame(String title) { + protected AbstractScalableComponentFrame(String title) { super(title); mainContainer = this.getContentPane(); stubComponentsFactory = new ComponentsFactory(); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/MovableComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/AbstractMovableComponentFrame.java similarity index 92% rename from app-ui/src/main/java/com/mercury/platform/ui/frame/movable/MovableComponentFrame.java rename to app-ui/src/main/java/com/mercury/platform/ui/frame/movable/AbstractMovableComponentFrame.java index 773044fb..c727e899 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/MovableComponentFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/AbstractMovableComponentFrame.java @@ -1,6 +1,6 @@ package com.mercury.platform.ui.frame.movable; -import com.mercury.platform.ui.frame.ScalableComponentFrame; +import com.mercury.platform.ui.frame.AbstractScalableComponentFrame; import com.mercury.platform.ui.frame.setup.location.LocationState; import com.mercury.platform.ui.misc.AppThemeColor; @@ -10,13 +10,13 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -public abstract class MovableComponentFrame extends ScalableComponentFrame { +public abstract class AbstractMovableComponentFrame extends AbstractScalableComponentFrame { private MovableFrameConstraints prevConstraints; private LocationState moveState = LocationState.DEFAULT; protected boolean locationWasChanged = false; protected boolean inMoveMode = false; protected boolean enableMouseOverBorder = true; - protected MovableComponentFrame(String title) { + protected AbstractMovableComponentFrame(String title) { super(title); mainContainer = this.getContentPane(); } @@ -101,15 +101,15 @@ private JPanel setUpMoveListeners(JPanel panel){ @Override public void mouseEntered(MouseEvent e) { getRootPane().setBorder(BorderFactory.createLineBorder(AppThemeColor.TEXT_MESSAGE, 1)); - MovableComponentFrame.this.repaint(); + AbstractMovableComponentFrame.this.repaint(); } @Override public void mouseExited(MouseEvent e) { - if (!MovableComponentFrame.this.getBounds().contains(e.getPoint())) { + if (!AbstractMovableComponentFrame.this.getBounds().contains(e.getPoint())) { getRootPane().setBorder(BorderFactory.createLineBorder(AppThemeColor.BORDER, 1)); } - MovableComponentFrame.this.repaint(); + AbstractMovableComponentFrame.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 19467490..538ee13a 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 @@ -1,11 +1,10 @@ package com.mercury.platform.ui.frame.movable; -import com.mercury.platform.shared.FrameStates; +import com.mercury.platform.shared.FrameVisibleState; 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.misc.AppThemeColor; -import com.mercury.platform.shared.pojo.ScaleData; import javax.swing.*; import java.awt.*; @@ -14,13 +13,13 @@ /** * Created by Константин on 02.03.2017. */ -public class CurrencySearchFrame extends MovableComponentFrame { +public class CurrencySearchFrame extends AbstractMovableComponentFrame { private JPanel setUpPanel; private JPanel loadingPanel; private JPanel resultPanel; public CurrencySearchFrame() { super("MT-CurrencySearchFrame"); - prevState = FrameStates.SHOW; + prevState = FrameVisibleState.SHOW; } @Override 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 409f0f1c..6b6071d3 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,11 +6,9 @@ import com.mercury.platform.ui.components.fields.style.MercuryScrollBarUI; import com.mercury.platform.ui.components.panel.HorizontalScrollContainer; import com.mercury.platform.ui.components.panel.grid.*; -import com.mercury.platform.shared.pojo.ScaleData; -import com.mercury.platform.ui.frame.ComponentFrame; import com.mercury.platform.ui.misc.event.*; -import com.mercury.platform.shared.pojo.ItemMessage; -import com.mercury.platform.shared.pojo.Message; +import com.mercury.platform.shared.entity.ItemMessage; +import com.mercury.platform.shared.entity.Message; 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; @@ -22,7 +20,7 @@ import java.awt.event.*; import java.util.Map; -public class ItemsGridFrame extends MovableComponentFrame{ +public class ItemsGridFrame extends AbstractMovableComponentFrame { private ItemsGridPanel itemsGridPanel; private HorizontalScrollContainer tabsContainer; private StashTabsContainer stashTabsContainer; 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 fddf4f6d..e5e070bf 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 @@ -1,7 +1,7 @@ package com.mercury.platform.ui.frame.movable; import com.mercury.platform.shared.ConfigManager; -import com.mercury.platform.shared.FrameStates; +import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.fields.font.FontStyle; @@ -10,7 +10,6 @@ import com.mercury.platform.ui.components.panel.taskbar.TaskBarController; import com.mercury.platform.ui.components.panel.taskbar.TaskBarPanel; import com.mercury.platform.ui.misc.AppThemeColor; -import com.mercury.platform.shared.pojo.ScaleData; import com.mercury.platform.ui.misc.event.RepaintEvent; import com.mercury.platform.ui.misc.event.ScaleChangeEvent; import org.pushingpixels.trident.Timeline; @@ -21,7 +20,7 @@ import java.awt.event.*; import java.util.Map; -public class TaskBarFrame extends MovableComponentFrame{ +public class TaskBarFrame extends AbstractMovableComponentFrame { private Timeline collapseAnimation; private int MIN_WIDTH; private int MAX_WIDTH; @@ -34,7 +33,7 @@ public TaskBarFrame() { stubComponentsFactory.setScale(ConfigManager.INSTANCE.getScaleData().get("taskbar")); processEResize = false; processSEResize = false; - prevState = FrameStates.SHOW; + prevState = FrameVisibleState.SHOW; } @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/IncMessageFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/IncMessageFrame.java index d4549f01..2de258be 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/IncMessageFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/IncMessageFrame.java @@ -2,11 +2,11 @@ import com.mercury.platform.core.AppStarter; import com.mercury.platform.shared.ConfigManager; -import com.mercury.platform.shared.FrameStates; +import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.*; -import com.mercury.platform.shared.pojo.ItemMessage; -import com.mercury.platform.shared.pojo.Message; +import com.mercury.platform.shared.entity.ItemMessage; +import com.mercury.platform.shared.entity.Message; 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; @@ -14,8 +14,8 @@ 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.frame.movable.MovableComponentFrame; -import com.mercury.platform.ui.frame.OverlaidFrame; +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; @@ -31,7 +31,7 @@ import java.util.HashMap; import java.util.Map; -public class IncMessageFrame extends MovableComponentFrame implements MessagesContainer { +public class IncMessageFrame extends AbstractMovableComponentFrame implements MessagesContainer { private Map currentMessages; private boolean wasVisible; private FlowDirections flowDirections; @@ -176,10 +176,10 @@ private void addMessage(Message message){ new NotificationMessageController(message), this.componentsFactory); - if (!dnd && !this.isVisible() && AppStarter.APP_STATUS == FrameStates.SHOW) { + if (!dnd && !this.isVisible() && AppStarter.APP_STATUS == FrameVisibleState.SHOW) { this.setVisible(true); } else { - prevState = FrameStates.SHOW; + prevState = FrameVisibleState.SHOW; } if (flowDirections.equals(FlowDirections.UPWARDS)) { mainContainer.add(messagePanel, 1); @@ -606,7 +606,7 @@ public void reloadMessage(MessagePanel panel1) {} return panel; } - private class ExpandAllFrame extends OverlaidFrame { + private class ExpandAllFrame extends AbstractOverlaidFrame { private int messageCount = 0; private JLabel msgCountLabel; private JButton expandButton; 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 b7f598ae..9a3d2d27 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 @@ -2,7 +2,7 @@ import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.AlertEvent; -import com.mercury.platform.ui.frame.OverlaidFrame; +import com.mercury.platform.ui.frame.AbstractOverlaidFrame; import com.mercury.platform.ui.misc.AppThemeColor; import javax.swing.*; @@ -13,7 +13,7 @@ /** * Created by Константин on 07.03.2017. */ -public class AlertFrame extends OverlaidFrame { +public class AlertFrame extends AbstractOverlaidFrame { private JLabel messageLabel; public AlertFrame() { super("MercuryTrade"); 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 0397ed92..f0581441 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 @@ -2,7 +2,7 @@ import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.HideLoadingFrame; -import com.mercury.platform.ui.frame.OverlaidFrame; +import com.mercury.platform.ui.frame.AbstractOverlaidFrame; import com.mercury.platform.ui.misc.AppThemeColor; import org.pushingpixels.trident.Timeline; import org.pushingpixels.trident.callback.TimelineCallback; @@ -11,7 +11,7 @@ import java.awt.*; -public class MercuryLoadingFrame extends OverlaidFrame { +public class MercuryLoadingFrame extends AbstractOverlaidFrame { private Timeline hideAnimation; private Timeline showAnimation; public MercuryLoadingFrame() { 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/NotificationFrame.java index 5450ecac..e48caea2 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/NotificationFrame.java @@ -4,7 +4,7 @@ import com.mercury.platform.shared.events.custom.NotificationEvent; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.frame.OverlaidFrame; +import com.mercury.platform.ui.frame.AbstractOverlaidFrame; import com.mercury.platform.ui.misc.AppThemeColor; import org.pushingpixels.trident.Timeline; import org.pushingpixels.trident.callback.TimelineCallback; @@ -15,7 +15,7 @@ /** * Created by Константин on 29.12.2016. */ -public class NotificationFrame extends OverlaidFrame { +public class NotificationFrame extends AbstractOverlaidFrame { private JLabel messageLabel; private Timeline showAnimation; public NotificationFrame() { 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 index ed0b7c91..026e3586 100644 --- 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 @@ -1,16 +1,16 @@ package com.mercury.platform.ui.frame.other; import com.mercury.platform.core.AppStarter; -import com.mercury.platform.shared.FrameStates; +import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.ChatCommandEvent; import com.mercury.platform.shared.events.custom.OutTradeMessageEvent; -import com.mercury.platform.shared.pojo.CurrencyMessage; -import com.mercury.platform.shared.pojo.ItemMessage; -import com.mercury.platform.shared.pojo.Message; +import com.mercury.platform.shared.entity.CurrencyMessage; +import com.mercury.platform.shared.entity.ItemMessage; +import com.mercury.platform.shared.entity.Message; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.frame.ComponentFrame; +import com.mercury.platform.ui.frame.AbstractComponentFrame; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.TooltipConstants; @@ -22,7 +22,7 @@ /** * Created by Константин on 12.01.2017. */ -public class OutMessageFrame extends ComponentFrame { +public class OutMessageFrame extends AbstractComponentFrame { public OutMessageFrame() { super("MercuryTrade"); } @@ -121,11 +121,11 @@ private JPanel getCurCountPanel(Double curCount, String currency){ @Override public void initHandlers() { EventRouter.CORE.registerHandler(OutTradeMessageEvent.class, event -> { - if (!this.isVisible() && AppStarter.APP_STATUS == FrameStates.SHOW) { + if (!this.isVisible() && AppStarter.APP_STATUS == FrameVisibleState.SHOW) { this.setAlwaysOnTop(true); this.setVisible(true); } else { - prevState = FrameStates.SHOW; + prevState = FrameVisibleState.SHOW; } Message message = ((OutTradeMessageEvent) event).getMessage(); addNewMessage(message); 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 410be8b6..8ea0cde7 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 @@ -1,6 +1,6 @@ package com.mercury.platform.ui.frame.other; -import com.mercury.platform.ui.frame.OverlaidFrame; +import com.mercury.platform.ui.frame.AbstractOverlaidFrame; import com.mercury.platform.ui.manager.FramesManager; import com.mercury.platform.ui.misc.AppThemeColor; @@ -9,7 +9,7 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -public class SetUpLocationFrame extends OverlaidFrame { +public class SetUpLocationFrame extends AbstractOverlaidFrame { public SetUpLocationFrame() { super("MercuryTrade"); } 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 c4eb8204..380205dc 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 @@ -4,10 +4,9 @@ import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.frame.OverlaidFrame; +import com.mercury.platform.ui.frame.AbstractOverlaidFrame; import com.mercury.platform.ui.manager.FramesManager; import com.mercury.platform.ui.misc.AppThemeColor; -import com.mercury.platform.shared.pojo.ScaleData; import com.mercury.platform.ui.misc.event.SaveScaleEvent; import com.mercury.platform.ui.misc.event.ScaleChangeEvent; @@ -17,7 +16,7 @@ import java.awt.event.MouseEvent; import java.util.Map; -public class SetUpScaleFrame extends OverlaidFrame { +public class SetUpScaleFrame extends AbstractOverlaidFrame { private Map scaleData; public SetUpScaleFrame() { super("MercuryTrade"); 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 b0a62247..ce545a76 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 @@ -6,7 +6,7 @@ import com.mercury.platform.ui.misc.event.ShowTooltipEvent; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.frame.OverlaidFrame; +import com.mercury.platform.ui.frame.AbstractOverlaidFrame; import com.mercury.platform.ui.misc.AppThemeColor; import javax.swing.*; @@ -15,7 +15,7 @@ /** * Created by Константин on 17.01.2017. */ -public class TooltipFrame extends OverlaidFrame { +public class TooltipFrame extends AbstractOverlaidFrame { private Timer tooltipTimer; public TooltipFrame() { super("MercuryTrade"); 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 4f4c2002..2553f7db 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 @@ -2,14 +2,14 @@ import com.mercury.platform.core.AppStarter; import com.mercury.platform.shared.ConfigManager; -import com.mercury.platform.shared.FrameStates; +import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.CheckOutPatchNotes; import com.mercury.platform.shared.events.custom.UpdateInfoEvent; -import com.mercury.platform.shared.pojo.FrameSettings; +import com.mercury.platform.shared.entity.FrameSettings; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.frame.OverlaidFrame; +import com.mercury.platform.ui.frame.AbstractOverlaidFrame; import com.mercury.platform.ui.misc.AppThemeColor; import javax.swing.*; @@ -17,7 +17,7 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -public class UpdateReadyFrame extends OverlaidFrame { +public class UpdateReadyFrame extends AbstractOverlaidFrame { public UpdateReadyFrame() { super("MercuryTrade"); } @@ -80,10 +80,10 @@ public void initHandlers() { if(deltaWidth < 0){ this.setLocation(tbLocation.x - Math.abs(deltaWidth), this.getLocation().y); } - if (!this.isVisible() && AppStarter.APP_STATUS == FrameStates.SHOW) { + if (!this.isVisible() && AppStarter.APP_STATUS == FrameVisibleState.SHOW) { this.setVisible(true); } else { - prevState = FrameStates.SHOW; + prevState = FrameVisibleState.SHOW; } pack(); }); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/setup/location/SetUpLocationCommander.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/setup/location/SetUpLocationCommander.java index 3ce32264..9d851e82 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/setup/location/SetUpLocationCommander.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/setup/location/SetUpLocationCommander.java @@ -1,13 +1,13 @@ package com.mercury.platform.ui.frame.setup.location; +import com.mercury.platform.ui.frame.movable.AbstractMovableComponentFrame; import com.mercury.platform.ui.frame.other.SetUpLocationFrame; -import com.mercury.platform.ui.frame.movable.MovableComponentFrame; import com.mercury.platform.ui.frame.setup.SetUpCommander; import com.mercury.platform.ui.manager.FramesManager; import java.util.*; -public class SetUpLocationCommander extends SetUpCommander{ +public class SetUpLocationCommander extends SetUpCommander{ public SetUpLocationCommander() { super(); } @@ -31,14 +31,14 @@ public void setUpAllExclude(Class[] framesClasses) { } @Override public void setUp(Class frameClass, boolean showingSetUpFrame) { - MovableComponentFrame frame = frames.get(frameClass); + AbstractMovableComponentFrame frame = frames.get(frameClass); enableMovement(frame,showingSetUpFrame); activeFrames.add(frame); } @Override public void setOrEndUp(Class frameClass, boolean showingSetUpFrame) { - MovableComponentFrame frame = frames.get(frameClass); + AbstractMovableComponentFrame frame = frames.get(frameClass); if(frame.getMoveState().equals(LocationState.DEFAULT)){ enableMovement(frame,showingSetUpFrame); activeFrames.add(frame); @@ -56,17 +56,17 @@ public void endUpAll() { @Override public void endUp(Class frameClass) { - MovableComponentFrame frame = frames.get(frameClass); + AbstractMovableComponentFrame frame = frames.get(frameClass); disableMovement(frame); activeFrames.remove(frame); } - private void enableMovement(MovableComponentFrame frame, boolean showSetUpFrame){ + private void enableMovement(AbstractMovableComponentFrame frame, boolean showSetUpFrame){ frame.setState(LocationState.MOVING); if(showSetUpFrame){ FramesManager.INSTANCE.showFrame(SetUpLocationFrame.class); } } - private void disableMovement(MovableComponentFrame frame){ + private void disableMovement(AbstractMovableComponentFrame frame){ frame.setState(LocationState.DEFAULT); FramesManager.INSTANCE.hideFrame(SetUpLocationFrame.class); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/setup/scale/SetUpScaleCommander.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/setup/scale/SetUpScaleCommander.java index 202c85e6..7fb8db0b 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/setup/scale/SetUpScaleCommander.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/setup/scale/SetUpScaleCommander.java @@ -1,10 +1,10 @@ package com.mercury.platform.ui.frame.setup.scale; -import com.mercury.platform.ui.frame.ScalableComponentFrame; +import com.mercury.platform.ui.frame.AbstractScalableComponentFrame; import com.mercury.platform.ui.frame.setup.SetUpCommander; -public class SetUpScaleCommander extends SetUpCommander{ +public class SetUpScaleCommander extends SetUpCommander{ public SetUpScaleCommander() { super(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TitledComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/AbstractTitledComponentFrame.java similarity index 90% rename from app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TitledComponentFrame.java rename to app-ui/src/main/java/com/mercury/platform/ui/frame/titled/AbstractTitledComponentFrame.java index 721c7049..c5d2f662 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TitledComponentFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/AbstractTitledComponentFrame.java @@ -1,6 +1,6 @@ package com.mercury.platform.ui.frame.titled; -import com.mercury.platform.ui.frame.ComponentFrame; +import com.mercury.platform.ui.frame.AbstractComponentFrame; import com.mercury.platform.ui.misc.AppThemeColor; import javax.swing.*; @@ -11,11 +11,11 @@ /** * Created by Константин on 18.01.2017. */ -public abstract class TitledComponentFrame extends ComponentFrame { +public abstract class AbstractTitledComponentFrame extends AbstractComponentFrame { protected JPanel miscPanel; protected JButton hideButton; private JLabel frameTitleLabel; - protected TitledComponentFrame(String title) { + protected AbstractTitledComponentFrame(String title) { super(title); miscPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); } @@ -51,7 +51,7 @@ private void initHeaderPanel(){ @Override public void mousePressed(MouseEvent e) { if(SwingUtilities.isLeftMouseButton(e)) { - TitledComponentFrame.this.setVisible(false); + AbstractTitledComponentFrame.this.setVisible(false); } } }); 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 b71adaa7..9cc189fd 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 @@ -13,7 +13,7 @@ import java.awt.event.MouseEvent; import java.io.File; -public class GamePathChooser extends TitledComponentFrame { +public class GamePathChooser extends AbstractTitledComponentFrame { private final Logger logger = LogManager.getLogger(GamePathChooser.class.getSimpleName()); private JLabel statusLabel; private String gamePath; 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 8882ccf4..9bb540f8 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 @@ -1,14 +1,14 @@ package com.mercury.platform.ui.frame.titled; import com.mercury.platform.shared.ConfigManager; -import com.mercury.platform.shared.FrameStates; +import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.ChunkLoadedEvent; import com.mercury.platform.shared.events.custom.StartUpdateEvent; import com.mercury.platform.shared.events.custom.UpdateReadyEvent; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.frame.OverlaidFrame; +import com.mercury.platform.ui.frame.AbstractOverlaidFrame; import com.mercury.platform.ui.frame.movable.ItemsGridFrame; import com.mercury.platform.ui.manager.FramesManager; import com.mercury.platform.ui.misc.AppThemeColor; @@ -21,7 +21,7 @@ import java.net.URI; import java.util.List; -public class NotesFrame extends TitledComponentFrame { +public class NotesFrame extends AbstractTitledComponentFrame { private List currentNotes; private ContentPanel contentPanel; private NotesType type; @@ -40,10 +40,10 @@ public NotesFrame(List notes, NotesType type) { if(type.equals(NotesType.INFO)) { boolean showOnStartUp = ConfigManager.INSTANCE.isShowOnStartUp(); if (showOnStartUp) { - prevState = FrameStates.SHOW; + prevState = FrameVisibleState.SHOW; } else { this.setVisible(false); - prevState = FrameStates.HIDE; + prevState = FrameVisibleState.HIDE; } } } @@ -156,7 +156,7 @@ public void mousePressed(MouseEvent e) { ConfigManager.INSTANCE.setShowOnStartUp(showOnStartUp.isSelected()); FramesManager.INSTANCE.enableMovementExclude(ItemsGridFrame.class); } - prevState = FrameStates.HIDE; + prevState = FrameVisibleState.HIDE; } } }); @@ -260,7 +260,7 @@ public enum NotesType { INFO, PATCH } - private class ProgressBarFrame extends OverlaidFrame { + private class ProgressBarFrame extends AbstractOverlaidFrame { private JProgressBar progressBar; private JLabel percentLabel; private int percent; 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 dba7ae6c..5c12f7ef 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 @@ -13,7 +13,7 @@ import java.util.*; import java.util.List; -public class SettingsFrame extends TitledComponentFrame { +public class SettingsFrame extends AbstractTitledComponentFrame { private List innerPanels; private boolean successfullySaved = true; public SettingsFrame(){ 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 d4f717fe..80dbf0a9 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,8 +3,7 @@ import com.mercury.platform.shared.MessageParser; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.*; -import com.mercury.platform.shared.pojo.Message; -import com.mercury.platform.ui.frame.titled.TitledComponentFrame; +import com.mercury.platform.shared.entity.Message; import com.mercury.platform.ui.misc.AppThemeColor; import javax.swing.*; @@ -15,7 +14,7 @@ import java.util.*; import java.util.List; -public class TestCasesFrame extends TitledComponentFrame { +public class TestCasesFrame extends AbstractTitledComponentFrame { private List items; private List currency; private List nickNames; 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 dd1e69ed..1088d0fd 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 @@ -13,7 +13,7 @@ /** * Created by Константин on 06.01.2017. */ -public class TimerFrame extends TitledComponentFrame { +public class TimerFrame extends AbstractTitledComponentFrame { private Timer timeAgo; private JLabel timeLabel; private int seconds = 0; 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 5139c6c5..f3d4daf0 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 @@ -5,9 +5,9 @@ import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.AddInterceptorEvent; import com.mercury.platform.shared.events.custom.RemoveInterceptorEvent; -import com.mercury.platform.shared.pojo.FrameSettings; +import com.mercury.platform.shared.entity.FrameSettings; import com.mercury.platform.ui.components.panel.chat.ChatFilterPanel; -import com.mercury.platform.ui.frame.titled.TitledComponentFrame; +import com.mercury.platform.ui.frame.titled.AbstractTitledComponentFrame; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.event.PackEvent; import com.mercury.platform.ui.misc.event.RepaintEvent; @@ -21,7 +21,7 @@ import java.util.*; import java.util.List; -public class ChatFilterFrame extends TitledComponentFrame{ +public class ChatFilterFrame extends AbstractTitledComponentFrame { private ChatFilterSettingsFrame settingsFrame; private ChatFilterPanel msgContainer; private MessageInterceptor interceptor; 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 95e98731..0b110d33 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 @@ -3,14 +3,14 @@ import com.mercury.platform.shared.ConfigManager; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.frame.titled.TitledComponentFrame; +import com.mercury.platform.ui.frame.titled.AbstractTitledComponentFrame; import com.mercury.platform.ui.misc.AppThemeColor; import org.apache.commons.lang3.StringUtils; import javax.swing.*; import java.awt.*; -public class ChatFilterSettingsFrame extends TitledComponentFrame { +public class ChatFilterSettingsFrame extends AbstractTitledComponentFrame { private ChatSettingsCallback callback; public ChatFilterSettingsFrame(ChatSettingsCallback callback) { 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 f84591a3..6b0f2bd5 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 @@ -6,14 +6,14 @@ import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.MercuryEvent; import com.mercury.platform.shared.events.custom.NewWhispersEvent; -import com.mercury.platform.shared.pojo.FrameSettings; -import com.mercury.platform.shared.pojo.Message; +import com.mercury.platform.shared.entity.FrameSettings; +import com.mercury.platform.shared.entity.Message; import com.mercury.platform.ui.components.fields.style.MercuryScrollBarUI; import com.mercury.platform.ui.components.panel.message.MessagePanel; 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.frame.titled.TitledComponentFrame; +import com.mercury.platform.ui.frame.titled.AbstractTitledComponentFrame; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.event.ReloadMessageEvent; import com.mercury.platform.ui.misc.event.RepaintEvent; @@ -24,7 +24,7 @@ import java.awt.event.*; -public class HistoryFrame extends TitledComponentFrame implements HistoryContainer { +public class HistoryFrame extends AbstractTitledComponentFrame implements HistoryContainer { private JPanel mainContainer; public HistoryFrame() { super("MercuryTrade"); 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 b1790a5f..01c46571 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 @@ -1,24 +1,24 @@ package com.mercury.platform.ui.manager; import com.mercury.platform.shared.ConfigManager; -import com.mercury.platform.shared.FrameStates; +import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.HasEventHandlers; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.ShowPatchNotesEvent; import com.mercury.platform.shared.events.custom.ShutDownForUpdateEvent; import com.mercury.platform.shared.events.custom.ShutdownApplication; import com.mercury.platform.shared.events.custom.UILoadedEvent; -import com.mercury.platform.shared.pojo.FrameSettings; -import com.mercury.platform.ui.frame.ScalableComponentFrame; -import com.mercury.platform.ui.frame.other.*; -import com.mercury.platform.ui.frame.ComponentFrame; -import com.mercury.platform.ui.frame.movable.container.IncMessageFrame; +import com.mercury.platform.shared.entity.FrameSettings; +import com.mercury.platform.ui.frame.AbstractComponentFrame; +import com.mercury.platform.ui.frame.AbstractScalableComponentFrame; import com.mercury.platform.ui.frame.movable.ItemsGridFrame; -import com.mercury.platform.ui.frame.movable.MovableComponentFrame; +import com.mercury.platform.ui.frame.movable.AbstractMovableComponentFrame; +import com.mercury.platform.ui.frame.movable.container.IncMessageFrame; +import com.mercury.platform.ui.frame.other.*; import com.mercury.platform.ui.frame.movable.TaskBarFrame; import com.mercury.platform.ui.frame.setup.scale.SetUpScaleCommander; import com.mercury.platform.ui.frame.titled.*; -import com.mercury.platform.ui.frame.OverlaidFrame; +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; @@ -40,7 +40,7 @@ private static class FramesManagerHolder { } public static FramesManager INSTANCE = FramesManagerHolder.HOLDER_INSTANCE; - private Map framesMap; + private Map framesMap; private SetUpLocationCommander locationCommander; private SetUpScaleCommander scaleCommander; @@ -52,18 +52,18 @@ private FramesManager() { public void start(){ createTrayIcon(); - OverlaidFrame incMessageFrame = new IncMessageFrame(); + AbstractOverlaidFrame incMessageFrame = new IncMessageFrame(); framesMap.put(IncMessageFrame.class,incMessageFrame); - OverlaidFrame taskBarFrame = new TaskBarFrame(); - OverlaidFrame itemsMeshFrame = new ItemsGridFrame(); + AbstractOverlaidFrame taskBarFrame = new TaskBarFrame(); + AbstractOverlaidFrame itemsMeshFrame = new ItemsGridFrame(); framesMap.put(ItemsGridFrame.class,itemsMeshFrame); - locationCommander.addFrame((MovableComponentFrame) incMessageFrame); - locationCommander.addFrame((MovableComponentFrame) taskBarFrame); - locationCommander.addFrame((MovableComponentFrame) itemsMeshFrame); + locationCommander.addFrame((AbstractMovableComponentFrame) incMessageFrame); + locationCommander.addFrame((AbstractMovableComponentFrame) taskBarFrame); + locationCommander.addFrame((AbstractMovableComponentFrame) itemsMeshFrame); - scaleCommander.addFrame((ScalableComponentFrame) incMessageFrame); - scaleCommander.addFrame((ScalableComponentFrame) taskBarFrame); - scaleCommander.addFrame((ScalableComponentFrame) itemsMeshFrame); + scaleCommander.addFrame((AbstractScalableComponentFrame) incMessageFrame); + scaleCommander.addFrame((AbstractScalableComponentFrame) taskBarFrame); + scaleCommander.addFrame((AbstractScalableComponentFrame) itemsMeshFrame); NotesLoader notesLoader = new NotesLoader(); @@ -78,7 +78,7 @@ public void start(){ framesMap.put(MercuryLoadingFrame.class,new MercuryLoadingFrame()); List patchNotes = notesLoader.getPatchNotes(); if(ConfigManager.INSTANCE.isShowPatchNotes() && patchNotes.size() != 0){ - NotesFrame patchNotesFrame = new NotesFrame(patchNotes,NotesFrame.NotesType.PATCH); + NotesFrame patchNotesFrame = new NotesFrame(patchNotes, NotesFrame.NotesType.PATCH); patchNotesFrame.init(); } framesMap.put(ChatFilterFrame.class,new ChatFilterFrame()); @@ -96,11 +96,11 @@ public void start(){ int maxOpacity = ConfigManager.INSTANCE.getMaxOpacity(); int minOpacity = ConfigManager.INSTANCE.getMinOpacity(); framesMap.forEach((k,frame) -> { - if(frame instanceof ComponentFrame) { + if(frame instanceof AbstractComponentFrame) { if (decayTime > 0) { - ((ComponentFrame)frame).enableHideEffect(decayTime, minOpacity, maxOpacity); + ((AbstractComponentFrame)frame).enableHideEffect(decayTime, minOpacity, maxOpacity); } else { - ((ComponentFrame)frame).disableHideEffect(); + ((AbstractComponentFrame)frame).disableHideEffect(); frame.setOpacity(maxOpacity / 100f); } } @@ -114,7 +114,7 @@ public void initHandlers() { String patchNotes = ((ShowPatchNotesEvent) handler).getPatchNotes(); NotesLoader notesLoader = new NotesLoader(); List notes = notesLoader.getPatchNotesFromString(patchNotes); - NotesFrame patchNotesFrame = new NotesFrame(notes,NotesFrame.NotesType.PATCH); + NotesFrame patchNotesFrame = new NotesFrame(notes, NotesFrame.NotesType.PATCH); patchNotesFrame.init(); patchNotesFrame.setFrameTitle("MercuryTrade v" + notesLoader.getVersionFrom(patchNotes)); patchNotesFrame.showComponent(); @@ -136,13 +136,13 @@ public void showFrame(Class frameClass){ framesMap.get(frameClass).showComponent(); } public void preShowFrame(Class frameClass){ - framesMap.get(frameClass).setPrevState(FrameStates.SHOW); + framesMap.get(frameClass).setPrevState(FrameVisibleState.SHOW); } public void hideFrame(Class frameClass){ framesMap.get(frameClass).hideComponent(); } public void hideOrShowFrame(Class frameClass){ - OverlaidFrame frame = framesMap.get(frameClass); + AbstractOverlaidFrame frame = framesMap.get(frameClass); if(frame != null && frame.isVisible()){ hideFrame(frameClass); }else { @@ -176,8 +176,8 @@ public void restoreDefaultLocation(){ FrameSettings settings = ConfigManager.INSTANCE.getDefaultFramesSettings().get(k.getSimpleName()); if(!v.getClass().equals(ItemsGridFrame.class) && settings != null){ v.setLocation(settings.getFrameLocation()); - if(v instanceof MovableComponentFrame){ - ((MovableComponentFrame) v).onLocationChange(settings.getFrameLocation()); + if(v instanceof AbstractMovableComponentFrame){ + ((AbstractMovableComponentFrame) v).onLocationChange(settings.getFrameLocation()); } } }); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/manager/HideSettingsManager.java b/app-ui/src/main/java/com/mercury/platform/ui/manager/HideSettingsManager.java index 9b7ab0d6..e3f316fd 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/manager/HideSettingsManager.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/manager/HideSettingsManager.java @@ -1,7 +1,7 @@ package com.mercury.platform.ui.manager; import com.mercury.platform.shared.ConfigManager; -import com.mercury.platform.ui.frame.ComponentFrame; +import com.mercury.platform.ui.frame.AbstractComponentFrame; import java.util.ArrayList; import java.util.List; @@ -12,12 +12,12 @@ private static class HideSettingsManagerHolder { } public static HideSettingsManager INSTANCE = HideSettingsManagerHolder.HOLDER_INSTANCE; - private List frames; + private List frames; private HideSettingsManager() { frames = new ArrayList<>(); } - public void registerFrame(ComponentFrame frame){ + public void registerFrame(AbstractComponentFrame frame){ frames.add(frame); } public void apply(int fadeTime, int minOpacity, int maxOpacity){ diff --git a/app-ui/src/main/java/com/mercury/platform/ui/misc/event/CloseGridItemEvent.java b/app-ui/src/main/java/com/mercury/platform/ui/misc/event/CloseGridItemEvent.java index dfcc18cb..9aee3123 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/misc/event/CloseGridItemEvent.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/misc/event/CloseGridItemEvent.java @@ -1,7 +1,7 @@ package com.mercury.platform.ui.misc.event; import com.mercury.platform.shared.events.MercuryEvent; -import com.mercury.platform.shared.pojo.ItemMessage; +import com.mercury.platform.shared.entity.ItemMessage; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/misc/event/CloseMessagePanelEvent.java b/app-ui/src/main/java/com/mercury/platform/ui/misc/event/CloseMessagePanelEvent.java index 13740fd0..de16946f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/misc/event/CloseMessagePanelEvent.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/misc/event/CloseMessagePanelEvent.java @@ -1,13 +1,9 @@ package com.mercury.platform.ui.misc.event; import com.mercury.platform.shared.events.MercuryEvent; -import com.mercury.platform.shared.pojo.Message; +import com.mercury.platform.shared.entity.Message; import lombok.AllArgsConstructor; import lombok.Data; -import lombok.Getter; -import lombok.Setter; - -import java.awt.*; @Data @AllArgsConstructor diff --git a/app-ui/src/main/java/com/mercury/platform/ui/misc/event/SaveScaleEvent.java b/app-ui/src/main/java/com/mercury/platform/ui/misc/event/SaveScaleEvent.java index 1cc749ef..be562ba5 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/misc/event/SaveScaleEvent.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/misc/event/SaveScaleEvent.java @@ -1,11 +1,8 @@ package com.mercury.platform.ui.misc.event; import com.mercury.platform.shared.events.MercuryEvent; -import com.mercury.platform.shared.pojo.ScaleData; import lombok.AllArgsConstructor; import lombok.Data; -import lombok.Getter; -import lombok.Setter; import java.util.Map; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/misc/event/ShowItemGridEvent.java b/app-ui/src/main/java/com/mercury/platform/ui/misc/event/ShowItemGridEvent.java index 7919ef7d..9ee6458f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/misc/event/ShowItemGridEvent.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/misc/event/ShowItemGridEvent.java @@ -1,7 +1,7 @@ package com.mercury.platform.ui.misc.event; import com.mercury.platform.shared.events.MercuryEvent; -import com.mercury.platform.shared.pojo.ItemMessage; +import com.mercury.platform.shared.entity.ItemMessage; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/pom.xml b/pom.xml index d1efa79f..51d9ad73 100644 --- a/pom.xml +++ b/pom.xml @@ -34,6 +34,7 @@ 21.0 1.16.8 0.5.8 + 1.2.9 UTF-8 UTF-8 @@ -125,7 +126,11 @@ lombok ${lombok.version} - + + io.reactivex + rxjava + ${rxjava.version} + org.apache.logging.log4j log4j-core From ac9ad594699c760d0f6e89ab433bbb1fe29792b2 Mon Sep 17 00:00:00 2001 From: Exslims Date: Sat, 8 Apr 2017 05:58:31 +0400 Subject: [PATCH 05/15] Added fasterjson, start of translation at a more convenient Config Manager --- app-core/pom.xml | 4 +++ .../platform/core/misc/SoundNotifier.java | 7 +++-- .../platform/shared/ConfigManager.java | 26 +++++++++--------- .../shared/config/BaseDataSource.java | 8 ++++++ .../config/ConfigurationInitializer.java | 8 ++++++ .../shared/config/ConfigurationService.java | 8 ++++++ .../config/FramesConfigurationService.java | 27 +++++++++++++++++++ .../shared/config/MercuryDataSource.java | 10 +++++++ .../platform/shared/store/MercuryStore.java | 3 +++ .../store/mock/DataTransformersMock.java | 8 ++++++ .../shared/store/MercuryStoreTest.java | 23 +++++++++++++++- pom.xml | 6 +++++ 12 files changed, 122 insertions(+), 16 deletions(-) create mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/BaseDataSource.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/ConfigurationInitializer.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/ConfigurationService.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/FramesConfigurationService.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/MercuryDataSource.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/store/mock/DataTransformersMock.java diff --git a/app-core/pom.xml b/app-core/pom.xml index 78d3e29c..9544323d 100644 --- a/app-core/pom.xml +++ b/app-core/pom.xml @@ -43,6 +43,10 @@ io.reactivex rxjava + + com.alibaba + fastjson + junit junit diff --git a/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java b/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java index 4a730d90..6ea11774 100644 --- a/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java +++ b/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java @@ -21,10 +21,13 @@ public class SoundNotifier { private boolean dnd = false; public SoundNotifier() { - MercuryStore.INSTANCE.soundSubject. - compose(DataTransformers.transformSoundData()) + MercuryStore.INSTANCE.soundSubject + .compose(DataTransformers.transformSoundData()) .subscribe( data -> play(data.get("path"), Float.valueOf(data.get("db")))); + MercuryStore.INSTANCE.soundSettingsSubject + .subscribe( + data -> play(data.get("path"), Float.valueOf(data.get("db")))); EventRouter.CORE.registerHandler(SoundNotificationEvent.WhisperSoundNotificationEvent.class, event -> { WhisperNotifierStatus status = ConfigManager.INSTANCE.getWhisperNotifier(); diff --git a/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java b/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java index 8cf36a76..2ed831cc 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java +++ b/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java @@ -475,19 +475,19 @@ private List getDefaultButtons(){ } public Map getDefaultFramesSettings(){ Map defaultFramesSettings = new HashMap<>(); - defaultFramesSettings.put("TaskBarFrame",new FrameSettings(new Point(400, 500),new Dimension(109,20))); - defaultFramesSettings.put("IncMessageFrame",new FrameSettings(new Point(700, 600),new Dimension(315,0))); - defaultFramesSettings.put("OutMessageFrame",new FrameSettings(new Point(200, 500),new Dimension(280,115))); - defaultFramesSettings.put("TestCasesFrame",new FrameSettings(new Point(1400, 500),new Dimension(400,100))); - defaultFramesSettings.put("SettingsFrame",new FrameSettings(new Point(600, 600),new Dimension(540,500))); - defaultFramesSettings.put("HistoryFrame",new FrameSettings(new Point(600, 500),new Dimension(280,400))); - defaultFramesSettings.put("TimerFrame",new FrameSettings(new Point(400, 600),new Dimension(240,102))); - defaultFramesSettings.put("ChatFilterFrame",new FrameSettings(new Point(400, 600),new Dimension(500,300))); - defaultFramesSettings.put("ItemsGridFrame",new FrameSettings(new Point(12, 79),new Dimension(641,718))); - defaultFramesSettings.put("NotesFrame",new FrameSettings(new Point(400, 600),new Dimension(540,100))); - defaultFramesSettings.put("ChatFilterSettingsFrame",new FrameSettings(new Point(400, 600),new Dimension(320,200))); - defaultFramesSettings.put("GamePathChooser",new FrameSettings(new Point(400, 600),new Dimension(520,30))); - defaultFramesSettings.put("CurrencySearchFrame",new FrameSettings(new Point(400, 600),new Dimension(400,300))); +// defaultFramesSettings.put("TaskBarFrame",new FrameSettings(new Point(400, 500),new Dimension(109,20))); +// defaultFramesSettings.put("IncMessageFrame",new FrameSettings(new Point(700, 600),new Dimension(315,0))); +// defaultFramesSettings.put("OutMessageFrame",new FrameSettings(new Point(200, 500),new Dimension(280,115))); +// defaultFramesSettings.put("TestCasesFrame",new FrameSettings(new Point(1400, 500),new Dimension(400,100))); +// defaultFramesSettings.put("SettingsFrame",new FrameSettings(new Point(600, 600),new Dimension(540,500))); +// defaultFramesSettings.put("HistoryFrame",new FrameSettings(new Point(600, 500),new Dimension(280,400))); +// defaultFramesSettings.put("TimerFrame",new FrameSettings(new Point(400, 600),new Dimension(240,102))); +// defaultFramesSettings.put("ChatFilterFrame",new FrameSettings(new Point(400, 600),new Dimension(500,300))); +// defaultFramesSettings.put("ItemsGridFrame",new FrameSettings(new Point(12, 79),new Dimension(641,718))); +// defaultFramesSettings.put("NotesFrame",new FrameSettings(new Point(400, 600),new Dimension(540,100))); +// defaultFramesSettings.put("ChatFilterSettingsFrame",new FrameSettings(new Point(400, 600),new Dimension(320,200))); +// defaultFramesSettings.put("GamePathChooser",new FrameSettings(new Point(400, 600),new Dimension(520,30))); +// defaultFramesSettings.put("CurrencySearchFrame",new FrameSettings(new Point(400, 600),new Dimension(400,300))); return defaultFramesSettings; } public Dimension getMinimumFrameSize(String frameName){ diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/BaseDataSource.java b/app-core/src/main/java/com/mercury/platform/shared/config/BaseDataSource.java new file mode 100644 index 00000000..38dc9350 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/config/BaseDataSource.java @@ -0,0 +1,8 @@ +package com.mercury.platform.shared.config; + +public abstract class BaseDataSource { + protected String configurationFilePath; + protected BaseDataSource(String filePath){ + this.configurationFilePath = filePath; + } +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/ConfigurationInitializer.java b/app-core/src/main/java/com/mercury/platform/shared/config/ConfigurationInitializer.java new file mode 100644 index 00000000..ea4f79ef --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/config/ConfigurationInitializer.java @@ -0,0 +1,8 @@ +package com.mercury.platform.shared.config; + +/** + * Created by Константин on 08.04.2017. + */ +public class ConfigurationInitializer { + +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/ConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/ConfigurationService.java new file mode 100644 index 00000000..739e70b8 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/config/ConfigurationService.java @@ -0,0 +1,8 @@ +package com.mercury.platform.shared.config; + + +public interface ConfigurationService { + void load(); + T get(K key); + void save(T entity, K key); +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/FramesConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/FramesConfigurationService.java new file mode 100644 index 00000000..3c47fd3a --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/config/FramesConfigurationService.java @@ -0,0 +1,27 @@ +package com.mercury.platform.shared.config; + +import com.mercury.platform.shared.entity.FrameSettings; + + +public class FramesConfigurationService implements ConfigurationService { + private BaseDataSource dataSource; + public FramesConfigurationService(BaseDataSource dataSource) { + this.dataSource = dataSource; + load(); + } + + @Override + public void load() { + + } + + @Override + public FrameSettings get(String key) { + return null; + } + + @Override + public void save(FrameSettings entity, String key) { + + } +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/MercuryDataSource.java b/app-core/src/main/java/com/mercury/platform/shared/config/MercuryDataSource.java new file mode 100644 index 00000000..c223b47a --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/config/MercuryDataSource.java @@ -0,0 +1,10 @@ +package com.mercury.platform.shared.config; + +/** + * Created by Константин on 08.04.2017. + */ +public class MercuryDataSource extends BaseDataSource { + protected MercuryDataSource() { + super(System.getenv("USERPROFILE") + "\\AppData\\Local\\MercuryTrade\\app-config.json"); + } +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java index 617fa545..07a84127 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java +++ b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java @@ -3,6 +3,8 @@ import com.mercury.platform.core.misc.SoundType; import rx.subjects.PublishSubject; +import java.util.Map; + public class MercuryStore { private static class MercuryStoreHolder { static final MercuryStore HOLDER_INSTANCE = new MercuryStore(); @@ -10,4 +12,5 @@ private static class MercuryStoreHolder { public static MercuryStore INSTANCE = MercuryStoreHolder.HOLDER_INSTANCE; public final PublishSubject soundSubject = PublishSubject.create(); + public final PublishSubject> soundSettingsSubject = PublishSubject.create(); } diff --git a/app-core/src/main/java/com/mercury/platform/shared/store/mock/DataTransformersMock.java b/app-core/src/main/java/com/mercury/platform/shared/store/mock/DataTransformersMock.java new file mode 100644 index 00000000..003e70b1 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/store/mock/DataTransformersMock.java @@ -0,0 +1,8 @@ +package com.mercury.platform.shared.store.mock; + +/** + * Created by Константин on 08.04.2017. + */ +public class DataTransformersMock { + +} diff --git a/app-core/src/test/java/com/mercury/platform/shared/store/MercuryStoreTest.java b/app-core/src/test/java/com/mercury/platform/shared/store/MercuryStoreTest.java index 489a6562..7283d35e 100644 --- a/app-core/src/test/java/com/mercury/platform/shared/store/MercuryStoreTest.java +++ b/app-core/src/test/java/com/mercury/platform/shared/store/MercuryStoreTest.java @@ -1,17 +1,38 @@ package com.mercury.platform.shared.store; +import com.alibaba.fastjson.JSON; import com.mercury.platform.core.misc.SoundType; +import com.mercury.platform.shared.entity.FrameSettings; import org.junit.Test; +import rx.observers.TestSubscriber; + +import java.awt.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class MercuryStoreTest { @Test public void testSoundReducer(){ + TestSubscriber> testSubscriber = new TestSubscriber<>(); + MercuryStore.INSTANCE.soundSubject .compose(DataTransformers.transformSoundData()) - .subscribe(System.out::println); + .subscribe(testSubscriber); MercuryStore.INSTANCE.soundSubject.onNext(SoundType.MESSAGE); + Map expectedValue = new HashMap<>(); +// Map settingss = new HashMap<>(); +// FrameSettings frameSettings = new FrameSettings(50, 50, 400, 400); +// FrameSettings frameSettings1 = new FrameSettings(50, 50, 400, 400); +// FrameSettings frameSettings2 = new FrameSettings(50, 50, 400, 400); +// +// settingss.put("taskBar",frameSettings); +// settingss.put("taskBar1",frameSettings1); +// settingss.put("taskBar2",frameSettings2); +// System.out.println(JSON.toJSONString(settingss)); } } \ No newline at end of file diff --git a/pom.xml b/pom.xml index 51d9ad73..f72d1113 100644 --- a/pom.xml +++ b/pom.xml @@ -35,6 +35,7 @@ 1.16.8 0.5.8 1.2.9 + 1.2.24 UTF-8 UTF-8 @@ -131,6 +132,11 @@ rxjava ${rxjava.version} + + com.alibaba + fastjson + ${fastjson.version} + org.apache.logging.log4j log4j-core From 97666408d54e017d13c51d10e4a872824ab5b2a8 Mon Sep 17 00:00:00 2001 From: Exslims Date: Sat, 8 Apr 2017 08:24:46 +0400 Subject: [PATCH 06/15] Configuration system step 2 --- .../platform/core/misc/SoundNotifier.java | 4 +- .../platform/shared/ConfigManager.java | 26 ++++++------- .../shared/config/BaseDataSource.java | 8 ---- .../platform/shared/config/ConfigManager.java | 11 ++++++ .../shared/config/ConfigManagerAdapter.java | 28 +++++++++++++ .../config/ConfigurationInitializer.java | 19 +++++++-- .../platform/shared/config/DataSource.java | 10 +++++ .../config/FramesConfigurationService.java | 27 ------------- .../shared/config/MercuryDataSource.java | 2 +- .../service/BaseConfigurationService.java | 13 +++++++ .../{ => service}/ConfigurationService.java | 2 +- .../service/FramesConfigurationService.java | 26 +++++++++++++ .../service/SoundConfigurationService.java | 26 +++++++++++++ .../platform/shared/entity/KeyData.java | 14 +++++++ .../shared/entity/SoundDescriptor.java | 16 ++++++++ .../shared/store/DataTransformers.java | 23 +++++++---- .../platform/shared/store/MercuryStore.java | 4 +- .../shared/store/MercuryStoreTest.java | 39 +++++++++++-------- 18 files changed, 217 insertions(+), 81 deletions(-) delete mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/BaseDataSource.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/ConfigManager.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/ConfigManagerAdapter.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/DataSource.java delete mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/FramesConfigurationService.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/service/BaseConfigurationService.java rename app-core/src/main/java/com/mercury/platform/shared/config/{ => service}/ConfigurationService.java (69%) create mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/service/FramesConfigurationService.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/service/SoundConfigurationService.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/entity/KeyData.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/entity/SoundDescriptor.java diff --git a/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java b/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java index 6ea11774..33a73344 100644 --- a/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java +++ b/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java @@ -24,10 +24,10 @@ public SoundNotifier() { MercuryStore.INSTANCE.soundSubject .compose(DataTransformers.transformSoundData()) .subscribe( - data -> play(data.get("path"), Float.valueOf(data.get("db")))); + data -> play(data.getWavPath(), data.getDb())); MercuryStore.INSTANCE.soundSettingsSubject .subscribe( - data -> play(data.get("path"), Float.valueOf(data.get("db")))); + data -> play(data.getWavPath(), data.getDb())); EventRouter.CORE.registerHandler(SoundNotificationEvent.WhisperSoundNotificationEvent.class, event -> { WhisperNotifierStatus status = ConfigManager.INSTANCE.getWhisperNotifier(); diff --git a/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java b/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java index 2ed831cc..8cf36a76 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java +++ b/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java @@ -475,19 +475,19 @@ private List getDefaultButtons(){ } public Map getDefaultFramesSettings(){ Map defaultFramesSettings = new HashMap<>(); -// defaultFramesSettings.put("TaskBarFrame",new FrameSettings(new Point(400, 500),new Dimension(109,20))); -// defaultFramesSettings.put("IncMessageFrame",new FrameSettings(new Point(700, 600),new Dimension(315,0))); -// defaultFramesSettings.put("OutMessageFrame",new FrameSettings(new Point(200, 500),new Dimension(280,115))); -// defaultFramesSettings.put("TestCasesFrame",new FrameSettings(new Point(1400, 500),new Dimension(400,100))); -// defaultFramesSettings.put("SettingsFrame",new FrameSettings(new Point(600, 600),new Dimension(540,500))); -// defaultFramesSettings.put("HistoryFrame",new FrameSettings(new Point(600, 500),new Dimension(280,400))); -// defaultFramesSettings.put("TimerFrame",new FrameSettings(new Point(400, 600),new Dimension(240,102))); -// defaultFramesSettings.put("ChatFilterFrame",new FrameSettings(new Point(400, 600),new Dimension(500,300))); -// defaultFramesSettings.put("ItemsGridFrame",new FrameSettings(new Point(12, 79),new Dimension(641,718))); -// defaultFramesSettings.put("NotesFrame",new FrameSettings(new Point(400, 600),new Dimension(540,100))); -// defaultFramesSettings.put("ChatFilterSettingsFrame",new FrameSettings(new Point(400, 600),new Dimension(320,200))); -// defaultFramesSettings.put("GamePathChooser",new FrameSettings(new Point(400, 600),new Dimension(520,30))); -// defaultFramesSettings.put("CurrencySearchFrame",new FrameSettings(new Point(400, 600),new Dimension(400,300))); + defaultFramesSettings.put("TaskBarFrame",new FrameSettings(new Point(400, 500),new Dimension(109,20))); + defaultFramesSettings.put("IncMessageFrame",new FrameSettings(new Point(700, 600),new Dimension(315,0))); + defaultFramesSettings.put("OutMessageFrame",new FrameSettings(new Point(200, 500),new Dimension(280,115))); + defaultFramesSettings.put("TestCasesFrame",new FrameSettings(new Point(1400, 500),new Dimension(400,100))); + defaultFramesSettings.put("SettingsFrame",new FrameSettings(new Point(600, 600),new Dimension(540,500))); + defaultFramesSettings.put("HistoryFrame",new FrameSettings(new Point(600, 500),new Dimension(280,400))); + defaultFramesSettings.put("TimerFrame",new FrameSettings(new Point(400, 600),new Dimension(240,102))); + defaultFramesSettings.put("ChatFilterFrame",new FrameSettings(new Point(400, 600),new Dimension(500,300))); + defaultFramesSettings.put("ItemsGridFrame",new FrameSettings(new Point(12, 79),new Dimension(641,718))); + defaultFramesSettings.put("NotesFrame",new FrameSettings(new Point(400, 600),new Dimension(540,100))); + defaultFramesSettings.put("ChatFilterSettingsFrame",new FrameSettings(new Point(400, 600),new Dimension(320,200))); + defaultFramesSettings.put("GamePathChooser",new FrameSettings(new Point(400, 600),new Dimension(520,30))); + defaultFramesSettings.put("CurrencySearchFrame",new FrameSettings(new Point(400, 600),new Dimension(400,300))); return defaultFramesSettings; } public Dimension getMinimumFrameSize(String frameName){ diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/BaseDataSource.java b/app-core/src/main/java/com/mercury/platform/shared/config/BaseDataSource.java deleted file mode 100644 index 38dc9350..00000000 --- a/app-core/src/main/java/com/mercury/platform/shared/config/BaseDataSource.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.mercury.platform.shared.config; - -public abstract class BaseDataSource { - protected String configurationFilePath; - protected BaseDataSource(String filePath){ - this.configurationFilePath = filePath; - } -} 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 new file mode 100644 index 00000000..5569d70f --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/config/ConfigManager.java @@ -0,0 +1,11 @@ +package com.mercury.platform.shared.config; + +import com.mercury.platform.shared.config.service.ConfigurationService; +import com.mercury.platform.shared.config.service.FramesConfigurationService; +import com.mercury.platform.shared.config.service.SoundConfigurationService; + + +public interface ConfigManager { + ConfigurationService framesConfigurationService(); + ConfigurationService soundConfigurationService(); +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/ConfigManagerAdapter.java b/app-core/src/main/java/com/mercury/platform/shared/config/ConfigManagerAdapter.java new file mode 100644 index 00000000..733106b1 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/config/ConfigManagerAdapter.java @@ -0,0 +1,28 @@ +package com.mercury.platform.shared.config; + +import com.mercury.platform.shared.config.service.ConfigurationService; +import lombok.Setter; + + +public class ConfigManagerAdapter implements ConfigManager { + @Setter + private ConfigurationService framesConfigurationService; + @Setter + private ConfigurationService soundConfigurationService; + @Override + public ConfigurationService framesConfigurationService() { + return framesConfigurationService; + } + @Override + public ConfigurationService soundConfigurationService() { + return soundConfigurationService; + } + + /** + * Initializing all services. + */ + public void load(){ + this.framesConfigurationService.load(); + this.soundConfigurationService.load(); + } +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/ConfigurationInitializer.java b/app-core/src/main/java/com/mercury/platform/shared/config/ConfigurationInitializer.java index ea4f79ef..111f2fa9 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/ConfigurationInitializer.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/ConfigurationInitializer.java @@ -1,8 +1,19 @@ package com.mercury.platform.shared.config; -/** - * Created by Константин on 08.04.2017. - */ -public class ConfigurationInitializer { +import com.mercury.platform.shared.config.service.FramesConfigurationService; +import com.mercury.platform.shared.config.service.SoundConfigurationService; + +public class ConfigurationInitializer { + public static ConfigManager createFrom(DataSource dataSource){ + ConfigManagerAdapter configManagerAdapter = new ConfigManagerAdapter(); + configManagerAdapter.setFramesConfigurationService( + new FramesConfigurationService(dataSource) + ); + configManagerAdapter.setSoundConfigurationService( + new SoundConfigurationService(dataSource) + ); + configManagerAdapter.load(); + return configManagerAdapter; + } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/DataSource.java b/app-core/src/main/java/com/mercury/platform/shared/config/DataSource.java new file mode 100644 index 00000000..515a88ca --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/config/DataSource.java @@ -0,0 +1,10 @@ +package com.mercury.platform.shared.config; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public abstract class DataSource { + private String configurationFilePath; +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/FramesConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/FramesConfigurationService.java deleted file mode 100644 index 3c47fd3a..00000000 --- a/app-core/src/main/java/com/mercury/platform/shared/config/FramesConfigurationService.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.mercury.platform.shared.config; - -import com.mercury.platform.shared.entity.FrameSettings; - - -public class FramesConfigurationService implements ConfigurationService { - private BaseDataSource dataSource; - public FramesConfigurationService(BaseDataSource dataSource) { - this.dataSource = dataSource; - load(); - } - - @Override - public void load() { - - } - - @Override - public FrameSettings get(String key) { - return null; - } - - @Override - public void save(FrameSettings entity, String key) { - - } -} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/MercuryDataSource.java b/app-core/src/main/java/com/mercury/platform/shared/config/MercuryDataSource.java index c223b47a..70ced77f 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/MercuryDataSource.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/MercuryDataSource.java @@ -3,7 +3,7 @@ /** * Created by Константин on 08.04.2017. */ -public class MercuryDataSource extends BaseDataSource { +public class MercuryDataSource extends DataSource { protected MercuryDataSource() { super(System.getenv("USERPROFILE") + "\\AppData\\Local\\MercuryTrade\\app-config.json"); } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/service/BaseConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/service/BaseConfigurationService.java new file mode 100644 index 00000000..415c7427 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/config/service/BaseConfigurationService.java @@ -0,0 +1,13 @@ +package com.mercury.platform.shared.config.service; + +import com.mercury.platform.shared.config.DataSource; + +/** + * Created by Константин on 08.04.2017. + */ +public abstract class BaseConfigurationService implements ConfigurationService{ + private DataSource dataSource; + protected BaseConfigurationService(DataSource dataSource){ + this.dataSource = dataSource; + } +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/ConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/service/ConfigurationService.java similarity index 69% rename from app-core/src/main/java/com/mercury/platform/shared/config/ConfigurationService.java rename to app-core/src/main/java/com/mercury/platform/shared/config/service/ConfigurationService.java index 739e70b8..c3297fc7 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/ConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/service/ConfigurationService.java @@ -1,4 +1,4 @@ -package com.mercury.platform.shared.config; +package com.mercury.platform.shared.config.service; public interface ConfigurationService { diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/service/FramesConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/service/FramesConfigurationService.java new file mode 100644 index 00000000..2642d963 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/config/service/FramesConfigurationService.java @@ -0,0 +1,26 @@ +package com.mercury.platform.shared.config.service; + +import com.mercury.platform.shared.config.DataSource; +import com.mercury.platform.shared.entity.FrameSettings; + + +public class FramesConfigurationService extends BaseConfigurationService { + public FramesConfigurationService(DataSource dataSource) { + super(dataSource); + } + + @Override + public void load() { + + } + + @Override + public FrameSettings get(String key) { + return null; + } + + @Override + public void save(FrameSettings entity, String key) { + + } +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/service/SoundConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/service/SoundConfigurationService.java new file mode 100644 index 00000000..a1411044 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/config/service/SoundConfigurationService.java @@ -0,0 +1,26 @@ +package com.mercury.platform.shared.config.service; + +import com.mercury.platform.shared.config.DataSource; +import com.mercury.platform.shared.entity.SoundDescriptor; + + +public class SoundConfigurationService extends BaseConfigurationService { + public SoundConfigurationService(DataSource dataSource) { + super(dataSource); + } + + @Override + public void load() { + + } + + @Override + public SoundDescriptor get(String key) { + return null; + } + + @Override + public void save(SoundDescriptor entity, String key) { + + } +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/entity/KeyData.java b/app-core/src/main/java/com/mercury/platform/shared/entity/KeyData.java new file mode 100644 index 00000000..8e16b486 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/KeyData.java @@ -0,0 +1,14 @@ +package com.mercury.platform.shared.entity; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class KeyData { + @JSONField + private String key; + @JSONField + private T data; +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/entity/SoundDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/entity/SoundDescriptor.java new file mode 100644 index 00000000..809c0998 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/SoundDescriptor.java @@ -0,0 +1,16 @@ +package com.mercury.platform.shared.entity; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SoundDescriptor { + @JSONField + private String wavPath; + @JSONField + private Float db; +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/store/DataTransformers.java b/app-core/src/main/java/com/mercury/platform/shared/store/DataTransformers.java index 09489cf5..2a3ab58a 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/store/DataTransformers.java +++ b/app-core/src/main/java/com/mercury/platform/shared/store/DataTransformers.java @@ -1,33 +1,42 @@ package com.mercury.platform.shared.store; import com.mercury.platform.core.misc.SoundType; +import com.mercury.platform.shared.entity.SoundDescriptor; import rx.Observable; -import java.util.HashMap; -import java.util.Map; +import java.util.Random; public class DataTransformers { - public static Observable.Transformer> transformSoundData() { + public static Observable.Transformer transformSoundData() { + String[] clicks = { + "app/sounds/click1/button-pressed-10.wav", + "app/sounds/click1/button-pressed-20.wav", + "app/sounds/click1/button-pressed-30.wav"}; return obs -> obs.map(soundType -> { - Map data = new HashMap<>(); + SoundDescriptor descriptor = new SoundDescriptor(); switch (soundType){ case MESSAGE:{ - data.put("path","app/notification.wav"); - data.put("db","-10"); + descriptor.setWavPath("app/notification.wav"); + descriptor.setDb(-10f); break; } case CHAT_SCANNER: { + break; } case CLICKS: { + descriptor.setWavPath(clicks[new Random().nextInt(3)]); + descriptor.setDb(-10f); break; } case UPDATE: { + descriptor.setWavPath("app/patch_tone.wav"); + descriptor.setDb(-10f); break; } } - return data; + return descriptor; }); } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java index 07a84127..772114f7 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java +++ b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java @@ -1,9 +1,9 @@ package com.mercury.platform.shared.store; import com.mercury.platform.core.misc.SoundType; +import com.mercury.platform.shared.entity.SoundDescriptor; import rx.subjects.PublishSubject; -import java.util.Map; public class MercuryStore { private static class MercuryStoreHolder { @@ -12,5 +12,5 @@ private static class MercuryStoreHolder { public static MercuryStore INSTANCE = MercuryStoreHolder.HOLDER_INSTANCE; public final PublishSubject soundSubject = PublishSubject.create(); - public final PublishSubject> soundSettingsSubject = PublishSubject.create(); + public final PublishSubject soundSettingsSubject = PublishSubject.create(); } diff --git a/app-core/src/test/java/com/mercury/platform/shared/store/MercuryStoreTest.java b/app-core/src/test/java/com/mercury/platform/shared/store/MercuryStoreTest.java index 7283d35e..591f7542 100644 --- a/app-core/src/test/java/com/mercury/platform/shared/store/MercuryStoreTest.java +++ b/app-core/src/test/java/com/mercury/platform/shared/store/MercuryStoreTest.java @@ -1,12 +1,20 @@ package com.mercury.platform.shared.store; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONReader; +import com.alibaba.fastjson.JSONWriter; import com.mercury.platform.core.misc.SoundType; import com.mercury.platform.shared.entity.FrameSettings; +import com.mercury.platform.shared.entity.KeyData; +import com.mercury.platform.shared.entity.SoundDescriptor; import org.junit.Test; import rx.observers.TestSubscriber; import java.awt.*; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -15,24 +23,23 @@ public class MercuryStoreTest { @Test - public void testSoundReducer(){ + public void testSoundReducer() throws IOException { TestSubscriber> testSubscriber = new TestSubscriber<>(); - MercuryStore.INSTANCE.soundSubject - .compose(DataTransformers.transformSoundData()) - .subscribe(testSubscriber); - - MercuryStore.INSTANCE.soundSubject.onNext(SoundType.MESSAGE); - Map expectedValue = new HashMap<>(); - -// Map settingss = new HashMap<>(); -// FrameSettings frameSettings = new FrameSettings(50, 50, 400, 400); -// FrameSettings frameSettings1 = new FrameSettings(50, 50, 400, 400); -// FrameSettings frameSettings2 = new FrameSettings(50, 50, 400, 400); +// MercuryStore.INSTANCE.soundSubject +// .compose(DataTransformers.transformSoundData()) +// .subscribe(testSubscriber); // -// settingss.put("taskBar",frameSettings); -// settingss.put("taskBar1",frameSettings1); -// settingss.put("taskBar2",frameSettings2); -// System.out.println(JSON.toJSONString(settingss)); +// MercuryStore.INSTANCE.soundSubject.onNext(SoundType.MESSAGE); +// Map expectedValue = new HashMap<>(); + + JSONReader reader = new JSONReader(new FileReader("qwe")); + reader.readObject(); + JSONWriter writer = new JSONWriter(new FileWriter("qwe")); + List> list = new ArrayList<>(); + list.add(new KeyData<>("1",new SoundDescriptor("test1.wav",10f))); + list.add(new KeyData<>("2",new SoundDescriptor("test2.wav",10f))); + list.add(new KeyData<>("3",new SoundDescriptor("test3.wav",10f))); + System.out.println(JSON.toJSONString(new KeyData<>("frameSettings", list))); } } \ No newline at end of file From 13389ff7cd5dcd2b11ad3dcc640858dead893a71 Mon Sep 17 00:00:00 2001 From: Exslims Date: Sat, 8 Apr 2017 19:03:32 +0400 Subject: [PATCH 07/15] Configuration system step 3 --- app-core/pom.xml | 4 +- .../com/mercury/platform/core/AppStarter.java | 10 ++-- .../platform/core/misc/SoundNotifier.java | 21 +++----- .../shared/config/BaseConfigManager.java | 49 +++++++++++++++++ .../platform/shared/config/ConfigManager.java | 8 +-- .../shared/config/ConfigManagerAdapter.java | 28 ---------- .../platform/shared/config/Configuration.java | 12 +++++ .../config/ConfigurationInitializer.java | 19 ------- .../platform/shared/config/JSONHelper.java | 50 ++++++++++++++++++ .../shared/config/MercuryDataSource.java | 4 +- .../service/BaseConfigurationService.java | 10 ++-- .../config/service/ConfigurationService.java | 6 ++- .../service/FramesConfigurationService.java | 2 +- .../service/SoundConfigurationService.java | 52 +++++++++++++++++-- .../platform/shared/entity/KeyData.java | 5 +- .../shared/entity/SoundDescriptor.java | 3 -- .../shared/store/DataTransformers.java | 14 ++--- .../shared/store/MercuryStoreTest.java | 21 -------- pom.xml | 7 +-- 19 files changed, 205 insertions(+), 120 deletions(-) create mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/BaseConfigManager.java delete mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/ConfigManagerAdapter.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/Configuration.java delete mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/ConfigurationInitializer.java create mode 100644 app-core/src/main/java/com/mercury/platform/shared/config/JSONHelper.java diff --git a/app-core/pom.xml b/app-core/pom.xml index 9544323d..9906e445 100644 --- a/app-core/pom.xml +++ b/app-core/pom.xml @@ -44,8 +44,8 @@ rxjava - com.alibaba - fastjson + com.google.code.gson + gson junit diff --git a/app-core/src/main/java/com/mercury/platform/core/AppStarter.java b/app-core/src/main/java/com/mercury/platform/core/AppStarter.java index a5ee4008..f40f7655 100644 --- a/app-core/src/main/java/com/mercury/platform/core/AppStarter.java +++ b/app-core/src/main/java/com/mercury/platform/core/AppStarter.java @@ -7,6 +7,9 @@ import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.HistoryManager; import com.mercury.platform.shared.UpdateManager; +import com.mercury.platform.shared.config.BaseConfigManager; +import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.MercuryDataSource; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.*; import com.sun.jna.Native; @@ -19,9 +22,6 @@ import java.util.concurrent.Executor; import java.util.concurrent.Executors; -/** - * Created by Константин on 31.12.2016. - */ public class AppStarter { private static final Logger logger = LogManager.getLogger(AppStarter.class.getSimpleName()); public static FrameVisibleState APP_STATUS = FrameVisibleState.HIDE; @@ -31,6 +31,10 @@ public class AppStarter { private boolean updating = false; public void startApplication(){ +// BaseConfigManager configuration = new BaseConfigManager(new MercuryDataSource()); +// configuration.load(); +// Configuration.set(configuration); + ConfigManager.INSTANCE.load(); new SoundNotifier(); new ChatHelper(); diff --git a/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java b/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java index 33a73344..3f2eaa27 100644 --- a/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java +++ b/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java @@ -21,13 +21,13 @@ public class SoundNotifier { private boolean dnd = false; public SoundNotifier() { - MercuryStore.INSTANCE.soundSubject - .compose(DataTransformers.transformSoundData()) - .subscribe( - data -> play(data.getWavPath(), data.getDb())); - MercuryStore.INSTANCE.soundSettingsSubject - .subscribe( - data -> play(data.getWavPath(), data.getDb())); +// MercuryStore.INSTANCE.soundSubject +// .compose(DataTransformers.transformSoundData()) +// .subscribe( +// data -> play(data.getWavPath(), data.getDb())); +// MercuryStore.INSTANCE.soundSettingsSubject +// .subscribe( +// data -> play(data.getWavPath(), data.getDb())); EventRouter.CORE.registerHandler(SoundNotificationEvent.WhisperSoundNotificationEvent.class, event -> { WhisperNotifierStatus status = ConfigManager.INSTANCE.getWhisperNotifier(); @@ -45,13 +45,6 @@ public SoundNotifier() { EventRouter.CORE.registerHandler(DndModeEvent.class, event -> { this.dnd = ((DndModeEvent)event).isDnd(); }); - EventRouter.CORE.registerHandler(SoundNotificationEvent.ClicksSoundNotificationEvent.class, event -> { - String[] clicks = { - "app/sounds/click1/button-pressed-10.wav", - "app/sounds/click1/button-pressed-20.wav", - "app/sounds/click1/button-pressed-30.wav"}; - play(clicks[new Random().nextInt(3)],((SoundNotificationEvent.ClicksSoundNotificationEvent)event).getDb()); - }); } private void play(String wavPath, float db){ diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/BaseConfigManager.java b/app-core/src/main/java/com/mercury/platform/shared/config/BaseConfigManager.java new file mode 100644 index 00000000..807abca4 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/config/BaseConfigManager.java @@ -0,0 +1,49 @@ +package com.mercury.platform.shared.config; + +import com.mercury.platform.shared.config.service.ConfigurationService; +import com.mercury.platform.shared.config.service.FramesConfigurationService; +import com.mercury.platform.shared.config.service.SoundConfigurationService; +import com.mercury.platform.shared.entity.FrameSettings; +import com.mercury.platform.shared.entity.SoundDescriptor; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.io.File; +import java.io.IOException; + + +public class BaseConfigManager implements ConfigManager { + private Logger logger = LogManager.getLogger(BaseConfigManager.class.getSimpleName()); + + private DataSource dataSource; + private ConfigurationService framesConfigurationService; + private ConfigurationService soundConfigurationService; + + public BaseConfigManager(DataSource dataSource){ + this.dataSource = dataSource; + + this.framesConfigurationService = new FramesConfigurationService(dataSource); + this.soundConfigurationService = new SoundConfigurationService(dataSource); + } + @Override + public ConfigurationService framesConfigurationService() { + return framesConfigurationService; + } + @Override + public ConfigurationService soundConfigurationService() { + return soundConfigurationService; + } + public void load(){ + try { + File file = new File(dataSource.getConfigurationFilePath()); + + if(!file.exists()){ + file.createNewFile(); + } + this.framesConfigurationService.load(); + this.soundConfigurationService.load(); + }catch (IOException e) { + logger.error("Error while created file:{}",dataSource.getConfigurationFilePath(),e); + } + } +} 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 5569d70f..dd6bf164 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 @@ -1,11 +1,11 @@ package com.mercury.platform.shared.config; import com.mercury.platform.shared.config.service.ConfigurationService; -import com.mercury.platform.shared.config.service.FramesConfigurationService; -import com.mercury.platform.shared.config.service.SoundConfigurationService; +import com.mercury.platform.shared.entity.FrameSettings; +import com.mercury.platform.shared.entity.SoundDescriptor; public interface ConfigManager { - ConfigurationService framesConfigurationService(); - ConfigurationService soundConfigurationService(); + ConfigurationService framesConfigurationService(); + ConfigurationService soundConfigurationService(); } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/ConfigManagerAdapter.java b/app-core/src/main/java/com/mercury/platform/shared/config/ConfigManagerAdapter.java deleted file mode 100644 index 733106b1..00000000 --- a/app-core/src/main/java/com/mercury/platform/shared/config/ConfigManagerAdapter.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.mercury.platform.shared.config; - -import com.mercury.platform.shared.config.service.ConfigurationService; -import lombok.Setter; - - -public class ConfigManagerAdapter implements ConfigManager { - @Setter - private ConfigurationService framesConfigurationService; - @Setter - private ConfigurationService soundConfigurationService; - @Override - public ConfigurationService framesConfigurationService() { - return framesConfigurationService; - } - @Override - public ConfigurationService soundConfigurationService() { - return soundConfigurationService; - } - - /** - * Initializing all services. - */ - public void load(){ - this.framesConfigurationService.load(); - this.soundConfigurationService.load(); - } -} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/Configuration.java b/app-core/src/main/java/com/mercury/platform/shared/config/Configuration.java new file mode 100644 index 00000000..7e80bf6b --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/config/Configuration.java @@ -0,0 +1,12 @@ +package com.mercury.platform.shared.config; + +public class Configuration { + private static ConfigManager configManager; + + public static ConfigManager get() { + return configManager; + } + public static void set(ConfigManager configManager){ + Configuration.configManager = configManager; + } +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/ConfigurationInitializer.java b/app-core/src/main/java/com/mercury/platform/shared/config/ConfigurationInitializer.java deleted file mode 100644 index 111f2fa9..00000000 --- a/app-core/src/main/java/com/mercury/platform/shared/config/ConfigurationInitializer.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.mercury.platform.shared.config; - -import com.mercury.platform.shared.config.service.FramesConfigurationService; -import com.mercury.platform.shared.config.service.SoundConfigurationService; - - -public class ConfigurationInitializer { - public static ConfigManager createFrom(DataSource dataSource){ - ConfigManagerAdapter configManagerAdapter = new ConfigManagerAdapter(); - configManagerAdapter.setFramesConfigurationService( - new FramesConfigurationService(dataSource) - ); - configManagerAdapter.setSoundConfigurationService( - new SoundConfigurationService(dataSource) - ); - configManagerAdapter.load(); - return configManagerAdapter; - } -} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/JSONHelper.java b/app-core/src/main/java/com/mercury/platform/shared/config/JSONHelper.java new file mode 100644 index 00000000..cb7099c2 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/config/JSONHelper.java @@ -0,0 +1,50 @@ +package com.mercury.platform.shared.config; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.mercury.platform.shared.entity.KeyData; +import com.mercury.platform.shared.entity.SoundDescriptor; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import rx.Observable; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +public class JSONHelper { + private Logger logger = LogManager.getLogger(JSONHelper.class.getSimpleName()); + private DataSource dataSource; + + public JSONHelper(DataSource dataSource){ + this.dataSource = dataSource; + } + public Observable>> readArrayKeyData(KeyData> key, TypeToken typeToken){ + return Observable.just(key) + .map(item -> { + try { + Gson gson = new Gson(); + try(JsonReader reader = new JsonReader(new FileReader(dataSource.getConfigurationFilePath()))) { + return gson.fromJson(reader,typeToken.getType()); + } + }catch (IOException e){ + logger.error(e); + } + return item; + }); + } + public void writeArrayObject(String key, List object, TypeToken typeToken){ + try { + Gson gson = new Gson(); + try(JsonWriter reader = new JsonWriter(new FileWriter(dataSource.getConfigurationFilePath()))) { + gson.toJson(new KeyData<>(key,object),typeToken.getType(),reader); + } + }catch (IOException e){ + logger.error(e); + } + + } +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/MercuryDataSource.java b/app-core/src/main/java/com/mercury/platform/shared/config/MercuryDataSource.java index 70ced77f..5cbb6e49 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/MercuryDataSource.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/MercuryDataSource.java @@ -4,7 +4,7 @@ * Created by Константин on 08.04.2017. */ public class MercuryDataSource extends DataSource { - protected MercuryDataSource() { - super(System.getenv("USERPROFILE") + "\\AppData\\Local\\MercuryTrade\\app-config.json"); + public MercuryDataSource() { + super(System.getenv("USERPROFILE") + "\\AppData\\Local\\MercuryTrade\\configuration.json"); } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/service/BaseConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/service/BaseConfigurationService.java index 415c7427..6c97fa1b 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/service/BaseConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/service/BaseConfigurationService.java @@ -1,13 +1,15 @@ package com.mercury.platform.shared.config.service; import com.mercury.platform.shared.config.DataSource; +import com.mercury.platform.shared.config.JSONHelper; + -/** - * Created by Константин on 08.04.2017. - */ public abstract class BaseConfigurationService implements ConfigurationService{ - private DataSource dataSource; + protected DataSource dataSource; + protected JSONHelper jsonHelper; + protected BaseConfigurationService(DataSource dataSource){ this.dataSource = dataSource; + this.jsonHelper = new JSONHelper(dataSource); } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/service/ConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/service/ConfigurationService.java index c3297fc7..fdb19eb6 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/service/ConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/service/ConfigurationService.java @@ -1,8 +1,10 @@ package com.mercury.platform.shared.config.service; +import java.io.IOException; + public interface ConfigurationService { - void load(); + void load() throws IOException; T get(K key); - void save(T entity, K key); + void save(); } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/service/FramesConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/service/FramesConfigurationService.java index 2642d963..51e839e9 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/service/FramesConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/service/FramesConfigurationService.java @@ -20,7 +20,7 @@ public FrameSettings get(String key) { } @Override - public void save(FrameSettings entity, String key) { + public void save() { } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/service/SoundConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/service/SoundConfigurationService.java index a1411044..c5b87f11 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/service/SoundConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/service/SoundConfigurationService.java @@ -1,26 +1,70 @@ package com.mercury.platform.shared.config.service; +import com.google.gson.reflect.TypeToken; import com.mercury.platform.shared.config.DataSource; +import com.mercury.platform.shared.entity.KeyData; import com.mercury.platform.shared.entity.SoundDescriptor; +import java.util.*; + public class SoundConfigurationService extends BaseConfigurationService { + private List> data; public SoundConfigurationService(DataSource dataSource) { super(dataSource); + this.data = new ArrayList<>(); } @Override - public void load() { - + public void load(){ + jsonHelper.readArrayKeyData(new KeyData<>("sound",new ArrayList<>()),new TypeToken>>(){}) + .subscribe(data -> { + if(data == null){ + toDefault(); + }else { + System.out.println(data); + } + }); } @Override public SoundDescriptor get(String key) { - return null; + Optional> first = this.data.stream() + .filter(item -> item.getKey().equals(key)) + .findFirst(); + + if(!first.isPresent()){ + SoundDescriptor data = getDefault() + .getData() + .stream() + .filter(item -> item.getKey().equals(key)) + .findFirst() + .get() + .getData(); + this.data.add(new KeyData<>(key,data)); + save(); + return data; + } + return first.get().getData(); } @Override - public void save(SoundDescriptor entity, String key) { + public void save() { +// jsonHelper.writeArrayObject(new KeyData<>("sound",this.data)); + } + + private void toDefault(){ + KeyData>> defaultSt = getDefault(); + this.data = defaultSt.getData(); + jsonHelper.writeArrayObject("sound",defaultSt.getData(),new TypeToken>>>(){}); + } + private KeyData>> getDefault(){ + List> defaultSettings = new ArrayList<>(); + defaultSettings.add(new KeyData<>("notification",new SoundDescriptor("app/notification.wav",0f))); + defaultSettings.add(new KeyData<>("chat_scanner",new SoundDescriptor("app/chat-filter.wav",0f))); + defaultSettings.add(new KeyData<>("clicks",new SoundDescriptor("default",0f))); + defaultSettings.add(new KeyData<>("update",new SoundDescriptor("default",0f))); + return new KeyData<>("sound",defaultSettings); } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/entity/KeyData.java b/app-core/src/main/java/com/mercury/platform/shared/entity/KeyData.java index 8e16b486..4f868bfa 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/entity/KeyData.java +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/KeyData.java @@ -1,14 +1,13 @@ package com.mercury.platform.shared.entity; -import com.alibaba.fastjson.annotation.JSONField; import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; @Data @AllArgsConstructor +@NoArgsConstructor public class KeyData { - @JSONField private String key; - @JSONField private T data; } diff --git a/app-core/src/main/java/com/mercury/platform/shared/entity/SoundDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/entity/SoundDescriptor.java index 809c0998..d4fd79a2 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/entity/SoundDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/SoundDescriptor.java @@ -1,6 +1,5 @@ package com.mercury.platform.shared.entity; -import com.alibaba.fastjson.annotation.JSONField; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -9,8 +8,6 @@ @AllArgsConstructor @NoArgsConstructor public class SoundDescriptor { - @JSONField private String wavPath; - @JSONField private Float db; } diff --git a/app-core/src/main/java/com/mercury/platform/shared/store/DataTransformers.java b/app-core/src/main/java/com/mercury/platform/shared/store/DataTransformers.java index 2a3ab58a..21dd6555 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/store/DataTransformers.java +++ b/app-core/src/main/java/com/mercury/platform/shared/store/DataTransformers.java @@ -1,6 +1,8 @@ package com.mercury.platform.shared.store; import com.mercury.platform.core.misc.SoundType; +import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.service.ConfigurationService; import com.mercury.platform.shared.entity.SoundDescriptor; import rx.Observable; @@ -8,6 +10,7 @@ public class DataTransformers { + private static final ConfigurationService soundService = Configuration.get().soundConfigurationService(); public static Observable.Transformer transformSoundData() { String[] clicks = { "app/sounds/click1/button-pressed-10.wav", @@ -17,22 +20,19 @@ public static Observable.Transformer transformSoundD SoundDescriptor descriptor = new SoundDescriptor(); switch (soundType){ case MESSAGE:{ - descriptor.setWavPath("app/notification.wav"); - descriptor.setDb(-10f); - break; + return soundService.get("notification"); } case CHAT_SCANNER: { - - break; + return soundService.get("chat_scanner"); } case CLICKS: { descriptor.setWavPath(clicks[new Random().nextInt(3)]); - descriptor.setDb(-10f); + descriptor.setDb(soundService.get("clicks").getDb()); break; } case UPDATE: { descriptor.setWavPath("app/patch_tone.wav"); - descriptor.setDb(-10f); + descriptor.setDb(soundService.get("update").getDb()); break; } } diff --git a/app-core/src/test/java/com/mercury/platform/shared/store/MercuryStoreTest.java b/app-core/src/test/java/com/mercury/platform/shared/store/MercuryStoreTest.java index 591f7542..0bbfc9af 100644 --- a/app-core/src/test/java/com/mercury/platform/shared/store/MercuryStoreTest.java +++ b/app-core/src/test/java/com/mercury/platform/shared/store/MercuryStoreTest.java @@ -1,10 +1,5 @@ package com.mercury.platform.shared.store; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONReader; -import com.alibaba.fastjson.JSONWriter; -import com.mercury.platform.core.misc.SoundType; -import com.mercury.platform.shared.entity.FrameSettings; import com.mercury.platform.shared.entity.KeyData; import com.mercury.platform.shared.entity.SoundDescriptor; import org.junit.Test; @@ -25,21 +20,5 @@ public class MercuryStoreTest { @Test public void testSoundReducer() throws IOException { TestSubscriber> testSubscriber = new TestSubscriber<>(); - -// MercuryStore.INSTANCE.soundSubject -// .compose(DataTransformers.transformSoundData()) -// .subscribe(testSubscriber); -// -// MercuryStore.INSTANCE.soundSubject.onNext(SoundType.MESSAGE); -// Map expectedValue = new HashMap<>(); - - JSONReader reader = new JSONReader(new FileReader("qwe")); - reader.readObject(); - JSONWriter writer = new JSONWriter(new FileWriter("qwe")); - List> list = new ArrayList<>(); - list.add(new KeyData<>("1",new SoundDescriptor("test1.wav",10f))); - list.add(new KeyData<>("2",new SoundDescriptor("test2.wav",10f))); - list.add(new KeyData<>("3",new SoundDescriptor("test3.wav",10f))); - System.out.println(JSON.toJSONString(new KeyData<>("frameSettings", list))); } } \ No newline at end of file diff --git a/pom.xml b/pom.xml index f72d1113..c4732bd4 100644 --- a/pom.xml +++ b/pom.xml @@ -36,6 +36,7 @@ 0.5.8 1.2.9 1.2.24 + 2.8.7 UTF-8 UTF-8 @@ -133,9 +134,9 @@ ${rxjava.version} - com.alibaba - fastjson - ${fastjson.version} + com.google.code.gson + gson + 2.8.0 org.apache.logging.log4j From 1256f71932d16fe30d6dafa263e9e1d6eb87a965 Mon Sep 17 00:00:00 2001 From: Exslims Date: Mon, 10 Apr 2017 00:10:31 +0400 Subject: [PATCH 08/15] Fixed reading json from configuration file. --- .../com/mercury/platform/core/AppStarter.java | 6 +- .../platform/core/misc/SoundNotifier.java | 9 ++- .../platform/shared/config/JSONHelper.java | 44 +++++++------- .../service/SoundConfigurationService.java | 57 ++++++------------- 4 files changed, 50 insertions(+), 66 deletions(-) diff --git a/app-core/src/main/java/com/mercury/platform/core/AppStarter.java b/app-core/src/main/java/com/mercury/platform/core/AppStarter.java index f40f7655..726c2195 100644 --- a/app-core/src/main/java/com/mercury/platform/core/AppStarter.java +++ b/app-core/src/main/java/com/mercury/platform/core/AppStarter.java @@ -31,9 +31,9 @@ public class AppStarter { private boolean updating = false; public void startApplication(){ -// BaseConfigManager configuration = new BaseConfigManager(new MercuryDataSource()); -// configuration.load(); -// Configuration.set(configuration); + BaseConfigManager configuration = new BaseConfigManager(new MercuryDataSource()); + configuration.load(); + Configuration.set(configuration); ConfigManager.INSTANCE.load(); new SoundNotifier(); diff --git a/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java b/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java index 3f2eaa27..a6585d26 100644 --- a/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java +++ b/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java @@ -5,8 +5,6 @@ import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.*; -import com.mercury.platform.shared.store.DataTransformers; -import com.mercury.platform.shared.store.MercuryStore; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -45,6 +43,13 @@ public SoundNotifier() { EventRouter.CORE.registerHandler(DndModeEvent.class, event -> { this.dnd = ((DndModeEvent)event).isDnd(); }); + EventRouter.CORE.registerHandler(SoundNotificationEvent.ClicksSoundNotificationEvent.class, event -> { + String[] clicks = { + "app/sounds/click1/button-pressed-10.wav", + "app/sounds/click1/button-pressed-20.wav", + "app/sounds/click1/button-pressed-30.wav"}; + play(clicks[new Random().nextInt(3)],((SoundNotificationEvent.ClicksSoundNotificationEvent)event).getDb()); + }); } private void play(String wavPath, float db){ diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/JSONHelper.java b/app-core/src/main/java/com/mercury/platform/shared/config/JSONHelper.java index cb7099c2..0567e06a 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/JSONHelper.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/JSONHelper.java @@ -1,19 +1,15 @@ package com.mercury.platform.shared.config; -import com.google.gson.Gson; +import com.google.gson.*; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.mercury.platform.shared.entity.KeyData; -import com.mercury.platform.shared.entity.SoundDescriptor; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import rx.Observable; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; +import java.util.Map; public class JSONHelper { private Logger logger = LogManager.getLogger(JSONHelper.class.getSimpleName()); @@ -22,25 +18,29 @@ public class JSONHelper { public JSONHelper(DataSource dataSource){ this.dataSource = dataSource; } - public Observable>> readArrayKeyData(KeyData> key, TypeToken typeToken){ - return Observable.just(key) - .map(item -> { - try { - Gson gson = new Gson(); - try(JsonReader reader = new JsonReader(new FileReader(dataSource.getConfigurationFilePath()))) { - return gson.fromJson(reader,typeToken.getType()); - } - }catch (IOException e){ - logger.error(e); - } - return item; - }); - } - public void writeArrayObject(String key, List object, TypeToken typeToken){ + public T readMapData(String key,TypeToken typeToken){ try { Gson gson = new Gson(); + JsonParser jsonParser = new JsonParser(); + try(JsonReader reader = new JsonReader(new FileReader(dataSource.getConfigurationFilePath()))) { + return gson.fromJson( + jsonParser.parse(reader) + .getAsJsonObject() + .get(key), + typeToken.getType()); + } + }catch (IOException e){ + logger.error(e); + return null; + } + } + public void writeMapObject(String key, Map object){ + try { + Gson gson = new GsonBuilder().enableComplexMapKeySerialization().setPrettyPrinting().create(); try(JsonWriter reader = new JsonWriter(new FileWriter(dataSource.getConfigurationFilePath()))) { - gson.toJson(new KeyData<>(key,object),typeToken.getType(),reader); + JsonObject jsonObject = new JsonObject(); + jsonObject.add(key,gson.toJsonTree(object)); + gson.toJson(jsonObject,reader); } }catch (IOException e){ logger.error(e); diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/service/SoundConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/service/SoundConfigurationService.java index c5b87f11..9404cc13 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/service/SoundConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/service/SoundConfigurationService.java @@ -2,69 +2,48 @@ import com.google.gson.reflect.TypeToken; import com.mercury.platform.shared.config.DataSource; -import com.mercury.platform.shared.entity.KeyData; import com.mercury.platform.shared.entity.SoundDescriptor; import java.util.*; public class SoundConfigurationService extends BaseConfigurationService { - private List> data; + private Map data; public SoundConfigurationService(DataSource dataSource) { super(dataSource); - this.data = new ArrayList<>(); + this.data = new HashMap<>(); } @Override public void load(){ - jsonHelper.readArrayKeyData(new KeyData<>("sound",new ArrayList<>()),new TypeToken>>(){}) - .subscribe(data -> { - if(data == null){ - toDefault(); - }else { - System.out.println(data); - } - }); + this.data = jsonHelper.readMapData("sound", new TypeToken>() {}); + if(data == null) { + toDefault(); + } + System.out.println(this.data); } @Override public SoundDescriptor get(String key) { - Optional> first = this.data.stream() - .filter(item -> item.getKey().equals(key)) - .findFirst(); - - if(!first.isPresent()){ - SoundDescriptor data = getDefault() - .getData() - .stream() - .filter(item -> item.getKey().equals(key)) - .findFirst() - .get() - .getData(); - this.data.add(new KeyData<>(key,data)); - save(); - return data; - } - return first.get().getData(); + return this.data.computeIfAbsent(key, k -> getDefault().get(key)); } @Override public void save() { -// jsonHelper.writeArrayObject(new KeyData<>("sound",this.data)); +// jsonHelper.writeMapObject(new KeyData<>("sound",this.data)); } private void toDefault(){ - KeyData>> defaultSt = getDefault(); - this.data = defaultSt.getData(); - jsonHelper.writeArrayObject("sound",defaultSt.getData(),new TypeToken>>>(){}); + Map defaultSt = getDefault(); + jsonHelper.writeMapObject("sound",defaultSt); } - private KeyData>> getDefault(){ - List> defaultSettings = new ArrayList<>(); - defaultSettings.add(new KeyData<>("notification",new SoundDescriptor("app/notification.wav",0f))); - defaultSettings.add(new KeyData<>("chat_scanner",new SoundDescriptor("app/chat-filter.wav",0f))); - defaultSettings.add(new KeyData<>("clicks",new SoundDescriptor("default",0f))); - defaultSettings.add(new KeyData<>("update",new SoundDescriptor("default",0f))); - return new KeyData<>("sound",defaultSettings); + private Map getDefault(){ + Map defaultSettings = new HashMap<>(); + defaultSettings.put("notification",new SoundDescriptor("app/notification.wav",0f)); + defaultSettings.put("chat_scanner",new SoundDescriptor("app/chat-filter.wav",0f)); + defaultSettings.put("clicks",new SoundDescriptor("default",0f)); + defaultSettings.put("update",new SoundDescriptor("default",0f)); + return defaultSettings; } } From c9a3c1b7416dacfc51ee9e7b8546c49e0cef5ae1 Mon Sep 17 00:00:00 2001 From: Exslims Date: Mon, 10 Apr 2017 01:10:11 +0400 Subject: [PATCH 09/15] Transforming sound configuration --- .../platform/core/misc/SoundNotifier.java | 45 +++++-------------- .../core/handlers/ResponseDispatcher.java | 4 +- .../IncTradeMessagesInterceptor.java | 3 +- .../shared/config/BaseConfigManager.java | 4 +- .../platform/shared/config/ConfigManager.java | 4 +- .../platform/shared/config/JSONHelper.java | 13 +++++- .../service/SoundConfigurationService.java | 9 ++-- .../shared/store/DataTransformers.java | 14 +++++- .../platform/shared/store/MercuryStore.java | 1 + .../ui/components/ComponentsFactory.java | 6 ++- .../panel/chat/ChatFilterPanel.java | 4 +- 11 files changed, 54 insertions(+), 53 deletions(-) diff --git a/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java b/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java index a6585d26..e3e2b2d0 100644 --- a/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java +++ b/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java @@ -1,10 +1,9 @@ package com.mercury.platform.core.misc; -import com.mercury.platform.core.AppStarter; -import com.mercury.platform.shared.ConfigManager; -import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.*; +import com.mercury.platform.shared.store.DataTransformers; +import com.mercury.platform.shared.store.MercuryStore; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -12,44 +11,20 @@ import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Clip; import javax.sound.sampled.FloatControl; -import java.util.Random; public class SoundNotifier { private final Logger logger = LogManager.getLogger(SoundNotifier.class); private boolean dnd = false; public SoundNotifier() { - -// MercuryStore.INSTANCE.soundSubject -// .compose(DataTransformers.transformSoundData()) -// .subscribe( -// data -> play(data.getWavPath(), data.getDb())); -// MercuryStore.INSTANCE.soundSettingsSubject -// .subscribe( -// data -> play(data.getWavPath(), data.getDb())); - - EventRouter.CORE.registerHandler(SoundNotificationEvent.WhisperSoundNotificationEvent.class, event -> { - WhisperNotifierStatus status = ConfigManager.INSTANCE.getWhisperNotifier(); - if (status == WhisperNotifierStatus.ALWAYS || - ((status == WhisperNotifierStatus.ALTAB) && (AppStarter.APP_STATUS == FrameVisibleState.HIDE))) { - play("app/notification.wav",((SoundNotificationEvent.WhisperSoundNotificationEvent)event).getDb()); - } - }); - EventRouter.CORE.registerHandler(SoundNotificationEvent.UpdateSoundNotificationEvent.class, event -> { - play("app/patch_tone.wav",((SoundNotificationEvent.UpdateSoundNotificationEvent)event).getDb()); - }); - EventRouter.CORE.registerHandler(SoundNotificationEvent.ChatScannerSoundNotificationEvent.class, event -> { - play("app/chat-filter.wav",((SoundNotificationEvent.ChatScannerSoundNotificationEvent)event).getDb()); - }); - EventRouter.CORE.registerHandler(DndModeEvent.class, event -> { - this.dnd = ((DndModeEvent)event).isDnd(); - }); - EventRouter.CORE.registerHandler(SoundNotificationEvent.ClicksSoundNotificationEvent.class, event -> { - String[] clicks = { - "app/sounds/click1/button-pressed-10.wav", - "app/sounds/click1/button-pressed-20.wav", - "app/sounds/click1/button-pressed-30.wav"}; - play(clicks[new Random().nextInt(3)],((SoundNotificationEvent.ClicksSoundNotificationEvent)event).getDb()); + MercuryStore.INSTANCE.soundSubject + .compose(DataTransformers.transformSoundData()) + .subscribe(data -> play(data.getWavPath(), data.getDb())); + MercuryStore.INSTANCE.soundSettingsSubject + .subscribe(data -> play(data.getWavPath(), data.getDb())); + MercuryStore.INSTANCE.dndSubject.subscribe(value -> { + this.dnd = value; }); + EventRouter.CORE.registerHandler(DndModeEvent.class, event -> this.dnd = ((DndModeEvent)event).isDnd()); } private void play(String wavPath, float db){ diff --git a/app-core/src/main/java/com/mercury/platform/core/update/core/handlers/ResponseDispatcher.java b/app-core/src/main/java/com/mercury/platform/core/update/core/handlers/ResponseDispatcher.java index 505d2b01..ca2f0bf3 100644 --- a/app-core/src/main/java/com/mercury/platform/core/update/core/handlers/ResponseDispatcher.java +++ b/app-core/src/main/java/com/mercury/platform/core/update/core/handlers/ResponseDispatcher.java @@ -1,11 +1,13 @@ package com.mercury.platform.core.update.core.handlers; +import com.mercury.platform.core.misc.SoundType; import com.mercury.platform.core.update.core.holder.ApplicationHolder; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.AlertEvent; import com.mercury.platform.shared.events.custom.ShowPatchNotesEvent; import com.mercury.platform.shared.events.custom.SoundNotificationEvent; import com.mercury.platform.shared.events.custom.UpdateInfoEvent; +import com.mercury.platform.shared.store.MercuryStore; import com.mercury.platform.update.AlreadyLatestUpdateMessage; import com.mercury.platform.update.PatchNotesDescriptor; import com.mercury.platform.update.UpdateDescriptor; @@ -20,7 +22,7 @@ public void process(Object object){ EventRouter.CORE.fireEvent(new ShowPatchNotesEvent(notes)); } if(object instanceof UpdateDescriptor){ - EventRouter.CORE.fireEvent(new SoundNotificationEvent.UpdateSoundNotificationEvent()); + MercuryStore.INSTANCE.soundSubject.onNext(SoundType.UPDATE); EventRouter.CORE.fireEvent(new UpdateInfoEvent(((UpdateDescriptor) object).getVersion())); } if(object instanceof AlreadyLatestUpdateMessage){ diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/IncTradeMessagesInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/IncTradeMessagesInterceptor.java index f1d08690..0fae9947 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/IncTradeMessagesInterceptor.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/IncTradeMessagesInterceptor.java @@ -20,8 +20,7 @@ public class IncTradeMessagesInterceptor extends MessageInterceptor { protected void process(String message) { Message parsedMessage = messageParser.parse(StringUtils.substringAfter(message,"@")); if(parsedMessage != null) { - EventRouter.CORE.fireEvent(new SoundNotificationEvent.WhisperSoundNotificationEvent()); -// MercuryStore.INSTANCE.soundSubject.onNext(SoundType.MESSAGE); + MercuryStore.INSTANCE.soundSubject.onNext(SoundType.MESSAGE); EventRouter.CORE.fireEvent(new NewWhispersEvent(parsedMessage)); } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/BaseConfigManager.java b/app-core/src/main/java/com/mercury/platform/shared/config/BaseConfigManager.java index 807abca4..19340994 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/BaseConfigManager.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/BaseConfigManager.java @@ -26,11 +26,11 @@ public BaseConfigManager(DataSource dataSource){ this.soundConfigurationService = new SoundConfigurationService(dataSource); } @Override - public ConfigurationService framesConfigurationService() { + public ConfigurationService framesConfiguration() { return framesConfigurationService; } @Override - public ConfigurationService soundConfigurationService() { + public ConfigurationService soundConfiguration() { return soundConfigurationService; } public void load(){ 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 dd6bf164..3ca29bda 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 @@ -6,6 +6,6 @@ public interface ConfigManager { - ConfigurationService framesConfigurationService(); - ConfigurationService soundConfigurationService(); + ConfigurationService framesConfiguration(); + ConfigurationService soundConfiguration(); } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/JSONHelper.java b/app-core/src/main/java/com/mercury/platform/shared/config/JSONHelper.java index 0567e06a..4335c6d5 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/JSONHelper.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/JSONHelper.java @@ -32,15 +32,24 @@ public T readMapData(String key,TypeToken typeToken){ }catch (IOException e){ logger.error(e); return null; + }catch (IllegalStateException e1) { + return null; } } public void writeMapObject(String key, Map object){ try { Gson gson = new GsonBuilder().enableComplexMapKeySerialization().setPrettyPrinting().create(); - try(JsonWriter reader = new JsonWriter(new FileWriter(dataSource.getConfigurationFilePath()))) { + JsonParser jsonParser = new JsonParser(); + + try(JsonWriter writer = new JsonWriter(new FileWriter(dataSource.getConfigurationFilePath())); + JsonReader reader = new JsonReader(new FileReader(dataSource.getConfigurationFilePath()))) { +// JsonElement jsonElement = jsonParser.parse(reader) +// .getAsJsonObject() +// .get(key); +// jsonElement.ad JsonObject jsonObject = new JsonObject(); jsonObject.add(key,gson.toJsonTree(object)); - gson.toJson(jsonObject,reader); + gson.toJson(jsonObject,writer); } }catch (IOException e){ logger.error(e); diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/service/SoundConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/service/SoundConfigurationService.java index 9404cc13..8bc11cd1 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/service/SoundConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/service/SoundConfigurationService.java @@ -8,6 +8,7 @@ public class SoundConfigurationService extends BaseConfigurationService { + private static final String OBJECT_KEY = "sound"; private Map data; public SoundConfigurationService(DataSource dataSource) { super(dataSource); @@ -16,11 +17,10 @@ public SoundConfigurationService(DataSource dataSource) { @Override public void load(){ - this.data = jsonHelper.readMapData("sound", new TypeToken>() {}); + this.data = jsonHelper.readMapData(OBJECT_KEY, new TypeToken>() {}); if(data == null) { toDefault(); } - System.out.println(this.data); } @Override @@ -30,12 +30,13 @@ public SoundDescriptor get(String key) { @Override public void save() { -// jsonHelper.writeMapObject(new KeyData<>("sound",this.data)); + jsonHelper.writeMapObject(OBJECT_KEY,this.data); } private void toDefault(){ Map defaultSt = getDefault(); - jsonHelper.writeMapObject("sound",defaultSt); + this.data = defaultSt; + jsonHelper.writeMapObject(OBJECT_KEY,defaultSt); } private Map getDefault(){ Map defaultSettings = new HashMap<>(); diff --git a/app-core/src/main/java/com/mercury/platform/shared/store/DataTransformers.java b/app-core/src/main/java/com/mercury/platform/shared/store/DataTransformers.java index 21dd6555..abfe939c 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/store/DataTransformers.java +++ b/app-core/src/main/java/com/mercury/platform/shared/store/DataTransformers.java @@ -1,6 +1,10 @@ package com.mercury.platform.shared.store; +import com.mercury.platform.core.AppStarter; import com.mercury.platform.core.misc.SoundType; +import com.mercury.platform.core.misc.WhisperNotifierStatus; +import com.mercury.platform.shared.ConfigManager; +import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.config.Configuration; import com.mercury.platform.shared.config.service.ConfigurationService; import com.mercury.platform.shared.entity.SoundDescriptor; @@ -10,7 +14,7 @@ public class DataTransformers { - private static final ConfigurationService soundService = Configuration.get().soundConfigurationService(); + private static final ConfigurationService soundService = Configuration.get().soundConfiguration(); public static Observable.Transformer transformSoundData() { String[] clicks = { "app/sounds/click1/button-pressed-10.wav", @@ -20,7 +24,13 @@ public static Observable.Transformer transformSoundD SoundDescriptor descriptor = new SoundDescriptor(); switch (soundType){ case MESSAGE:{ - return soundService.get("notification"); + SoundDescriptor desc = soundService.get("notification"); + WhisperNotifierStatus status = ConfigManager.INSTANCE.getWhisperNotifier(); + if (status == WhisperNotifierStatus.ALWAYS || + ((status == WhisperNotifierStatus.ALTAB) && (AppStarter.APP_STATUS == FrameVisibleState.HIDE))) { + return desc; + } + return new SoundDescriptor(desc.getWavPath(),-80f); } case CHAT_SCANNER: { return soundService.get("chat_scanner"); diff --git a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java index 772114f7..6c608107 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java +++ b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java @@ -13,4 +13,5 @@ private static class MercuryStoreHolder { public final PublishSubject soundSubject = PublishSubject.create(); public final PublishSubject soundSettingsSubject = PublishSubject.create(); + public final PublishSubject dndSubject = PublishSubject.create(); } 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 bcd6f7ee..97bac01e 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 @@ -1,8 +1,10 @@ package com.mercury.platform.ui.components; +import com.mercury.platform.core.misc.SoundType; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.HideTooltipEvent; import com.mercury.platform.shared.events.custom.SoundNotificationEvent; +import com.mercury.platform.shared.store.MercuryStore; import com.mercury.platform.ui.misc.event.ShowTooltipEvent; import com.mercury.platform.ui.components.fields.style.MercuryComboBoxUI; import com.mercury.platform.ui.components.fields.font.FontStyle; @@ -84,7 +86,7 @@ protected void paintBorder(Graphics g) { @Override public void mousePressed(MouseEvent e) { if(SwingUtilities.isLeftMouseButton(e)) { - EventRouter.CORE.fireEvent(new SoundNotificationEvent.ClicksSoundNotificationEvent()); + MercuryStore.INSTANCE.soundSubject.onNext(SoundType.CLICKS); } } }); @@ -197,7 +199,7 @@ public void mousePressed(MouseEvent e) { @Override public void mousePressed(MouseEvent e) { if(SwingUtilities.isLeftMouseButton(e)) { - EventRouter.CORE.fireEvent(new SoundNotificationEvent.ClicksSoundNotificationEvent()); + MercuryStore.INSTANCE.soundSubject.onNext(SoundType.CLICKS); } } }); 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 a8c52646..ad490f0d 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,7 +1,9 @@ package com.mercury.platform.ui.components.panel.chat; +import com.mercury.platform.core.misc.SoundType; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.SoundNotificationEvent; +import com.mercury.platform.shared.store.MercuryStore; import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.fields.style.MercuryScrollBarUI; import com.mercury.platform.ui.components.panel.VerticalScrollContainer; @@ -112,7 +114,7 @@ private void addMessageToFilter(String message) { expiresMessages.put(nickname,message); EventRouter.UI.fireEvent(new PackEvent.PackChatFilter()); if(soundEnable){ - EventRouter.CORE.fireEvent(new SoundNotificationEvent.ChatScannerSoundNotificationEvent()); + MercuryStore.INSTANCE.soundSubject.onNext(SoundType.CHAT_SCANNER); } if(scrollToBottom) { container.scrollRectToVisible(new Rectangle(0, container.getHeight() - 1, 1, 1)); From 90dd4231f26031c0276d5291f7fe5c85f0367755 Mon Sep 17 00:00:00 2001 From: Exslims Date: Tue, 11 Apr 2017 05:47:11 +0400 Subject: [PATCH 10/15] Volume settings --- .../platform/shared/config/JSONHelper.java | 8 +- .../config/service/ConfigurationService.java | 2 + .../service/FramesConfigurationService.java | 7 ++ .../service/SoundConfigurationService.java | 5 + .../panel/settings/SoundSettingsPanel.java | 89 +++++++++++++----- .../src/main/resources/currency/chromatic.png | Bin 0 -> 7967 bytes 6 files changed, 78 insertions(+), 33 deletions(-) create mode 100644 app-ui/src/main/resources/currency/chromatic.png diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/JSONHelper.java b/app-core/src/main/java/com/mercury/platform/shared/config/JSONHelper.java index 4335c6d5..536016f5 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/JSONHelper.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/JSONHelper.java @@ -39,14 +39,8 @@ public T readMapData(String key,TypeToken typeToken){ public void writeMapObject(String key, Map object){ try { Gson gson = new GsonBuilder().enableComplexMapKeySerialization().setPrettyPrinting().create(); - JsonParser jsonParser = new JsonParser(); - try(JsonWriter writer = new JsonWriter(new FileWriter(dataSource.getConfigurationFilePath())); - JsonReader reader = new JsonReader(new FileReader(dataSource.getConfigurationFilePath()))) { -// JsonElement jsonElement = jsonParser.parse(reader) -// .getAsJsonObject() -// .get(key); -// jsonElement.ad + try(JsonWriter writer = new JsonWriter(new FileWriter(dataSource.getConfigurationFilePath()))) { JsonObject jsonObject = new JsonObject(); jsonObject.add(key,gson.toJsonTree(object)); gson.toJson(jsonObject,writer); diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/service/ConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/service/ConfigurationService.java index fdb19eb6..ecfca38c 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/service/ConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/service/ConfigurationService.java @@ -2,9 +2,11 @@ import java.io.IOException; +import java.util.Map; public interface ConfigurationService { void load() throws IOException; T get(K key); + Map getMap(); void save(); } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/service/FramesConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/service/FramesConfigurationService.java index 51e839e9..a446b205 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/service/FramesConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/service/FramesConfigurationService.java @@ -3,6 +3,8 @@ import com.mercury.platform.shared.config.DataSource; import com.mercury.platform.shared.entity.FrameSettings; +import java.util.Map; + public class FramesConfigurationService extends BaseConfigurationService { public FramesConfigurationService(DataSource dataSource) { @@ -19,6 +21,11 @@ public FrameSettings get(String key) { return null; } + @Override + public Map getMap() { + return null; + } + @Override public void save() { diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/service/SoundConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/service/SoundConfigurationService.java index 8bc11cd1..dd55f658 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/service/SoundConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/service/SoundConfigurationService.java @@ -28,6 +28,11 @@ public SoundDescriptor get(String key) { return this.data.computeIfAbsent(key, k -> getDefault().get(key)); } + @Override + public Map getMap() { + return this.data; + } + @Override public void save() { jsonHelper.writeMapObject(OBJECT_KEY,this.data); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java index 244a84fb..3e5ba675 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java @@ -1,7 +1,8 @@ package com.mercury.platform.ui.components.panel.settings; -import com.mercury.platform.shared.events.EventRouter; -import com.mercury.platform.shared.events.custom.SoundNotificationEvent; +import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.entity.SoundDescriptor; +import com.mercury.platform.shared.store.MercuryStore; 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; @@ -11,14 +12,26 @@ import javax.swing.filechooser.FileNameExtensionFilter; import java.awt.*; import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.util.HashMap; +import java.util.Map; public class SoundSettingsPanel extends ConfigurationPanel { + private Map wavPaths; + + private JSlider notificationSlider; + private JSlider chatScannerSlider; + private JSlider clicksSlider; + private JSlider updateSlider; public SoundSettingsPanel() { super(); + this.wavPaths = new HashMap<>(); + this.wavPaths.put("notification","app/notification.wav"); + this.wavPaths.put("chat_scanner","app/chat-filter.wav"); + this.wavPaths.put("clicks","app/sounds/click1/button-pressed-10.wav"); + this.wavPaths.put("update","app/patch_tone.wav"); this.createUI(); } @@ -29,6 +42,8 @@ public void createUI() { } private JPanel getVolumePanel(){ + Map map = Configuration.get().soundConfiguration().getMap(); + JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); JLabel volumeLabel = componentsFactory.getTextLabel(FontStyle.REGULAR, AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP, 17f, "Volume"); @@ -44,44 +59,48 @@ private JPanel getVolumePanel(){ BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), BorderFactory.createEmptyBorder(3,0,3,0))); - JSlider notificationSlider = componentsFactory.getSlider(-40, 6, 0); + notificationSlider = componentsFactory.getSlider(-40, 6, + map.get("notification").getDb().intValue() == -80? -40: map.get("notification").getDb().intValue()); notificationSlider.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { - EventRouter.CORE.fireEvent( - new SoundNotificationEvent.WhisperSoundNotificationEvent( - notificationSlider.getValue() == -40 ? -80f : (float)notificationSlider.getValue()) - ); + MercuryStore.INSTANCE.soundSettingsSubject.onNext(new SoundDescriptor( + wavPaths.get("notification"), + notificationSlider.getValue() == -40 ? -80f : (float)notificationSlider.getValue() + )); } }); - JSlider chatScannerSlider = componentsFactory.getSlider(-40, 6, 0); + chatScannerSlider = componentsFactory.getSlider(-40, 6, + map.get("chat_scanner").getDb().intValue() == -80? -40: map.get("chat_scanner").getDb().intValue()); chatScannerSlider.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { - EventRouter.CORE.fireEvent( - new SoundNotificationEvent.ChatScannerSoundNotificationEvent( - chatScannerSlider.getValue() == -40 ? -80f : (float)chatScannerSlider.getValue()) - ); + MercuryStore.INSTANCE.soundSettingsSubject.onNext(new SoundDescriptor( + wavPaths.get("chat_scanner"), + chatScannerSlider.getValue() == -40 ? -80f : (float)chatScannerSlider.getValue() + )); } }); - JSlider clicksSlider = componentsFactory.getSlider(-40, 6, 0); + clicksSlider = componentsFactory.getSlider(-40, 6, + map.get("clicks").getDb().intValue() == -80? -40: map.get("clicks").getDb().intValue()); clicksSlider.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { - EventRouter.CORE.fireEvent( - new SoundNotificationEvent.ClicksSoundNotificationEvent( - clicksSlider.getValue() == -40 ? -80f : (float)clicksSlider.getValue()) - ); + MercuryStore.INSTANCE.soundSettingsSubject.onNext(new SoundDescriptor( + wavPaths.get("clicks"), + clicksSlider.getValue() == -40 ? -80f : (float)clicksSlider.getValue() + )); } }); - JSlider update = componentsFactory.getSlider(-40, 6, 0); - update.addMouseListener(new MouseAdapter() { + updateSlider = componentsFactory.getSlider(-40, 6, + map.get("update").getDb().intValue() == -80? -40: map.get("update").getDb().intValue()); + updateSlider.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { - EventRouter.CORE.fireEvent( - new SoundNotificationEvent.UpdateSoundNotificationEvent( - clicksSlider.getValue() == -40 ? -80f : (float)update.getValue()) - ); + MercuryStore.INSTANCE.soundSettingsSubject.onNext(new SoundDescriptor( + wavPaths.get("update"), + updateSlider.getValue() == -40 ? -80f : (float)updateSlider.getValue() + )); } }); container.add(componentsFactory.getTextLabel("Notification:",FontStyle.REGULAR)); @@ -91,7 +110,7 @@ public void mouseReleased(MouseEvent e) { container.add(componentsFactory.getTextLabel("Clicks",FontStyle.REGULAR)); container.add(clicksSlider); container.add(componentsFactory.getTextLabel("Update notification",FontStyle.REGULAR)); - container.add(update); + container.add(updateSlider); root.add(volumeLabel,BorderLayout.PAGE_START); root.add(container,BorderLayout.CENTER); @@ -147,11 +166,29 @@ private JPanel getSoundPickerPanel(){ @Override public boolean processAndSave() { + Map map = Configuration.get().soundConfiguration().getMap(); + map.get("notification") + .setDb(notificationSlider.getValue() == -40 ? -80f : (float)notificationSlider.getValue()); + map.get("chat_scanner") + .setDb(chatScannerSlider.getValue() == -40 ? -80f : (float)chatScannerSlider.getValue()); + map.get("clicks") + .setDb(clicksSlider.getValue() == -40 ? -80f : (float)clicksSlider.getValue()); + map.get("update") + .setDb(updateSlider.getValue() == -40 ? -80f : (float)updateSlider.getValue()); + Configuration.get().soundConfiguration().save(); return true; } @Override public void restore() { - + Map map = Configuration.get().soundConfiguration().getMap(); + notificationSlider.setValue( + map.get("notification").getDb().intValue() == -80? -40: map.get("notification").getDb().intValue()); + chatScannerSlider.setValue( + map.get("chat_scanner").getDb().intValue() == -80? -40: map.get("chat_scanner").getDb().intValue()); + clicksSlider.setValue( + map.get("clicks").getDb().intValue() == -80? -40: map.get("clicks").getDb().intValue()); + updateSlider.setValue( + map.get("update").getDb().intValue() == -80? -40: map.get("update").getDb().intValue()); } } diff --git a/app-ui/src/main/resources/currency/chromatic.png b/app-ui/src/main/resources/currency/chromatic.png new file mode 100644 index 0000000000000000000000000000000000000000..55751a8501e78ab0f849b7b90946afd92570d6ff GIT binary patch literal 7967 zcmV+)AK>7LP)x?u*4y9r!=W24x~zXNEFGSG zm`qqB)pr5q*!UaiOC<)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c7Z4@EkN&t*^N!jH(p&zp62*AXYu> zVTaxwF?@|WA*qEN4pN&cqHXRXk?JRy0$a^edFnWJu7T1KC(xciYLrkK2Aj35{Q0G? zXQuHCU#}g;OSQkhnVJ46Cy~TSq9}5AM|)&kX%9rHC`i3Fol%9jDriV9dO5YApZfpCc@{G2ut#Yr}?C#qCeUDCTxLyN@mSx`H8h|KgH_DYuB zsnglqwT%bn?`E_#gD!ck*7U+KF9VsAZ1Py)B4@GsZePq2h6k%l4SYU{q>vcCD$LT} zAJE#rj0tFiZ8Y*BLZud$Mb2X=wu2uYdyq!JWaGJK+O3&vA1@PymqE2+Kcg?|pNVMN z%^{EI{A`m(MPcx&e(+k%JbHq*;q4ga3e_WvBw}Z?CF%0B zWuovh5dx=PZhgV8$PrZK?7C2-!m2?i;St+jWofcZGP(}G(WE@TL{_V@nr+f-bH^)( z53S*4rtmVWHSM343dUbcO~<2V4%b6!%(o^kb?t`L34w@i!Qa-v@lBFju=cbvCwB5X zK;m~$q$Bd7{*nGaHR`pVdcmt1miZI>+P#h0mAg3Qlv7SQ<&;xSIpvg7PWip@e*pAV Vjuq1vLbm__002ovPDHLkV1lkPWRU;> literal 0 HcmV?d00001 From 77dde6925480e2e620507513484ded3af812e130 Mon Sep 17 00:00:00 2001 From: Exslims Date: Fri, 14 Apr 2017 18:16:15 +0400 Subject: [PATCH 11/15] Transform some events to mercurystore --- .../com/mercury/platform/core/AppStarter.java | 7 ++- .../platform/shared/ConfigManager.java | 1 + .../shared/config/BaseConfigManager.java | 2 +- .../custom/ChangeFrameVisibleEvent.java | 12 ---- .../shared/events/custom/UILoadedEvent.java | 6 -- .../platform/shared/store/MercuryStore.java | 3 + .../panel/settings/SupportPanel.java | 13 ++--- .../ui/frame/AbstractOverlaidFrame.java | 55 ++++++++---------- .../platform/ui/manager/FramesManager.java | 4 +- app-ui/src/main/resources/app/paypal.png | Bin 3592 -> 5480 bytes 10 files changed, 40 insertions(+), 63 deletions(-) delete mode 100644 app-core/src/main/java/com/mercury/platform/shared/events/custom/ChangeFrameVisibleEvent.java delete mode 100644 app-core/src/main/java/com/mercury/platform/shared/events/custom/UILoadedEvent.java diff --git a/app-core/src/main/java/com/mercury/platform/core/AppStarter.java b/app-core/src/main/java/com/mercury/platform/core/AppStarter.java index 726c2195..4bbbb8c9 100644 --- a/app-core/src/main/java/com/mercury/platform/core/AppStarter.java +++ b/app-core/src/main/java/com/mercury/platform/core/AppStarter.java @@ -12,6 +12,7 @@ import com.mercury.platform.shared.config.MercuryDataSource; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.*; +import com.mercury.platform.shared.store.MercuryStore; import com.sun.jna.Native; import com.sun.jna.PointerType; import org.apache.logging.log4j.LogManager; @@ -46,7 +47,7 @@ public void startApplication(){ HistoryManager.INSTANCE.load(); UpdateManager updateManager = new UpdateManager(); - EventRouter.CORE.registerHandler(UILoadedEvent.class, event -> { + MercuryStore.INSTANCE.uiLoadedSubject.subscribe(state -> { Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override @@ -65,7 +66,7 @@ public void run() { if(!Native.toString(windowText).equals("Path of Exile")){ if(APP_STATUS == FrameVisibleState.SHOW) { APP_STATUS = FrameVisibleState.HIDE; - EventRouter.CORE.fireEvent(new ChangeFrameVisibleEvent(FrameVisibleState.HIDE)); + MercuryStore.INSTANCE.frameVisibleSubject.onNext(FrameVisibleState.HIDE); } }else{ if(APP_STATUS == FrameVisibleState.HIDE) { @@ -75,7 +76,7 @@ public void run() { } catch (InterruptedException e) { } APP_STATUS = FrameVisibleState.SHOW; - EventRouter.CORE.fireEvent(new ChangeFrameVisibleEvent(FrameVisibleState.SHOW)); + MercuryStore.INSTANCE.frameVisibleSubject.onNext(FrameVisibleState.SHOW); } } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java b/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java index 8cf36a76..f7fe882c 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java +++ b/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java @@ -22,6 +22,7 @@ */ //todo generalization @SuppressWarnings("unchecked") +@Deprecated public class ConfigManager { private Logger logger = LogManager.getLogger(ConfigManager.class); diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/BaseConfigManager.java b/app-core/src/main/java/com/mercury/platform/shared/config/BaseConfigManager.java index 19340994..9215f68f 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/BaseConfigManager.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/BaseConfigManager.java @@ -43,7 +43,7 @@ public void load(){ this.framesConfigurationService.load(); this.soundConfigurationService.load(); }catch (IOException e) { - logger.error("Error while created file:{}",dataSource.getConfigurationFilePath(),e); + logger.error("Error while processing file:{}",dataSource.getConfigurationFilePath(),e); } } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/events/custom/ChangeFrameVisibleEvent.java b/app-core/src/main/java/com/mercury/platform/shared/events/custom/ChangeFrameVisibleEvent.java deleted file mode 100644 index e3a68b83..00000000 --- a/app-core/src/main/java/com/mercury/platform/shared/events/custom/ChangeFrameVisibleEvent.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.mercury.platform.shared.events.custom; - -import com.mercury.platform.shared.FrameVisibleState; -import com.mercury.platform.shared.events.MercuryEvent; -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class ChangeFrameVisibleEvent implements MercuryEvent { - private FrameVisibleState states; -} diff --git a/app-core/src/main/java/com/mercury/platform/shared/events/custom/UILoadedEvent.java b/app-core/src/main/java/com/mercury/platform/shared/events/custom/UILoadedEvent.java deleted file mode 100644 index 673b1128..00000000 --- a/app-core/src/main/java/com/mercury/platform/shared/events/custom/UILoadedEvent.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.mercury.platform.shared.events.custom; - -import com.mercury.platform.shared.events.MercuryEvent; - -public class UILoadedEvent implements MercuryEvent { -} diff --git a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java index 6c608107..3e3a903d 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java +++ b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java @@ -1,6 +1,7 @@ package com.mercury.platform.shared.store; import com.mercury.platform.core.misc.SoundType; +import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.entity.SoundDescriptor; import rx.subjects.PublishSubject; @@ -14,4 +15,6 @@ private static class MercuryStoreHolder { public final PublishSubject soundSubject = PublishSubject.create(); public final PublishSubject soundSettingsSubject = PublishSubject.create(); public final PublishSubject dndSubject = PublishSubject.create(); + public final PublishSubject frameVisibleSubject = PublishSubject.create(); + public final PublishSubject uiLoadedSubject = PublishSubject.create(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SupportPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SupportPanel.java index 0321bf38..0125c34b 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SupportPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SupportPanel.java @@ -52,7 +52,7 @@ public void mouseExited(MouseEvent e) { @Override public void mousePressed(MouseEvent e) { 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(); } @@ -102,7 +102,7 @@ public void mouseWheelMoved(MouseWheelEvent e) { getDonations().forEach(pair -> { JPanel item = componentsFactory.getTransparentPanel(new BorderLayout()); item.add(componentsFactory.getTextLabel(pair.name, FontStyle.REGULAR),BorderLayout.CENTER); - item.add(componentsFactory.getTextLabel(pair.value.intValue() + "$", FontStyle.REGULAR),BorderLayout.LINE_END); +// item.add(componentsFactory.getTextLabel(pair.value.intValue() + "$", FontStyle.REGULAR),BorderLayout.LINE_END); donationsList.add(item); }); @@ -111,13 +111,8 @@ public void mouseWheelMoved(MouseWheelEvent e) { } private List getDonations(){ List donations = new ArrayList<>(); - donations.add(new DonationPair("Anonymus",15d)); - donations.add(new DonationPair("Anonymus",10d)); - donations.add(new DonationPair("Anonymus",10d)); - donations.add(new DonationPair("Anonymus",10d)); - donations.add(new DonationPair("Anonymus",5d)); - donations.add(new DonationPair("Anonymus",5d)); - donations.add(new DonationPair("Anonymus",2d)); + donations.add(new DonationPair("StubenZocker",0d)); + donations.add(new DonationPair("x8 Anonymus",0d)); return donations; } 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 4e54cc5e..e51cb3f4 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 @@ -3,9 +3,7 @@ import com.mercury.platform.shared.ConfigManager; import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.HasEventHandlers; -import com.mercury.platform.shared.events.EventRouter; -import com.mercury.platform.shared.events.MercuryEventHandler; -import com.mercury.platform.shared.events.custom.ChangeFrameVisibleEvent; +import com.mercury.platform.shared.store.MercuryStore; import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.misc.AppThemeColor; @@ -42,37 +40,34 @@ public void mouseEntered(MouseEvent e) { } }); - EventRouter.CORE.registerHandler(ChangeFrameVisibleEvent.class, new MercuryEventHandler() { - @Override - public void handle(ChangeFrameVisibleEvent event) { - if(!SwingUtilities.isEventDispatchThread()) { - SwingUtilities.invokeLater(()-> changeVisible(event.getStates())); - }else { - changeVisible(event.getStates()); - } + MercuryStore.INSTANCE.frameVisibleSubject.subscribe(state -> { + if(!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeLater(()-> changeVisible(state)); + }else { + changeVisible(state); } - private void changeVisible(FrameVisibleState state){ - if (processingHideEvent) { - switch (state) { - case SHOW: { - if (prevState.equals(FrameVisibleState.SHOW)) { - showComponent(); - } - } - break; - case HIDE: { - if (AbstractOverlaidFrame.this.isVisible()) { - prevState = FrameVisibleState.SHOW; - }else { - prevState = FrameVisibleState.HIDE; - } - hideComponent(); - } - break; + }); + } + private void changeVisible(FrameVisibleState state){ + if (processingHideEvent) { + switch (state) { + case SHOW: { + if (prevState.equals(FrameVisibleState.SHOW)) { + showComponent(); } } + break; + case HIDE: { + if (AbstractOverlaidFrame.this.isVisible()) { + prevState = FrameVisibleState.SHOW; + }else { + prevState = FrameVisibleState.HIDE; + } + hideComponent(); + } + break; } - }); + } } public void init(){ this.layout = getFrameLayout(); 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 01c46571..5f7d99c8 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 @@ -7,8 +7,8 @@ import com.mercury.platform.shared.events.custom.ShowPatchNotesEvent; import com.mercury.platform.shared.events.custom.ShutDownForUpdateEvent; import com.mercury.platform.shared.events.custom.ShutdownApplication; -import com.mercury.platform.shared.events.custom.UILoadedEvent; import com.mercury.platform.shared.entity.FrameSettings; +import com.mercury.platform.shared.store.MercuryStore; import com.mercury.platform.ui.frame.AbstractComponentFrame; import com.mercury.platform.ui.frame.AbstractScalableComponentFrame; import com.mercury.platform.ui.frame.movable.ItemsGridFrame; @@ -106,7 +106,7 @@ public void start(){ } }); initHandlers(); - EventRouter.CORE.fireEvent(new UILoadedEvent()); + MercuryStore.INSTANCE.uiLoadedSubject.onNext(true); } @Override public void initHandlers() { diff --git a/app-ui/src/main/resources/app/paypal.png b/app-ui/src/main/resources/app/paypal.png index 4700ced8c066bb1c4f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2JWox_ tdV9L8JvE@Dd@65lsK92Wte6h-`yuP~m1DQ+plWeD=1;w6@b8rAzXAF@K*0b2 From 0d34dd6fd1121c83e0f86dc939039fe48faa8d6f Mon Sep 17 00:00:00 2001 From: Exslims Date: Fri, 14 Apr 2017 20:43:56 +0400 Subject: [PATCH 12/15] Another part to switch to another event system --- .../com/mercury/platform/core/ChatHelper.java | 18 +++------ .../platform/core/misc/SoundNotifier.java | 8 ++-- .../core/handlers/ResponseDispatcher.java | 1 - .../core/utils/MessageFileHandler.java | 9 +++-- .../core/utils/error/ErrorHandler.java | 5 +-- .../IncTradeMessagesInterceptor.java | 8 +--- .../platform/shared/ConfigManager.java | 2 +- .../events/custom/AddInterceptorEvent.java | 12 ------ .../events/custom/ChatCommandEvent.java | 11 ------ .../shared/events/custom/DndModeEvent.java | 11 ------ .../events/custom/HideLoadingFrame.java | 6 --- .../events/custom/NewWhispersEvent.java | 12 ------ .../shared/events/custom/OpenChatEvent.java | 11 ------ .../events/custom/RemoveInterceptorEvent.java | 12 ------ .../events/custom/SoundNotificationEvent.java | 39 ------------------- .../platform/shared/store/MercuryStore.java | 8 ++++ .../ui/components/ComponentsFactory.java | 1 - .../ui/components/ControlsFactory.java | 4 -- .../panel/chat/ChatFilterPanel.java | 1 - .../panel/chat/ChatMessagePanel.java | 7 ++-- .../panel/message/MessagePanel.java | 2 +- .../panel/message/MessagePanelBuilder.java | 6 +++ .../NotificationMessageController.java | 14 +++---- .../panel/settings/SoundSettingsPanel.java | 28 ++++++------- .../taskbar/MercuryTaskBarController.java | 9 ++--- .../movable/container/IncMessageFrame.java | 8 ++-- .../ui/frame/other/MercuryLoadingFrame.java | 8 ++-- .../ui/frame/other/OutMessageFrame.java | 6 +-- .../ui/frame/titled/TestCasesFrame.java | 10 +++-- .../ui/frame/titled/chat/ChatFilterFrame.java | 7 ++-- .../frame/titled/container/HistoryFrame.java | 28 ++++++------- .../java/com/mercury/platform/AppMain.java | 6 +-- 32 files changed, 91 insertions(+), 227 deletions(-) delete mode 100644 app-core/src/main/java/com/mercury/platform/shared/events/custom/AddInterceptorEvent.java delete mode 100644 app-core/src/main/java/com/mercury/platform/shared/events/custom/ChatCommandEvent.java delete mode 100644 app-core/src/main/java/com/mercury/platform/shared/events/custom/DndModeEvent.java delete mode 100644 app-core/src/main/java/com/mercury/platform/shared/events/custom/HideLoadingFrame.java delete mode 100644 app-core/src/main/java/com/mercury/platform/shared/events/custom/NewWhispersEvent.java delete mode 100644 app-core/src/main/java/com/mercury/platform/shared/events/custom/OpenChatEvent.java delete mode 100644 app-core/src/main/java/com/mercury/platform/shared/events/custom/RemoveInterceptorEvent.java delete mode 100644 app-core/src/main/java/com/mercury/platform/shared/events/custom/SoundNotificationEvent.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelBuilder.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 16b08cdb..362fbeb8 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 @@ -2,10 +2,7 @@ import com.mercury.platform.shared.ConfigManager; import com.mercury.platform.shared.HasEventHandlers; -import com.mercury.platform.shared.events.EventRouter; -import com.mercury.platform.shared.events.custom.ChatCommandEvent; -import com.mercury.platform.shared.events.custom.DndModeEvent; -import com.mercury.platform.shared.events.custom.OpenChatEvent; +import com.mercury.platform.shared.store.MercuryStore; import com.sun.jna.Native; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -105,16 +102,11 @@ private void gameToFront(){ @Override public void initHandlers() { - EventRouter.CORE.registerHandler(ChatCommandEvent.class, event - -> executeMessage(((ChatCommandEvent)event).getMessage())); - - EventRouter.CORE.registerHandler(OpenChatEvent.class, event -> { - openChat(((OpenChatEvent) event).getWhisper()); - }); - EventRouter.CORE.registerHandler(DndModeEvent.class, event -> { - boolean dnd = ((DndModeEvent) event).isDnd(); + MercuryStore.INSTANCE.chatCommandSubject.subscribe(this::executeMessage); + MercuryStore.INSTANCE.openChatSubject.subscribe(this::openChat); + MercuryStore.INSTANCE.dndSubject.subscribe(state -> { if(ConfigManager.INSTANCE.isInGameDnd()){ - if(dnd) { + if(state) { executeMessage("/dnd " + ConfigManager.INSTANCE.getDndResponseText()); }else { executeMessage("/dnd"); diff --git a/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java b/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java index e3e2b2d0..5bffeb13 100644 --- a/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java +++ b/app-core/src/main/java/com/mercury/platform/core/misc/SoundNotifier.java @@ -21,14 +21,12 @@ public SoundNotifier() { .subscribe(data -> play(data.getWavPath(), data.getDb())); MercuryStore.INSTANCE.soundSettingsSubject .subscribe(data -> play(data.getWavPath(), data.getDb())); - MercuryStore.INSTANCE.dndSubject.subscribe(value -> { - this.dnd = value; - }); - EventRouter.CORE.registerHandler(DndModeEvent.class, event -> this.dnd = ((DndModeEvent)event).isDnd()); + MercuryStore.INSTANCE.dndSubject + .subscribe(value -> this.dnd = value); } private void play(String wavPath, float db){ - if(!dnd) { + if(!dnd && db > -40) { ClassLoader classLoader = getClass().getClassLoader(); try (AudioInputStream stream = AudioSystem.getAudioInputStream(classLoader.getResource(wavPath))) { Clip clip = AudioSystem.getClip(); diff --git a/app-core/src/main/java/com/mercury/platform/core/update/core/handlers/ResponseDispatcher.java b/app-core/src/main/java/com/mercury/platform/core/update/core/handlers/ResponseDispatcher.java index ca2f0bf3..b355e1aa 100644 --- a/app-core/src/main/java/com/mercury/platform/core/update/core/handlers/ResponseDispatcher.java +++ b/app-core/src/main/java/com/mercury/platform/core/update/core/handlers/ResponseDispatcher.java @@ -5,7 +5,6 @@ import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.AlertEvent; import com.mercury.platform.shared.events.custom.ShowPatchNotesEvent; -import com.mercury.platform.shared.events.custom.SoundNotificationEvent; import com.mercury.platform.shared.events.custom.UpdateInfoEvent; import com.mercury.platform.shared.store.MercuryStore; import com.mercury.platform.update.AlreadyLatestUpdateMessage; 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 e701451f..94ea7119 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 @@ -4,6 +4,7 @@ import com.mercury.platform.shared.HasEventHandlers; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.*; +import com.mercury.platform.shared.store.MercuryStore; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -81,12 +82,12 @@ public void parse() { @Override public void initHandlers() { - EventRouter.CORE.registerHandler(AddInterceptorEvent.class, event -> { - interceptors.add(((AddInterceptorEvent) event).getInterceptor()); + MercuryStore.INSTANCE.addInterceptorSubject.subscribe(interceptor -> { + interceptors.add(interceptor); lastMessageDate = new Date(); }); - EventRouter.CORE.registerHandler(RemoveInterceptorEvent.class, event -> { - interceptors.remove(((RemoveInterceptorEvent) event).getInterceptor()); + MercuryStore.INSTANCE.removeInterceptorSubject.subscribe(interceptor -> { + interceptors.remove(interceptor); }); } } diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/error/ErrorHandler.java b/app-core/src/main/java/com/mercury/platform/core/utils/error/ErrorHandler.java index 3de7fef7..61a8d618 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/error/ErrorHandler.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/error/ErrorHandler.java @@ -1,7 +1,6 @@ package com.mercury.platform.core.utils.error; -import com.mercury.platform.shared.events.EventRouter; -import com.mercury.platform.shared.events.custom.HideLoadingFrame; +import com.mercury.platform.shared.store.MercuryStore; import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -10,7 +9,7 @@ public class ErrorHandler { private Logger logger = LogManager.getLogger(ErrorHandler.class.getSimpleName()); public ErrorHandler(){ Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> { - EventRouter.CORE.fireEvent(new HideLoadingFrame()); + MercuryStore.INSTANCE.appLoadingSubject.onNext(false); logger.error(ExceptionUtils.getStackTrace(throwable)); }); } diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/IncTradeMessagesInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/IncTradeMessagesInterceptor.java index 0fae9947..5944dff8 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/IncTradeMessagesInterceptor.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/IncTradeMessagesInterceptor.java @@ -3,16 +3,10 @@ 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.events.EventRouter; -import com.mercury.platform.shared.events.custom.NewWhispersEvent; -import com.mercury.platform.shared.events.custom.SoundNotificationEvent; import com.mercury.platform.shared.entity.Message; import com.mercury.platform.shared.store.MercuryStore; import org.apache.commons.lang3.StringUtils; -/** - * Created by Константин on 11.01.2017. - */ public class IncTradeMessagesInterceptor extends MessageInterceptor { private MessageParser messageParser = new MessageParser(); @@ -21,7 +15,7 @@ protected void process(String message) { Message parsedMessage = messageParser.parse(StringUtils.substringAfter(message,"@")); if(parsedMessage != null) { MercuryStore.INSTANCE.soundSubject.onNext(SoundType.MESSAGE); - EventRouter.CORE.fireEvent(new NewWhispersEvent(parsedMessage)); + MercuryStore.INSTANCE.messageSubject.onNext(parsedMessage); } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java b/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java index f7fe882c..56f242d0 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java +++ b/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java @@ -81,7 +81,7 @@ private static class ConfigManagerHolder { public ConfigManager() { minimumFrameSize = new HashMap<>(); minimumFrameSize.put("TaskBarFrame",new Dimension(109,20)); - minimumFrameSize.put("IncMessageFrame",new Dimension(315,10)); + minimumFrameSize.put("IncMessageFrame",new Dimension(360,10)); minimumFrameSize.put("OutMessageFrame",new Dimension(280,115)); minimumFrameSize.put("TestCasesFrame",new Dimension(400,100)); minimumFrameSize.put("SettingsFrame",new Dimension(540,400)); diff --git a/app-core/src/main/java/com/mercury/platform/shared/events/custom/AddInterceptorEvent.java b/app-core/src/main/java/com/mercury/platform/shared/events/custom/AddInterceptorEvent.java deleted file mode 100644 index e7ee6a93..00000000 --- a/app-core/src/main/java/com/mercury/platform/shared/events/custom/AddInterceptorEvent.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.mercury.platform.shared.events.custom; - -import com.mercury.platform.core.utils.interceptor.MessageInterceptor; -import com.mercury.platform.shared.events.MercuryEvent; -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class AddInterceptorEvent implements MercuryEvent { - private MessageInterceptor interceptor; -} diff --git a/app-core/src/main/java/com/mercury/platform/shared/events/custom/ChatCommandEvent.java b/app-core/src/main/java/com/mercury/platform/shared/events/custom/ChatCommandEvent.java deleted file mode 100644 index a660274e..00000000 --- a/app-core/src/main/java/com/mercury/platform/shared/events/custom/ChatCommandEvent.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.mercury.platform.shared.events.custom; - -import com.mercury.platform.shared.events.MercuryEvent; -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class ChatCommandEvent implements MercuryEvent { - private String message; -} diff --git a/app-core/src/main/java/com/mercury/platform/shared/events/custom/DndModeEvent.java b/app-core/src/main/java/com/mercury/platform/shared/events/custom/DndModeEvent.java deleted file mode 100644 index fdb2d665..00000000 --- a/app-core/src/main/java/com/mercury/platform/shared/events/custom/DndModeEvent.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.mercury.platform.shared.events.custom; - -import com.mercury.platform.shared.events.MercuryEvent; -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class DndModeEvent implements MercuryEvent { - private boolean dnd; -} diff --git a/app-core/src/main/java/com/mercury/platform/shared/events/custom/HideLoadingFrame.java b/app-core/src/main/java/com/mercury/platform/shared/events/custom/HideLoadingFrame.java deleted file mode 100644 index fbcad6b0..00000000 --- a/app-core/src/main/java/com/mercury/platform/shared/events/custom/HideLoadingFrame.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.mercury.platform.shared.events.custom; - -import com.mercury.platform.shared.events.MercuryEvent; - -public class HideLoadingFrame implements MercuryEvent { -} diff --git a/app-core/src/main/java/com/mercury/platform/shared/events/custom/NewWhispersEvent.java b/app-core/src/main/java/com/mercury/platform/shared/events/custom/NewWhispersEvent.java deleted file mode 100644 index 4570b331..00000000 --- a/app-core/src/main/java/com/mercury/platform/shared/events/custom/NewWhispersEvent.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.mercury.platform.shared.events.custom; - -import com.mercury.platform.shared.events.MercuryEvent; -import com.mercury.platform.shared.entity.Message; -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class NewWhispersEvent implements MercuryEvent { - private Message message; -} diff --git a/app-core/src/main/java/com/mercury/platform/shared/events/custom/OpenChatEvent.java b/app-core/src/main/java/com/mercury/platform/shared/events/custom/OpenChatEvent.java deleted file mode 100644 index 78b484d0..00000000 --- a/app-core/src/main/java/com/mercury/platform/shared/events/custom/OpenChatEvent.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.mercury.platform.shared.events.custom; - -import com.mercury.platform.shared.events.MercuryEvent; -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class OpenChatEvent implements MercuryEvent { - private String whisper; -} diff --git a/app-core/src/main/java/com/mercury/platform/shared/events/custom/RemoveInterceptorEvent.java b/app-core/src/main/java/com/mercury/platform/shared/events/custom/RemoveInterceptorEvent.java deleted file mode 100644 index de5b7c91..00000000 --- a/app-core/src/main/java/com/mercury/platform/shared/events/custom/RemoveInterceptorEvent.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.mercury.platform.shared.events.custom; - -import com.mercury.platform.core.utils.interceptor.MessageInterceptor; -import com.mercury.platform.shared.events.MercuryEvent; -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class RemoveInterceptorEvent implements MercuryEvent { - private MessageInterceptor interceptor; -} diff --git a/app-core/src/main/java/com/mercury/platform/shared/events/custom/SoundNotificationEvent.java b/app-core/src/main/java/com/mercury/platform/shared/events/custom/SoundNotificationEvent.java deleted file mode 100644 index eca514ef..00000000 --- a/app-core/src/main/java/com/mercury/platform/shared/events/custom/SoundNotificationEvent.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.mercury.platform.shared.events.custom; - -import com.mercury.platform.shared.events.MercuryEvent; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -@Data -@AllArgsConstructor -@NoArgsConstructor -public class SoundNotificationEvent implements MercuryEvent { - private Float db = 0f; - - @NoArgsConstructor - public static class WhisperSoundNotificationEvent extends SoundNotificationEvent { - public WhisperSoundNotificationEvent(Float db) { - super(db); - } - } - @NoArgsConstructor - public static class ChatScannerSoundNotificationEvent extends SoundNotificationEvent { - public ChatScannerSoundNotificationEvent(Float db) { - super(db); - } - } - @NoArgsConstructor - public static class ClicksSoundNotificationEvent extends SoundNotificationEvent { - public ClicksSoundNotificationEvent(Float db) { - super(db); - } - } - @NoArgsConstructor - public static class UpdateSoundNotificationEvent extends SoundNotificationEvent { - public UpdateSoundNotificationEvent(Float db) { - super(db); - } - } -} diff --git a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java index 3e3a903d..86917178 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java +++ b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStore.java @@ -1,7 +1,9 @@ package com.mercury.platform.shared.store; import com.mercury.platform.core.misc.SoundType; +import com.mercury.platform.core.utils.interceptor.MessageInterceptor; import com.mercury.platform.shared.FrameVisibleState; +import com.mercury.platform.shared.entity.Message; import com.mercury.platform.shared.entity.SoundDescriptor; import rx.subjects.PublishSubject; @@ -17,4 +19,10 @@ private static class MercuryStoreHolder { public final PublishSubject dndSubject = PublishSubject.create(); public final PublishSubject frameVisibleSubject = PublishSubject.create(); public final PublishSubject uiLoadedSubject = PublishSubject.create(); + public final PublishSubject addInterceptorSubject = PublishSubject.create(); + public final PublishSubject removeInterceptorSubject = PublishSubject.create(); + public final PublishSubject chatCommandSubject = PublishSubject.create(); + public final PublishSubject openChatSubject = PublishSubject.create(); + public final PublishSubject messageSubject = PublishSubject.create(); + public final PublishSubject appLoadingSubject = PublishSubject.create(); } 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 97bac01e..9c8aee14 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 @@ -3,7 +3,6 @@ import com.mercury.platform.core.misc.SoundType; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.events.custom.HideTooltipEvent; -import com.mercury.platform.shared.events.custom.SoundNotificationEvent; import com.mercury.platform.shared.store.MercuryStore; import com.mercury.platform.ui.misc.event.ShowTooltipEvent; import com.mercury.platform.ui.components.fields.style.MercuryComboBoxUI; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/ControlsFactory.java b/app-ui/src/main/java/com/mercury/platform/ui/components/ControlsFactory.java index 002371a8..6a5925c5 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/ControlsFactory.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/ControlsFactory.java @@ -1,15 +1,11 @@ package com.mercury.platform.ui.components; -import com.mercury.platform.shared.events.EventRouter; -import com.mercury.platform.shared.events.custom.ChatCommandEvent; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.TooltipConstants; import lombok.NonNull; import javax.swing.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; //todo generic for components constructor public class ControlsFactory { 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 ad490f0d..3b2ca3cc 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 @@ -2,7 +2,6 @@ import com.mercury.platform.core.misc.SoundType; import com.mercury.platform.shared.events.EventRouter; -import com.mercury.platform.shared.events.custom.SoundNotificationEvent; import com.mercury.platform.shared.store.MercuryStore; import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.fields.style.MercuryScrollBarUI; 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 52df271e..870c2f3d 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 @@ -1,8 +1,7 @@ package com.mercury.platform.ui.components.panel.chat; import com.mercury.platform.shared.events.EventRouter; -import com.mercury.platform.shared.events.custom.ChatCommandEvent; -import com.mercury.platform.shared.events.custom.OpenChatEvent; +import com.mercury.platform.shared.store.MercuryStore; 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; @@ -51,7 +50,7 @@ public void createUI() { @Override public void mousePressed(MouseEvent e) { if(SwingUtilities.isLeftMouseButton(e)) { - EventRouter.CORE.fireEvent(new ChatCommandEvent("/invite " + nickName)); + MercuryStore.INSTANCE.chatCommandSubject.onNext("/invite " + nickName); } } }); @@ -60,7 +59,7 @@ public void mousePressed(MouseEvent e) { @Override public void mousePressed(MouseEvent e) { if(SwingUtilities.isLeftMouseButton(e)) { - EventRouter.CORE.fireEvent(new OpenChatEvent(nickName)); + MercuryStore.INSTANCE.openChatSubject.onNext(nickName); } } }); 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 index 7cee0408..ecddff0d 100644 --- 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 @@ -236,7 +236,7 @@ private JPanel getCurrencyRatePanel(){ Double currForSaleCount = message.getCurrForSaleCount(); Double curCount = message.getCurCount(); double rate = curCount / currForSaleCount; - DecimalFormat decimalFormat = new DecimalFormat("#.##"); + 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,"(")); 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 new file mode 100644 index 00000000..0225fa0b --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelBuilder.java @@ -0,0 +1,6 @@ +package com.mercury.platform.ui.components.panel.message; + + +public class MessagePanelBuilder { + +} 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/message/NotificationMessageController.java index 80377135..2e41f0af 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/message/NotificationMessageController.java @@ -1,10 +1,9 @@ package com.mercury.platform.ui.components.panel.message; import com.mercury.platform.shared.events.EventRouter; -import com.mercury.platform.shared.events.custom.ChatCommandEvent; -import com.mercury.platform.shared.events.custom.OpenChatEvent; import com.mercury.platform.shared.entity.ItemMessage; import com.mercury.platform.shared.entity.Message; +import com.mercury.platform.shared.store.MercuryStore; import com.mercury.platform.ui.misc.event.*; import lombok.NonNull; import org.apache.logging.log4j.LogManager; @@ -25,30 +24,29 @@ public NotificationMessageController(Message message){ } @Override public void performInvite() { - EventRouter.CORE.fireEvent(new ChatCommandEvent("/invite " + message.getWhisperNickname())); + MercuryStore.INSTANCE.chatCommandSubject.onNext("/invite " + message.getWhisperNickname()); showITH(); } @Override public void performKick() { - EventRouter.CORE.fireEvent(new ChatCommandEvent("/kick " + message.getWhisperNickname())); + MercuryStore.INSTANCE.chatCommandSubject.onNext("/kick " + message.getWhisperNickname()); } @Override public void performOfferTrade() { - EventRouter.CORE.fireEvent(new ChatCommandEvent("/tradewith " + message.getWhisperNickname())); + MercuryStore.INSTANCE.chatCommandSubject.onNext("/tradewith " + message.getWhisperNickname()); } @Override public void performOpenChat() { - EventRouter.CORE.fireEvent(new OpenChatEvent(message.getWhisperNickname())); + MercuryStore.INSTANCE.openChatSubject.onNext(message.getWhisperNickname()); } @Override public void performResponse(@NonNull String responseText) { - - EventRouter.CORE.fireEvent(new ChatCommandEvent("@" + message.getWhisperNickname() + " " + responseText)); + MercuryStore.INSTANCE.chatCommandSubject.onNext("@" + message.getWhisperNickname() + " " + responseText); } @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java index 3e5ba675..ae553a7f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java @@ -59,8 +59,7 @@ private JPanel getVolumePanel(){ BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), BorderFactory.createEmptyBorder(3,0,3,0))); - notificationSlider = componentsFactory.getSlider(-40, 6, - map.get("notification").getDb().intValue() == -80? -40: map.get("notification").getDb().intValue()); + notificationSlider = componentsFactory.getSlider(-40, 6, map.get("notification").getDb().intValue()); notificationSlider.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { @@ -70,8 +69,7 @@ public void mouseReleased(MouseEvent e) { )); } }); - chatScannerSlider = componentsFactory.getSlider(-40, 6, - map.get("chat_scanner").getDb().intValue() == -80? -40: map.get("chat_scanner").getDb().intValue()); + chatScannerSlider = componentsFactory.getSlider(-40, 6, map.get("chat_scanner").getDb().intValue()); chatScannerSlider.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { @@ -81,8 +79,7 @@ public void mouseReleased(MouseEvent e) { )); } }); - clicksSlider = componentsFactory.getSlider(-40, 6, - map.get("clicks").getDb().intValue() == -80? -40: map.get("clicks").getDb().intValue()); + clicksSlider = componentsFactory.getSlider(-40, 6, map.get("clicks").getDb().intValue()); clicksSlider.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { @@ -92,8 +89,7 @@ public void mouseReleased(MouseEvent e) { )); } }); - updateSlider = componentsFactory.getSlider(-40, 6, - map.get("update").getDb().intValue() == -80? -40: map.get("update").getDb().intValue()); + updateSlider = componentsFactory.getSlider(-40, 6, map.get("update").getDb().intValue()); updateSlider.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { @@ -168,13 +164,13 @@ private JPanel getSoundPickerPanel(){ public boolean processAndSave() { Map map = Configuration.get().soundConfiguration().getMap(); map.get("notification") - .setDb(notificationSlider.getValue() == -40 ? -80f : (float)notificationSlider.getValue()); + .setDb((float)notificationSlider.getValue()); map.get("chat_scanner") - .setDb(chatScannerSlider.getValue() == -40 ? -80f : (float)chatScannerSlider.getValue()); + .setDb((float)chatScannerSlider.getValue()); map.get("clicks") - .setDb(clicksSlider.getValue() == -40 ? -80f : (float)clicksSlider.getValue()); + .setDb((float)clicksSlider.getValue()); map.get("update") - .setDb(updateSlider.getValue() == -40 ? -80f : (float)updateSlider.getValue()); + .setDb((float)updateSlider.getValue()); Configuration.get().soundConfiguration().save(); return true; } @@ -183,12 +179,12 @@ public boolean processAndSave() { public void restore() { Map map = Configuration.get().soundConfiguration().getMap(); notificationSlider.setValue( - map.get("notification").getDb().intValue() == -80? -40: map.get("notification").getDb().intValue()); + map.get("notification").getDb().intValue()); chatScannerSlider.setValue( - map.get("chat_scanner").getDb().intValue() == -80? -40: map.get("chat_scanner").getDb().intValue()); + map.get("chat_scanner").getDb().intValue()); clicksSlider.setValue( - map.get("clicks").getDb().intValue() == -80? -40: map.get("clicks").getDb().intValue()); + map.get("clicks").getDb().intValue()); updateSlider.setValue( - map.get("update").getDb().intValue() == -80? -40: map.get("update").getDb().intValue()); + map.get("update").getDb().intValue()); } } 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 0d6e7d96..0f0e1a86 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 @@ -1,9 +1,8 @@ package com.mercury.platform.ui.components.panel.taskbar; import com.mercury.platform.shared.events.EventRouter; -import com.mercury.platform.shared.events.custom.ChatCommandEvent; -import com.mercury.platform.shared.events.custom.DndModeEvent; import com.mercury.platform.shared.events.custom.NotificationEvent; +import com.mercury.platform.shared.store.MercuryStore; import com.mercury.platform.ui.frame.movable.ItemsGridFrame; import com.mercury.platform.ui.frame.titled.chat.ChatFilterFrame; import com.mercury.platform.ui.frame.titled.container.HistoryFrame; @@ -16,14 +15,14 @@ public class MercuryTaskBarController implements TaskBarController { public void enableDND() { EventRouter.UI.fireEvent(new RepaintEvent.RepaintTaskBar()); EventRouter.UI.fireEvent(new NotificationEvent("DND on")); - EventRouter.CORE.fireEvent(new DndModeEvent(true)); + MercuryStore.INSTANCE.dndSubject.onNext(true); } @Override public void disableDND() { EventRouter.UI.fireEvent(new RepaintEvent.RepaintTaskBar()); EventRouter.UI.fireEvent(new NotificationEvent("DND off")); - EventRouter.CORE.fireEvent(new DndModeEvent(false)); + MercuryStore.INSTANCE.dndSubject.onNext(false); } @Override @@ -33,7 +32,7 @@ public void showITH() { @Override public void performHideout() { - EventRouter.CORE.fireEvent(new ChatCommandEvent("/hideout")); + MercuryStore.INSTANCE.chatCommandSubject.onNext("/hideout"); } @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/IncMessageFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/IncMessageFrame.java index 2de258be..699a3090 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/IncMessageFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/IncMessageFrame.java @@ -7,6 +7,7 @@ import com.mercury.platform.shared.events.custom.*; import com.mercury.platform.shared.entity.ItemMessage; import com.mercury.platform.shared.entity.Message; +import com.mercury.platform.shared.store.MercuryStore; 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; @@ -94,8 +95,8 @@ protected LayoutManager getFrameLayout() { @Override public void initHandlers() { - EventRouter.CORE.registerHandler(DndModeEvent.class, event -> { - this.dnd = ((DndModeEvent)event).isDnd(); + MercuryStore.INSTANCE.dndSubject.subscribe(state -> { + this.dnd = state; if(dnd){ this.setVisible(false); expandAllFrame.setVisible(false); @@ -109,9 +110,8 @@ public void initHandlers() { setUpExpandButton(); } }); - EventRouter.CORE.registerHandler(NewWhispersEvent.class, event -> { + MercuryStore.INSTANCE.messageSubject.subscribe(message -> { SwingUtilities.invokeLater(()-> { - Message message = ((NewWhispersEvent) event).getMessage(); if(!currentMessages.containsKey(message)) { addMessage(message); } 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 f0581441..4ea20539 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 @@ -1,7 +1,6 @@ package com.mercury.platform.ui.frame.other; -import com.mercury.platform.shared.events.EventRouter; -import com.mercury.platform.shared.events.custom.HideLoadingFrame; +import com.mercury.platform.shared.store.MercuryStore; import com.mercury.platform.ui.frame.AbstractOverlaidFrame; import com.mercury.platform.ui.misc.AppThemeColor; import org.pushingpixels.trident.Timeline; @@ -52,9 +51,8 @@ public void onTimelinePulse(float durationFraction, float timelinePosition) { @Override public void initHandlers() { - EventRouter.CORE.registerHandler(HideLoadingFrame.class, e-> { - hideAnimation.play(); - }); + MercuryStore.INSTANCE.appLoadingSubject + .subscribe(state -> hideAnimation.play()); } @Override 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 index 026e3586..22e4573a 100644 --- 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 @@ -3,11 +3,11 @@ import com.mercury.platform.core.AppStarter; import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.events.EventRouter; -import com.mercury.platform.shared.events.custom.ChatCommandEvent; import com.mercury.platform.shared.events.custom.OutTradeMessageEvent; import com.mercury.platform.shared.entity.CurrencyMessage; import com.mercury.platform.shared.entity.ItemMessage; import com.mercury.platform.shared.entity.Message; +import com.mercury.platform.shared.store.MercuryStore; 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; @@ -66,7 +66,7 @@ public void mouseDragged(MouseEvent e) { hoIn.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { - EventRouter.CORE.fireEvent(new ChatCommandEvent("/hideout " + message.getWhisperNickname())); + MercuryStore.INSTANCE.chatCommandSubject.onNext("/hideout " + message.getWhisperNickname()); } }); miscPanel.add(hoIn); @@ -74,7 +74,7 @@ public void mousePressed(MouseEvent e) { hoOut.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { - EventRouter.CORE.fireEvent(new ChatCommandEvent("/hideout")); + MercuryStore.INSTANCE.chatCommandSubject.onNext("/hideout"); } }); miscPanel.add(hoOut); 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 80dbf0a9..f2d9389e 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,9 +1,11 @@ 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.events.EventRouter; import com.mercury.platform.shared.events.custom.*; import com.mercury.platform.shared.entity.Message; +import com.mercury.platform.shared.store.MercuryStore; import com.mercury.platform.ui.misc.AppThemeColor; import javax.swing.*; @@ -176,7 +178,7 @@ public void mousePressed(MouseEvent e) { random.nextInt(12) + 1, offer.get(random.nextInt(offer.size())) )); - EventRouter.CORE.fireEvent(new NewWhispersEvent(message)); + MercuryStore.INSTANCE.messageSubject.onNext(message); } }); testPanel.add(button,buttonColumn); @@ -198,7 +200,7 @@ public void mousePressed(MouseEvent e) { leagues.get(random.nextInt(leagues.size())), offer.get(random.nextInt(offer.size())) )); - EventRouter.CORE.fireEvent(new NewWhispersEvent(message)); + MercuryStore.INSTANCE.messageSubject.onNext(message); } }); testPanel.add(button1,buttonColumn); @@ -213,7 +215,6 @@ public void mousePressed(MouseEvent e) { button2.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { - EventRouter.CORE.fireEvent(new SoundNotificationEvent.WhisperSoundNotificationEvent()); String nickname = nickNames.get(random.nextInt(nickNames.size())); Message message = parser.parse(String.format(currencyTemplate, nickname, @@ -224,7 +225,8 @@ public void mousePressed(MouseEvent e) { leagues.get(random.nextInt(leagues.size())), offer.get(random.nextInt(offer.size())) )); - EventRouter.CORE.fireEvent(new NewWhispersEvent(message)); + MercuryStore.INSTANCE.messageSubject.onNext(message); + MercuryStore.INSTANCE.soundSubject.onNext(SoundType.MESSAGE); Timer joinedTimer = new Timer(1000,null); joinedTimer.addActionListener(e1 -> { 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 f3d4daf0..e1907159 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 @@ -3,9 +3,8 @@ import com.mercury.platform.core.utils.interceptor.MessageInterceptor; import com.mercury.platform.core.utils.interceptor.filter.MessageFilter; import com.mercury.platform.shared.events.EventRouter; -import com.mercury.platform.shared.events.custom.AddInterceptorEvent; -import com.mercury.platform.shared.events.custom.RemoveInterceptorEvent; import com.mercury.platform.shared.entity.FrameSettings; +import com.mercury.platform.shared.store.MercuryStore; import com.mercury.platform.ui.components.panel.chat.ChatFilterPanel; import com.mercury.platform.ui.frame.titled.AbstractTitledComponentFrame; import com.mercury.platform.ui.misc.AppThemeColor; @@ -71,7 +70,7 @@ private void performNewStrings(String[] strings){ msgContainer.setNewChunks(Arrays.asList(strings)); if (interceptor != null) { - EventRouter.CORE.fireEvent(new RemoveInterceptorEvent(interceptor)); + MercuryStore.INSTANCE.removeInterceptorSubject.onNext(interceptor); } interceptor = new MessageInterceptor() { @Override @@ -97,7 +96,7 @@ protected MessageFilter getFilter() { }; } }; - EventRouter.CORE.fireEvent(new AddInterceptorEvent(interceptor)); + MercuryStore.INSTANCE.addInterceptorSubject.onNext(interceptor); } @Override 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 6b0f2bd5..aa9e2d5c 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,10 +4,9 @@ import com.mercury.platform.shared.HistoryManager; import com.mercury.platform.shared.MessageParser; import com.mercury.platform.shared.events.EventRouter; -import com.mercury.platform.shared.events.MercuryEvent; -import com.mercury.platform.shared.events.custom.NewWhispersEvent; import com.mercury.platform.shared.entity.FrameSettings; import com.mercury.platform.shared.entity.Message; +import com.mercury.platform.shared.store.MercuryStore; import com.mercury.platform.ui.components.fields.style.MercuryScrollBarUI; import com.mercury.platform.ui.components.panel.message.MessagePanel; import com.mercury.platform.ui.components.panel.VerticalScrollContainer; @@ -126,20 +125,17 @@ protected String getFrameTitle() { @Override public void initHandlers() { - EventRouter.CORE.registerHandler(NewWhispersEvent.class, (MercuryEvent event) -> { - SwingUtilities.invokeLater(()-> { - Message message = ((NewWhispersEvent) event).getMessage(); - HistoryManager.INSTANCE.add(message); - MessagePanel messagePanel = new MessagePanel( - message, - MessagePanelStyle.HISTORY, - new NotificationMessageController(message), - this.componentsFactory); - mainContainer.add(messagePanel); - trimContainer(); - this.pack(); - }); - }); + MercuryStore.INSTANCE.messageSubject.subscribe(message -> SwingUtilities.invokeLater(()-> { + HistoryManager.INSTANCE.add(message); + MessagePanel messagePanel = new MessagePanel( + message, + MessagePanelStyle.HISTORY, + new NotificationMessageController(message), + this.componentsFactory); + mainContainer.add(messagePanel); + trimContainer(); + this.pack(); + })); EventRouter.UI.registerHandler(ReloadMessageEvent.class,event -> { onReloadMessage(((ReloadMessageEvent)event).getPanel()); }); diff --git a/app/src/main/java/com/mercury/platform/AppMain.java b/app/src/main/java/com/mercury/platform/AppMain.java index ca9a7c77..a59db3b2 100644 --- a/app/src/main/java/com/mercury/platform/AppMain.java +++ b/app/src/main/java/com/mercury/platform/AppMain.java @@ -4,7 +4,7 @@ import com.mercury.platform.core.utils.FileMonitor; import com.mercury.platform.shared.ConfigManager; import com.mercury.platform.shared.events.EventRouter; -import com.mercury.platform.shared.events.custom.HideLoadingFrame; +import com.mercury.platform.shared.store.MercuryStore; import com.mercury.platform.ui.frame.other.MercuryLoadingFrame; import com.mercury.platform.ui.frame.titled.GamePathChooser; import com.mercury.platform.ui.manager.FramesManager; @@ -20,13 +20,13 @@ public static void main(String[] args) { new AppStarter().startApplication(); String gamePath = ConfigManager.INSTANCE.getGamePath(); if(gamePath.equals("") || !ConfigManager.INSTANCE.isValidGamePath(gamePath)){ - EventRouter.CORE.fireEvent(new HideLoadingFrame()); + MercuryStore.INSTANCE.appLoadingSubject.onNext(false); GamePathChooser gamePathChooser = new GamePathChooser(); gamePathChooser.init(); }else{ new FileMonitor().start(); FramesManager.INSTANCE.start(); - EventRouter.CORE.fireEvent(new HideLoadingFrame()); + MercuryStore.INSTANCE.appLoadingSubject.onNext(false); } } } \ No newline at end of file From d93f2b11c1aa9c1e1ce3f6120cfc378d21dc29b1 Mon Sep 17 00:00:00 2001 From: Exslims Date: Sat, 15 Apr 2017 11:14:16 +0400 Subject: [PATCH 13/15] Fixed an issue when mercury randomly disappear --- .../com/mercury/platform/core/AppStarter.java | 11 +++-- .../com/mercury/platform/core/ChatHelper.java | 32 -------------- .../com/mercury/platform/core/User32.java | 1 + .../test/java/com/mercury/platform/Test.java | 43 +++++++++++++++++++ 4 files changed, 51 insertions(+), 36 deletions(-) create mode 100644 app-ui/src/test/java/com/mercury/platform/Test.java diff --git a/app-core/src/main/java/com/mercury/platform/core/AppStarter.java b/app-core/src/main/java/com/mercury/platform/core/AppStarter.java index 4bbbb8c9..f9cb631b 100644 --- a/app-core/src/main/java/com/mercury/platform/core/AppStarter.java +++ b/app-core/src/main/java/com/mercury/platform/core/AppStarter.java @@ -15,6 +15,7 @@ import com.mercury.platform.shared.store.MercuryStore; import com.sun.jna.Native; import com.sun.jna.PointerType; +import com.sun.jna.platform.win32.WinDef; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -26,6 +27,7 @@ public class AppStarter { private static final Logger logger = LogManager.getLogger(AppStarter.class.getSimpleName()); public static FrameVisibleState APP_STATUS = FrameVisibleState.HIDE; + public static WinDef.HWND poeWindow; private User32 user32 = User32.INSTANCE; private boolean shutdown = false; private volatile int delay = 100; @@ -60,15 +62,16 @@ public void run() { } System.exit(0); } - byte[] windowText = new byte[512]; - PointerType hwnd = user32.GetForegroundWindow(); - User32.INSTANCE.GetWindowTextA(hwnd, windowText, 512); - if(!Native.toString(windowText).equals("Path of Exile")){ + byte[] className = new byte[512]; + WinDef.HWND hwnd = user32.GetForegroundWindow(); + User32.INSTANCE.GetClassNameA(hwnd, className, 512); + if(!Native.toString(className).equals("POEWindowClass")){ if(APP_STATUS == FrameVisibleState.SHOW) { APP_STATUS = FrameVisibleState.HIDE; MercuryStore.INSTANCE.frameVisibleSubject.onNext(FrameVisibleState.HIDE); } }else{ + poeWindow = hwnd; if(APP_STATUS == FrameVisibleState.HIDE) { try { Thread.sleep(delay); 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 362fbeb8..345a614d 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 @@ -3,20 +3,13 @@ import com.mercury.platform.shared.ConfigManager; import com.mercury.platform.shared.HasEventHandlers; import com.mercury.platform.shared.store.MercuryStore; -import com.sun.jna.Native; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import java.awt.*; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.StringSelection; import java.awt.event.KeyEvent; -import java.util.*; -import java.util.List; public class ChatHelper implements HasEventHandlers { - private final Logger logger = LogManager.getLogger(ChatHelper.class.getSimpleName()); - private User32 user32 = User32.INSTANCE; private Robot robot; public ChatHelper() { @@ -33,8 +26,6 @@ private void executeMessage(String message) { Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(selection, null); - gameToFront(); - robot.keyPress(KeyEvent.VK_ENTER); robot.keyRelease(KeyEvent.VK_ENTER); @@ -54,8 +45,6 @@ private void executeMessage(String message) { robot.keyRelease(KeyEvent.VK_ENTER); } private void openChat(String whisper) { - gameToFront(); - StringSelection selection = new StringSelection("@" + whisper); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(selection, selection); @@ -78,27 +67,6 @@ private void openChat(String whisper) { robot.keyPress(KeyEvent.VK_SPACE); robot.keyRelease(KeyEvent.VK_SPACE); } - /** - * NEED REFACTORING - */ - private void gameToFront(){ - List titles = new ArrayList<>(); - titles.add("Path of Exile"); - user32.EnumWindows((hWnd, arg1) -> { - byte[] windowText = new byte[512]; - user32.GetWindowTextA(hWnd, windowText, 512); - String wText = Native.toString(windowText); - - if (wText.isEmpty()) { - return true; - } - if (titles.contains(wText)) { - user32.SetForegroundWindow(hWnd); - return false; - } - return true; - }, null); - } @Override public void initHandlers() { diff --git a/app-core/src/main/java/com/mercury/platform/core/User32.java b/app-core/src/main/java/com/mercury/platform/core/User32.java index 9805511f..f7219e01 100644 --- a/app-core/src/main/java/com/mercury/platform/core/User32.java +++ b/app-core/src/main/java/com/mercury/platform/core/User32.java @@ -14,6 +14,7 @@ public interface User32 extends StdCallLibrary { User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class); boolean EnumWindows(WinUser.WNDENUMPROC lpEnumFunc, Pointer arg); + int GetClassNameA(WinDef.HWND hwnd, byte[] lpString,int nMaxCount); WinDef.HWND SetFocus(WinDef.HWND hWnd); int GetWindowTextA(WinDef.HWND hWnd, byte[] lpString, int nMaxCount); int GetWindowTextA(PointerType hWnd, byte[] lpString, int nMaxCount); diff --git a/app-ui/src/test/java/com/mercury/platform/Test.java b/app-ui/src/test/java/com/mercury/platform/Test.java new file mode 100644 index 00000000..212316e1 --- /dev/null +++ b/app-ui/src/test/java/com/mercury/platform/Test.java @@ -0,0 +1,43 @@ +package com.mercury.platform; + +import com.sun.jna.Native; +import com.sun.jna.Pointer; +import com.sun.jna.platform.win32.WinDef; +import com.sun.jna.platform.win32.WinUser; +import com.sun.jna.win32.StdCallLibrary; + +/** + * Created by Константин on 15.04.2017. + */ +public class Test { + public static void main(String[] args) { + final User32 user32 = User32.INSTANCE; + user32.EnumWindows(new WinUser.WNDENUMPROC() { + int count = 0; + @Override + public boolean callback(WinDef.HWND hwnd, Pointer pointer) { + byte[] windowText = new byte[512]; + byte[] className = new byte[512]; + user32.GetWindowTextA(hwnd, windowText, 512); + user32.GetClassNameA(hwnd, className, 512); + String title = Native.toString(windowText); + String classN = Native.toString(className); + + // get rid of this if block if you want all windows regardless of whether + // or not they have text + if (title.isEmpty()) { + return true; + } + + System.out.println("Title: " + title + " Class name: " + classN); + return true; + } + },null); + } + public interface User32 extends StdCallLibrary { + User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class); + boolean EnumWindows(WinUser.WNDENUMPROC lpEnumFunc, Pointer arg); + int GetWindowTextA(WinDef.HWND hWnd, byte[] lpString, int nMaxCount); + int GetClassNameA(WinDef.HWND hwnd, byte[] lpString,int nMaxCount); + } +} From cec2da68587854a26d0ecc77f01a1ec15c529d38 Mon Sep 17 00:00:00 2001 From: Exslims Date: Sat, 15 Apr 2017 14:39:24 +0400 Subject: [PATCH 14/15] Fixed expand all frame --- .../platform/shared/ConfigManager.java | 2 +- .../panel/settings/GeneralSettings.java | 2 +- .../ui/frame/AbstractOverlaidFrame.java | 2 +- .../movable/container/IncMessageFrame.java | 33 ++++++++++++------- .../ui/frame/titled/TestCasesFrame.java | 3 +- 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java b/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java index 56f242d0..924618cd 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java +++ b/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java @@ -68,7 +68,7 @@ private static class ConfigManagerHolder { @Getter private boolean checkUpdateOnStartUp = true; @Getter - private boolean dismissAfterKick = false; + private boolean dismissAfterKick = true; @Getter private boolean showLeague = false; @Getter diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/GeneralSettings.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/GeneralSettings.java index 6584553f..ecc2ebe8 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/GeneralSettings.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/GeneralSettings.java @@ -211,7 +211,7 @@ private JPanel getSettingsSlidePanel(){ componentsFactory.getIconButton("app/open-tests.png", 30, AppThemeColor.TRANSPARENT, - "Test frames"); + "Open tests"); openTests.addActionListener(action -> { FramesManager.INSTANCE.hideFrame(SettingsFrame.class); FramesManager.INSTANCE.preShowFrame(TestCasesFrame.class); 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 e51cb3f4..450078b6 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 @@ -48,7 +48,7 @@ public void mouseEntered(MouseEvent e) { } }); } - private void changeVisible(FrameVisibleState state){ + protected void changeVisible(FrameVisibleState state){ if (processingHideEvent) { switch (state) { case SHOW: { diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/IncMessageFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/IncMessageFrame.java index 699a3090..77e870c5 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/IncMessageFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/IncMessageFrame.java @@ -110,13 +110,11 @@ public void initHandlers() { setUpExpandButton(); } }); - MercuryStore.INSTANCE.messageSubject.subscribe(message -> { - SwingUtilities.invokeLater(()-> { - if(!currentMessages.containsKey(message)) { - addMessage(message); - } - }); - }); + MercuryStore.INSTANCE.messageSubject.subscribe(message -> SwingUtilities.invokeLater(()-> { + if(!currentMessages.containsKey(message)) { + addMessage(message); + } + })); EventRouter.UI.registerHandler(CloseMessagePanelEvent.class, event -> { Message message = ((CloseMessagePanelEvent) event).getMessage(); MessagePanel panel = currentMessages.get(message); @@ -197,7 +195,9 @@ private void addMessage(Message message){ messagePanel.setVisible(false); } if (mainContainer.getComponentCount() > limitMsgCount) { - setUpExpandButton(); + if(AppStarter.APP_STATUS == FrameVisibleState.SHOW) { + setUpExpandButton(); + } expandAllFrame.incMessageCount(); } break; @@ -207,7 +207,9 @@ private void addMessage(Message message){ messagePanel.setVisible(false); } if (mainContainer.getComponentCount() > (limitMsgCount + 1)) { - setUpExpandButton(); + if(AppStarter.APP_STATUS == FrameVisibleState.SHOW) { + setUpExpandButton(); + } expandAllFrame.incMessageCount(); } break; @@ -215,6 +217,14 @@ private void addMessage(Message message){ } } + @Override + protected void changeVisible(FrameVisibleState state) { + super.changeVisible(state); + if(state.equals(FrameVisibleState.SHOW)) { + setUpExpandButton(); + } + } + private void setUpExpandButton(){ if(!inScaleSettings && !inMoveMode && !dnd) { switch (flowDirections) { @@ -318,9 +328,8 @@ protected JPanel getPanelForPINSettings() { private void onLimitCountChange(){ expandAllFrame.resetMessageCount(); - Arrays.stream(mainContainer.getComponents()).forEach(component -> { - component.setVisible(true); - }); + Arrays.stream(mainContainer.getComponents()) + .forEach(component -> component.setVisible(true)); switch (flowDirections){ case DOWNWARDS:{ Component[] components = mainContainer.getComponents(); 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 f2d9389e..dda8a82e 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 @@ -11,6 +11,8 @@ import javax.swing.*; import javax.swing.Timer; import java.awt.*; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.*; @@ -32,7 +34,6 @@ public TestCasesFrame() { nickNames = new ArrayList<>(); offer = new ArrayList<>(); leagues = new ArrayList<>(); - items.add("Wondertrap Velvet Slippers"); items.add("Rain of Arrows"); items.add("Dreadarc Cleaver"); From 9b8d7a5e2ba223a8a0ab04b0e3fef0abef26adcb Mon Sep 17 00:00:00 2001 From: Exslims Date: Sat, 15 Apr 2017 20:57:44 +0400 Subject: [PATCH 15/15] Chat scanner improvements --- .../platform/core/MercuryConstants.java | 2 +- .../platform/shared/ConfigManager.java | 11 ++- .../platform/shared/UpdateManager.java | 4 +- .../ui/components/ComponentsFactory.java | 3 +- .../panel/chat/ChatMessagePanel.java | 12 +-- .../panel/chat/HtmlMessageBuilder.java | 3 +- .../panel/settings/SoundSettingsPanel.java | 66 +++++++-------- .../panel/settings/SupportPanel.java | 2 +- .../ui/frame/other/SetUpLocationFrame.java | 2 +- .../platform/ui/frame/other/TooltipFrame.java | 2 +- .../titled/AbstractTitledComponentFrame.java | 8 +- .../platform/ui/frame/titled/NotesFrame.java | 2 +- .../ui/frame/titled/chat/ChatFilterFrame.java | 76 +++++++++++++++++- .../titled/chat/ChatFilterSettingsFrame.java | 32 +++++++- .../resources/app/chat_scanner_response.png | Bin 0 -> 1052 bytes app-ui/src/main/resources/app/menu.png | Bin 0 -> 255 bytes app-ui/src/main/resources/app/minimize.png | Bin 0 -> 5133 bytes app-ui/src/main/resources/app/openChat.png | Bin 798 -> 828 bytes 18 files changed, 163 insertions(+), 62 deletions(-) create mode 100644 app-ui/src/main/resources/app/chat_scanner_response.png create mode 100644 app-ui/src/main/resources/app/menu.png create mode 100644 app-ui/src/main/resources/app/minimize.png 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 e6522f55..93e1aa94 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.2"; + public static final String APP_VERSION = "1.0.1.3"; 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/ConfigManager.java b/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java index 924618cd..36444741 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java +++ b/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java @@ -77,6 +77,8 @@ private static class ConfigManagerHolder { private String dndResponseText = "Response text"; @Getter private String defaultWords = "!wtb, uber, boss, perandus"; + @Getter + private String quickResponse = "invite me pls"; public ConfigManager() { minimumFrameSize = new HashMap<>(); @@ -87,7 +89,7 @@ public ConfigManager() { minimumFrameSize.put("SettingsFrame",new Dimension(540,400)); minimumFrameSize.put("HistoryFrame",new Dimension(280,400)); minimumFrameSize.put("TimerFrame",new Dimension(240,102)); - minimumFrameSize.put("ChatFilterFrame",new Dimension(400,200)); + minimumFrameSize.put("ChatFilterFrame",new Dimension(400,100)); minimumFrameSize.put("ItemsGridFrame",new Dimension(150,150)); minimumFrameSize.put("NotesFrame",new Dimension(540,100)); minimumFrameSize.put("ChatFilterSettingsFrame",new Dimension(300,200)); @@ -113,6 +115,7 @@ public ConfigManager() { defaultAppSettings.put("showLeague",false); defaultAppSettings.put("dndResponseText","Response text"); defaultAppSettings.put("defaultWords","!wtb, uber, boss, perandus"); + defaultAppSettings.put("quickResponse","invite me pls"); } @@ -157,6 +160,7 @@ public void load() { saveProperty("inGameDnd", String.valueOf(defaultAppSettings.get("inGameDnd"))); saveProperty("dndResponseText", defaultAppSettings.get("dndResponseText")); saveProperty("defaultWords", defaultAppSettings.get("defaultWords")); + saveProperty("quickResponse", defaultAppSettings.get("quickResponse")); saveProperty("scaleData", defaultAppSettings.get("scaleData")); saveProperty("showLeague", String.valueOf(defaultAppSettings.get("showLeague"))); @@ -218,6 +222,7 @@ private void loadConfigFile(){ showLeague = Boolean.valueOf(loadProperty("showLeague")); dndResponseText = loadProperty("dndResponseText"); defaultWords = loadProperty("defaultWords"); + quickResponse = loadProperty("quickResponse"); } catch (Exception e) { logger.error("Error in loadConfigFile: ",e); } @@ -465,6 +470,10 @@ public void setDefaultWords(String defaultWords) { this.defaultWords = defaultWords; saveProperty("defaultWords",defaultWords); } + public void setQuickResponse(String quickResponse) { + this.quickResponse = quickResponse; + saveProperty("quickResponse",quickResponse); + } private List getDefaultButtons(){ List defaultButtons = new ArrayList<>(); diff --git a/app-core/src/main/java/com/mercury/platform/shared/UpdateManager.java b/app-core/src/main/java/com/mercury/platform/shared/UpdateManager.java index 4cc6f42c..c06d0100 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/UpdateManager.java +++ b/app-core/src/main/java/com/mercury/platform/shared/UpdateManager.java @@ -6,9 +6,6 @@ import java.io.File; -/** - * Created by Константин on 21.02.2017. - */ public class UpdateManager { private final static Logger logger = LogManager.getLogger(UpdateManager.class.getSimpleName()); private final static String LOCAL_UPDATER_PATH = System.getenv("USERPROFILE") + "\\AppData\\Local\\MercuryTrade\\local-updater.jar"; @@ -19,6 +16,7 @@ public void doUpdate(){ logger.debug("Execute local updater, source path: {}",path); if(new File(JAR_FILE_PATH).exists()) { Runtime.getRuntime().exec("java -jar " + LOCAL_UPDATER_PATH + " " + "\"" + path + "\""); + System.exit(0); } } catch (Exception e1) { logger.error("Error while execute local-updater: ", e1); 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 9c8aee14..c10ea946 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 @@ -376,6 +376,7 @@ public JTextField getTextField(String text, FontStyle style, float fontSize){ textField.setFont(getSelectedFont(style).deriveFont(scale*fontSize)); } textField.setForeground(AppThemeColor.TEXT_DEFAULT); + textField.setCaretColor(AppThemeColor.TEXT_DEFAULT); textField.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(AppThemeColor.TEXT_DEFAULT,1), BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,3) @@ -541,7 +542,7 @@ public ImageIcon getImage(String iconPath){ public Dimension convertSize(Dimension initialSize){ return new Dimension((int)(initialSize.width * scale),(int)(initialSize.height*scale)); } - public JTextArea getSimpleTextAre(String text){ + public JTextArea getSimpleTextArea(String text){ JTextArea area = new JTextArea(text); area.setEditable(false); area.setWrapStyleWord(true); 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 870c2f3d..a180d948 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 @@ -1,6 +1,6 @@ package com.mercury.platform.ui.components.panel.chat; -import com.mercury.platform.shared.events.EventRouter; +import com.mercury.platform.shared.ConfigManager; import com.mercury.platform.shared.store.MercuryStore; import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.fields.font.FontStyle; @@ -45,12 +45,12 @@ public void createUI() { JPanel miscPanel = componentsFactory.getTransparentPanel(new BorderLayout()); JPanel operationsPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); - JButton invite = componentsFactory.getIconButton("app/invite.png", 16, AppThemeColor.SLIDE_BG, TooltipConstants.INVITE); - invite.addMouseListener(new MouseAdapter() { + JButton quickResponse = componentsFactory.getIconButton("app/chat_scanner_response.png", 17, AppThemeColor.SLIDE_BG, "Quick response"); + quickResponse.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if(SwingUtilities.isLeftMouseButton(e)) { - MercuryStore.INSTANCE.chatCommandSubject.onNext("/invite " + nickName); + MercuryStore.INSTANCE.chatCommandSubject.onNext("@" + nickName + " " + ConfigManager.INSTANCE.getQuickResponse()); } } }); @@ -73,9 +73,9 @@ public void mousePressed(MouseEvent e) { nickName); nicknameLabel.setPreferredSize(new Dimension(75,nicknameLabel.getPreferredSize().height)); nicknameLabel.setBorder(null); - invite.setBorder(null); + quickResponse.setBorder(null); openChat.setBorder(null); - operationsPanel.add(invite); + operationsPanel.add(quickResponse); operationsPanel.add(openChat); JPanel nicknamePanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); 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 defe315c..2ab32b73 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 @@ -17,11 +17,10 @@ public HtmlMessageBuilder() { * @param message source message * @return html equivalent */ - //RED - Navy public String build(String message) { List resultStrs = new ArrayList<>(); resultStrs.add(""); - String[] words = message.split("((?<= )|(?= )|(?<=\\.)|(?=\\.)|(?<=,)|(?<=\\?)|(?=\\?)|(?=,)|(?<=!)|(?=!)|(?<=/)|(?=/)|(?<=>)|(?=>))"); + String[] words = message.split("((?<=\\s)|(?=\\s)|(?<=\\.)|(?=\\.)|(?<=,)|(?<=\\?)|(?=\\?)|(?=,)|(?<=!)|(?=!)|(?<=/)|(?=/)|(?<=>)|(?=>))"); Arrays.stream(words).forEach(word -> { if(chunkStrings.stream().noneMatch(word::equalsIgnoreCase)){ resultStrs.add(word); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java index ae553a7f..005d5682 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java @@ -116,45 +116,45 @@ public void mouseReleased(MouseEvent e) { private JPanel getSoundPickerPanel(){ JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); - JLabel soundLabel = componentsFactory.getTextLabel(FontStyle.REGULAR, AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP, 17f, "Sound"); + JLabel soundLabel = componentsFactory.getTextLabel(FontStyle.REGULAR, AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP, 17f, "Sound (in next update)"); soundLabel.setBorder( new CompoundBorder( BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), BorderFactory.createEmptyBorder(3,5,3,5))); - JPanel container = componentsFactory.getTransparentPanel(new GridLayout(2, 2,0,1)); - container.setBackground(AppThemeColor.SETTINGS_BG); - container.setBorder(new CompoundBorder( - BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), - BorderFactory.createEmptyBorder(3,0,3,0))); - - JComboBox notificationComboBox = componentsFactory.getComboBox(new String[]{"Mercury Notification", "Mercury Chat Scanner", "Browse"}); - notificationComboBox.addItemListener(e -> { - switch (e.getStateChange()){ - case ItemEvent.SELECTED: { - if(notificationComboBox.getSelectedItem().equals("Browse")){ - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setFileFilter(new FileNameExtensionFilter("*.wav","wav")); - int returnVal = fileChooser.showOpenDialog(null); - if(returnVal == JFileChooser.APPROVE_OPTION) { - System.out.println(fileChooser.getSelectedFile().getPath()); - } - } - break; - } - } - }); - - - JComboBox chatScannerComboBox = componentsFactory.getComboBox(new String[]{"Mercury Notification", "Mercury Chat Scanner", "Browse"}); - - - container.add(componentsFactory.getTextLabel("Notification:",FontStyle.REGULAR)); - container.add(notificationComboBox); - container.add(componentsFactory.getTextLabel("Chat Scanner",FontStyle.REGULAR)); - container.add(chatScannerComboBox); +// JPanel container = componentsFactory.getTransparentPanel(new GridLayout(2, 2,0,1)); +// container.setBackground(AppThemeColor.SETTINGS_BG); +// container.setBorder(new CompoundBorder( +// BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), +// BorderFactory.createEmptyBorder(3,0,3,0))); +// +// JComboBox notificationComboBox = componentsFactory.getComboBox(new String[]{"Mercury Notification", "Mercury Chat Scanner", "Browse"}); +// notificationComboBox.addItemListener(e -> { +// switch (e.getStateChange()){ +// case ItemEvent.SELECTED: { +// if(notificationComboBox.getSelectedItem().equals("Browse")){ +// JFileChooser fileChooser = new JFileChooser(); +// fileChooser.setFileFilter(new FileNameExtensionFilter("*.wav","wav")); +// int returnVal = fileChooser.showOpenDialog(null); +// if(returnVal == JFileChooser.APPROVE_OPTION) { +// System.out.println(fileChooser.getSelectedFile().getPath()); +// } +// } +// break; +// } +// } +// }); +// +// +// JComboBox chatScannerComboBox = componentsFactory.getComboBox(new String[]{"Mercury Notification", "Mercury Chat Scanner", "Browse"}); +// +// +// container.add(componentsFactory.getTextLabel("Notification:",FontStyle.REGULAR)); +// container.add(notificationComboBox); +// container.add(componentsFactory.getTextLabel("Chat Scanner",FontStyle.REGULAR)); +// container.add(chatScannerComboBox); root.add(soundLabel,BorderLayout.PAGE_START); - root.add(container,BorderLayout.CENTER); +// root.add(container,BorderLayout.CENTER); return root; } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SupportPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SupportPanel.java index 0125c34b..0131af77 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SupportPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SupportPanel.java @@ -58,7 +58,7 @@ public void mousePressed(MouseEvent e) { } } }); - JTextArea donateText = componentsFactory.getSimpleTextAre("We aimed to create a convenience tool in form of an easy-to-use application, primarily for trading purposes. If MercuryTrade successfully managed to save your time or improve your experience, you can thank us by donating and telling your friends."); + JTextArea donateText = componentsFactory.getSimpleTextArea("We aimed to create a convenience tool in form of an easy-to-use application, primarily for trading purposes. If MercuryTrade successfully managed to save your time or improve your experience, you can thank us by donating and telling your friends."); donateText.setPreferredSize(new Dimension(300,150)); JPanel donateTextPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); JPanel donateButtonPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); 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 8ea0cde7..02de14ed 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 @@ -26,7 +26,7 @@ protected void initialize() { JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); root.setBorder(BorderFactory.createLineBorder(AppThemeColor.HEADER)); root.setBackground(AppThemeColor.SLIDE_BG); - root.add(componentsFactory.getSimpleTextAre("Panels UNLOCKED Move them and click Lock when done."),BorderLayout.CENTER); + root.add(componentsFactory.getSimpleTextArea("Panels UNLOCKED Move them and click Lock when done."),BorderLayout.CENTER); JPanel miscPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); JButton restoreDefault = componentsFactory.getBorderedButton("Restore defaults"); 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 ce545a76..e246f4a9 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 @@ -39,7 +39,7 @@ public void initHandlers() { JLabel tooltipLabel = componentsFactory.getTextLabel(FontStyle.REGULAR,AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP,16f,tooltip); this.add(tooltipLabel,BorderLayout.CENTER); }else { - JTextArea tooltipArea = componentsFactory.getSimpleTextAre(""); + JTextArea tooltipArea = componentsFactory.getSimpleTextArea(""); this.add(tooltipArea,BorderLayout.CENTER); tooltipArea.setText(tooltip); if(tooltip.toCharArray().length < 120){ 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 c5d2f662..6a54ee1d 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 @@ -8,16 +8,14 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -/** - * Created by Константин on 18.01.2017. - */ public abstract class AbstractTitledComponentFrame extends AbstractComponentFrame { protected JPanel miscPanel; protected JButton hideButton; + protected JPanel headerPanel; private JLabel frameTitleLabel; protected AbstractTitledComponentFrame(String title) { super(title); - miscPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + miscPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); } @Override @@ -28,7 +26,7 @@ protected void initialize() { private void initHeaderPanel(){ if(layout instanceof BorderLayout) { - JPanel headerPanel = new JPanel(new BorderLayout()); + headerPanel = new JPanel(new BorderLayout()); headerPanel.setBackground(AppThemeColor.HEADER); headerPanel.setPreferredSize(new Dimension(100,26)); headerPanel.setBorder(BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER)); 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 9bb540f8..706bb1ce 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 @@ -214,7 +214,7 @@ private void renderCurrentNote(){ innerContent.setPreferredSize(new Dimension(530,270)); JLabel image = componentsFactory.getIconLabel(note.getImagePath()); - JTextArea textArea = componentsFactory.getSimpleTextAre(note.getText()); + JTextArea textArea = componentsFactory.getSimpleTextArea(note.getText()); switch (note.getLayout()){ case VERTICAL:{ innerContent.setLayout(new BoxLayout(innerContent,BoxLayout.Y_AXIS)); 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 e1907159..2c90b014 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 @@ -2,9 +2,11 @@ import com.mercury.platform.core.utils.interceptor.MessageInterceptor; import com.mercury.platform.core.utils.interceptor.filter.MessageFilter; +import com.mercury.platform.shared.ConfigManager; import com.mercury.platform.shared.events.EventRouter; import com.mercury.platform.shared.entity.FrameSettings; import com.mercury.platform.shared.store.MercuryStore; +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; @@ -24,15 +26,21 @@ public class ChatFilterFrame extends AbstractTitledComponentFrame { private ChatFilterSettingsFrame settingsFrame; 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("MercuryTrade"); FrameSettings frameSettings = configManager.getFrameSettings(this.getClass().getSimpleName()); this.setPreferredSize(frameSettings.getFrameSize()); - this.settingsFrame = new ChatFilterSettingsFrame(this::performNewStrings); + this.settingsFrame = new ChatFilterSettingsFrame(strings -> { + if(chatEnable){ + performNewStrings(strings); + } + }); } @Override @@ -46,13 +54,73 @@ public void componentResized(ComponentEvent e) { } }); 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.add(getNavigationPanel(),BorderLayout.LINE_END); 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) { + MercuryStore.INSTANCE.removeInterceptorSubject.onNext(interceptor); + } + enableButton.setText("Start"); + enableButton.setForeground(AppThemeColor.TEXT_SUCCESS); + repaint(); + }, + () -> { + chatEnable = true; + String chunkStr = StringUtils.deleteWhitespace(ConfigManager.INSTANCE.getDefaultWords()); + 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<>(); @@ -120,7 +188,7 @@ public void initHandlers() { }); } - private JPanel getNavigationPanel(){ + private JPanel getToolbar(){ JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); root.setBorder(BorderFactory.createEmptyBorder(2,2,2,2)); @@ -136,7 +204,7 @@ private JPanel getNavigationPanel(){ "Chat Scanner settings"); edit.addActionListener( action -> this.settingsFrame.showAuxiliaryFrame( - new Point(this.getLocation().x+this.getSize().width/2,this.getLocation().y), + new Point(this.getLocation().x,this.getLocation().y), this.getPreferredSize().height)); JButton clear = componentsFactory.getIconButton( "app/clear-history.png", 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 0b110d33..39b99e84 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 @@ -12,6 +12,7 @@ public class ChatFilterSettingsFrame extends AbstractTitledComponentFrame { private ChatSettingsCallback callback; + private JTextField quickResponseField; public ChatFilterSettingsFrame(ChatSettingsCallback callback) { super("MercuryTrade"); @@ -37,7 +38,7 @@ protected void initialize() { 15f, "Show messages containing the following words:"); title.setBorder(BorderFactory.createEmptyBorder(2,0,6,0)); - JTextArea words = componentsFactory.getSimpleTextAre(ConfigManager.INSTANCE.getDefaultWords()); + JTextArea words = componentsFactory.getSimpleTextArea(ConfigManager.INSTANCE.getDefaultWords()); words.setEditable(true); words.setCaretColor(AppThemeColor.TEXT_DEFAULT); words.setBorder(BorderFactory.createLineBorder(AppThemeColor.HEADER)); @@ -48,6 +49,8 @@ protected void initialize() { JButton save = componentsFactory.getBorderedButton("Save"); save.addActionListener(action -> { ConfigManager.INSTANCE.setDefaultWords(words.getText()); + ConfigManager.INSTANCE.setQuickResponse(quickResponseField.getText()); + String chunkStr = StringUtils.deleteWhitespace(words.getText()); String[] split = chunkStr.split(","); @@ -73,10 +76,35 @@ protected void initialize() { root.add(setupArea,BorderLayout.CENTER); root.add(getMemo(),BorderLayout.LINE_END); - root.add(navBar,BorderLayout.PAGE_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 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"); + quickResponseField = componentsFactory.getTextField(ConfigManager.INSTANCE.getQuickResponse(),FontStyle.REGULAR,16f); + quickResponseField.setBackground(AppThemeColor.SLIDE_BG); + quickResponseField.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(AppThemeColor.HEADER,1), + BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,3) + )); + setupArea.add(quickResponse,BorderLayout.LINE_START); + setupArea.add(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/resources/app/chat_scanner_response.png b/app-ui/src/main/resources/app/chat_scanner_response.png new file mode 100644 index 0000000000000000000000000000000000000000..a9607e7c6959d86e418db27dd9285dd3b61669c0 GIT binary patch literal 1052 zcmeAS@N?(olHy`uVBq!ia0vp^89?m8!3HFyHf)#a~60+7BevL9R^{>)E81?Jr`;BhIQ^`*kr>D&eGFPk0gtK7=dy!CS`_e}FS zxi#!hMfZ#jkE*yF77x2+nZMT8{Qvw`_z%lvrnvf5@8x+T_i%X`NP1f;W;W`?F&;MO z^g4Iu!=#jrraX5Kg$D(-O;hRCO}rttYtqK!8-T*1JU0)83H3r}bq7I#D z2N-lcL^rfQd@2xmrj;>jf>r{*;_(SbWh54`u4MWqP$YKZks!nz4ol8WKe*U399K2i zw#YQGq>5s zwyb~$%{%8!`tsvJV)mk0?4=f}FF!Um*YJd1UZ8h$lAOFvN;`<@I%!_~hY7M_zRkN* zyrW`aOwU^)6({&sFLR9LQ$4A~e>3r_$%@mb{~J$tZE9A0DHUhuy2;{j^EC(4Z-?y7 zSN!UD<8@0UsN#auieqwhjrab^nOs)l|GDb6h=|1!Zo#${pPM+OT9&Z9 z%l*Cjx0dU(4ZAFwc-KsndZ4KCH~F*3TD>BN$rGj=*qd8l8n2pT6v2C{)pyNIsYi+` zs{R+VJUBB%CJF7>{&xL4?deuc9J5-Nu)H~Y|J@bar$PP#j)x~~X|TTi?$x}a71|vO zGCiUi=GyvSd^OMf?D<2>uEp?vy)akhP4rvS?V0Zwd!2<2tottFa-pWe^UmdOq2DJu zTRXBaJ5748nWf#4aN@$G4UhM-3i4#BzN};}Z?#slo?g(a(3GgF(z;+)LV~a7$F6L~ zwrdlvw8}Ku{uXjExS_mK+LC4WH}#H$ACjK2ClzmO_jhFBp5pP!kMH2Qzg$WYO720^ zi#Wc$ixxPjv|goDyFKCiKUP7V#VVz`?Fs+C3%G0$Q2p4JwriU68@rGnmUp}_SRa}& z`GPlxmdKI;Vst0CVTZD*ylh literal 0 HcmV?d00001 diff --git a/app-ui/src/main/resources/app/menu.png b/app-ui/src/main/resources/app/menu.png new file mode 100644 index 0000000000000000000000000000000000000000..60cc9e1ef8167b62a301060860951825e4004c5d GIT binary patch literal 255 zcmeAS@N?(olHy`uVBq!ia0vp^S|H591|*LjJ{b+97>k44ofy`glX(f`u%tWsIx;Y9 z?C1WI$O`0h7I;J!GcfQS24TkI`72U@f|4b!5hcO-X(i=}MX3x0iJ5sNdU>fO3MP66 zdWOa(%+XaqMfsjCjv*25Z~F|n7!(8!|M|cCd|+#jtkRYV3ukUhd&V6g<(SE`RB(!0 zfYi?ZN?zaf3tyU=>=n+sC!EEOO?dvoG8C2SA-rD78odilnl5p8$!|8>urKR$_lD3Y Ppw$eXu6{1-oD!M=p~Xd zDH>{gEA(cNPiVL&`Zm)&&pUykkigra(rOSD$mJ_)tj%DYM+0FNpZY}EP1ac&FHLAGEZWFtAXZ-7i$T2%Z293zT%BKePNU!L> z6ApK>noChFrOV69!<4pY@57HjYs~|qcYkHvY0n*6{oB{EG7^0Jcd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