Skip to content

Commit

Permalink
Upwards works as it should
Browse files Browse the repository at this point in the history
  • Loading branch information
Exslims committed Aug 24, 2017
1 parent acbdff1 commit 9372ffd
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,34 @@
import java.util.Objects;

public abstract class IncomingNotificationPanel<T extends TradeNotificationDescriptor> extends NotificationPanel<T, IncomingPanelController> {
private PlainConfigurationService<NotificationSettingsDescriptor> config;
protected PlainConfigurationService<NotificationSettingsDescriptor> config;
private PlainConfigurationService<HotKeysSettingsDescriptor> hotKeysConfig;
private JPanel messagePanel;
private JPanel responseButtonsPanel;
private JPanel chatPanel;
private JPanel chatContainer;
private Subscription chatSubscription;

@Override
public void onViewInit() {
super.onViewInit();
this.config = Configuration.get().notificationConfiguration();
this.hotKeysConfig = Configuration.get().hotKeysConfiguration();
this.messagePanel = this.getMessagePanel();
this.responseButtonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 2));
this.responseButtonsPanel.setBackground(AppThemeColor.FRAME);
this.responseButtonsPanel = this.componentsFactory.getJPanel(new FlowLayout(FlowLayout.CENTER, 5, 2), AppThemeColor.FRAME);
this.chatPanel = this.getChatPanel();
this.chatPanel.setVisible(false);
this.contentPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME);
switch (config.get().getFlowDirections()) {
case DOWNWARDS: {
this.add(this.getHeader(), BorderLayout.PAGE_START);
this.add(this.responseButtonsPanel, BorderLayout.PAGE_END);
this.contentPanel.add(this.responseButtonsPanel, BorderLayout.PAGE_END);
break;
}
case UPWARDS: {
this.add(this.getHeader(), BorderLayout.PAGE_END);
this.add(this.responseButtonsPanel, BorderLayout.PAGE_START);
this.contentPanel.add(this.responseButtonsPanel, BorderLayout.PAGE_START);
break;
}
}
this.add(this.messagePanel, BorderLayout.CENTER);
this.contentPanel.add(this.getMessagePanel(), BorderLayout.CENTER);
this.add(this.contentPanel, BorderLayout.CENTER);
this.updateHotKeyPool();
}

Expand Down Expand Up @@ -95,11 +92,9 @@ private JPanel getHeader() {
if (this.chatPanel.isVisible()) {
this.chatPanel.setVisible(false);
this.remove(this.chatPanel);
this.add(this.messagePanel, BorderLayout.CENTER);
this.add(this.responseButtonsPanel, BorderLayout.PAGE_END);
this.add(this.contentPanel, BorderLayout.CENTER);
} else {
this.remove(this.messagePanel);
this.remove(this.responseButtonsPanel);
this.remove(this.contentPanel);
this.chatPanel.setVisible(true);
this.add(this.chatPanel, BorderLayout.CENTER);
}
Expand Down Expand Up @@ -302,22 +297,4 @@ private String getNicknameText() {
}
return result;
}

private JButton getExpandButton() {
String iconPath = "app/expand-mp.png";
JButton expandButton = componentsFactory.getIconButton(iconPath, 18f, AppThemeColor.MSG_HEADER, "");
expandButton.addActionListener(action -> {
if (this.messagePanel.isVisible()) {
this.messagePanel.setVisible(false);
this.responseButtonsPanel.setVisible(false);
expandButton.setIcon(this.componentsFactory.getIcon("app/default-mp.png", 18f));
} else {
this.messagePanel.setVisible(true);
this.responseButtonsPanel.setVisible(true);
expandButton.setIcon(this.componentsFactory.getIcon("app/expand-mp.png", 18f));
}
SwingUtilities.getWindowAncestor(IncomingNotificationPanel.this).pack();
});
return expandButton;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ public class ItemIncNotificationPanel extends IncomingNotificationPanel<ItemTrad

@Override
protected JPanel getMessagePanel() {
this.labelsPanel = new JPanel();
this.labelsPanel.setLayout(new BorderLayout());
this.labelsPanel.setBackground(AppThemeColor.FRAME);
this.labelsPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME);

JButton itemButton = componentsFactory.getButton(
FontStyle.BOLD,
AppThemeColor.BUTTON,
BorderFactory.createEmptyBorder(0, 4, 0, 2),
BorderFactory.createEmptyBorder(4, 4, 4, 4),
this.data.getItemName(), 16f);

itemButton.setForeground(AppThemeColor.TEXT_IMPORTANT);
Expand All @@ -33,7 +31,6 @@ protected JPanel getMessagePanel() {
itemButton.addActionListener(action -> {
this.controller.showITH();
});
this.labelsPanel.add(itemButton, BorderLayout.CENTER);

JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 15, AppThemeColor.FRAME, TooltipConstants.OPEN_CHAT);
openChatButton.addActionListener(e -> controller.performOpenChat());
Expand All @@ -42,15 +39,17 @@ protected JPanel getMessagePanel() {
buttons.add(stillInterestedButton);
buttons.add(openChatButton);

JPanel miscPanel = this.componentsFactory.getJPanel(new GridLayout(1, 0, 4, 0), AppThemeColor.FRAME);
miscPanel.add(itemButton);
JLabel offerLabel = this.getOfferLabel();
if (offerLabel != null) {
this.labelsPanel.add(offerLabel, BorderLayout.PAGE_END);
miscPanel.add(offerLabel);
}
labelsPanel.add(buttons, BorderLayout.LINE_END);
this.labelsPanel.add(miscPanel, BorderLayout.CENTER);
this.labelsPanel.add(buttons, BorderLayout.LINE_END);
return labelsPanel;
}

@Override
public void setDuplicate(boolean duplicate) {
if (duplicate) {
JButton ignoreButton = componentsFactory.getIconButton("app/adr/visible_node_off.png", 15, AppThemeColor.FRAME, "Ignore item 1 hour");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.mercury.platform.ui.components.fields.font.TextAlignment;
import com.mercury.platform.ui.components.panel.misc.ViewDestroy;
import com.mercury.platform.ui.components.panel.misc.ViewInit;
import com.mercury.platform.ui.frame.movable.NotificationFrame;
import com.mercury.platform.ui.misc.AppThemeColor;
import com.mercury.platform.ui.misc.MercuryStoreUI;
import lombok.Getter;
Expand Down Expand Up @@ -37,6 +38,9 @@ public abstract class NotificationPanel<T, C> extends JPanel implements AsSubscr
protected boolean blurReverse;
@Setter
protected boolean duplicate;
protected JPanel chatPanel;
protected JPanel chatContainer;
protected JPanel contentPanel;
@Setter
private float paintAlphaValue = 1f;
private Subscription settingsPostSubscription;
Expand Down Expand Up @@ -114,6 +118,25 @@ public void actionPerformed(ActionEvent e) {
return root;
}

protected JButton getExpandButton() {
String iconPath = "app/expand-mp.png";
JButton expandButton = componentsFactory.getIconButton(iconPath, 18f, AppThemeColor.MSG_HEADER, "");
expandButton.addActionListener(action -> {
NotificationFrame frame = (NotificationFrame) SwingUtilities.getWindowAncestor(NotificationPanel.this);
if (this.contentPanel.isVisible()) {
this.contentPanel.setVisible(false);
expandButton.setIcon(this.componentsFactory.getIcon("app/default-mp.png", 18f));
frame.changeBufferSize(this.contentPanel.getPreferredSize().height);
} else {
this.contentPanel.setVisible(true);
expandButton.setIcon(this.componentsFactory.getIcon("app/expand-mp.png", 18f));
frame.changeBufferSize(-this.contentPanel.getPreferredSize().height);
}
frame.pack();
});
return expandButton;
}

protected void onBlur() {
this.blurEffect = true;
this.setBorder(BorderFactory.createCompoundBorder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public abstract class OutgoingNotificationPanel<T extends TradeNotificationDescr
private PlainConfigurationService<NotificationSettingsDescriptor> config;
private PlainConfigurationService<HotKeysSettingsDescriptor> hotKeysConfig;
private JPanel responseButtonsPanel;
private JPanel bottomPanel;

@Override
public void onViewInit() {
Expand All @@ -33,10 +32,10 @@ public void onViewInit() {

this.responseButtonsPanel = new JPanel(new GridLayout(1, 0, 0, 5));
this.responseButtonsPanel.setBackground(AppThemeColor.FRAME);
this.bottomPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME);
this.bottomPanel.add(this.getContentPanel(), BorderLayout.CENTER);
this.bottomPanel.add(this.componentsFactory.wrapToSlide(this.responseButtonsPanel, AppThemeColor.FRAME), BorderLayout.LINE_END);
this.add(bottomPanel, BorderLayout.CENTER);
this.contentPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME);
this.contentPanel.add(this.getContentPanel(), BorderLayout.CENTER);
this.contentPanel.add(this.componentsFactory.wrapToSlide(this.responseButtonsPanel, AppThemeColor.FRAME), BorderLayout.LINE_END);
this.add(contentPanel, BorderLayout.CENTER);
this.updateHotKeyPool();
}

Expand Down Expand Up @@ -198,20 +197,4 @@ public void subscribe() {
public void onViewDestroy() {
super.onViewDestroy();
}

private JButton getExpandButton() {
String iconPath = "app/expand-mp.png";
JButton expandButton = componentsFactory.getIconButton(iconPath, 18f, AppThemeColor.MSG_HEADER, "");
expandButton.addActionListener(action -> {
if (this.bottomPanel.isVisible()) {
this.bottomPanel.setVisible(false);
expandButton.setIcon(this.componentsFactory.getIcon("app/default-mp.png", 18f));
} else {
this.bottomPanel.setVisible(true);
expandButton.setIcon(this.componentsFactory.getIcon("app/expand-mp.png", 18f));
}
SwingUtilities.getWindowAncestor(OutgoingNotificationPanel.this).pack();
});
return expandButton;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class ScannerNotificationPanel extends NotificationPanel<PlainMessageDesc
private PlainConfigurationService<ScannerDescriptor> config;
private PlainConfigurationService<NotificationSettingsDescriptor> nConfig;
private PlainConfigurationService<HotKeysSettingsDescriptor> hotKeysConfig;
private JPanel contentPanel;

@Override
public void onViewInit() {
Expand Down Expand Up @@ -118,20 +117,4 @@ protected void updateHotKeyPool() {
public void onViewDestroy() {
super.onViewDestroy();
}

private JButton getExpandButton() {
String iconPath = "app/expand-mp.png";
JButton expandButton = componentsFactory.getIconButton(iconPath, 18f, AppThemeColor.MSG_HEADER, "");
expandButton.addActionListener(action -> {
if (this.contentPanel.isVisible()) {
this.contentPanel.setVisible(false);
expandButton.setIcon(this.componentsFactory.getIcon("app/default-mp.png", 18f));
} else {
this.contentPanel.setVisible(true);
expandButton.setIcon(this.componentsFactory.getIcon("app/expand-mp.png", 18f));
}
SwingUtilities.getWindowAncestor(ScannerNotificationPanel.this).pack();
});
return expandButton;
}
}
Loading

0 comments on commit 9372ffd

Please sign in to comment.