Browse Source

REPORT-9221 10.0插件兼容-版本管理

research/10.0
hzzz 6 years ago
parent
commit
e8a5d074a4
  1. 8
      designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java
  2. 24
      designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java
  3. 27
      designer-base/src/main/java/com/fr/design/file/NewTemplatePane.java
  4. 14
      designer-base/src/main/java/com/fr/design/fun/TemplateTreeShortCutProvider.java
  5. 26
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractTemplateTreeShortCutProvider.java
  6. 274
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  7. 36
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  8. 8
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  9. 36
      designer-base/src/main/java/com/fr/design/mainframe/ToolBarNewTemplatePane.java
  10. 49
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  11. 45
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/VcsScene.java
  12. 7
      designer-base/src/main/java/com/fr/design/menu/ShortCut.java
  13. 6
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  14. 9
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java
  15. 7
      designer-realize/src/main/java/com/fr/start/Designer.java

8
designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java

@ -1,6 +1,7 @@
package com.fr.design.actions.file; package com.fr.design.actions.file;
import com.fr.base.extension.FileExtension; import com.fr.base.extension.FileExtension;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.fun.PreviewProvider; import com.fr.design.fun.PreviewProvider;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
@ -15,6 +16,7 @@ import com.fr.stable.web.AbstractWebletCreator;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
public final class WebPreviewUtils { public final class WebPreviewUtils {
@ -34,6 +36,12 @@ public final class WebPreviewUtils {
return; return;
} }
if (map == null || map == Collections.EMPTY_MAP) {
map = new HashMap<>();
}
if (DesignerMode.isVcsMode()) {
map.put("mode", DesignerMode.getMode().toString());
}
DesignerContext.getDesignerFrame().refreshToolbar(); DesignerContext.getDesignerFrame().refreshToolbar();
jt.stopEditing(); jt.stopEditing();

24
designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java

@ -3,6 +3,7 @@ package com.fr.design.file;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.GraphHelper; import com.fr.base.GraphHelper;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.imenu.UIScrollPopUpMenu; import com.fr.design.gui.imenu.UIScrollPopUpMenu;
@ -313,6 +314,15 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
} }
public void paint(Graphics g) {
//不可见时,按钮.4f透明
AlphaComposite composite = DesignerMode.isVcsMode()
? AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f)
: (AlphaComposite) ((Graphics2D) g).getComposite();
((Graphics2D) g).setComposite(composite);
super.paint(g);
}
private void paintBackgroundAndLine(Graphics2D g2d, double maxWidth) { private void paintBackgroundAndLine(Graphics2D g2d, double maxWidth) {
paintDefaultBackground(g2d); paintDefaultBackground(g2d);
//最多能画的个数 //最多能画的个数
@ -359,7 +369,9 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
templateStartX += realWidth; templateStartX += realWidth;
} }
if (!DesignerMode.isVcsMode()) {
paintListDown(g2d, maxWidth); paintListDown(g2d, maxWidth);
}
paintUnderLine(templateStartX, maxWidth, g2d); paintUnderLine(templateStartX, maxWidth, g2d);
} }
@ -538,7 +550,9 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
g2d.drawString(sheetName, (int) templateStartX + sheeticon.getIconWidth() + 2 * GAP, getHeight() - GAP * 2); g2d.drawString(sheetName, (int) templateStartX + sheeticon.getIconWidth() + 2 * GAP, getHeight() - GAP * 2);
int closePosition = (int) templateStartX + realWidth - CLOSE.getIconWidth() - SMALLGAP; int closePosition = (int) templateStartX + realWidth - CLOSE.getIconWidth() - SMALLGAP;
int closeY = (getHeight() - closeIcon.getIconHeight()) / 2; int closeY = (getHeight() - closeIcon.getIconHeight()) / 2;
if (!DesignerMode.isVcsMode()) {
closeIcon.paintIcon(this, g2d, closePosition, closeY); closeIcon.paintIcon(this, g2d, closePosition, closeY);
}
return closePosition; return closePosition;
} }
@ -594,7 +608,9 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
g2d.drawString(sheetName, (int) templateStartX + sheeticon.getIconWidth() + 2 * GAP, getHeight() - GAP * 2); g2d.drawString(sheetName, (int) templateStartX + sheeticon.getIconWidth() + 2 * GAP, getHeight() - GAP * 2);
int closeY = (getHeight() - closeIcon.getIconHeight()) / 2; int closeY = (getHeight() - closeIcon.getIconHeight()) / 2;
int closePosition = (int) templateStartX + realWidth - CLOSE.getIconWidth() - SMALLGAP; int closePosition = (int) templateStartX + realWidth - CLOSE.getIconWidth() - SMALLGAP;
if (!DesignerMode.isVcsMode()) {
closeIcon.paintIcon(this, g2d, closePosition, closeY); closeIcon.paintIcon(this, g2d, closePosition, closeY);
}
return closePosition; return closePosition;
} }
@ -640,6 +656,10 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
//如果在版本管理情况下,不允许切换tab
if (DesignerMode.isVcsMode()) {
return;
}
int evtX = e.getX(); int evtX = e.getX();
int evtY = e.getY(); int evtY = e.getY();
@ -672,7 +692,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
openedTemplate.get(selectedIndex).stopEditing(); openedTemplate.get(selectedIndex).stopEditing();
selectedIndex = getTemplateIndex(evtX); selectedIndex = getTemplateIndex(evtX);
//如果在权限编辑情况下,不允许切换到表单类型的工作簿 //如果在权限编辑情况下,不允许切换到表单类型的工作簿
if (BaseUtils.isAuthorityEditing() && !openedTemplate.get(selectedIndex).isJWorkBook()) { if (DesignerMode.isAuthorityEditing() && !openedTemplate.get(selectedIndex).isJWorkBook()) {
DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(tempSelectedIndex)); DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(tempSelectedIndex));
JOptionPane.showMessageDialog(this, com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Form-AuthorityEdited_Cannot_be_Supported") JOptionPane.showMessageDialog(this, com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Form-AuthorityEdited_Cannot_be_Supported")
+ "!", com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Alert"), JOptionPane.WARNING_MESSAGE); + "!", com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Alert"), JOptionPane.WARNING_MESSAGE);
@ -712,7 +732,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
filename = OperatingSystem.isWindows() ? filename.replaceAll("/", "\\\\") : filename.replaceAll("\\\\", "/"); filename = OperatingSystem.isWindows() ? filename.replaceAll("/", "\\\\") : filename.replaceAll("\\\\", "/");
if (!specifiedTemplate.isALLSaved()) { if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) {
specifiedTemplate.stopEditing(); specifiedTemplate.stopEditing();
int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Utils-Would_you_like_to_save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Utils-Would_you_like_to_save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?",
ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);

27
designer-base/src/main/java/com/fr/design/file/NewTemplatePane.java

@ -1,6 +1,7 @@
package com.fr.design.file; package com.fr.design.file;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
@ -20,11 +21,10 @@ import java.awt.geom.Rectangle2D;
public abstract class NewTemplatePane extends JComponent implements MouseListener, MouseMotionListener { public abstract class NewTemplatePane extends JComponent implements MouseListener, MouseMotionListener {
private static final Icon GRAY_NEW_CPT = BaseUtils.readIcon("/com/fr/design/images/buttonicon/additicon_grey.png"); private static final Icon GRAY_NEW_CPT = BaseUtils.readIcon("/com/fr/design/images/buttonicon/additicon_grey.png");
private static final int PRE_GAP = 0; private static final int ICON_START_X = 5;
private static final int HEIGHT = 26; private static final int HEIGHT = 26;
private Graphics2D g2d; private Graphics2D g2d;
private Icon newWorkBookIconMode = null; private Icon newWorkBookIconMode = null;
private int newIconStartX = PRE_GAP;
public NewTemplatePane() { public NewTemplatePane() {
@ -49,7 +49,7 @@ public abstract class NewTemplatePane extends JComponent implements MouseListene
g2d.setColor(UIConstants.TEMPLATE_TAB_PANE_BACKGROUND); g2d.setColor(UIConstants.TEMPLATE_TAB_PANE_BACKGROUND);
g2d.fill(new Rectangle2D.Double(0, 0, getWidth(),getHeight())); g2d.fill(new Rectangle2D.Double(0, 0, getWidth(),getHeight()));
int sheetIconY = (getHeight() - newWorkBookIconMode.getIconHeight()) / 2; int sheetIconY = (getHeight() - newWorkBookIconMode.getIconHeight()) / 2;
newWorkBookIconMode.paintIcon(this, g2d, newIconStartX, sheetIconY); newWorkBookIconMode.paintIcon(this, g2d, ICON_START_X, sheetIconY);
// paintUnderLine(g2d); // paintUnderLine(g2d);
} }
@ -65,7 +65,7 @@ public abstract class NewTemplatePane extends JComponent implements MouseListene
* @param e 事件 * @param e 事件
*/ */
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if (BaseUtils.isAuthorityEditing()) { if (needGrayNewCpt()) {
newWorkBookIconMode = GRAY_NEW_CPT; newWorkBookIconMode = GRAY_NEW_CPT;
} }
} }
@ -76,12 +76,11 @@ public abstract class NewTemplatePane extends JComponent implements MouseListene
*/ */
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
int evtX = e.getX(); int evtX = e.getX();
if (BaseUtils.isAuthorityEditing()) { if (needGrayNewCpt()) {
newWorkBookIconMode = GRAY_NEW_CPT; newWorkBookIconMode = GRAY_NEW_CPT;
} }
if (isOverNewIcon(evtX) && newWorkBookIconMode != GRAY_NEW_CPT) { if (isOverNewIcon(evtX) && newWorkBookIconMode != GRAY_NEW_CPT) {
newWorkBookIconMode = getMousePressNew(); newWorkBookIconMode = getMousePressNew();
newIconStartX = 0;
DesignerContext.getDesignerFrame().addAndActivateJTemplate(); DesignerContext.getDesignerFrame().addAndActivateJTemplate();
} }
this.repaint(); this.repaint();
@ -92,7 +91,7 @@ public abstract class NewTemplatePane extends JComponent implements MouseListene
* @param e 事件 * @param e 事件
*/ */
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
if (BaseUtils.isAuthorityEditing()) { if (needGrayNewCpt()) {
newWorkBookIconMode = GRAY_NEW_CPT; newWorkBookIconMode = GRAY_NEW_CPT;
} }
} }
@ -102,7 +101,7 @@ public abstract class NewTemplatePane extends JComponent implements MouseListene
* @param e 事件 * @param e 事件
*/ */
public void mouseEntered(MouseEvent e) { public void mouseEntered(MouseEvent e) {
if (BaseUtils.isAuthorityEditing()) { if (needGrayNewCpt()) {
newWorkBookIconMode = GRAY_NEW_CPT; newWorkBookIconMode = GRAY_NEW_CPT;
} }
} }
@ -112,8 +111,7 @@ public abstract class NewTemplatePane extends JComponent implements MouseListene
* @param e 事件 * @param e 事件
*/ */
public void mouseExited(MouseEvent e) { public void mouseExited(MouseEvent e) {
newIconStartX = PRE_GAP; if (needGrayNewCpt()) {
if (BaseUtils.isAuthorityEditing()) {
newWorkBookIconMode = GRAY_NEW_CPT; newWorkBookIconMode = GRAY_NEW_CPT;
} else { } else {
newWorkBookIconMode = getNew(); newWorkBookIconMode = getNew();
@ -135,10 +133,9 @@ public abstract class NewTemplatePane extends JComponent implements MouseListene
*/ */
public void mouseMoved(MouseEvent e) { public void mouseMoved(MouseEvent e) {
int evtX = e.getX(); int evtX = e.getX();
if (BaseUtils.isAuthorityEditing()) { if (needGrayNewCpt()) {
newWorkBookIconMode = GRAY_NEW_CPT; newWorkBookIconMode = GRAY_NEW_CPT;
} else if (isOverNewIcon(evtX)) { } else if (isOverNewIcon(evtX)) {
newIconStartX = 0;
newWorkBookIconMode = getMouseOverNew(); newWorkBookIconMode = getMouseOverNew();
} }
@ -146,9 +143,13 @@ public abstract class NewTemplatePane extends JComponent implements MouseListene
} }
private boolean needGrayNewCpt() {
return DesignerMode.isAuthorityEditing() || DesignerMode.isVcsMode();
}
private boolean isOverNewIcon(int evtX) { private boolean isOverNewIcon(int evtX) {
return (evtX >= PRE_GAP && evtX <= PRE_GAP + newWorkBookIconMode.getIconWidth()); return (evtX >= ICON_START_X && evtX <= ICON_START_X + newWorkBookIconMode.getIconWidth());
} }
public void setButtonGray(boolean isGray) { public void setButtonGray(boolean isGray) {

14
designer-base/src/main/java/com/fr/design/fun/TemplateTreeShortCutProvider.java

@ -0,0 +1,14 @@
package com.fr.design.fun;
import com.fr.stable.fun.mark.Aftermath;
import com.fr.stable.fun.mark.Mutable;
/**
* 左上角目录树上边工具条的插件接口
* Created by hzzz on 2017/11/30.
*/
public interface TemplateTreeShortCutProvider extends Mutable, Aftermath {
String XML_TAG = "TemplateTreeShortCut";
int CURRENT_LEVEL = 1;
}

26
designer-base/src/main/java/com/fr/design/fun/impl/AbstractTemplateTreeShortCutProvider.java

@ -0,0 +1,26 @@
package com.fr.design.fun.impl;
import com.fr.design.actions.UpdateAction;
import com.fr.design.fun.TemplateTreeShortCutProvider;
import com.fr.stable.fun.mark.API;
/**
* 左上角目录树上边工具条的插件接口
* Created by hzzz on 2017/11/30.
*/
@API(level = TemplateTreeShortCutProvider.CURRENT_LEVEL)
public abstract class AbstractTemplateTreeShortCutProvider extends UpdateAction implements TemplateTreeShortCutProvider {
@Override
public String mark4Provider() {
return getClass().getName();
}
@Override
public void process() {
}
@Override
public void undo() {
}
}

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

@ -4,18 +4,16 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState; import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.file.SwitchExistEnv;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.event.DesignerOpenedListener; import com.fr.design.event.DesignerOpenedListener;
import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener; import com.fr.design.event.TargetModifiedListener;
@ -28,6 +26,7 @@ import com.fr.design.fun.TitlePlaceProcessor;
import com.fr.design.fun.impl.AbstractTemplateTreeShortCutProvider; import com.fr.design.fun.impl.AbstractTemplateTreeShortCutProvider;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UIMenuHighLight; import com.fr.design.gui.imenu.UIMenuHighLight;
import com.fr.design.gui.iprogressbar.ProgressDialog;
import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
@ -43,10 +42,9 @@ import com.fr.file.FILEFactory;
import com.fr.file.FileFILE; import com.fr.file.FileFILE;
import com.fr.file.FileNodeFILE; import com.fr.file.FileNodeFILE;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.Inter;
import com.fr.general.env.EnvContext; import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginContext;
import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.manage.PluginFilter;
@ -56,12 +54,30 @@ import com.fr.stable.CoreConstants;
import com.fr.stable.OperatingSystem; import com.fr.stable.OperatingSystem;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.image4j.codec.ico.ICODecoder; import com.fr.stable.image4j.codec.ico.ICODecoder;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import javax.swing.*; import com.fr.workspace.Workspace;
import com.fr.workspace.connect.WorkspaceConnection;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLayeredPane;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
import javax.swing.border.MatteBorder; import javax.swing.border.MatteBorder;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable; import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants; import java.awt.dnd.DnDConstants;
@ -85,40 +101,54 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
public class DesignerFrame extends JFrame implements JTemplateActionListener, TargetModifiedListener { public class DesignerFrame extends JFrame implements JTemplateActionListener, TargetModifiedListener {
public static final String DESIGNER_FRAME_NAME = "designer_frame"; public static final String DESIGNER_FRAME_NAME = "designer_frame";
public static final Dimension MIN_SIZE = new Dimension(100, 100); public static final Dimension MIN_SIZE = new Dimension(100, 100);
private static final long serialVersionUID = -8732559571067484460L; private static final long serialVersionUID = -8732559571067484460L;
private static final int LEFT_ALIGN_GAP = -5; private static final int LEFT_ALIGN_GAP = -5;
private static final int MENU_HEIGHT = 26; private static final int MENU_HEIGHT = 26;
private static final Integer SECOND_LAYER = new Integer(100); private static final Integer SECOND_LAYER = new Integer(100);
private static final Integer TOP_LAYER = new Integer((200)); private static final Integer TOP_LAYER = new Integer((200));
private static java.util.List<App<?>> appList = new java.util.ArrayList<App<?>>(); private static java.util.List<App<?>> appList = new java.util.ArrayList<App<?>>();
private List<DesignerOpenedListener> designerOpenedListenerList = new ArrayList<>(); private List<DesignerOpenedListener> designerOpenedListenerList = new ArrayList<>();
//顶部日志+登陆按钮 private ToolBarMenuDock ad;
private static final JPanel northEastPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
private static ToolBarMenuDock ad;
private DesktopCardPane centerTemplateCardPane; private DesktopCardPane centerTemplateCardPane;
private JPanel toolbarPane; private JPanel toolbarPane;
private JComponent toolbarComponent; private JComponent toolbarComponent;
private JPanel menuPane; private JPanel menuPane;
private JMenuBar menuBar; private JMenuBar menuBar;
private JPanel eastCenterPane; private JPanel eastCenterPane;
private UIToolbar combineUp; private UIToolbar combineUp;
private NewTemplatePane newWorkBookPane = null; private NewTemplatePane newWorkBookPane = null;
private Icon closeMode = UIConstants.CLOSE_OF_AUTHORITY; private Icon closeMode = UIConstants.CLOSE_OF_AUTHORITY;
private JLayeredPane layeredPane = this.getLayeredPane(); private JLayeredPane layeredPane = this.getLayeredPane();
private JPanel basePane = new JPanel(); private JPanel basePane = new JPanel();
// 上面的虚线 // 上面的虚线
private DottedLine upDottedLine; private DottedLine upDottedLine;
// 下面的虚线 // 下面的虚线
private DottedLine downDottedLine; private DottedLine downDottedLine;
@ -129,18 +159,18 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
private DottedLine rightDottedLine; private DottedLine rightDottedLine;
private int contentWidth = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth()); private int contentWidth = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth());
private int contentHeight = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight()); private int contentHeight = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight());
private WindowAdapter windowAdapter = new WindowAdapter() { private WindowAdapter windowAdapter = new WindowAdapter() {
public void windowOpened(WindowEvent e) { public void windowOpened(WindowEvent e) {
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setComposite();
reCalculateFrameSize();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().doResize();
} }
@Override @Override
public void windowClosing(WindowEvent e) { public void windowClosing(WindowEvent e) {
SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true); SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true);
// 只有一个文件未保存时 // 只有一个文件未保存时
if (HistoryTemplateListPane.getInstance().getHistoryCount() == 1) { if (HistoryTemplateListPane.getInstance().getHistoryCount() == 1) {
@ -158,7 +188,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}; };
private JComponent closeButton = new JComponent() { private JComponent closeButton = new JComponent() {
protected void paintComponent(Graphics g) { protected void paintComponent(Graphics g) {
g.setColor(UIConstants.NORMAL_BACKGROUND); g.setColor(UIConstants.NORMAL_BACKGROUND);
g.fillArc(0, 0, UIConstants.CLOSE_AUTHORITY_HEIGHT_AND_WIDTH, UIConstants.CLOSE_AUTHORITY_HEIGHT_AND_WIDTH, g.fillArc(0, 0, UIConstants.CLOSE_AUTHORITY_HEIGHT_AND_WIDTH, UIConstants.CLOSE_AUTHORITY_HEIGHT_AND_WIDTH,
0, 360); 0, 360);
@ -167,19 +199,23 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}; };
private MouseListener closeMouseListener = new MouseAdapter() { private MouseListener closeMouseListener = new MouseAdapter() {
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
closeMode = UIConstants.CLOSE_PRESS_AUTHORITY; closeMode = UIConstants.CLOSE_PRESS_AUTHORITY;
closeButton.setBackground(UIConstants.NORMAL_BACKGROUND); closeButton.setBackground(UIConstants.NORMAL_BACKGROUND);
closeButton.repaint(); closeButton.repaint();
} }
public void mouseExited(MouseEvent e) { public void mouseExited(MouseEvent e) {
closeMode = UIConstants.CLOSE_OF_AUTHORITY; closeMode = UIConstants.CLOSE_OF_AUTHORITY;
closeButton.setBackground(UIConstants.NORMAL_BACKGROUND); closeButton.setBackground(UIConstants.NORMAL_BACKGROUND);
closeButton.repaint(); closeButton.repaint();
} }
public void mouseMoved(MouseEvent e) { public void mouseMoved(MouseEvent e) {
closeMode = UIConstants.CLOSE_OVER_AUTHORITY; closeMode = UIConstants.CLOSE_OVER_AUTHORITY;
closeButton.setBackground(UIConstants.NORMAL_BACKGROUND); closeButton.setBackground(UIConstants.NORMAL_BACKGROUND);
closeButton.repaint(); closeButton.repaint();
@ -200,12 +236,15 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
public void mouseEntered(MouseEvent e) { public void mouseEntered(MouseEvent e) {
closeMode = UIConstants.CLOSE_OVER_AUTHORITY; closeMode = UIConstants.CLOSE_OVER_AUTHORITY;
closeButton.setBackground(UIConstants.NORMAL_BACKGROUND); closeButton.setBackground(UIConstants.NORMAL_BACKGROUND);
closeButton.repaint(); closeButton.repaint();
} }
}; };
private ProgressDialog progressDialog;
public DesignerFrame(ToolBarMenuDock ad) { public DesignerFrame(ToolBarMenuDock ad) {
setName(DESIGNER_FRAME_NAME); setName(DESIGNER_FRAME_NAME);
@ -218,7 +257,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
// the content pane // the content pane
basePane.setLayout(new BorderLayout()); basePane.setLayout(new BorderLayout());
toolbarPane = new JPanel() { toolbarPane = new JPanel() {
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize(); Dimension dim = super.getPreferredSize();
// dim.height = TOOLBAR_HEIGHT; // dim.height = TOOLBAR_HEIGHT;
return dim; return dim;
@ -261,19 +302,32 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
this.addWindowListeners(getFrameListeners()); this.addWindowListeners(getFrameListeners());
this.addComponentListener(new ComponentAdapter() { this.addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent e) { public void componentResized(ComponentEvent e) {
reCalculateFrameSize(); reCalculateFrameSize();
if (DesignerMode.isAuthorityEditing()) { if (BaseUtils.isAuthorityEditing()) {
doResize(); doResize();
} }
} }
}); });
this.addDesignerOpenedListener(new DesignerOpenedListener() {
@Override
public void designerOpened() {
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setComposite();
reCalculateFrameSize();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().doResize();
}
});
this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.setVisible(false); this.setVisible(false);
this.setExtendedState(JFrame.MAXIMIZED_BOTH); this.setExtendedState(JFrame.MAXIMIZED_BOTH);
this.setDropTarget(new DropTarget(this, DnDConstants.ACTION_MOVE, new FileDropTargetListener(), true)); this.setDropTarget(new DropTarget(this, DnDConstants.ACTION_MOVE, new FileDropTargetListener(), true));
closeMode = UIConstants.CLOSE_OF_AUTHORITY; closeMode = UIConstants.CLOSE_OF_AUTHORITY;
initMenuPane(); initMenuPane();
this.progressDialog = new ProgressDialog(this);
} }
/** /**
@ -282,6 +336,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @param app 注册app. * @param app 注册app.
*/ */
public static void registApp(App<?> app) { public static void registApp(App<?> app) {
if (app != null) { if (app != null) {
appList.add(app); appList.add(app);
} }
@ -298,6 +353,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 注册"设计器初始化完成"的监听 * 注册"设计器初始化完成"的监听
*/ */
public void addDesignerOpenedListener(DesignerOpenedListener listener) { public void addDesignerOpenedListener(DesignerOpenedListener listener) {
designerOpenedListenerList.add(listener); designerOpenedListenerList.add(listener);
} }
@ -305,12 +361,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 触发"设计器初始化完成"事件 * 触发"设计器初始化完成"事件
*/ */
public void fireDesignerOpened() { public void fireDesignerOpened() {
for (DesignerOpenedListener listener : designerOpenedListenerList) { for (DesignerOpenedListener listener : designerOpenedListenerList) {
listener.designerOpened(); listener.designerOpened();
} }
} }
protected DesktopCardPane getCenterTemplateCardPane() { protected DesktopCardPane getCenterTemplateCardPane() {
return centerTemplateCardPane; return centerTemplateCardPane;
} }
@ -318,41 +376,45 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 初始menuPane的方法 方便OEM时修改该组件 * 初始menuPane的方法 方便OEM时修改该组件
*/ */
protected void initMenuPane() { protected void initMenuPane() {
menuPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); menuPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
menuPane.add(new UIMenuHighLight(), BorderLayout.SOUTH); menuPane.add(new UIMenuHighLight(), BorderLayout.SOUTH);
menuPane.add(initNorthEastPane(), BorderLayout.EAST); menuPane.add(initNorthEastPane(ad), BorderLayout.EAST);
basePane.add(menuPane, BorderLayout.NORTH); basePane.add(menuPane, BorderLayout.NORTH);
this.resetToolkitByPlus(null); this.resetToolkitByPlus(null);
} }
/** /**
* @param ad
* @return * @return
*/ */
protected JPanel initNorthEastPane() { protected JPanel initNorthEastPane(final ToolBarMenuDock ad) {
//hugh: private修改为protected方便oem的时候修改右上的组件构成 //hugh: private修改为protected方便oem的时候修改右上的组件构成
//顶部日志+登陆按钮
final JPanel northEastPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
//优先级为-1,保证最后全面刷新一次 //优先级为-1,保证最后全面刷新一次
GeneralContext.listenPluginRunningChanged(new PluginEventListener(-1) { GeneralContext.listenPluginRunningChanged(new PluginEventListener(-1) {
@Override @Override
public void on(PluginEvent event) { public void on(PluginEvent event) {
refreshNorthEastPane(); refreshNorthEastPane(northEastPane, ad);
DesignUtils.refreshDesignerFrame(FRContext.getCurrentEnv()); DesignUtils.refreshDesignerFrame();
} }
}, new PluginFilter() { }, new PluginFilter() {
@Override @Override
public boolean accept(PluginContext context) { public boolean accept(PluginContext context) {
return !SwitchExistEnv.isSwitching()
&& context.contain(PluginModule.ExtraDesign); return context.contain(PluginModule.ExtraDesign);
} }
}); });
refreshNorthEastPane(); refreshNorthEastPane(northEastPane, ad);
return northEastPane; return northEastPane;
} }
public static void refreshNorthEastPane() { private void refreshNorthEastPane(JPanel northEastPane, ToolBarMenuDock ad) {
northEastPane.removeAll(); northEastPane.removeAll();
northEastPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); northEastPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
northEastPane.add(LogMessageBar.getInstance()); northEastPane.add(LogMessageBar.getInstance());
@ -368,24 +430,27 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
public void initTitleIcon() { public void initTitleIcon() {
try { try {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<BufferedImage> image = ICODecoder.read(DesignerFrame.class List<BufferedImage> image = ICODecoder.read(DesignerFrame.class
.getResourceAsStream("/com/fr/base/images/oem/logo.ico")); .getResourceAsStream("/com/fr/base/images/oem/logo.ico"));
this.setIconImages(image); this.setIconImages(image);
} catch (IOException e) { } catch (IOException e) {
FRContext.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png")); this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png"));
} }
} }
private void addWindowListeners(ArrayList<WindowListener> listeners) { private void addWindowListeners(ArrayList<WindowListener> listeners) {
for (WindowListener listener : listeners) { for (WindowListener listener : listeners) {
this.addWindowListener(listener); this.addWindowListener(listener);
} }
} }
protected ArrayList<WindowListener> getFrameListeners() { protected ArrayList<WindowListener> getFrameListeners() {
ArrayList<WindowListener> arrayList = new ArrayList<WindowListener>(); ArrayList<WindowListener> arrayList = new ArrayList<WindowListener>();
arrayList.add(windowAdapter); arrayList.add(windowAdapter);
return arrayList; return arrayList;
@ -393,11 +458,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
protected void laoyoutWestPane() { protected void laoyoutWestPane() {
basePane.add(WestRegionContainerPane.getInstance(), BorderLayout.WEST); basePane.add(WestRegionContainerPane.getInstance(), BorderLayout.WEST);
} }
// 调整windows大小 // 调整windows大小
private void reCalculateFrameSize() { private void reCalculateFrameSize() {
contentHeight = layeredPane.getHeight(); contentHeight = layeredPane.getHeight();
contentWidth = layeredPane.getWidth(); contentWidth = layeredPane.getWidth();
layeredPane.remove(basePane); layeredPane.remove(basePane);
@ -410,6 +477,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 更新 * 更新
*/ */
public void populateAuthorityArea() { public void populateAuthorityArea() {
int centerWidth = contentWidth - WestRegionContainerPane.getInstance().getContainerWidth() int centerWidth = contentWidth - WestRegionContainerPane.getInstance().getContainerWidth()
- EastRegionContainerPane.getInstance().getContainerWidth(); - EastRegionContainerPane.getInstance().getContainerWidth();
// 上面的虚线 // 上面的虚线
@ -434,6 +502,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
private void addDottedLine() { private void addDottedLine() {
layeredPane.add(upDottedLine, SECOND_LAYER); layeredPane.add(upDottedLine, SECOND_LAYER);
layeredPane.add(downDottedLine, SECOND_LAYER); layeredPane.add(downDottedLine, SECOND_LAYER);
layeredPane.add(leftDottedLine, SECOND_LAYER); layeredPane.add(leftDottedLine, SECOND_LAYER);
@ -442,6 +511,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
private void removeDottedLine() { private void removeDottedLine() {
layeredPane.remove(upDottedLine); layeredPane.remove(upDottedLine);
layeredPane.remove(downDottedLine); layeredPane.remove(downDottedLine);
layeredPane.remove(leftDottedLine); layeredPane.remove(leftDottedLine);
@ -450,6 +520,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
public JLayeredPane getContentFrame() { public JLayeredPane getContentFrame() {
return layeredPane; return layeredPane;
} }
@ -457,7 +528,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 刷新 * 刷新
*/ */
public void refreshDottedLine() { public void refreshDottedLine() {
if (DesignerMode.isAuthorityEditing()) {
if (BaseUtils.isAuthorityEditing()) {
populateAuthorityArea(); populateAuthorityArea();
populateCloseButton(); populateCloseButton();
addDottedLine(); addDottedLine();
@ -471,6 +543,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 刷新DottedLine * 刷新DottedLine
*/ */
public void doResize() { public void doResize() {
removeDottedLine(); removeDottedLine();
populateAuthorityArea(); populateAuthorityArea();
populateCloseButton(); populateCloseButton();
@ -495,6 +568,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 退出权限编辑时将所有的做过权限编辑的状态作为一个状态赋给报报表主体 * 退出权限编辑时将所有的做过权限编辑的状态作为一个状态赋给报报表主体
*/ */
private void fireAuthorityStateToNomal() { private void fireAuthorityStateToNomal() {
java.util.List<JTemplate<?, ?>> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); java.util.List<JTemplate<?, ?>> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList();
for (int i = 0; i < opendedTemplate.size(); i++) { for (int i = 0; i < opendedTemplate.size(); i++) {
// 如果在权限编辑时做过操作,则将做过的操作作为一个整体状态赋给正在报表 // 如果在权限编辑时做过操作,则将做过的操作作为一个整体状态赋给正在报表
@ -505,10 +579,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
public void setCloseMode(Icon closeMode) { public void setCloseMode(Icon closeMode) {
this.closeMode = closeMode; this.closeMode = closeMode;
} }
private UIToolbar combineUpTooBar(JComponent[] toolbar4Form) { private UIToolbar combineUpTooBar(JComponent[] toolbar4Form) {
combineUp = new UIToolbar(FlowLayout.LEFT); combineUp = new UIToolbar(FlowLayout.LEFT);
combineUp.setBorder(new MatteBorder(new Insets(0, LEFT_ALIGN_GAP, 1, 0), UIConstants.LINE_COLOR)); combineUp.setBorder(new MatteBorder(new Insets(0, LEFT_ALIGN_GAP, 1, 0), UIConstants.LINE_COLOR));
combineUp.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 2)); combineUp.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 2));
@ -516,7 +592,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
for (int i = 0; i < fixButtons.length; i++) { for (int i = 0; i < fixButtons.length; i++) {
combineUp.add(fixButtons[i]); combineUp.add(fixButtons[i]);
} }
if (!DesignerMode.isAuthorityEditing()) { if (!BaseUtils.isAuthorityEditing()) {
combineUp.addSeparator(new Dimension(2, 16)); combineUp.addSeparator(new Dimension(2, 16));
if (toolbar4Form != null) { if (toolbar4Form != null) {
for (int i = 0; i < toolbar4Form.length; i++) { for (int i = 0; i < toolbar4Form.length; i++) {
@ -535,6 +611,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
private void addExtraButtons() { private void addExtraButtons() {
JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (jt == null) { if (jt == null) {
return; return;
@ -551,6 +628,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
private void addShareButton() { private void addShareButton() {
JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (jt == null) { if (jt == null) {
return; return;
@ -570,6 +648,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @param al 组件名称 * @param al 组件名称
*/ */
public void checkCombineUp(boolean flag, ArrayList<String> al) { public void checkCombineUp(boolean flag, ArrayList<String> al) {
combineUp.checkComponentsByNames(flag, al); combineUp.checkComponentsByNames(flag, al);
} }
@ -578,6 +657,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 刷新工具条. * 刷新工具条.
*/ */
public void refreshToolbar() { public void refreshToolbar() {
this.ad.updateToolBarDef(); this.ad.updateToolBarDef();
} }
@ -587,6 +667,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @param plus 工具条中相关信息 * @param plus 工具条中相关信息
*/ */
public void resetToolkitByPlus(ToolBarMenuDockPlus plus) { public void resetToolkitByPlus(ToolBarMenuDockPlus plus) {
if (plus == null) { if (plus == null) {
plus = ToolBarMenuDock.NULLAVOID; plus = ToolBarMenuDock.NULLAVOID;
} }
@ -619,6 +700,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
public JComponent getToolbarComponent() { public JComponent getToolbarComponent() {
return this.toolbarComponent; return this.toolbarComponent;
} }
@ -627,22 +709,22 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
public void needToAddAuhtorityPaint() { public void needToAddAuhtorityPaint() {
newWorkBookPane.setButtonGray(DesignerMode.isAuthorityEditing()); newWorkBookPane.setButtonGray(BaseUtils.isAuthorityEditing());
// 进入或退出权限编辑模式,通知插件 // 进入或退出权限编辑模式,通知插件
Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts(); Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts();
for (ShortCut shortCut : extraShortCuts) { for (ShortCut shortCut : extraShortCuts) {
if (shortCut instanceof AbstractTemplateTreeShortCutProvider) { if (shortCut instanceof AbstractTemplateTreeShortCutProvider) {
((AbstractTemplateTreeShortCutProvider) shortCut).notifyFromAuhtorityChange(DesignerMode.isAuthorityEditing()); ((AbstractTemplateTreeShortCutProvider) shortCut).notifyFromAuhtorityChange(BaseUtils.isAuthorityEditing());
} }
} }
} }
/** /**
* 检查工具条. * 检查工具条.
*/ */
private void checkToolbarMenuEnable() { private void checkToolbarMenuEnable() {
if (this.ad != null) { if (this.ad != null) {
this.ad.updateMenuDef(); this.ad.updateMenuDef();
this.ad.updateToolBarDef(); this.ad.updateToolBarDef();
@ -653,29 +735,34 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 设置标题 * 设置标题
*/ */
public void setTitle() { public void setTitle() {
JTemplate<?, ?> editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
StringBuilder defaultTitleSB = new StringBuilder(); StringBuilder defaultTitleSB = new StringBuilder();
defaultTitleSB.append(ProductConstants.PRODUCT_NAME); defaultTitleSB.append(ProductConstants.PRODUCT_NAME);
defaultTitleSB.append(" "); defaultTitleSB.append(" ");
defaultTitleSB.append(ProductConstants.BRANCH); defaultTitleSB.append(ProductConstants.BRANCH);
defaultTitleSB.append(" ");
// james:标识登录的用户和登录的ENV // james:标识登录的用户和登录的ENV
String envName = DesignerEnvManager.getEnvManager().getCurEnvName(); String envName = DesignerEnvManager.getEnvManager().getCurEnvName();
Env env = DesignerEnvManager.getEnvManager().getEnv(envName); Workspace workspace = WorkContext.getCurrent();
if (env != null) { DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(envName);
defaultTitleSB.append(env.getUser()).append('@').append(envName).append('[');
defaultTitleSB.append(env.getEnvDescription()); String username = null;
defaultTitleSB.append(']'); if (info != null) {
WorkspaceConnection connection = info.getConnection();
username = connection == null ? StringUtils.EMPTY : connection.getUserName();
}
defaultTitleSB.append(username).append("@").append(envName).append("[").append(workspace.getDescription()).append("]");
if (editingTemplate != null) { if (editingTemplate != null) {
String path = editingTemplate.getEditingFILE().getPath(); String path = editingTemplate.getEditingFILE().getPath();
if (!editingTemplate.getEditingFILE().exists()) { if (!editingTemplate.getEditingFILE().exists()) {
path = FILEFactory.MEM_PREFIX + path; path = FILEFactory.MEM_PREFIX + path;
} else if (path.startsWith(ProjectConstants.REPORTLETS_NAME)) { } else if (path.startsWith(ProjectConstants.REPORTLETS_NAME)) {
path = env.getPath() + File.separator + path; path = workspace.getPath() + File.separator + path;
} }
defaultTitleSB.append(" " + path); defaultTitleSB.append(" " + path);
} }
}
setTitle(defaultTitleSB.toString()); setTitle(defaultTitleSB.toString());
} }
@ -712,16 +799,16 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
/** /**
* 报表运行环境改变时,需要刷新某些面板 * 报表运行环境改变时,需要刷新某些面板
*
* @param env 环境
*/ */
public void refreshEnv(Env env) { public void refreshEnv() {
this.setTitle(); this.setTitle();
DesignerFrameFileDealerPane.getInstance().refreshDockingView(); DesignerFrameFileDealerPane.getInstance().refreshDockingView();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
TemplateTreePane.getInstance().refreshDockingView(); TemplateTreePane.getInstance().refreshDockingView();
DesignTableDataManager.clearGlobalDs(); DesignTableDataManager.clearGlobalDs();
EastRegionContainerPane.getInstance().refreshDownPane(); EastRegionContainerPane.getInstance().refreshDownPane();
JTemplate template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (template != null) { if (template != null) {
template.refreshToolArea(); template.refreshToolArea();
@ -732,6 +819,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 返回选中的模板. * 返回选中的模板.
*/ */
public JTemplate<?, ?> getSelectedJTemplate() { public JTemplate<?, ?> getSelectedJTemplate() {
return this.centerTemplateCardPane.getSelectedJTemplate(); return this.centerTemplateCardPane.getSelectedJTemplate();
} }
@ -740,6 +828,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
public void saveCurrentEditingTemplate() { public void saveCurrentEditingTemplate() {
JTemplate<?, ?> editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (editingTemplate == null) { if (editingTemplate == null) {
return; return;
@ -752,23 +841,19 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
editingTemplate.stopEditing(); editingTemplate.stopEditing();
if (!editingTemplate.getEditingFILE().exists()) { if (!editingTemplate.getEditingFILE().exists()) {
int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
Inter.getLocText("Utils-Would_you_like_to_save") + " \"" + editingTemplate.getEditingFILE() com.fr.design.i18n.Toolkit.i18nText("Utils-Would_you_like_to_save") + " \"" + editingTemplate.getEditingFILE()
+ "\" ?", ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_OPTION, + "\" ?", ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE); JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION && editingTemplate.saveTemplate()) { if (returnVal == JOptionPane.YES_OPTION && editingTemplate.saveTemplate()) {
editingTemplate.saveTemplate(); editingTemplate.saveTemplate();
FRLogger.getLogger().log( FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Template_Already_Saved",
Level.INFO, editingTemplate.getEditingFILE().getName()));
Inter.getLocText(new String[]{"Template", "already-saved"}, new String[]{
editingTemplate.getEditingFILE().getName(), "."}));
} }
} else { } else {
if (editingTemplate.saveTemplate()) { if (editingTemplate.saveTemplate()) {
editingTemplate.saveTemplate(); editingTemplate.saveTemplate();
FRLogger.getLogger().log( FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Template_Already_Saved",
Level.INFO, editingTemplate.getEditingFILE().getName()));
Inter.getLocText(new String[]{"Template", "already-saved"}, new String[]{
editingTemplate.getEditingFILE().getName(), "."}));
} }
} }
} }
@ -778,6 +863,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 添加新建模板, 并激活. * 添加新建模板, 并激活.
*/ */
public void addAndActivateJTemplate() { public void addAndActivateJTemplate() {
addAndActivateJTemplate(ad.createNewTemplate()); addAndActivateJTemplate(ad.createNewTemplate());
layeredPane.repaint(); layeredPane.repaint();
} }
@ -822,6 +908,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @param e 事件 * @param e 事件
*/ */
public void targetModified(TargetModifiedEvent e) { public void targetModified(TargetModifiedEvent e) {
this.checkToolbarMenuEnable(); this.checkToolbarMenuEnable();
} }
@ -831,6 +918,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @param jt 模板 * @param jt 模板
*/ */
public void templateClosed(JTemplate<?, ?> jt) { public void templateClosed(JTemplate<?, ?> jt) {
} }
/** /**
@ -839,6 +927,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @param jt 模板 * @param jt 模板
*/ */
public void templateOpened(JTemplate<?, ?> jt) { public void templateOpened(JTemplate<?, ?> jt) {
} }
/** /**
@ -847,6 +936,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @param jt 模板 * @param jt 模板
*/ */
public void templateSaved(JTemplate<?, ?> jt) { public void templateSaved(JTemplate<?, ?> jt) {
this.checkToolbarMenuEnable(); this.checkToolbarMenuEnable();
} }
@ -857,22 +947,22 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
public void openTemplate(FILE tplFile) { public void openTemplate(FILE tplFile) {
// 测试连接,如果连接失败,则提示 // 测试连接,如果连接失败,则提示
try { // try {
if (FRContext.getCurrentEnv() != null // if (FRContext.getCommonOperator() != null
&& !FRContext.getCurrentEnv().testServerConnectionWithOutShowMessagePane()) { // && !FRContext.getCommonOperator().testServerConnectionWithOutShowMessagePane()) {
JOptionPane.showMessageDialog( // JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(), // DesignerContext.getDesignerFrame(),
Inter.getLocText(new String[]{"FR-Chart-Server_disconnected", "FR-Server-Design_template_unopened"}, new String[]{ // com.fr.design.i18n.Toolkit.i18nText(new String[]{"FR-Chart-Server_disconnected", "FR-Server-Design_template_unopened"}, new String[]{
",", "!"}), Inter.getLocText("FR-Server-All_Error"), JOptionPane.ERROR_MESSAGE); // ",", "!"}), com.fr.design.i18n.Toolkit.i18nText("FR-Server-All_Error"), JOptionPane.ERROR_MESSAGE);
return; // return;
} // }
} catch (Exception e) { // } catch (Exception e) {
FRLogger.getLogger().error(e.getMessage()); // FineLoggerFactory.getLogger().error(e.getMessage());
} // }
// p:判断一下,如何文件为空或者文件不存在,直接返回. // p:判断一下,如何文件为空或者文件不存在,直接返回.
if (tplFile == null || !tplFile.exists()) { if (tplFile == null || !tplFile.exists()) {
JOptionPane.showMessageDialog(this, Inter.getLocText("Warning-Template_Do_Not_Exsit"), JOptionPane.showMessageDialog(this, com.fr.design.i18n.Toolkit.i18nText("Warning-Template_Do_Not_Exsit"),
ProductConstants.PRODUCT_NAME, JOptionPane.INFORMATION_MESSAGE); ProductConstants.PRODUCT_NAME, JOptionPane.INFORMATION_MESSAGE);
DesignerFrameFileDealerPane.getInstance().refresh(); DesignerFrameFileDealerPane.getInstance().refresh();
return; return;
@ -881,7 +971,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
try { try {
openFile(tplFile); openFile(tplFile);
} catch (Throwable t) { } catch (Throwable t) {
FRLogger.getLogger().error(t.getMessage(), t); FineLoggerFactory.getLogger().error(t.getMessage(), t);
addAndActivateJTemplate(); addAndActivateJTemplate();
} }
@ -895,6 +985,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @date 2014-10-14-下午6:30:37 * @date 2014-10-14-下午6:30:37
*/ */
private boolean inValidDesigner(JTemplate jt) { private boolean inValidDesigner(JTemplate jt) {
return jt.isOldDesigner() || (!jt.isJWorkBook() && jt.isNewDesigner()); return jt.isOldDesigner() || (!jt.isJWorkBook() && jt.isNewDesigner());
} }
@ -905,6 +996,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @date 2014-10-14-下午6:31:05 * @date 2014-10-14-下午6:31:05
*/ */
private void openFile(FILE tplFile) { private void openFile(FILE tplFile) {
String fileName = tplFile.getName(); String fileName = tplFile.getName();
int indexOfLastDot = fileName.lastIndexOf(CoreConstants.DOT); int indexOfLastDot = fileName.lastIndexOf(CoreConstants.DOT);
if (indexOfLastDot < 0) { if (indexOfLastDot < 0) {
@ -913,16 +1005,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
String fileExtention = fileName.substring(indexOfLastDot + 1); String fileExtention = fileName.substring(indexOfLastDot + 1);
for (int i = 0, len = appList.size(); i < len; i++) { for (int i = 0, len = appList.size(); i < len; i++) {
App<?> app = appList.get(i); App<?> app = appList.get(i);
String[] defaultAppExtentions = app.defaultExtentions(); String[] defaultAppExtentions = app.defaultExtensions();
boolean opened = false; boolean opened = false;
for (int j = 0; j < defaultAppExtentions.length; j++) { for (int j = 0; j < defaultAppExtentions.length; j++) {
if (defaultAppExtentions[j].equalsIgnoreCase(fileExtention)) { if (defaultAppExtentions[j].equalsIgnoreCase(fileExtention)) {
JTemplate jt = null; // 不要catch
try { JTemplate jt = app.openTemplate(tplFile);
jt = app.openTemplate(tplFile);
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage(), e);
}
if (jt == null) { if (jt == null) {
return; return;
} }
@ -953,16 +1042,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
private void activeTemplate(FILE tplFile, JTemplate jt) { private void activeTemplate(FILE tplFile, JTemplate jt) {
// 如果该模板已经打开,则进行激活就可以了 // 如果该模板已经打开,则进行激活就可以了
String fullName = StableUtils.pathJoin(new String[]{ProjectConstants.REPORTLETS_NAME, tplFile.getName()}); int index = HistoryTemplateListPane.getInstance().contains(tplFile.getPath());
if (tplFile instanceof FileNodeFILE) {
fullName = ((FileNodeFILE) tplFile).getEnvPath() + "/" + tplFile.getPath();
}
// 如果是从文件夹打开的文件,不是从设计器文件树打开的文件,则直接取path就行
if (tplFile instanceof FileFILE) {
fullName = tplFile.getPath();
}
fullName = OperatingSystem.isWindows() ? fullName.replaceAll("/", "\\\\") : fullName.replaceAll("\\\\", "/");
int index = HistoryTemplateListPane.getInstance().contains(fullName);
List<JTemplate<?, ?>> historyList = HistoryTemplateListPane.getInstance().getHistoryList(); List<JTemplate<?, ?>> historyList = HistoryTemplateListPane.getInstance().getHistoryList();
if (index != -1) { if (index != -1) {
historyList.get(index).activeJTemplate(index, jt); historyList.get(index).activeJTemplate(index, jt);
@ -975,9 +1055,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* Exit退出 * Exit退出
*/ */
public void exit() { public void exit() {
Thread thread = new Thread() { Thread thread = new Thread() {
@Override @Override
public void run() { public void run() {
DesignerEnvManager.doEndMapSaveWorkersIndesign(); DesignerEnvManager.doEndMapSaveWorkersIndesign();
} }
}; };
@ -986,7 +1069,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
try { try {
thread.join(); thread.join();
} catch (InterruptedException e) { } catch (InterruptedException e) {
FRLogger.getLogger().error("Map Thread Error"); FineLoggerFactory.getLogger().error("Map Thread Error");
} }
DesignerEnvManager.getEnvManager().setLastOpenFile( DesignerEnvManager.getEnvManager().setLastOpenFile(
@ -1003,14 +1086,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
DesignerEnvManager.getEnvManager().saveXMLFile(); DesignerEnvManager.getEnvManager().saveXMLFile();
Env currentEnv = FRContext.getCurrentEnv(); WorkContext.switchTo(null);
try {
EnvContext.fireBeforeSignOut();
currentEnv.signOut();
EnvContext.fireAfterSignOut();
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
this.setVisible(false); this.setVisible(false);
this.dispose(); this.dispose();
@ -1024,18 +1101,22 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
@Override @Override
public void dragEnter(DropTargetDragEvent event) { public void dragEnter(DropTargetDragEvent event) {
} }
@Override @Override
public void dragExit(DropTargetEvent event) { public void dragExit(DropTargetEvent event) {
} }
@Override @Override
public void dragOver(DropTargetDragEvent event) { public void dragOver(DropTargetDragEvent event) {
} }
@Override @Override
public void dropActionChanged(DropTargetDragEvent event) { public void dropActionChanged(DropTargetDragEvent event) {
if (!isDragAcceptable(event)) { if (!isDragAcceptable(event)) {
event.rejectDrag(); event.rejectDrag();
return; return;
@ -1045,6 +1126,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public void drop(DropTargetDropEvent event) { public void drop(DropTargetDropEvent event) {
if (!isDropAcceptable(event)) { if (!isDropAcceptable(event)) {
event.rejectDrop(); event.rejectDrop();
return; return;
@ -1065,19 +1147,25 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
} }
} catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }
event.dropComplete(true); event.dropComplete(true);
} }
public boolean isDragAcceptable(DropTargetDragEvent event) { public boolean isDragAcceptable(DropTargetDragEvent event) {
return (event.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE) != 0; return (event.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE) != 0;
} }
public boolean isDropAcceptable(DropTargetDropEvent event) { public boolean isDropAcceptable(DropTargetDropEvent event) {
return (event.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE) != 0; return (event.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE) != 0;
} }
} }
public ProgressDialog getProgressDialog() {
return progressDialog;
}
} }

36
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

@ -31,21 +31,30 @@ import com.fr.file.FILE;
import com.fr.file.FileNodeFILE; import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.io.utils.ResourceIOUtils; import com.fr.io.utils.ResourceIOUtils;
import com.fr.stable.CoreConstants; import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter; import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -59,9 +68,13 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private CardLayout card; private CardLayout card;
private JPanel cardPane; private JPanel cardPane;
private java.util.List<FileToolbarStateChangeListener> otherToobarStateChangeListeners= new ArrayList<>();
private FileOperations selectedOperation; public FileOperations getSelectedOperation() {
return selectedOperation;
}
private FileOperations selectedOperation;
private UIToolbar toolBar; private UIToolbar toolBar;
private OpenReportAction openReportAction = new OpenReportAction(); private OpenReportAction openReportAction = new OpenReportAction();
@ -244,6 +257,21 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
selectedOperation.refresh(); selectedOperation.refresh();
stateChange(); stateChange();
}
}
public void addToobarStateChangeListener(FileToolbarStateChangeListener toobarStateChangeListener) {
this.otherToobarStateChangeListeners.add(toobarStateChangeListener);
}
public void removeToobarStateChangeListener(FileToolbarStateChangeListener toobarStateChangeListener) {
this.otherToobarStateChangeListeners.remove(toobarStateChangeListener);
}
private void otherStateChange() {
for (FileToolbarStateChangeListener toobarStateChangeListener : otherToobarStateChangeListeners) {
toobarStateChangeListener.stateChange();
} }
} }

8
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -6,6 +6,7 @@ import com.fr.base.Parameter;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.base.io.BaseBook; import com.fr.base.io.BaseBook;
import com.fr.base.iofile.attr.TemplateIdAttrMark; import com.fr.base.iofile.attr.TemplateIdAttrMark;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState; import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
@ -32,6 +33,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.templateinfo.TemplateInfoCollector; import com.fr.design.mainframe.templateinfo.TemplateInfoCollector;
import com.fr.design.mainframe.templateinfo.TemplateProcessInfo; import com.fr.design.mainframe.templateinfo.TemplateProcessInfo;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.mainframe.toolbar.VcsScene;
import com.fr.design.menu.MenuDef; import com.fr.design.menu.MenuDef;
import com.fr.design.menu.NameSeparator; import com.fr.design.menu.NameSeparator;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
@ -699,7 +701,9 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
*/ */
@Override @Override
public ShortCut[] shortcut4FileMenu() { public ShortCut[] shortcut4FileMenu() {
if (BaseUtils.isAuthorityEditing()) { if (DesignerMode.isVcsMode()) {
return VcsScene.shortcut4FileMenu(this);
} else if (DesignerMode.isAuthorityEditing()) {
return new ShortCut[]{new SaveTemplateAction(this), new UndoAction(this), new RedoAction(this)}; return new ShortCut[]{new SaveTemplateAction(this), new UndoAction(this), new RedoAction(this)};
} else { } else {
return new ShortCut[]{new SaveTemplateAction(this), new SaveAsTemplateAction(this), new UndoAction(this), new RedoAction(this)}; return new ShortCut[]{new SaveTemplateAction(this), new SaveAsTemplateAction(this), new UndoAction(this), new RedoAction(this)};
@ -721,7 +725,9 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
tplMenu.addShortCut(new TableDataSourceAction(this)); tplMenu.addShortCut(new TableDataSourceAction(this));
tplMenu.addShortCut(shortcut4TemplateMenu()); tplMenu.addShortCut(shortcut4TemplateMenu());
} }
if (!DesignerMode.isVcsMode()) {
tplMenu.addShortCut(shortCuts4Authority()); tplMenu.addShortCut(shortCuts4Authority());
}
return new MenuDef[]{tplMenu}; return new MenuDef[]{tplMenu};
} }

36
designer-base/src/main/java/com/fr/design/mainframe/ToolBarNewTemplatePane.java

@ -0,0 +1,36 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.design.file.NewTemplatePane;
import javax.swing.Icon;
/**
* Created by hzzz on 2017/12/26.
*/
public class ToolBarNewTemplatePane extends NewTemplatePane {
private static final ToolBarNewTemplatePane instance = new ToolBarNewTemplatePane();
private ToolBarNewTemplatePane() {
}
public static NewTemplatePane getInstance() {
return instance;
}
@Override
public Icon getNew() {
return BaseUtils.readIcon("/com/fr/design/images/buttonicon/addicon.png");
}
@Override
public Icon getMouseOverNew() {
return BaseUtils.readIcon("/com/fr/design/images/buttonicon/add_press.png");
}
@Override
public Icon getMousePressNew() {
return BaseUtils.readIcon("/com/fr/design/images/buttonicon/add_press.png");
}
}

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

@ -3,8 +3,8 @@
*/ */
package com.fr.design.mainframe.toolbar; package com.fr.design.mainframe.toolbar;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignState; import com.fr.design.DesignState;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
@ -42,6 +42,7 @@ import com.fr.design.gui.imenu.UIMenuBar;
import com.fr.design.gui.itoolbar.UILargeToolbar; import com.fr.design.gui.itoolbar.UILargeToolbar;
import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.ToolBarNewTemplatePane;
import com.fr.design.menu.MenuDef; import com.fr.design.menu.MenuDef;
import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.SeparatorDef;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
@ -50,7 +51,6 @@ import com.fr.design.remote.action.RemoteDesignAuthorityManagerAction;
import com.fr.design.utils.ThemeUtils; import com.fr.design.utils.ThemeUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginRuntime; import com.fr.plugin.context.PluginRuntime;
import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.manage.PluginFilter;
@ -61,8 +61,17 @@ import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.JComponent;
import java.awt.*; import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -320,10 +329,15 @@ public abstract class ToolBarMenuDock {
} }
public MenuDef createFileMenuDef(ToolBarMenuDockPlus plus) { public MenuDef createFileMenuDef(ToolBarMenuDockPlus plus) {
if (DesignerMode.isVcsMode()) {
MenuDef menuDef = VcsScene.createFileMenuDef(plus);
insertMenu(menuDef, MenuHandler.FILE);
return menuDef;
}
MenuDef menuDef = new MenuDef(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_File"), 'F'); MenuDef menuDef = new MenuDef(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_File"), 'F');
ShortCut[] scs = new ShortCut[0]; ShortCut[] scs = new ShortCut[0];
if (!BaseUtils.isAuthorityEditing()) { if (!DesignerMode.isAuthorityEditing()) {
scs = createNewFileShortCuts(); scs = createNewFileShortCuts();
} }
if (!ArrayUtils.isEmpty(scs)) { if (!ArrayUtils.isEmpty(scs)) {
@ -354,13 +368,13 @@ public abstract class ToolBarMenuDock {
} }
protected void addCloseCurrentTemplateAction(MenuDef menuDef) { protected void addCloseCurrentTemplateAction(MenuDef menuDef) {
if (!BaseUtils.isAuthorityEditing()) { if (!DesignerMode.isAuthorityEditing()) {
menuDef.addShortCut(new CloseCurrentTemplateAction()); menuDef.addShortCut(new CloseCurrentTemplateAction());
} }
} }
protected void addPreferenceAction(MenuDef menuDef) { protected void addPreferenceAction(MenuDef menuDef) {
if (!BaseUtils.isAuthorityEditing()) { if (!DesignerMode.isAuthorityEditing()) {
menuDef.addShortCut(new PreferenceAction()); menuDef.addShortCut(new PreferenceAction());
} }
} }
@ -396,7 +410,7 @@ public abstract class ToolBarMenuDock {
protected MenuDef createServerMenuDef(ToolBarMenuDockPlus plus) { protected MenuDef createServerMenuDef(ToolBarMenuDockPlus plus) {
MenuDef menuDef = new MenuDef(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_M-Server"), 'S'); MenuDef menuDef = new MenuDef(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_M-Server"), 'S');
if (!BaseUtils.isAuthorityEditing()) { if (!DesignerMode.isAuthorityEditing()) {
menuDef.addShortCut( menuDef.addShortCut(
new ConnectionListAction(), new ConnectionListAction(),
createGlobalTDAction() createGlobalTDAction()
@ -412,7 +426,7 @@ public abstract class ToolBarMenuDock {
menuDef.addShortCut(new RemoteDesignAuthorityManagerAction()); menuDef.addShortCut(new RemoteDesignAuthorityManagerAction());
} }
if (!BaseUtils.isAuthorityEditing()) { if (!DesignerMode.isAuthorityEditing()) {
if (shouldShowPlugin()) { if (shouldShowPlugin()) {
menuDef.addShortCut( menuDef.addShortCut(
new PluginManagerAction() new PluginManagerAction()
@ -588,22 +602,7 @@ public abstract class ToolBarMenuDock {
} }
public NewTemplatePane getNewTemplatePane() { public NewTemplatePane getNewTemplatePane() {
return new NewTemplatePane() { return ToolBarNewTemplatePane.getInstance();
@Override
public Icon getNew() {
return BaseUtils.readIcon("/com/fr/design/images/buttonicon/addicon.png");
}
@Override
public Icon getMouseOverNew() {
return BaseUtils.readIcon("/com/fr/design/images/buttonicon/add_press.png");
}
@Override
public Icon getMousePressNew() {
return BaseUtils.readIcon("/com/fr/design/images/buttonicon/add_press.png");
}
};
} }
protected void insertMenu(MenuDef menuDef, String anchor) { protected void insertMenu(MenuDef menuDef, String anchor) {

45
designer-base/src/main/java/com/fr/design/mainframe/toolbar/VcsScene.java

@ -0,0 +1,45 @@
package com.fr.design.mainframe.toolbar;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.actions.edit.RedoAction;
import com.fr.design.actions.edit.UndoAction;
import com.fr.design.actions.file.ExitDesignerAction;
import com.fr.design.actions.file.PreferenceAction;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.SeparatorDef;
import com.fr.design.menu.ShortCut;
import com.fr.stable.ArrayUtils;
/**
* Created by hzzz on 2017/12/28.
*/
public class VcsScene {
public static MenuDef createFileMenuDef(ToolBarMenuDockPlus plus) {
MenuDef menuDef = new MenuDef(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_File"), 'F');
ShortCut[] scs = new ShortCut[0];
if (!ArrayUtils.isEmpty(scs)) {
menuDef.addShortCut(scs);
}
scs = plus.shortcut4FileMenu();
if (!ArrayUtils.isEmpty(scs)) {
menuDef.addShortCut(SeparatorDef.DEFAULT);
menuDef.addShortCut(scs);
menuDef.addShortCut(SeparatorDef.DEFAULT);
}
if (!DesignerMode.isAuthorityEditing()) {
menuDef.addShortCut(new PreferenceAction());
}
menuDef.addShortCut(new ExitDesignerAction());
return menuDef;
}
public static ShortCut[] shortcut4FileMenu(JTemplate jTemplate) {
return new ShortCut[]{new UndoAction(jTemplate), new RedoAction(jTemplate)};
}
}

7
designer-base/src/main/java/com/fr/design/menu/ShortCut.java

@ -71,4 +71,11 @@ public abstract class ShortCut extends AbstractProvider implements Mutable {
public void setMenuKeySet(MenuKeySet menuKeySet) { public void setMenuKeySet(MenuKeySet menuKeySet) {
this.menuKeySet = menuKeySet; this.menuKeySet = menuKeySet;
} }
/**
* 权限编辑模式变更时候会调用这个方法
* @param isAuhtority
*/
public void notifyFromAuhtorityChange(boolean isAuhtority) {
}
} }

6
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -3,6 +3,7 @@ package com.fr.design.mainframe;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.PaperSize; import com.fr.base.PaperSize;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignState; import com.fr.design.DesignState;
import com.fr.design.actions.core.WorkBookSupportable; import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.actions.file.WebPreviewUtils; import com.fr.design.actions.file.WebPreviewUtils;
@ -55,7 +56,6 @@ import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.page.PaperSettingProvider; import com.fr.page.PaperSettingProvider;
import com.fr.report.worksheet.FormElementCase; import com.fr.report.worksheet.FormElementCase;
@ -204,7 +204,8 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
*/ */
public ShortCut[] shortcut4FileMenu() { public ShortCut[] shortcut4FileMenu() {
return (ShortCut[]) ArrayUtils.addAll( return (ShortCut[]) ArrayUtils.addAll(
super.shortcut4FileMenu(), new ShortCut[]{this.createWorkBookExportMenu()} super.shortcut4FileMenu(),
DesignerMode.isVcsMode() ? new ShortCut[0] : new ShortCut[]{this.createWorkBookExportMenu()}
); );
} }
@ -257,6 +258,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
}); });
formDesign.addDesignerEditListener(new DesignerEditListener() { formDesign.addDesignerEditListener(new DesignerEditListener() {
private XComponent lastAffectedCreator; private XComponent lastAffectedCreator;
@Override @Override
public void fireCreatorModified(DesignerEvent evt) { public void fireCreatorModified(DesignerEvent evt) {
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_CUTED) { if (evt.getCreatorEventID() == DesignerEvent.CREATOR_CUTED) {

9
designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java

@ -5,6 +5,7 @@ import com.fr.base.DynamicUnitList;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.AllowAuthorityEditAction; import com.fr.design.actions.AllowAuthorityEditAction;
@ -632,9 +633,11 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
*/ */
@Override @Override
public ShortCut[] shortcut4FileMenu() { public ShortCut[] shortcut4FileMenu() {
return (ShortCut[]) ArrayUtils.addAll( boolean showWorkBookExportMenu = DesignerMode.isVcsMode()
super.shortcut4FileMenu(), || DesignerMode.isAuthorityEditing()
BaseUtils.isAuthorityEditing() || (!WorkContext.getCurrent().isLocal()) ? new ShortCut[0] : new ShortCut[]{this.createWorkBookExportMenu()} || !WorkContext.getCurrent().isLocal();
return (ShortCut[]) ArrayUtils.addAll(super.shortcut4FileMenu(),
showWorkBookExportMenu ? new ShortCut[0] : new ShortCut[]{this.createWorkBookExportMenu()}
); );
} }

7
designer-realize/src/main/java/com/fr/start/Designer.java

@ -2,6 +2,7 @@ package com.fr.start;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.file.WebPreviewUtils; import com.fr.design.actions.file.WebPreviewUtils;
@ -192,7 +193,7 @@ public class Designer extends BaseDesigner {
return menuDef; return menuDef;
} }
if (!BaseUtils.isAuthorityEditing()) { if (!DesignerMode.isAuthorityEditing()) {
menuDef.addShortCut(SeparatorDef.DEFAULT); menuDef.addShortCut(SeparatorDef.DEFAULT);
if (WorkContext.getCurrent().isRoot()) { if (WorkContext.getCurrent().isRoot()) {
@ -362,7 +363,7 @@ public class Designer extends BaseDesigner {
if (jt == null) { if (jt == null) {
return; return;
} }
saveButton.setEnabled(!jt.isSaved()); saveButton.setEnabled(!jt.isSaved() && !DesignerMode.isVcsMode());
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(HistoryTemplateListPane.getInstance().getHistoryList()); MutilTempalteTabPane.getInstance().refreshOpenedTemplate(HistoryTemplateListPane.getInstance().getHistoryList());
MutilTempalteTabPane.getInstance().repaint(); MutilTempalteTabPane.getInstance().repaint();
if (DesignerEnvManager.getEnvManager().isSupportUndo()) { if (DesignerEnvManager.getEnvManager().isSupportUndo()) {
@ -387,7 +388,7 @@ public class Designer extends BaseDesigner {
@Override @Override
public JComponent resetToolBar(JComponent toolbarComponent, ToolBarMenuDockPlus plus) { public JComponent resetToolBar(JComponent toolbarComponent, ToolBarMenuDockPlus plus) {
//如果是处于权限编辑状态 //如果是处于权限编辑状态
if (BaseUtils.isAuthorityEditing()) { if (DesignerMode.isAuthorityEditing()) {
if (plus instanceof JWorkBook && plus.toolbars4Target() == null) { if (plus instanceof JWorkBook && plus.toolbars4Target() == null) {
//聚合块编辑 //聚合块编辑
return super.polyToolBar(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Privilege_Poly_Block_Edit")); return super.polyToolBar(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Privilege_Poly_Block_Edit"));

Loading…
Cancel
Save