Browse Source

REPORT-51958 远程环境检测及同步

feature/10.0
pengda 4 years ago
parent
commit
7d5d567597
  1. 5
      designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java
  2. 1
      designer-base/src/main/java/com/fr/design/gui/UILookAndFeel.java
  3. 2
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  4. 4
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  5. 40
      designer-base/src/main/java/com/fr/design/notification/Notification.java
  6. 33
      designer-base/src/main/java/com/fr/design/notification/NotificationCenter.java
  7. 222
      designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterDialog.java
  8. 54
      designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterPane.java
  9. 14
      designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java
  10. 5
      designer-realize/src/main/java/com/fr/start/MainDesigner.java

5
designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java

@ -4,6 +4,8 @@ package com.fr.design.dialog;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.notification.Notification;
import com.fr.design.notification.NotificationCenter;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
@ -46,6 +48,7 @@ public class NotificationDialog extends JDialog {
} }
public void initComponents(int messageType, String message, boolean isModal,NotificationDialogAction action) { public void initComponents(int messageType, String message, boolean isModal,NotificationDialogAction action) {
NotificationCenter.getInstance().addNotification(new Notification(messageType,message,action));
notificationDialogAction = action; notificationDialogAction = action;
setModal(isModal); setModal(isModal);
setResizable(false); setResizable(false);
@ -116,7 +119,7 @@ public class NotificationDialog extends JDialog {
propertyName = "OptionPane.newMessageIcon"; propertyName = "OptionPane.newMessageIcon";
break; break;
case 2: case 2:
propertyName = "OptionPane.warningIcon"; propertyName = "OptionPane.circularWarningIcon";
break; break;
default: default:
return null; return null;

1
designer-base/src/main/java/com/fr/design/gui/UILookAndFeel.java

@ -179,6 +179,7 @@ public class UILookAndFeel extends MetalLookAndFeel {
table.put("OptionPane.circularWarningIcon", loadIcon("circularWarningIcon.png", this)); table.put("OptionPane.circularWarningIcon", loadIcon("circularWarningIcon.png", this));
table.put("OptionPane.newMessageIcon", loadIcon("newMessageIcon.png", this)); table.put("OptionPane.newMessageIcon", loadIcon("newMessageIcon.png", this));
table.put("OptionPane.circularErrorIcon", loadIcon("circularErrorIcon.png", this)); table.put("OptionPane.circularErrorIcon", loadIcon("circularErrorIcon.png", this));
table.put("OptionPane.deleteIcon", loadIcon("deleteIcon.png", this));
table.put("OptionPane.questionIcon", loadIcon("QuestionIcon.png", this)); table.put("OptionPane.questionIcon", loadIcon("QuestionIcon.png", this));
table.put("OptionPane.tipIcon", loadIcon("TipIcon.png", this)); table.put("OptionPane.tipIcon", loadIcon("TipIcon.png", this));
table.put("ScrollPane.border", new UIScrollPaneBorder()); table.put("ScrollPane.border", new UIScrollPaneBorder());

2
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -486,6 +486,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
if (!DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) { if (!DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) {
ad.createAlphaFinePane().setVisible(false); ad.createAlphaFinePane().setVisible(false);
} }
northEastPane.add(ad.createNotificationCenterPane());
OSSupportCenter.buildAction(new OSBasedAction() { OSSupportCenter.buildAction(new OSBasedAction() {
@Override @Override
public void execute(Object... objects) { public void execute(Object... objects) {

4
designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -465,6 +465,10 @@ public abstract class ToolBarMenuDock {
return new UILabel(); return new UILabel();
} }
public Component createNotificationCenterPane(){
return new UILabel();
}
protected MenuDef createServerMenuDef(ToolBarMenuDockPlus plus) { protected MenuDef createServerMenuDef(ToolBarMenuDockPlus plus) {
MenuDef menuDef = new MenuDef(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic__M_Server"), 'S'); MenuDef menuDef = new MenuDef(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic__M_Server"), 'S');

40
designer-base/src/main/java/com/fr/design/notification/Notification.java

@ -0,0 +1,40 @@
package com.fr.design.notification;
import com.fr.design.dialog.NotificationDialogAction;
public class Notification {
private int type;
private String message;
private NotificationDialogAction notificationDialogAction;
public static final int ERROR_MESSAGE = 0;
public static final int NEW_MESSAGE = 1;
public static final int WARNING_MESSAGE = 2;
public Notification(int type,String message,NotificationDialogAction notificationDialogAction){
this.type = type;
this.message = message;
this.notificationDialogAction = notificationDialogAction;
}
public Notification(String message){
this.type = WARNING_MESSAGE;
this.message = message;
this.notificationDialogAction = new NotificationDialogAction() {
@Override
public void doClick() {
//do nothing
}
};
}
public NotificationDialogAction getNotificationDialogAction() {
return notificationDialogAction;
}
public int getType(){
return type;
}
public String getMessage(){
return message;
}
}

33
designer-base/src/main/java/com/fr/design/notification/NotificationCenter.java

@ -0,0 +1,33 @@
package com.fr.design.notification;
import com.fr.design.notification.ui.NotificationCenterPane;
import java.util.ArrayList;
import java.util.List;
public class NotificationCenter {
private static NotificationCenter notificationCenter = new NotificationCenter();
private List<Notification> notifications;
private NotificationCenter(){
notifications = new ArrayList<>();
}
public static NotificationCenter getInstance(){
return notificationCenter;
}
public void addNotification(Notification message){
notifications.add(message);
NotificationCenterPane.getNotificationCenterPane().refreshButton();
}
public List<Notification> getNotifications(){
return notifications;
}
public void clearAllNotifications(){
notifications.clear();
NotificationCenterPane.getNotificationCenterPane().refreshButton();
}
}

222
designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterDialog.java

@ -0,0 +1,222 @@
package com.fr.design.notification.ui;
import com.fr.design.dialog.NotificationDialogAction;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.notification.Notification;
import com.fr.design.notification.NotificationCenter;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.UIManager;
public class NotificationCenterDialog extends JDialog {
private ArrayList<NotificationPane> notificationNeedShow;
private JPanel centerPanel;
private UILabel deleteLabel;
private static final int NOTIFICATIONCOUNT = 5;
public NotificationCenterDialog(Frame parent) {
super(parent, true);
setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Notification"));
setResizable(false);
notificationNeedShow = new ArrayList<>();
initComponents();
}
public void initComponents() {
centerPanel = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(1);
addNotification();
deleteLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Clear_Notifications") + "(" + NotificationCenter.getInstance().getNotifications().size() + ")");
deleteLabel.setForeground(Color.BLUE);
deleteLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
NotificationCenter.getInstance().clearAllNotifications();
centerPanel.removeAll();
addNotification();
pack();
deleteLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Clear_Notifications") + "(" + NotificationCenter.getInstance().getNotifications().size() + ")");
if (notificationNeedShow.size() == 0) {
hideDialog();
}
}
});
JPanel deletePane = new JPanel(FRGUIPaneFactory.createCenterFlowLayout());
deletePane.add(deleteLabel);
deletePane.setPreferredSize(new Dimension(240, 30));
add(centerPanel, BorderLayout.CENTER);
add(deletePane, BorderLayout.SOUTH);
pack();
centerWindow();
}
private void hideDialog() {
this.dispose();
}
private void addNotification() {
notificationNeedShow.clear();
List<Notification> notifications = NotificationCenter.getInstance().getNotifications();
int size = notifications.size();
for (int i = NOTIFICATIONCOUNT; i > 0; i--) {
int j = size - i;
if (j >= 0) {
Notification notification = notifications.get(j);
NotificationPane notificationPane = new NotificationPane(notification.getType(), notification.getMessage(), i, notification.getNotificationDialogAction());
notificationNeedShow.add(notificationPane);
}
}
size = notificationNeedShow.size();
for (int i = size - 1; i >= 0; i--) {
centerPanel.add(notificationNeedShow.get(i));
}
}
private void centerWindow() {
Window win = this;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension winSize = win.getSize();
if (winSize.height > screenSize.height) {
winSize.height = screenSize.height;
}
if (winSize.width > screenSize.width) {
winSize.width = screenSize.width;
}
//这里设置位置:水平居中,竖直偏上
win.setLocation(screenSize.width - winSize.width - 90, 50);
}
/**
* 一条消息面板
*/
class NotificationPane extends JPanel {
private int index;
private UILabel messageLabel;
private UILabel messageIcon;
private NotificationDialogAction notificationDialogAction;
public NotificationPane(int type, String message, int index, NotificationDialogAction notificationDialogAction) {
this.index = index;
this.notificationDialogAction = notificationDialogAction;
this.setLayout(FRGUIPaneFactory.createBorderLayout());
setTypeIcon(getIconForType(type));
setNotification(message);
setDeleteIcon();
}
public void setTypeIcon(Icon icon) {
messageIcon = new UILabel(icon);
messageIcon.addMouseListener(messageAndIconListener);
JPanel messageIconPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
messageIconPanel.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8));
messageIconPanel.add(messageIcon);
add(messageIconPanel, BorderLayout.WEST);
}
public void setDeleteIcon() {
UILabel deleteIcon = new UILabel(UIManager.getIcon("OptionPane.deleteIcon"));
JPanel deleteIconPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
deleteIconPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 7));
deleteIconPane.add(deleteIcon);
deleteIconPane.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
NotificationCenter.getInstance().getNotifications().remove(NotificationCenter.getInstance().getNotifications().size() - index);
centerPanel.removeAll();
addNotification();
deleteLabel.setText("清除所有消息" + "(" + NotificationCenter.getInstance().getNotifications().size() + ")");
pack();
if (notificationNeedShow.size() == 0) {
centerWindow();
}
NotificationCenterPane.getNotificationCenterPane().refreshButton();
}
@Override
public void mouseEntered(MouseEvent e) {
deleteIcon.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
@Override
public void mouseExited(MouseEvent e) {
deleteIcon.setCursor(Cursor.getDefaultCursor());
}
});
add(deleteIconPane, BorderLayout.EAST);
}
public int getIndex() {
return index;
}
public void setNotification(String message) {
messageLabel = new UILabel("<html>" + message + "</html>");
messageLabel.addMouseListener(messageAndIconListener);
JPanel labelPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
labelPanel.add(messageLabel);
this.add(labelPanel, BorderLayout.CENTER);
}
protected Icon getIconForType(int messageType) {
String propertyName;
switch (messageType) {
case 0:
propertyName = "OptionPane.circularErrorIcon";
break;
case 1:
propertyName = "OptionPane.newMessageIcon";
break;
case 2:
propertyName = "OptionPane.circularWarningIcon";
break;
default:
return null;
}
return UIManager.getIcon(propertyName);
}
private MouseListener messageAndIconListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
hideDialog();
notificationDialogAction.doClick();
}
@Override
public void mouseEntered(MouseEvent e) {
messageLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
messageIcon.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
messageLabel.setForeground(new Color(250, 170, 57));
}
@Override
public void mouseExited(MouseEvent e) {
messageLabel.setCursor(Cursor.getDefaultCursor());
messageIcon.setCursor(Cursor.getDefaultCursor());
messageLabel.setForeground(Color.BLACK);
}
};
}
}

54
designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterPane.java

@ -0,0 +1,54 @@
package com.fr.design.notification.ui;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.notification.NotificationCenter;
import com.fr.general.IOUtils;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class NotificationCenterPane extends BasicPane {
private static NotificationCenterPane notificationCenterPane = new NotificationCenterPane();
private static UIButton notificationCenterButton;
private NotificationCenterPane() {
setPreferredSize(new Dimension(24, 24));
setLayout(new BorderLayout());
notificationCenterButton = new UIButton();
notificationCenterButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/notificationcenter/notificationCenter.png"));
notificationCenterButton.setToolTipText(Toolkit.i18nText("显示当前通知"));
notificationCenterButton.set4ToolbarButton();
notificationCenterButton.setRolloverEnabled(false);
this.add(notificationCenterButton);
notificationCenterButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
NotificationCenterDialog notificationCenterDialog = new NotificationCenterDialog(DesignerContext.getDesignerFrame());
notificationCenterDialog.setVisible(true);
}
});
this.setBackground(UIConstants.TEMPLATE_TAB_PANE_BACKGROUND);
}
public static NotificationCenterPane getNotificationCenterPane() {
return notificationCenterPane;
}
public void refreshButton() {
if (NotificationCenter.getInstance().getNotifications().size() > 0) {
notificationCenterButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/notificationcenter/normal.png"));
} else {
notificationCenterButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/notificationcenter/notificationCenter.png"));
}
}
@Override
protected String title4PopupWindow() {
return "NotificationCenter";
}
}

14
designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java

@ -2,11 +2,14 @@ package com.fr.design.versioncheck;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.NotificationDialog;
import com.fr.design.dialog.NotificationDialogAction;
import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.RemoteWorkspace; import com.fr.design.env.RemoteWorkspace;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.env.CheckServiceDialog;
import com.fr.env.VersionCheckMessageDialog; import com.fr.env.VersionCheckMessageDialog;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
@ -68,8 +71,15 @@ public class VersionCheckUtils {
public static void showVersionCheckDialog(String envName) { public static void showVersionCheckDialog(String envName) {
if (!VersionCheckUtils.versionCheck(envName)) { if (!VersionCheckUtils.versionCheck(envName)) {
VersionCheckMessageDialog versionCheckMessageDialog = new VersionCheckMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Sync_Check_Brief_Info"), envName); NotificationDialog notificationDialog = new NotificationDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Sync_Prompt"),
versionCheckMessageDialog.setVisible(true); true, NotificationDialog.WARNING_MESSAGE, Toolkit.i18nText("Fine-Design_Basic_Sync_Check_Brief_Info"), new NotificationDialogAction() {
@Override
public void doClick() {
CheckServiceDialog checkServiceDialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), GeneralUtils.readFullBuildNO(), getRemoteBranch(envName),getNoExistServiceDescription(envName));
checkServiceDialog.setVisible(true);
}
});
notificationDialog.setVisible(true);
} }
} }

5
designer-realize/src/main/java/com/fr/start/MainDesigner.java

@ -29,6 +29,7 @@ import com.fr.design.mainframe.JWorkBook;
import com.fr.design.mainframe.alphafine.component.AlphaFinePane; import com.fr.design.mainframe.alphafine.component.AlphaFinePane;
import com.fr.design.mainframe.bbs.UserInfoLabel; import com.fr.design.mainframe.bbs.UserInfoLabel;
import com.fr.design.mainframe.bbs.UserInfoPane; import com.fr.design.mainframe.bbs.UserInfoPane;
import com.fr.design.notification.ui.NotificationCenterPane;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.MenuDef; import com.fr.design.menu.MenuDef;
@ -413,6 +414,10 @@ public class MainDesigner extends BaseDesigner {
return AlphaFinePane.getAlphaFinePane(); return AlphaFinePane.getAlphaFinePane();
} }
public Component createNotificationCenterPane(){
return NotificationCenterPane.getNotificationCenterPane();
}
/** /**
* 收集用户信息吗 * 收集用户信息吗
*/ */

Loading…
Cancel
Save