ju 6 years ago
parent
commit
6f62db4633
  1. 3
      designer-base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java
  2. 25
      designer-base/src/com/fr/design/mainframe/DesignerFrame.java
  3. 249
      designer-base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  4. 24
      designer-base/src/com/fr/design/mainframe/JTemplate.java
  5. 12
      designer-base/src/com/fr/design/utils/DesignUtils.java

3
designer-base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java

@ -1,6 +1,5 @@
package com.fr.design.actions.help.alphafine; package com.fr.design.actions.help.alphafine;
import com.fr.base.FRContext;
import com.fr.license.function.VT4FR; import com.fr.license.function.VT4FR;
import com.fr.stable.OperatingSystem; import com.fr.stable.OperatingSystem;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -75,7 +74,7 @@ public class AlphaFineConfigManager implements XMLable {
public static boolean isALPHALicAvailable() { public static boolean isALPHALicAvailable() {
return FRContext.getCommonOperator() != null && VT4FR.AlphaFine.isSupport(); return VT4FR.AlphaFine.isSupport();
} }
@Override @Override

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

@ -4,7 +4,6 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
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;
@ -836,18 +835,18 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
public void openTemplate(FILE tplFile) { public void openTemplate(FILE tplFile) {
// 测试连接,如果连接失败,则提示 // 测试连接,如果连接失败,则提示
try { // try {
if (FRContext.getCommonOperator() != null // if (FRContext.getCommonOperator() != null
&& !FRContext.getCommonOperator().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[]{ // Inter.getLocText(new String[]{"FR-Chart-Server_disconnected", "FR-Server-Design_template_unopened"}, new String[]{
",", "!"}), Inter.getLocText("FR-Server-All_Error"), JOptionPane.ERROR_MESSAGE); // ",", "!"}), Inter.getLocText("FR-Server-All_Error"), JOptionPane.ERROR_MESSAGE);
return; // return;
} // }
} catch (Exception e) { // } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage()); // FineLoggerFactory.getLogger().error(e.getMessage());
} // }
// p:判断一下,如何文件为空或者文件不存在,直接返回. // p:判断一下,如何文件为空或者文件不存在,直接返回.
if (tplFile == null || !tplFile.exists()) { if (tplFile == null || !tplFile.exists()) {

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

@ -37,19 +37,10 @@ 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 javax.swing.BorderFactory; import javax.swing.*;
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.BorderLayout; import java.awt.*;
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;
@ -59,37 +50,48 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange { public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange {
private static final String FILE = "file"; private static final String FILE = "file";
private static DesignerFrameFileDealerPane THIS; private static DesignerFrameFileDealerPane THIS;
private CardLayout card; private CardLayout card;
private JPanel cardPane; private JPanel cardPane;
private FileOperations selectedOperation; private FileOperations selectedOperation;
private UIToolbar toolBar; private UIToolbar toolBar;
private OpenReportAction openReportAction = new OpenReportAction(); private OpenReportAction openReportAction = new OpenReportAction();
private RefreshTreeAction refreshTreeAction = new RefreshTreeAction(); private RefreshTreeAction refreshTreeAction = new RefreshTreeAction();
private OpenFolderAction openFolderAction = new OpenFolderAction(); private OpenFolderAction openFolderAction = new OpenFolderAction();
private RenameAction renameAction = new RenameAction(); private RenameAction renameAction = new RenameAction();
private DelFileAction delFileAction = new DelFileAction(); private DelFileAction delFileAction = new DelFileAction();
/** /**
* 刷新 * 刷新
*/ */
public void refresh() { public void refresh() {
selectedOperation.refresh(); selectedOperation.refresh();
} }
public static final DesignerFrameFileDealerPane getInstance() { public static final DesignerFrameFileDealerPane getInstance() {
if (THIS == null) { if (THIS == null) {
THIS = new DesignerFrameFileDealerPane(); THIS = new DesignerFrameFileDealerPane();
} }
return THIS; return THIS;
} }
private DesignerFrameFileDealerPane() { private DesignerFrameFileDealerPane() {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
toolBar = ToolBarDef.createJToolBar(); toolBar = ToolBarDef.createJToolBar();
toolBar.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.TOOLBAR_BORDER_COLOR)); toolBar.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.TOOLBAR_BORDER_COLOR));
@ -100,22 +102,23 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
parent.setBorder(BorderFactory.createEmptyBorder(3, 0, 4, 0)); parent.setBorder(BorderFactory.createEmptyBorder(3, 0, 4, 0));
tooBarPane.add(parent, BorderLayout.CENTER); tooBarPane.add(parent, BorderLayout.CENTER);
tooBarPane.add(new UIMenuHighLight(), BorderLayout.SOUTH); tooBarPane.add(new UIMenuHighLight(), BorderLayout.SOUTH);
add(tooBarPane, BorderLayout.NORTH); add(tooBarPane, BorderLayout.NORTH);
cardPane = new JPanel(card = new CardLayout()); cardPane = new JPanel(card = new CardLayout());
cardPane.add(TemplateTreePane.getInstance(), FILE); cardPane.add(TemplateTreePane.getInstance(), FILE);
selectedOperation = TemplateTreePane.getInstance(); selectedOperation = TemplateTreePane.getInstance();
card.show(cardPane, FILE); card.show(cardPane, FILE);
TemplateTreePane.getInstance().setToobarStateChangeListener(this); TemplateTreePane.getInstance().setToobarStateChangeListener(this);
add(cardPane, BorderLayout.CENTER); add(cardPane, BorderLayout.CENTER);
stateChange(); stateChange();
} }
public final void setCurrentEditingTemplate(JTemplate<?, ?> jt) { public final void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
DesignModelAdapter.setCurrentModelAdapter(jt == null ? null : jt.getModel()); DesignModelAdapter.setCurrentModelAdapter(jt == null ? null : jt.getModel());
fireDSChanged(); fireDSChanged();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
@ -125,35 +128,37 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
if (BaseUtils.isAuthorityEditing()) { if (BaseUtils.isAuthorityEditing()) {
RolesAlreadyEditedPane.getInstance().refreshDockingView(); RolesAlreadyEditedPane.getInstance().refreshDockingView();
} }
jt.setComposite(); jt.setComposite();
jt.refreshToolArea(); jt.refreshToolArea();
jt.fireJTemplateOpened(); jt.fireJTemplateOpened();
jt.requestFocus(); jt.requestFocus();
jt.revert(); jt.revert();
FRContext.getLogger().info("\"" + jt.getEditingFILE().getName() + "\"" + Inter.getLocText("LOG-Has_Been_Openned") + "!"); FRContext.getLogger().info("\"" + jt.getEditingFILE().getName() + "\"" + Inter.getLocText("LOG-Has_Been_Openned") + "!");
} }
/** /**
* 刷新菜单 * 刷新菜单
*/ */
public void refreshDockingView() { public void refreshDockingView() {
ToolBarDef toolbarDef = new ToolBarDef(); ToolBarDef toolbarDef = new ToolBarDef();
toolbarDef.addShortCut(openReportAction, refreshTreeAction); toolbarDef.addShortCut(openReportAction, refreshTreeAction);
toolbarDef.addShortCut(openFolderAction, renameAction); toolbarDef.addShortCut(openFolderAction, renameAction);
toolbarDef.addShortCut(delFileAction); toolbarDef.addShortCut(delFileAction);
Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts(); Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts();
for (ShortCut shortCut : extraShortCuts){ for (ShortCut shortCut : extraShortCuts) {
toolbarDef.addShortCut(shortCut); toolbarDef.addShortCut(shortCut);
} }
toolbarDef.updateToolBar(toolBar); toolbarDef.updateToolBar(toolBar);
refreshActions(); refreshActions();
} }
private void refreshActions() { private void refreshActions() {
openReportAction.setEnabled(false); openReportAction.setEnabled(false);
refreshTreeAction.setEnabled(true); refreshTreeAction.setEnabled(true);
openFolderAction.setEnabled(false); openFolderAction.setEnabled(false);
@ -161,123 +166,134 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
delFileAction.setEnabled(false); delFileAction.setEnabled(false);
this.repaint(); this.repaint();
} }
/** /**
* 响应数据集改变 * 响应数据集改变
*/ */
public void fireDSChanged() { public void fireDSChanged() {
fireDSChanged(new HashMap<String, String>()); fireDSChanged(new HashMap<String, String>());
} }
/** /**
* 响应数据集改变 * 响应数据集改变
* @param map 改变名字的数据集 *
* @param map 改变名字的数据集
*/ */
public void fireDSChanged(Map<String, String> map) { public void fireDSChanged(Map<String, String> map) {
DesignTableDataManager.fireDSChanged(map); DesignTableDataManager.fireDSChanged(map);
} }
/* /*
* Open Report Action * Open Report Action
*/ */
private class OpenReportAction extends UpdateAction { private class OpenReportAction extends UpdateAction {
public OpenReportAction() { public OpenReportAction() {
this.setName(KeySetUtils.OPEN_TEMPLATE.getMenuKeySetName()); this.setName(KeySetUtils.OPEN_TEMPLATE.getMenuKeySetName());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/open.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/open.png"));
} }
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
selectedOperation.openSelectedReport(); selectedOperation.openSelectedReport();
} }
} }
private class OpenFolderAction extends UpdateAction { private class OpenFolderAction extends UpdateAction {
public OpenFolderAction() { public OpenFolderAction() {
this.setName(Inter.getLocText("FR-Designer_Show_in_Containing_Folder")); this.setName(Inter.getLocText("FR-Designer_Show_in_Containing_Folder"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/view_folder.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/view_folder.png"));
} }
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
selectedOperation.openContainerFolder(); selectedOperation.openContainerFolder();
} }
} }
/* /*
* 刷新ReportletsTree * 刷新ReportletsTree
*/ */
private class RefreshTreeAction extends UpdateAction { private class RefreshTreeAction extends UpdateAction {
public RefreshTreeAction() { public RefreshTreeAction() {
this.setName(Inter.getLocText("FR-Designer_Refresh")); this.setName(Inter.getLocText("FR-Designer_Refresh"));
this.setSmallIcon(UIConstants.REFRESH_ICON); this.setSmallIcon(UIConstants.REFRESH_ICON);
} }
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
selectedOperation.refresh(); selectedOperation.refresh();
stateChange(); stateChange();
} }
} }
/* /*
* 重命名文件 * 重命名文件
*/ */
private class RenameAction extends UpdateAction { private class RenameAction extends UpdateAction {
public RenameAction() { public RenameAction() {
this.setName(Inter.getLocText("FR-Designer_Rename")); this.setName(Inter.getLocText("FR-Designer_Rename"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/rename.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/rename.png"));
} }
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
new RenameDialog(); new RenameDialog();
MutilTempalteTabPane.getInstance().repaint(); MutilTempalteTabPane.getInstance().repaint();
} }
} }
/* /*
* 删除指定文件 * 删除指定文件
*/ */
private class DelFileAction extends UpdateAction { private class DelFileAction extends UpdateAction {
public DelFileAction() { public DelFileAction() {
this.setName(Inter.getLocText("FR-Designer_Remove")); this.setName(Inter.getLocText("FR-Designer_Remove"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/delete.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/delete.png"));
} }
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
selectedOperation.deleteFile(); selectedOperation.deleteFile();
} }
} }
/** /**
* 按钮状态改变 * 按钮状态改变
*/ */
@Override @Override
public void stateChange() { public void stateChange() {
//当前环境为远程环境时
if (FRContext.getCommonOperator() != null) { if (selectedOperation.getSelectedTemplatePath() != null) {
//当前环境为本地环境时 openReportAction.setEnabled(true);
if (selectedOperation.getSelectedTemplatePath() != null) { renameAction.setEnabled(true);
openReportAction.setEnabled(true); delFileAction.setEnabled(true);
renameAction.setEnabled(true); } else {
delFileAction.setEnabled(true); openReportAction.setEnabled(false);
} else { renameAction.setEnabled(false);
openReportAction.setEnabled(false); delFileAction.setEnabled(false);
renameAction.setEnabled(false);
delFileAction.setEnabled(false);
}
openFolderAction.setEnabled(containsFolderNums() + seletedTemplateNums() != 0);
} }
openFolderAction.setEnabled(containsFolderNums() + seletedTemplateNums() != 0);
refreshTreeAction.setEnabled(true); refreshTreeAction.setEnabled(true);
if (containsFolderNums() > 0 && (containsFolderNums() + seletedTemplateNums() > 1)) { if (containsFolderNums() > 0 && (containsFolderNums() + seletedTemplateNums() > 1)) {
refreshActions(); refreshActions();
@ -288,21 +304,22 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
renameAction.setEnabled(false); renameAction.setEnabled(false);
delFileAction.setEnabled(true); delFileAction.setEnabled(true);
} }
} }
/** /**
* 是否包含文件夹 * 是否包含文件夹
* *
* @return * @return
*/ */
private int containsFolderNums() { private int containsFolderNums() {
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree(); TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) { if (fileTree.getSelectionPaths() == null) {
return 0; return 0;
} }
//选择的包含文件和文件夹的数目 //选择的包含文件和文件夹的数目
if (fileTree.getSelectionPaths().length == 0) { if (fileTree.getSelectionPaths().length == 0) {
return 0; return 0;
@ -310,45 +327,53 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
//所有的num减去模板的num,得到文件夹的num //所有的num减去模板的num,得到文件夹的num
return fileTree.getSelectionPaths().length - fileTree.getSelectedTemplatePaths().length; return fileTree.getSelectionPaths().length - fileTree.getSelectedTemplatePaths().length;
} }
/** /**
* 是否选择了多个模板 * 是否选择了多个模板
* *
* @return * @return
*/ */
private int seletedTemplateNums() { private int seletedTemplateNums() {
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree(); TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) { if (fileTree.getSelectionPaths() == null) {
return 0; return 0;
} }
return fileTree.getSelectedTemplatePaths().length; return fileTree.getSelectedTemplatePaths().length;
} }
// js: 重命名对话框,模仿Eclipse的重命名,支持快捷键F2,Enter,ESC // js: 重命名对话框,模仿Eclipse的重命名,支持快捷键F2,Enter,ESC
private class RenameDialog { private class RenameDialog {
private UITextField jt; private UITextField jt;
private String userInput; private String userInput;
private String oldName; private String oldName;
private UILabel hintsLabel; private UILabel hintsLabel;
private UIButton confirmButton; private UIButton confirmButton;
private JDialog jd; private JDialog jd;
private String suffix; private String suffix;
public RenameDialog() { public RenameDialog() {
final String reportPath = selectedOperation.getSelectedTemplatePath(); final String reportPath = selectedOperation.getSelectedTemplatePath();
if (reportPath == null) { if (reportPath == null) {
return; return;
} }
final FileNodeFILE nodeFile = new FileNodeFILE(new FileNode(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath), false)); final FileNodeFILE nodeFile = new FileNodeFILE(new FileNode(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath), false));
final String path = nodeFile.getPath(); final String path = nodeFile.getPath();
oldName = nodeFile.getName(); oldName = nodeFile.getName();
suffix = oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length()); suffix = oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replaceAll(suffix, ""); oldName = oldName.replaceAll(suffix, "");
jd = new JDialog(); jd = new JDialog();
jd.setLayout(new GridLayout(2, 2)); jd.setLayout(new GridLayout(2, 2));
jd.setModal(true); jd.setModal(true);
@ -359,14 +384,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
jt.getDocument().addDocumentListener(getdoDocumentListener()); jt.getDocument().addDocumentListener(getdoDocumentListener());
jt.selectAll(); jt.selectAll();
jt.setPreferredSize(new Dimension(150, 20)); jt.setPreferredSize(new Dimension(150, 20));
JPanel newNamePanel = new JPanel(); JPanel newNamePanel = new JPanel();
newNamePanel.setLayout(new BoxLayout(newNamePanel, BoxLayout.X_AXIS)); newNamePanel.setLayout(new BoxLayout(newNamePanel, BoxLayout.X_AXIS));
newNamePanel.add(Box.createHorizontalGlue()); newNamePanel.add(Box.createHorizontalGlue());
newNamePanel.add(newNameLabel); newNamePanel.add(newNameLabel);
newNamePanel.add(Box.createHorizontalStrut(5)); newNamePanel.add(Box.createHorizontalStrut(5));
jd.add(newNamePanel); jd.add(newNamePanel);
JPanel jtPanel = new JPanel(); JPanel jtPanel = new JPanel();
jtPanel.setLayout(new BoxLayout(jtPanel, BoxLayout.Y_AXIS)); jtPanel.setLayout(new BoxLayout(jtPanel, BoxLayout.Y_AXIS));
JPanel containJt = new JPanel(new BorderLayout()); JPanel containJt = new JPanel(new BorderLayout());
@ -376,42 +401,46 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
jtPanel.add(containJt); jtPanel.add(containJt);
jtPanel.add(Box.createVerticalGlue()); jtPanel.add(Box.createVerticalGlue());
jd.add(jtPanel); jd.add(jtPanel);
addUITextFieldListener(nodeFile, path); addUITextFieldListener(nodeFile, path);
hintsLabel = new UILabel(); hintsLabel = new UILabel();
hintsLabel.setBounds(20, 50, 250, 30); hintsLabel.setBounds(20, 50, 250, 30);
hintsLabel.setMaximumSize(new Dimension(200, 30)); hintsLabel.setMaximumSize(new Dimension(200, 30));
hintsLabel.setHorizontalAlignment(SwingConstants.RIGHT); hintsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
hintsLabel.setForeground(Color.RED); hintsLabel.setForeground(Color.RED);
hintsLabel.setVisible(false); hintsLabel.setVisible(false);
confirmButton = new UIButton(Inter.getLocText("FR-Designer_Confirm")); confirmButton = new UIButton(Inter.getLocText("FR-Designer_Confirm"));
confirmButton.setPreferredSize(new Dimension(80, 25)); confirmButton.setPreferredSize(new Dimension(80, 25));
confirmButton.setMinimumSize(new Dimension(80, 25)); confirmButton.setMinimumSize(new Dimension(80, 25));
confirmButton.setMaximumSize(new Dimension(80, 25)); confirmButton.setMaximumSize(new Dimension(80, 25));
confirmButton.addActionListener(new ActionListener() { confirmButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
confirmClose(nodeFile, path); confirmClose(nodeFile, path);
} }
}); });
UIButton cancelButton = new UIButton(Inter.getLocText("FR-Designer_Cancel")); UIButton cancelButton = new UIButton(Inter.getLocText("FR-Designer_Cancel"));
cancelButton.setPreferredSize(new Dimension(80, 25)); cancelButton.setPreferredSize(new Dimension(80, 25));
cancelButton.setMinimumSize(new Dimension(80, 25)); cancelButton.setMinimumSize(new Dimension(80, 25));
cancelButton.setMaximumSize(new Dimension(80, 25)); cancelButton.setMaximumSize(new Dimension(80, 25));
cancelButton.addActionListener(new ActionListener() { cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
jd.dispose(); jd.dispose();
} }
}); });
JPanel hintsPanel = new JPanel(); JPanel hintsPanel = new JPanel();
hintsPanel.setLayout(new BorderLayout()); hintsPanel.setLayout(new BorderLayout());
hintsPanel.add(hintsLabel, BorderLayout.EAST); hintsPanel.add(hintsLabel, BorderLayout.EAST);
jd.add(hintsLabel); jd.add(hintsLabel);
JPanel btPanel = new JPanel(new BorderLayout()); JPanel btPanel = new JPanel(new BorderLayout());
btPanel.setLayout(new BoxLayout(btPanel, BoxLayout.X_AXIS)); btPanel.setLayout(new BoxLayout(btPanel, BoxLayout.X_AXIS));
btPanel.add(Box.createHorizontalGlue()); btPanel.add(Box.createHorizontalGlue());
@ -420,7 +449,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
btPanel.add(cancelButton); btPanel.add(cancelButton);
btPanel.add(Box.createHorizontalStrut(20)); btPanel.add(Box.createHorizontalStrut(20));
jd.add(btPanel); jd.add(btPanel);
jd.setSize(380, 200); jd.setSize(380, 200);
jd.setTitle(Inter.getLocText("FR-Designer_Rename")); jd.setTitle(Inter.getLocText("FR-Designer_Rename"));
jd.setResizable(false); jd.setResizable(false);
@ -430,22 +459,24 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
GUICoreUtils.centerWindow(jd); GUICoreUtils.centerWindow(jd);
jd.setVisible(true); jd.setVisible(true);
} }
public void confirmClose(FileNodeFILE nodeFile, String path) { public void confirmClose(FileNodeFILE nodeFile, String path) {
userInput = userInput == null ? oldName : userInput; userInput = userInput == null ? oldName : userInput;
String oldPath = path.replaceAll("/", "\\\\"); String oldPath = path.replaceAll("/", "\\\\");
String newPath = path.replace(nodeFile.getName(), userInput + suffix); String newPath = path.replace(nodeFile.getName(), userInput + suffix);
renameTemplateInMemory(nodeFile, userInput + suffix, oldName + suffix); renameTemplateInMemory(nodeFile, userInput + suffix, oldName + suffix);
DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldPath, newPath.replaceAll("/", "\\\\")); DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldPath, newPath.replaceAll("/", "\\\\"));
//模版重命名 //模版重命名
ResourceIOUtils.renameTo(path, newPath); ResourceIOUtils.renameTo(path, newPath);
selectedOperation.refresh(); selectedOperation.refresh();
DesignerContext.getDesignerFrame().setTitle(); DesignerContext.getDesignerFrame().setTitle();
jd.dispose(); jd.dispose();
} }
private void renameTemplateInMemory(FILE tplFile, String newName, String oldName) { private void renameTemplateInMemory(FILE tplFile, String newName, String oldName) {
JTemplate<?, ?> dPane = getSpecialTemplateByFILE(tplFile); JTemplate<?, ?> dPane = getSpecialTemplateByFILE(tplFile);
if (dPane == null) { if (dPane == null) {
return; return;
@ -453,20 +484,24 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
FILE renameFile = dPane.getEditingFILE(); FILE renameFile = dPane.getEditingFILE();
renameFile.setPath(renameFile.getPath().replace(oldName, newName)); renameFile.setPath(renameFile.getPath().replace(oldName, newName));
} }
// 增加enter以及esc快捷键的支持 // 增加enter以及esc快捷键的支持
public void addUITextFieldListener(final FileNodeFILE nodeFile, final String path) { public void addUITextFieldListener(final FileNodeFILE nodeFile, final String path) {
jt.addKeyListener(new KeyAdapter() { jt.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
jd.dispose(); jd.dispose();
} }
} }
}); });
jt.addKeyListener(new KeyAdapter() { jt.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (e.getKeyCode() == KeyEvent.VK_ENTER) {
if (confirmButton.isEnabled()) { if (confirmButton.isEnabled()) {
confirmClose(nodeFile, path); confirmClose(nodeFile, path);
@ -474,30 +509,35 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
} }
} }
}); });
} }
// UITextField的输入监听 // UITextField的输入监听
public DocumentListener getdoDocumentListener() { public DocumentListener getdoDocumentListener() {
DocumentListener dl = new DocumentListener() { DocumentListener dl = new DocumentListener() {
public void changedUpdate(DocumentEvent e) { public void changedUpdate(DocumentEvent e) {
isNameAlreadyExist(); isNameAlreadyExist();
} }
public void insertUpdate(DocumentEvent e) { public void insertUpdate(DocumentEvent e) {
isNameAlreadyExist(); isNameAlreadyExist();
} }
public void removeUpdate(DocumentEvent e) { public void removeUpdate(DocumentEvent e) {
isNameAlreadyExist(); isNameAlreadyExist();
} }
}; };
return dl; return dl;
} }
private void isNameAlreadyExist() { private void isNameAlreadyExist() {
userInput = jt.getText().trim(); userInput = jt.getText().trim();
if (selectedOperation.isNameAlreadyExist(userInput, oldName, suffix)) { if (selectedOperation.isNameAlreadyExist(userInput, oldName, suffix)) {
jt.selectAll(); jt.selectAll();
@ -511,12 +551,13 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
} }
} }
} }
/** /**
* @param tplFile * @param tplFile
* @return 内存中的template重命名一下 * @return 内存中的template重命名一下
*/ */
private JTemplate<?, ?> getSpecialTemplateByFILE(FILE tplFile) { private JTemplate<?, ?> getSpecialTemplateByFILE(FILE tplFile) {
HistoryTemplateListPane historyHandle = HistoryTemplateListPane.getInstance(); HistoryTemplateListPane historyHandle = HistoryTemplateListPane.getInstance();
if (ComparatorUtils.equals(historyHandle.getCurrentEditingTemplate().getEditingFILE(), tplFile)) { if (ComparatorUtils.equals(historyHandle.getCurrentEditingTemplate().getEditingFILE(), tplFile)) {
return historyHandle.getCurrentEditingTemplate(); return historyHandle.getCurrentEditingTemplate();
@ -528,5 +569,5 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
} }
return null; return null;
} }
} }

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

@ -523,18 +523,18 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
if (editingFILE == null) { if (editingFILE == null) {
return false; return false;
} }
//检查一下连接是否成功 // //检查一下连接是否成功
try { // try {
if (FRContext.getCommonOperator() != null && !FRContext.getCommonOperator().testServerConnectionWithOutShowMessagePane()) { // if (FRContext.getCommonOperator() != null && !FRContext.getCommonOperator().testServerConnectionWithOutShowMessagePane()) {
//连接不成功,提示 // //连接不成功,提示
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), // JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Inter.getLocText(new String[]{"server_disconnected", "template_unsaved"}, new String[]{",", "!"}) // Inter.getLocText(new String[]{"server_disconnected", "template_unsaved"}, new String[]{",", "!"})
, Inter.getLocText("FR-Designer_Error"), JOptionPane.ERROR_MESSAGE); // , Inter.getLocText("FR-Designer_Error"), JOptionPane.ERROR_MESSAGE);
return false; // return false;
} // }
} catch (Exception e) { // } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage()); // FineLoggerFactory.getLogger().error(e.getMessage());
} // }
// 检查一下editingFILE是不是已存在的文件,如果不存在则用saveAs // 检查一下editingFILE是不是已存在的文件,如果不存在则用saveAs

12
designer-base/src/com/fr/design/utils/DesignUtils.java

@ -20,7 +20,6 @@ import com.fr.general.GeneralContext;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.security.JwtUtils;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.CodeUtils; import com.fr.stable.CodeUtils;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
@ -47,7 +46,6 @@ import java.net.ServerSocket;
import java.net.Socket; import java.net.Socket;
import java.net.URI; import java.net.URI;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.Calendar;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Locale; import java.util.Locale;
@ -302,16 +300,6 @@ public class DesignUtils {
if (!WorkContext.getCurrent().isLocal()) { if (!WorkContext.getCurrent().isLocal()) {
try { try {
if (Utils.isEmbeddedParameter(postfixOfUri)) {
String time = Calendar.getInstance().getTime().toString().replaceAll(" ", "");
// boolean isUserPrivilege = FRContext.getCommonOperator()).writePrivilegeMap(time, postfixOfUri);
boolean isUserPrivilege = false;
postfixOfUri = isUserPrivilege ? postfixOfUri + "&fr_check_url=" + time + "&id=" + FRContext.getCommonOperator().getUserID() : postfixOfUri;
}
// 加参数给远程设计校验权限。
String design = JwtUtils.createDefaultJWT(FRContext.getCommonOperator().getUser());
postfixOfUri = postfixOfUri + "&design=" + design;
String urlPath = getWebBrowserPath(); String urlPath = getWebBrowserPath();
Desktop.getDesktop().browse(new URI(urlPath + postfixOfUri)); Desktop.getDesktop().browse(new URI(urlPath + postfixOfUri));
} catch (Exception e) { } catch (Exception e) {

Loading…
Cancel
Save