Skip to content

Commit

Permalink
ItemLabel on Notification Panel now as button which showing item grid…
Browse files Browse the repository at this point in the history
… and copy item name to clipboard, improvement UX clarity in Item Grid settings. Added Item Grid tooltip.
  • Loading branch information
Exslims committed Mar 13, 2017
1 parent 37e58f9 commit 17f60d2
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public ConfigManager() {
defaultAppSettings.put("flowDirection","DOWNWARDS");
defaultAppSettings.put("tradeMode","DEFAULT");
defaultAppSettings.put("limitMsgCount",3);
defaultAppSettings.put("expandedMsgCount",0);
defaultAppSettings.put("expandedMsgCount",2);
defaultAppSettings.put("itemsGridEnable",true);
defaultAppSettings.put("checkUpdateOnStartUp",true);
defaultAppSettings.put("dismissAfterKick",false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public MessagePanel(Message message, ComponentFrame owner, MessagePanelStyle sty
BorderFactory.createLineBorder(AppThemeColor.BORDER, 1)));

this.messagePanel = getFormattedMessagePanel();
this.customButtonsPanel = getButtonsPanel(whisper);
this.customButtonsPanel = getButtonsPanel();
init();
initHandlers();
setMaximumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height));
Expand Down Expand Up @@ -124,10 +124,47 @@ private JPanel getFormattedMessagePanel(){

JPanel tradePanel = new JPanel(new BorderLayout());
tradePanel.setBackground(AppThemeColor.TRANSPARENT);
tradePanel.setBorder(BorderFactory.createEmptyBorder(-11,0,-11,0));
tradePanel.setBorder(BorderFactory.createEmptyBorder(-11,2,-11,0));
if(message instanceof ItemMessage) {
JLabel itemLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_IMPORTANT, TextAlignment.CENTER, 16f, ((ItemMessage)message).getItemName());
tradePanel.add(itemLabel,BorderLayout.CENTER);
JButton itemButton = componentsFactory.getButton(((ItemMessage) message).getItemName());
itemButton.setForeground(AppThemeColor.TEXT_IMPORTANT);
itemButton.setFont(componentsFactory.getFont(FontStyle.BOLD).deriveFont(16f));
itemButton.setBackground(AppThemeColor.TRANSPARENT);
itemButton.setBorder(BorderFactory.createEmptyBorder(0,4,0,2));
itemButton.setHorizontalAlignment(SwingConstants.LEFT);
itemButton.setContentAreaFilled(false);
itemButton.setRolloverEnabled(false);
itemButton.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if(message instanceof ItemMessage) {
copyItemNameToClipboard(((ItemMessage) message).getItemName());
if (((ItemMessage) message).getTabInfo() != null) {
EventRouter.INSTANCE.fireEvent(new ShowItemMeshEvent(message.getWhisperNickname(), ((ItemMessage) message).getTabInfo()));
}
}
}

@Override
public void mouseReleased(MouseEvent e) {
owner.repaint();
}

@Override
public void mouseEntered(MouseEvent e) {
itemButton.setBorder(new CompoundBorder(
BorderFactory.createMatteBorder(0,1,0,1,AppThemeColor.BORDER),
BorderFactory.createEmptyBorder(0,3,0,1)));
owner.repaint();
}

@Override
public void mouseExited(MouseEvent e) {
itemButton.setBorder(BorderFactory.createEmptyBorder(0,4,0,2));
owner.repaint();
}
});
tradePanel.add(itemButton,BorderLayout.CENTER);
}else if(message instanceof CurrencyMessage){
CurrencyMessage message = (CurrencyMessage) this.message;
JPanel curCountPanel = new JPanel();
Expand Down Expand Up @@ -214,13 +251,7 @@ private JPanel getWhisperPanel(){
inviteButton.addActionListener(e -> {
EventRouter.INSTANCE.fireEvent(new ChatCommandEvent("/invite " + whisper));
if(message instanceof ItemMessage) {
Timer timer = new Timer(30, action -> {
StringSelection selection = new StringSelection(((ItemMessage) message).getItemName());
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, null);
});
timer.setRepeats(false);
timer.start();
copyItemNameToClipboard(((ItemMessage) message).getItemName());
if (((ItemMessage) message).getTabInfo() != null) {
EventRouter.INSTANCE.fireEvent(new ShowItemMeshEvent(message.getWhisperNickname(), ((ItemMessage) message).getTabInfo()));
}
Expand Down Expand Up @@ -379,7 +410,7 @@ public void setStyle(MessagePanelStyle style) {
public MessagePanelStyle getStyle() {
return style;
}
private JPanel getButtonsPanel(String whisper){
private JPanel getButtonsPanel(){
JPanel panel = new JPanel(new FlowLayout());
panel.setBackground(AppThemeColor.TRANSPARENT);
initResponseButtons(panel);
Expand Down Expand Up @@ -423,15 +454,23 @@ private void initResponseButtons(JPanel panel){
button.addActionListener(e -> {
EventRouter.INSTANCE.fireEvent(new ChatCommandEvent("@" + whisper + " " + buttonConfig.getResponseText()));
if(buttonConfig.isClose() && !style.equals(MessagePanelStyle.SP_MODE)){
try{
Thread.sleep(50);
Timer timer = new Timer(30, action -> {
EventRouter.INSTANCE.fireEvent(new CloseMessagePanelEvent(MessagePanel.this, message));
}catch (InterruptedException ex){

}
});
timer.setRepeats(false);
timer.start();
}
});
panel.add(button);
});
}
private void copyItemNameToClipboard(String itemName){
Timer timer = new Timer(30, action -> {
StringSelection selection = new StringSelection(itemName);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, null);
});
timer.setRepeats(false);
timer.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ protected JPanel panelWhenMove() {
configManager.setItemsGridEnable(true);
repaint();
},configManager.isItemsGridEnable());
JButton hideButton = componentsFactory.getIconButton("app/close.png", 12, AppThemeColor.FRAME_ALPHA, "");
hideButton.setBorder(BorderFactory.createEmptyBorder(2,0,0,2));
JButton hideButton = componentsFactory.getBorderedButton("Save");
hideButton.setPreferredSize(new Dimension(90,24));
hideButton.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
Expand Down Expand Up @@ -249,7 +249,6 @@ public void mousePressed(MouseEvent e) {
itemsMesh.setBackground(AppThemeColor.FRAME_ALPHA);
panel.add(itemsMesh,BorderLayout.CENTER);
setUpResizePanels(panel);
// panel.setSize(this.getSize());
return panel;
}

Expand All @@ -259,36 +258,15 @@ private void setUpResizePanels(JPanel root){
rightPanel.setBackground(AppThemeColor.FRAME);
rightPanel.add(rightArrow,BorderLayout.CENTER);

rightPanel.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
rightPanel.setBackground(AppThemeColor.TEXT_DISABLE);
}

@Override
public void mouseReleased(MouseEvent e) {
rightPanel.setBackground(AppThemeColor.FRAME);
}
});
rightPanel.addMouseListener(new ArrowMouseListener(rightPanel,new Cursor(Cursor.E_RESIZE_CURSOR)));
rightPanel.addMouseMotionListener(new ResizeByWidthMouseMotionListener());

JLabel downArrow = componentsFactory.getIconLabel("app/expand-mp.png",16); //todo
JPanel downPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER));
downPanel.setBorder(BorderFactory.createEmptyBorder(-10,0,0,0));
downPanel.setBackground(AppThemeColor.FRAME);
downPanel.add(downArrow);

downPanel.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
downPanel.setBackground(AppThemeColor.TEXT_DISABLE);
}

@Override
public void mouseReleased(MouseEvent e) {
downPanel.setBackground(AppThemeColor.FRAME);
}
});
downPanel.addMouseListener(new ArrowMouseListener(downPanel, new Cursor(Cursor.N_RESIZE_CURSOR)));
downPanel.addMouseMotionListener(new ResizeByHeightMouseMotionListener());

root.add(rightPanel,BorderLayout.LINE_END);
Expand Down Expand Up @@ -320,4 +298,33 @@ public void mouseDragged(MouseEvent e) {
configManager.saveFrameSize(ItemsGridFrame.class.getSimpleName(),getSize());
}
}
private class ArrowMouseListener extends MouseAdapter {
private JPanel panel;
private Cursor cursor;

private ArrowMouseListener(JPanel panel, Cursor cursor) {
this.panel = panel;
this.cursor = cursor;
}

@Override
public void mousePressed(MouseEvent e) {
panel.setBackground(AppThemeColor.TEXT_DISABLE);
}

@Override
public void mouseReleased(MouseEvent e) {
panel.setBackground(AppThemeColor.FRAME);
}

@Override
public void mouseEntered(MouseEvent e) {
setCursor(cursor);
}

@Override
public void mouseExited(MouseEvent e) {
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private JPanel getTaskBarPanel(){
true
);

JButton itemGrid = componentsFactory.getIconButton("app/item-grid-enable.png",24,AppThemeColor.FRAME_ALPHA, TooltipConstants.VISIBLE_MODE);
JButton itemGrid = componentsFactory.getIconButton("app/item-grid-enable.png",24,AppThemeColor.FRAME_ALPHA, TooltipConstants.ITEM_GRID);
itemGrid.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
Expand All @@ -107,19 +107,6 @@ public void mousePressed(MouseEvent e) {
}
}
});
// componentsFactory.setUpToggleCallbacks(itemGrid,
// () -> {
// itemGrid.setIcon(componentsFactory.getIcon("app/item-grid-enable.png", 24));
// TaskBarFrame.this.repaint();
// FramesManager.INSTANCE.enableMovementDirect("ItemsGridFrame");
// },
// () -> {
// itemGrid.setIcon(componentsFactory.getIcon("app/item-grid-disable.png", 24));
// TaskBarFrame.this.repaint();
// FramesManager.INSTANCE.disableMovement("ItemsGridFrame");
// },
// true
// );

JButton toHideOut = componentsFactory.getIconButton("app/hideout.png",24,AppThemeColor.FRAME_ALPHA,TooltipConstants.HIDEOUT);
toHideOut.addActionListener(action -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class TooltipConstants {
public static final String HISTORY = "History. Browse through all notifications you received previously.";
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 EXIT = "Exit";

//Timer tooltips
Expand Down

0 comments on commit 17f60d2

Please sign in to comment.