From 6a3c63277e377f01de99b3f9aed36acf64e5d430 Mon Sep 17 00:00:00 2001 From: Exslims Date: Tue, 28 Mar 2017 20:03:52 +0400 Subject: [PATCH] Minor improvements before release. --- .../platform/core/utils/error/ErrorHandler.java | 3 ++- .../ui/components/ComponentsFactory.java | 2 +- .../components/panel/taskbar/TaskBarPanel.java | 2 +- .../ui/frame/movable/ItemsGridFrame.java | 16 +++++++++++----- .../ui/frame/movable/MovableComponentFrame.java | 6 ++++-- .../platform/ui/frame/movable/TaskBarFrame.java | 8 ++++++-- .../platform/ui/frame/other/TooltipFrame.java | 7 ++++--- .../platform/ui/frame/titled/SettingsFrame.java | 2 +- .../platform/ui/manager/FramesManager.java | 11 ++++++++--- .../platform/ui/misc/TooltipConstants.java | 4 +--- 10 files changed, 39 insertions(+), 22 deletions(-) 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 7457f913..b57d0205 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,5 +1,6 @@ package com.mercury.platform.core.utils.error; +import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -7,7 +8,7 @@ public class ErrorHandler { private Logger logger = LogManager.getLogger(ErrorHandler.class.getSimpleName()); public ErrorHandler(){ Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> { - logger.error(throwable.fillInStackTrace()); + logger.error(ExceptionUtils.getStackTrace(throwable)); }); } } 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 c168f2d7..c7ce0668 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 @@ -40,7 +40,7 @@ public class ComponentsFactory{ public ComponentsFactory() { loadFonts(); - this.scale = ConfigManager.INSTANCE.getScaleData().get("other"); + this.scale = 1.0f; } /** diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarPanel.java index 02c9966f..566eecf8 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarPanel.java @@ -114,7 +114,7 @@ public void mouseClicked(MouseEvent e) { "app/scale-settings.png", 24, AppThemeColor.FRAME_ALPHA, - TooltipConstants.SETUP_FRAMES_LOCATION); + TooltipConstants.SCALE_SETTINGS); scaleButton.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { 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 f66757f3..409f0f1c 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 @@ -7,6 +7,7 @@ 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; @@ -117,7 +118,7 @@ protected JPanel getPanelForPINSettings() { } } quadGridPanel.setBackground(AppThemeColor.FRAME_ALPHA); - JPanel labelPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); + JPanel labelPanel = componentsFactory.getTransparentPanel(new BorderLayout()); JComboBox tabType = componentsFactory.getComboBox(new String[]{"1x1", "4x4"}); tabType.addItemListener(e -> { if(e.getStateChange() == ItemEvent.SELECTED){ @@ -135,11 +136,12 @@ protected JPanel getPanelForPINSettings() { } } }); + tabType.setPreferredSize(new Dimension((int)(componentsFactory.getScale() * 70),tabType.getHeight())); - labelPanel.add(tabType); + labelPanel.add(tabType,BorderLayout.LINE_START); Color titleColor = configManager.isItemsGridEnable()?AppThemeColor.TEXT_NICKNAME:AppThemeColor.TEXT_DISABLE; JLabel titleLabel = componentsFactory.getTextLabel(FontStyle.BOLD, titleColor, TextAlignment.LEFTOP, 20f, "Align this grid(approximately)"); - labelPanel.add(titleLabel); + labelPanel.add(titleLabel,BorderLayout.CENTER); headerPanel.add(labelPanel, BorderLayout.CENTER); String title = (configManager.isItemsGridEnable())?"Disable" : "Enable"; @@ -293,7 +295,6 @@ public void mouseDragged(MouseEvent e) { JPanel source = (JPanel) e.getSource(); Point frameLocation = getLocation(); setSize(new Dimension(e.getLocationOnScreen().x - frameLocation.x + source.getWidth(), getHeight())); - configManager.saveFrameSize(ItemsGridFrame.class.getSimpleName(),getSize()); } } private class ResizeByHeightMouseMotionListener extends MouseMotionAdapter { @@ -303,7 +304,6 @@ public void mouseDragged(MouseEvent e) { JPanel source = (JPanel) e.getSource(); Point frameLocation = getLocation(); setSize(new Dimension(getWidth(),e.getLocationOnScreen().y - frameLocation.y + source.getHeight())); - configManager.saveFrameSize(ItemsGridFrame.class.getSimpleName(),getSize()); } } private class ArrowMouseListener extends MouseAdapter { @@ -317,12 +317,18 @@ private ArrowMouseListener(JPanel panel, Cursor cursor) { @Override public void mousePressed(MouseEvent e) { + Dimension size = configManager.getMinimumFrameSize(ItemsGridFrame.this.getClass().getSimpleName()); + ItemsGridFrame.this.setMinimumSize(size); panel.setBackground(AppThemeColor.TEXT_DISABLE); } @Override public void mouseReleased(MouseEvent e) { + Dimension size = ItemsGridFrame.this.getSize(); + ItemsGridFrame.this.setMaximumSize(size); + ItemsGridFrame.this.setMinimumSize(size); panel.setBackground(AppThemeColor.FRAME); + configManager.saveFrameSize(ItemsGridFrame.class.getSimpleName(),getSize()); } @Override 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/MovableComponentFrame.java index 5e2f473f..773044fb 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/MovableComponentFrame.java @@ -86,8 +86,10 @@ public void setState(LocationState state){ @Override public void onLocationChange(Point location) { super.onLocationChange(location); - prevConstraints.location = location; - locationWasChanged = true; + if(inMoveMode) { + prevConstraints.location = location; + locationWasChanged = true; + } } private JPanel setUpMoveListeners(JPanel panel){ 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 29968015..fddf4f6d 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 @@ -41,6 +41,7 @@ public TaskBarFrame() { protected void initialize() { super.initialize(); createUI(); + this.setMaximumSize(taskBarPanel.getPreferredSize()); collapseListener = new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { @@ -126,7 +127,8 @@ protected JPanel getPanelForPINSettings() { JPanel labelPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); labelPanel.add(componentsFactory.getTextLabel(FontStyle.BOLD,AppThemeColor.TEXT_MESSAGE, TextAlignment.LEFTOP,20f,"Task Bar")); panel.add(labelPanel); - panel.setPreferredSize(this.getSize()); +// panel.setPreferredSize(new Dimension(taskBarPanel.getWidthOf(4),taskBarPanel.getHeight())); +// System.out.println(panel.getPreferredSize()); panel.setBackground(AppThemeColor.FRAME); return panel; } @@ -147,7 +149,7 @@ protected void performScaling(Map scaleData) { @Override public void createUI() { JPanel panel = componentsFactory.getTransparentPanel(new BorderLayout()); - TaskBarPanel taskBarPanel = new TaskBarPanel(new MercuryTaskBarController(),componentsFactory); + taskBarPanel = new TaskBarPanel(new MercuryTaskBarController(),componentsFactory); panel.add(taskBarPanel, BorderLayout.CENTER); panel.setBackground(AppThemeColor.FRAME); mainContainer = panel; @@ -190,6 +192,8 @@ public void exit() {} this.MIN_WIDTH = taskBarPanel.getWidthOf(4); this.MAX_WIDTH = taskBarPanel.getPreferredSize().width; this.setSize(new Dimension(MIN_WIDTH,this.getHeight())); + this.setMinimumSize(new Dimension(MIN_WIDTH,taskBarPanel.getHeight())); + this.setMaximumSize(new Dimension(MAX_WIDTH,taskBarPanel.getHeight())); return panel; } } 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 7374f915..b0a62247 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 @@ -27,6 +27,7 @@ public TooltipFrame() { @Override protected void initialize() { + this.componentsFactory.setScale(1.1f); } @Override public void initHandlers() { @@ -43,12 +44,12 @@ public void initHandlers() { tooltipArea.setText(tooltip); if(tooltip.toCharArray().length < 120){ if(tooltip.toCharArray().length < 85){ - this.setPreferredSize(new Dimension(320, 50)); + this.setPreferredSize(new Dimension(320, 55)); }else { - this.setPreferredSize(new Dimension(320, 70)); + this.setPreferredSize(new Dimension(320, 75)); } }else { - this.setPreferredSize(new Dimension(320, 110)); + this.setPreferredSize(new Dimension(320, 145)); } } this.pack(); 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 8af05162..c30686b2 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 @@ -46,7 +46,7 @@ private void initContainer() { tabbedPane.addTab("General",generalSettings); tabbedPane.addTab("Notification panel",cbSettings); tabbedPane.addTab("Task panel",taskBarSettings); - tabbedPane.addTab("Help",new HelpPanel()); +// tabbedPane.addTab("Help",new HelpPanel()); tabbedPane.addTab("Support",new SupportPanel()); tabbedPane.addTab("About",new AboutPanel()); 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 d0eb3c36..bc021bb9 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 @@ -183,11 +183,16 @@ public void restoreDefaultLocation(){ } private void createTrayIcon(){ PopupMenu trayMenu = new PopupMenu(); - MenuItem item = new MenuItem("Exit"); - item.addActionListener(e -> { + MenuItem exit = new MenuItem("Exit"); + exit.addActionListener(e -> { exit(); }); - trayMenu.add(item); + MenuItem restore = new MenuItem("Restore default location"); + restore.addActionListener(e -> { + FramesManager.INSTANCE.restoreDefaultLocation(); + }); + trayMenu.add(restore); + trayMenu.add(exit); BufferedImage icon = null; try { diff --git a/app-ui/src/main/java/com/mercury/platform/ui/misc/TooltipConstants.java b/app-ui/src/main/java/com/mercury/platform/ui/misc/TooltipConstants.java index 84330266..9b8a0f15 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/misc/TooltipConstants.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/misc/TooltipConstants.java @@ -1,8 +1,5 @@ package com.mercury.platform.ui.misc; -/** - * Created by Константин on 19.01.2017. - */ public class TooltipConstants { //Shared public static final String CLOSE_BUTTON = "Close"; @@ -16,6 +13,7 @@ public class TooltipConstants { public static final String SETUP_FRAMES_LOCATION = "Panel unlock. Unlock panels to reposition."; public static final String SETTINGS = "Settings"; public static final String ITEM_GRID = "Items Grid settings"; + public static final String SCALE_SETTINGS = "Components scale settings"; public static final String EXIT = "Exit"; //Timer tooltips