From 090f7713bd28de455b112d7e0102763dbcd3c98b Mon Sep 17 00:00:00 2001 From: Exslims Date: Sun, 6 Aug 2017 15:03:15 +0400 Subject: [PATCH] AdrIconSelect dialog performance improvements --- .../platform/ui/adr/components/AdrComponentsFactory.java | 6 +----- .../platform/ui/adr/components/AdrManagerFrame.java | 9 ++++++++- .../adr/components/panel/ui/IconsListCellRenderer.java | 9 +++------ .../com/mercury/platform/ui/misc/MercuryStoreUI.java | 2 ++ 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrComponentsFactory.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrComponentsFactory.java index 17c8ed43..1b88c543 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrComponentsFactory.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrComponentsFactory.java @@ -216,17 +216,13 @@ public JPanel getIconSelectPanel(AdrDurationComponentDescriptor descriptor){ root.add(iconPathLabel,BorderLayout.CENTER); JButton selectIcon = this.componentsFactory.getBorderedButton("Select"); selectIcon.addActionListener(action -> { - AdrIconSelectDialog adrIconSelectDialog = new AdrIconSelectDialog(); - adrIconSelectDialog.setSelectedIcon(descriptor.getIconPath()); - adrIconSelectDialog.setCallback(selectedIconPath -> { + MercuryStoreUI.adrOpenIconSelectSubject.onNext(selectedIconPath -> { descriptor.setIconPath(selectedIconPath); iconLabel.setIcon(this.componentsFactory.getIcon(this.config.getIcon(selectedIconPath),26)); iconPathLabel.setText(descriptor.getIconPath()); MercuryStoreUI.adrReloadSubject.onNext(descriptor); }); - adrIconSelectDialog.setLocationRelativeTo(root); - adrIconSelectDialog.setVisible(true); }); root.add(selectIcon,BorderLayout.LINE_END); return root; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrManagerFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrManagerFrame.java index ca03f78b..f13e4983 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrManagerFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrManagerFrame.java @@ -9,6 +9,7 @@ import com.mercury.platform.ui.adr.components.panel.tree.main.AdrMainTreeNodeRenderer; import com.mercury.platform.ui.adr.components.panel.tree.AdrTreePanel; import com.mercury.platform.ui.adr.dialog.AdrExportDialog; +import com.mercury.platform.ui.adr.dialog.AdrIconSelectDialog; import com.mercury.platform.ui.adr.dialog.AdrNewProfileDialog; import com.mercury.platform.ui.adr.routing.AdrPageDefinition; import com.mercury.platform.ui.adr.routing.AdrPageState; @@ -36,6 +37,7 @@ public class AdrManagerFrame extends AbstractTitledComponentFrame{ private AdrTreePanel tree; private JComboBox profileSelector; private AdrExportDialog exportDialog; + private AdrIconSelectDialog iconSelectDialog; @Getter private AdrProfileDescriptor selectedProfile; public AdrManagerFrame(AdrProfileDescriptor selectedProfile) { @@ -47,6 +49,8 @@ public AdrManagerFrame(AdrProfileDescriptor selectedProfile) { this.setAlwaysOnTop(false); this.selectedProfile = selectedProfile; this.exportDialog = new AdrExportDialog(this,new ArrayList<>()); + this.iconSelectDialog = new AdrIconSelectDialog(); + this.iconSelectDialog.setLocationRelativeTo(null); FrameDescriptor frameDescriptor = this.framesConfig.get(this.getClass().getSimpleName()); this.setPreferredSize(frameDescriptor.getFrameSize()); UIManager.put("MenuItem.background", AppThemeColor.ADR_BG); @@ -56,7 +60,6 @@ public AdrManagerFrame(AdrProfileDescriptor selectedProfile) { UIManager.put("ComboBox.selectionBackground", AppThemeColor.HEADER); UIManager.put("ComboBox.selectionForeground", AppThemeColor.ADR_POPUP_BG); UIManager.put("ComboBox.disabledForeground", AppThemeColor.ADR_FOOTER_BG); - this.subscribe(); } @Override @@ -125,6 +128,10 @@ public void subscribe() { MercuryStoreUI.adrManagerRepaint.subscribe(state -> { this.repaint(); }); + MercuryStoreUI.adrOpenIconSelectSubject.subscribe(callback -> { + this.iconSelectDialog.setCallback(callback); + this.iconSelectDialog.setVisible(true); + }); } public void setSelectedProfile(AdrProfileDescriptor profile){ diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/ui/IconsListCellRenderer.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/ui/IconsListCellRenderer.java index d93fccb4..4ab06b68 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/ui/IconsListCellRenderer.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/ui/IconsListCellRenderer.java @@ -15,14 +15,11 @@ public class IconsListCellRenderer implements ListCellRenderer { private IconBundleConfigurationService config = Configuration.get().iconBundleConfiguration(); @Override public Component getListCellRendererComponent(JList list, String value, int index, boolean isSelected, boolean cellHasFocus) { - JPanel root = this.componentsFactory.getJPanel(new BorderLayout()); - root.setBorder(BorderFactory.createEmptyBorder(2,2,2,2)); - JLabel iconLabel = this.componentsFactory.getIconLabel(this.config.getIcon(value), 48); - root.add(iconLabel,BorderLayout.CENTER); - + JLabel iconLabel = this.componentsFactory.getIconLabel(this.config.getIcon(value), 64); + iconLabel.setBorder(BorderFactory.createEmptyBorder(2,2,2,2)); if(isSelected){ iconLabel.setBorder(BorderFactory.createLineBorder(AppThemeColor.TEXT_MESSAGE)); } - return root; + return iconLabel; } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java b/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java index 77d494f4..67bf946d 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java @@ -10,6 +10,7 @@ import com.mercury.platform.ui.components.panel.grid.ItemInfoPanel; import com.mercury.platform.ui.components.panel.grid.TabInfoPanel; import com.mercury.platform.ui.components.panel.message.MessagePanel; +import com.mercury.platform.ui.dialog.DialogCallback; import rx.subjects.PublishSubject; import java.util.Map; @@ -49,6 +50,7 @@ public class MercuryStoreUI { public static final PublishSubject adrRepaintSubject = PublishSubject.create(); public static final PublishSubject adrExportSubject = PublishSubject.create(); public static final PublishSubject adrUpdateSubject = PublishSubject.create(); + public static final PublishSubject> adrOpenIconSelectSubject = PublishSubject.create(); public static final PublishSubject onDestroySubject = PublishSubject.create(); }