ju 7 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. 95
      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;
import com.fr.base.FRContext;
import com.fr.license.function.VT4FR;
import com.fr.stable.OperatingSystem;
import com.fr.stable.StringUtils;
@ -75,7 +74,7 @@ public class AlphaFineConfigManager implements XMLable {
public static boolean isALPHALicAvailable() {
return FRContext.getCommonOperator() != null && VT4FR.AlphaFine.isSupport();
return VT4FR.AlphaFine.isSupport();
}
@Override

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

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

95
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.project.ProjectConstants;
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.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
@ -59,19 +50,27 @@ import java.util.Map;
import java.util.Set;
public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange {
private static final String FILE = "file";
private static DesignerFrameFileDealerPane THIS;
private CardLayout card;
private JPanel cardPane;
private FileOperations selectedOperation;
private UIToolbar toolBar;
private OpenReportAction openReportAction = new OpenReportAction();
private RefreshTreeAction refreshTreeAction = new RefreshTreeAction();
private OpenFolderAction openFolderAction = new OpenFolderAction();
private RenameAction renameAction = new RenameAction();
private DelFileAction delFileAction = new DelFileAction();
@ -79,10 +78,12 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
* 刷新
*/
public void refresh() {
selectedOperation.refresh();
}
public static final DesignerFrameFileDealerPane getInstance() {
if (THIS == null) {
THIS = new DesignerFrameFileDealerPane();
}
@ -90,6 +91,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
private DesignerFrameFileDealerPane() {
setLayout(new BorderLayout());
toolBar = ToolBarDef.createJToolBar();
toolBar.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.TOOLBAR_BORDER_COLOR));
@ -116,6 +118,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
public final void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
DesignModelAdapter.setCurrentModelAdapter(jt == null ? null : jt.getModel());
fireDSChanged();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
@ -139,12 +142,13 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
* 刷新菜单
*/
public void refreshDockingView() {
ToolBarDef toolbarDef = new ToolBarDef();
toolbarDef.addShortCut(openReportAction, refreshTreeAction);
toolbarDef.addShortCut(openFolderAction, renameAction);
toolbarDef.addShortCut(delFileAction);
Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts();
for (ShortCut shortCut : extraShortCuts){
for (ShortCut shortCut : extraShortCuts) {
toolbarDef.addShortCut(shortCut);
}
@ -154,6 +158,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private void refreshActions() {
openReportAction.setEnabled(false);
refreshTreeAction.setEnabled(true);
openFolderAction.setEnabled(false);
@ -166,14 +171,17 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
* 响应数据集改变
*/
public void fireDSChanged() {
fireDSChanged(new HashMap<String, String>());
}
/**
* 响应数据集改变
* @param map 改变名字的数据集
* 响应数据集改变
*
* @param map 改变名字的数据集
*/
public void fireDSChanged(Map<String, String> map) {
DesignTableDataManager.fireDSChanged(map);
}
@ -184,12 +192,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private class OpenReportAction extends UpdateAction {
public OpenReportAction() {
this.setName(KeySetUtils.OPEN_TEMPLATE.getMenuKeySetName());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/open.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
selectedOperation.openSelectedReport();
}
@ -198,12 +208,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private class OpenFolderAction extends UpdateAction {
public OpenFolderAction() {
this.setName(Inter.getLocText("FR-Designer_Show_in_Containing_Folder"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/view_folder.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
selectedOperation.openContainerFolder();
}
}
@ -214,12 +226,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private class RefreshTreeAction extends UpdateAction {
public RefreshTreeAction() {
this.setName(Inter.getLocText("FR-Designer_Refresh"));
this.setSmallIcon(UIConstants.REFRESH_ICON);
}
@Override
public void actionPerformed(ActionEvent evt) {
selectedOperation.refresh();
stateChange();
}
@ -231,12 +245,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private class RenameAction extends UpdateAction {
public RenameAction() {
this.setName(Inter.getLocText("FR-Designer_Rename"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/rename.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
new RenameDialog();
MutilTempalteTabPane.getInstance().repaint();
}
@ -249,12 +265,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private class DelFileAction extends UpdateAction {
public DelFileAction() {
this.setName(Inter.getLocText("FR-Designer_Remove"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/delete.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
selectedOperation.deleteFile();
}
}
@ -264,20 +282,18 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
*/
@Override
public void stateChange() {
//当前环境为远程环境时
if (FRContext.getCommonOperator() != null) {
//当前环境为本地环境时
if (selectedOperation.getSelectedTemplatePath() != null) {
openReportAction.setEnabled(true);
renameAction.setEnabled(true);
delFileAction.setEnabled(true);
} else {
openReportAction.setEnabled(false);
renameAction.setEnabled(false);
delFileAction.setEnabled(false);
}
openFolderAction.setEnabled(containsFolderNums() + seletedTemplateNums() != 0);
if (selectedOperation.getSelectedTemplatePath() != null) {
openReportAction.setEnabled(true);
renameAction.setEnabled(true);
delFileAction.setEnabled(true);
} else {
openReportAction.setEnabled(false);
renameAction.setEnabled(false);
delFileAction.setEnabled(false);
}
openFolderAction.setEnabled(containsFolderNums() + seletedTemplateNums() != 0);
refreshTreeAction.setEnabled(true);
if (containsFolderNums() > 0 && (containsFolderNums() + seletedTemplateNums() > 1)) {
refreshActions();
@ -298,6 +314,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
*/
private int containsFolderNums() {
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) {
return 0;
@ -317,6 +334,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
* @return
*/
private int seletedTemplateNums() {
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) {
return 0;
@ -330,14 +348,21 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private class RenameDialog {
private UITextField jt;
private String userInput;
private String oldName;
private UILabel hintsLabel;
private UIButton confirmButton;
private JDialog jd;
private String suffix;
public RenameDialog() {
final String reportPath = selectedOperation.getSelectedTemplatePath();
if (reportPath == null) {
return;
@ -391,7 +416,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
confirmButton.setMinimumSize(new Dimension(80, 25));
confirmButton.setMaximumSize(new Dimension(80, 25));
confirmButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
confirmClose(nodeFile, path);
}
});
@ -402,7 +429,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
cancelButton.setMaximumSize(new Dimension(80, 25));
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jd.dispose();
}
});
@ -432,6 +461,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
public void confirmClose(FileNodeFILE nodeFile, String path) {
userInput = userInput == null ? oldName : userInput;
String oldPath = path.replaceAll("/", "\\\\");
String newPath = path.replace(nodeFile.getName(), userInput + suffix);
@ -446,6 +476,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
private void renameTemplateInMemory(FILE tplFile, String newName, String oldName) {
JTemplate<?, ?> dPane = getSpecialTemplateByFILE(tplFile);
if (dPane == null) {
return;
@ -458,7 +489,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
public void addUITextFieldListener(final FileNodeFILE nodeFile, final String path) {
jt.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
jd.dispose();
}
@ -466,7 +499,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
});
jt.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
if (confirmButton.isEnabled()) {
confirmClose(nodeFile, path);
@ -479,17 +514,21 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
// UITextField的输入监听
public DocumentListener getdoDocumentListener() {
DocumentListener dl = new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
isNameAlreadyExist();
}
public void insertUpdate(DocumentEvent e) {
isNameAlreadyExist();
}
public void removeUpdate(DocumentEvent e) {
isNameAlreadyExist();
}
};
@ -498,6 +537,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
private void isNameAlreadyExist() {
userInput = jt.getText().trim();
if (selectedOperation.isNameAlreadyExist(userInput, oldName, suffix)) {
jt.selectAll();
@ -517,6 +557,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
* @return 内存中的template重命名一下
*/
private JTemplate<?, ?> getSpecialTemplateByFILE(FILE tplFile) {
HistoryTemplateListPane historyHandle = HistoryTemplateListPane.getInstance();
if (ComparatorUtils.equals(historyHandle.getCurrentEditingTemplate().getEditingFILE(), tplFile)) {
return historyHandle.getCurrentEditingTemplate();

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) {
return false;
}
//检查一下连接是否成功
try {
if (FRContext.getCommonOperator() != null && !FRContext.getCommonOperator().testServerConnectionWithOutShowMessagePane()) {
//连接不成功,提示
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Inter.getLocText(new String[]{"server_disconnected", "template_unsaved"}, new String[]{",", "!"})
, Inter.getLocText("FR-Designer_Error"), JOptionPane.ERROR_MESSAGE);
return false;
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
}
// //检查一下连接是否成功
// try {
// if (FRContext.getCommonOperator() != null && !FRContext.getCommonOperator().testServerConnectionWithOutShowMessagePane()) {
// //连接不成功,提示
// JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
// Inter.getLocText(new String[]{"server_disconnected", "template_unsaved"}, new String[]{",", "!"})
// , Inter.getLocText("FR-Designer_Error"), JOptionPane.ERROR_MESSAGE);
// return false;
// }
// } catch (Exception e) {
// FineLoggerFactory.getLogger().error(e.getMessage());
// }
// 检查一下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.http.HttpClient;
import com.fr.log.FineLoggerFactory;
import com.fr.security.JwtUtils;
import com.fr.stable.ArrayUtils;
import com.fr.stable.CodeUtils;
import com.fr.stable.EncodeConstants;
@ -47,7 +46,6 @@ import java.net.ServerSocket;
import java.net.Socket;
import java.net.URI;
import java.net.URLEncoder;
import java.util.Calendar;
import java.util.Enumeration;
import java.util.Locale;
@ -302,16 +300,6 @@ public class DesignUtils {
if (!WorkContext.getCurrent().isLocal()) {
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();
Desktop.getDesktop().browse(new URI(urlPath + postfixOfUri));
} catch (Exception e) {

Loading…
Cancel
Save