Skip to content

Commit

Permalink
AdrIconSelect dialog performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Exslims committed Aug 6, 2017
1 parent 024095e commit 090f771
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@ public class IconsListCellRenderer implements ListCellRenderer<String> {
private IconBundleConfigurationService config = Configuration.get().iconBundleConfiguration();
@Override
public Component getListCellRendererComponent(JList<? extends String> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -49,6 +50,7 @@ public class MercuryStoreUI {
public static final PublishSubject<Boolean> adrRepaintSubject = PublishSubject.create();
public static final PublishSubject<AdrComponentDescriptor> adrExportSubject = PublishSubject.create();
public static final PublishSubject<AdrComponentDescriptor> adrUpdateSubject = PublishSubject.create();
public static final PublishSubject<DialogCallback<String>> adrOpenIconSelectSubject = PublishSubject.create();

public static final PublishSubject<Boolean> onDestroySubject = PublishSubject.create();
}

0 comments on commit 090f771

Please sign in to comment.