Browse Source

Merge pull request #242 in DESIGN/design from ~HZZZ/design61:release/10.0 to release/10.0

* commit 'ee9ebf43b23e6a8741921822338436d20f39f67a':
  REPORT-9388 远程设计重构-设计器目录树-工具栏-10.0远程下比9.0多出两个工具栏按钮
  REPORT-9706 在远程环境下,切换成本地的时候弹出一个错误提示框呢
  REPORT-9741【10.0二轮回归】设计器菜单栏-文件-切换至远程服务器
master
Hzzz 6 years ago
parent
commit
24fde225d0
  1. 13
      designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java
  2. 262
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  3. 10
      designer-base/src/main/java/com/fr/design/mainframe/TemplatePane.java
  4. 3
      designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java

13
designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java

@ -22,7 +22,8 @@ import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.AuthException;
import javax.swing.*;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.Iterator;
@ -108,9 +109,8 @@ public class SwitchExistEnv extends MenuDef {
try {
workspace = DesignerWorkspaceGenerator.generate(selectedEnv);
if (workspace == null) {
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Inter.getLocText(new String[]{"FR-Designer_M-SwitchWorkspace", "Failed"}));
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"FR-Designer_M-SwitchWorkspace", "Failed"}),
null, 0, UIManager.getIcon("OptionPane.errorIcon"));
return;
}
WorkContext.switchTo(workspace, new WorkContextCallback() {
@ -125,9 +125,8 @@ public class SwitchExistEnv extends MenuDef {
}
});
} catch (AuthException exception) {
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Inter.getLocText(new String[]{"Fine-Designer_Basic_Remote_Connect_Auth_Failed"}));
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"Fine-Designer_Basic_Remote_Connect_Auth_Failed", "Failed"}),
null, 0, UIManager.getIcon("OptionPane.errorIcon"));
}
}
}

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

@ -36,6 +36,7 @@ import com.fr.io.utils.ResourceIOUtils;
import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
@ -50,35 +51,35 @@ import java.util.Map;
import java.util.Set;
public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange {
private static final String FILE = "file";
private static volatile 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();
/**
* 刷新
*/
public void refresh() {
selectedOperation.refresh();
}
@ -93,9 +94,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
return THIS;
}
private DesignerFrameFileDealerPane() {
setLayout(new BorderLayout());
toolBar = ToolBarDef.createJToolBar();
toolBar.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.TOOLBAR_BORDER_COLOR));
@ -106,23 +107,23 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
parent.setBorder(BorderFactory.createEmptyBorder(3, 0, 4, 0));
tooBarPane.add(parent, BorderLayout.CENTER);
tooBarPane.add(new UIMenuHighLight(), BorderLayout.SOUTH);
add(tooBarPane, BorderLayout.NORTH);
cardPane = new JPanel(card = new CardLayout());
cardPane.add(TemplateTreePane.getInstance(), FILE);
selectedOperation = TemplateTreePane.getInstance();
card.show(cardPane, FILE);
TemplateTreePane.getInstance().setToobarStateChangeListener(this);
add(cardPane, BorderLayout.CENTER);
stateChange();
}
public final void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
DesignModelAdapter.setCurrentModelAdapter(jt == null ? null : jt.getModel());
fireDSChanged();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
@ -132,37 +133,40 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
if (BaseUtils.isAuthorityEditing()) {
RolesAlreadyEditedPane.getInstance().refreshDockingView();
}
jt.setComposite();
jt.refreshToolArea();
jt.fireJTemplateOpened();
jt.requestFocus();
jt.revert();
FRContext.getLogger().info("\"" + jt.getEditingFILE().getName() + "\"" + Inter.getLocText("LOG-Has_Been_Openned") + "!");
}
/**
* 刷新菜单
*/
public void refreshDockingView() {
ToolBarDef toolbarDef = new ToolBarDef();
toolbarDef.addShortCut(openReportAction, refreshTreeAction);
toolbarDef.addShortCut(openFolderAction, renameAction);
if (WorkContext.getCurrent().isLocal()) {
toolbarDef.addShortCut(openFolderAction, renameAction);
}
toolbarDef.addShortCut(delFileAction);
Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts();
for (ShortCut shortCut : extraShortCuts) {
toolbarDef.addShortCut(shortCut);
}
toolbarDef.updateToolBar(toolBar);
refreshActions();
refresh();
}
private void refreshActions() {
openReportAction.setEnabled(false);
refreshTreeAction.setEnabled(true);
openFolderAction.setEnabled(false);
@ -170,123 +174,123 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
delFileAction.setEnabled(false);
this.repaint();
}
/**
* 响应数据集改变
*/
public void fireDSChanged() {
fireDSChanged(new HashMap<String, String>());
}
/**
* 响应数据集改变
*
* @param map 改变名字的数据集
*/
public void fireDSChanged(Map<String, String> map) {
DesignTableDataManager.fireDSChanged(map);
}
/*
* Open Report Action
*/
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();
}
}
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();
}
}
/*
* 刷新ReportletsTree
*/
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();
}
}
/*
* 重命名文件
*/
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();
}
}
/*
* 删除指定文件
*/
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();
}
}
/**
* 按钮状态改变
*/
@Override
public void stateChange() {
if (selectedOperation.getSelectedTemplatePath() != null) {
openReportAction.setEnabled(true);
renameAction.setEnabled(true);
@ -297,7 +301,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
delFileAction.setEnabled(false);
}
openFolderAction.setEnabled(containsFolderNums() + seletedTemplateNums() != 0);
refreshTreeAction.setEnabled(true);
if (containsFolderNums() > 0 && (containsFolderNums() + seletedTemplateNums() > 1)) {
refreshActions();
@ -308,22 +312,22 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
renameAction.setEnabled(false);
delFileAction.setEnabled(true);
}
}
/**
* 是否包含文件夹
*
* @return
*/
private int containsFolderNums() {
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) {
return 0;
}
//选择的包含文件和文件夹的数目
if (fileTree.getSelectionPaths().length == 0) {
return 0;
@ -331,53 +335,53 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
//所有的num减去模板的num,得到文件夹的num
return fileTree.getSelectionPaths().length - fileTree.getSelectedTemplatePaths().length;
}
/**
* 是否选择了多个模板
*
* @return
*/
private int seletedTemplateNums() {
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) {
return 0;
}
return fileTree.getSelectedTemplatePaths().length;
}
// js: 重命名对话框,模仿Eclipse的重命名,支持快捷键F2,Enter,ESC
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;
}
final FileNodeFILE nodeFile = new FileNodeFILE(new FileNode(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath), false));
final String path = nodeFile.getPath();
oldName = nodeFile.getName();
suffix = oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replaceAll(suffix, "");
jd = new JDialog();
jd.setLayout(new GridLayout(2, 2));
jd.setModal(true);
@ -388,14 +392,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
jt.getDocument().addDocumentListener(getdoDocumentListener());
jt.selectAll();
jt.setPreferredSize(new Dimension(150, 20));
JPanel newNamePanel = new JPanel();
newNamePanel.setLayout(new BoxLayout(newNamePanel, BoxLayout.X_AXIS));
newNamePanel.add(Box.createHorizontalGlue());
newNamePanel.add(newNameLabel);
newNamePanel.add(Box.createHorizontalStrut(5));
jd.add(newNamePanel);
JPanel jtPanel = new JPanel();
jtPanel.setLayout(new BoxLayout(jtPanel, BoxLayout.Y_AXIS));
JPanel containJt = new JPanel(new BorderLayout());
@ -405,46 +409,46 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
jtPanel.add(containJt);
jtPanel.add(Box.createVerticalGlue());
jd.add(jtPanel);
addUITextFieldListener(nodeFile, path);
hintsLabel = new UILabel();
hintsLabel.setBounds(20, 50, 250, 30);
hintsLabel.setMaximumSize(new Dimension(200, 30));
hintsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
hintsLabel.setForeground(Color.RED);
hintsLabel.setVisible(false);
confirmButton = new UIButton(Inter.getLocText("FR-Designer_Confirm"));
confirmButton.setPreferredSize(new Dimension(80, 25));
confirmButton.setMinimumSize(new Dimension(80, 25));
confirmButton.setMaximumSize(new Dimension(80, 25));
confirmButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
confirmClose(nodeFile, path);
}
});
UIButton cancelButton = new UIButton(Inter.getLocText("FR-Designer_Cancel"));
cancelButton.setPreferredSize(new Dimension(80, 25));
cancelButton.setMinimumSize(new Dimension(80, 25));
cancelButton.setMaximumSize(new Dimension(80, 25));
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jd.dispose();
}
});
JPanel hintsPanel = new JPanel();
hintsPanel.setLayout(new BorderLayout());
hintsPanel.add(hintsLabel, BorderLayout.EAST);
jd.add(hintsLabel);
JPanel btPanel = new JPanel(new BorderLayout());
btPanel.setLayout(new BoxLayout(btPanel, BoxLayout.X_AXIS));
btPanel.add(Box.createHorizontalGlue());
@ -453,7 +457,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
btPanel.add(cancelButton);
btPanel.add(Box.createHorizontalStrut(20));
jd.add(btPanel);
jd.setSize(380, 200);
jd.setTitle(Inter.getLocText("FR-Designer_Rename"));
jd.setResizable(false);
@ -463,24 +467,24 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
GUICoreUtils.centerWindow(jd);
jd.setVisible(true);
}
public void confirmClose(FileNodeFILE nodeFile, String path) {
userInput = userInput == null ? oldName : userInput;
String oldPath = path.replaceAll("/", "\\\\");
String newPath = path.replace(nodeFile.getName(), userInput + suffix);
renameTemplateInMemory(nodeFile, userInput + suffix, oldName + suffix);
DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldPath, newPath.replaceAll("/", "\\\\"));
//模版重命名
ResourceIOUtils.renameTo(path, newPath);
selectedOperation.refresh();
DesignerContext.getDesignerFrame().setTitle();
jd.dispose();
}
private void renameTemplateInMemory(FILE tplFile, String newName, String oldName) {
JTemplate<?, ?> dPane = getSpecialTemplateByFILE(tplFile);
if (dPane == null) {
return;
@ -488,24 +492,24 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
FILE renameFile = dPane.getEditingFILE();
renameFile.setPath(renameFile.getPath().replace(oldName, newName));
}
// 增加enter以及esc快捷键的支持
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();
}
}
});
jt.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
if (confirmButton.isEnabled()) {
confirmClose(nodeFile, path);
@ -513,35 +517,35 @@ 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();
}
};
return dl;
}
private void isNameAlreadyExist() {
userInput = jt.getText().trim();
if (selectedOperation.isNameAlreadyExist(userInput, oldName, suffix)) {
jt.selectAll();
@ -555,13 +559,13 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
}
}
/**
* @param tplFile
* @return 内存中的template重命名一下
*/
private JTemplate<?, ?> getSpecialTemplateByFILE(FILE tplFile) {
HistoryTemplateListPane historyHandle = HistoryTemplateListPane.getInstance();
if (ComparatorUtils.equals(historyHandle.getCurrentEditingTemplate().getEditingFILE(), tplFile)) {
return historyHandle.getCurrentEditingTemplate();
@ -573,5 +577,5 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
return null;
}
}

10
designer-base/src/main/java/com/fr/design/mainframe/TemplatePane.java

@ -20,6 +20,7 @@ import com.fr.stable.EnvChangedListener;
import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.AuthException;
import javax.swing.*;
import java.awt.*;
@ -135,9 +136,8 @@ public class TemplatePane extends JPanel implements MouseListener {
try {
Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv);
if (workspace == null) {
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Inter.getLocText(new String[]{"FR-Designer_M-SwitchWorkspace", "Failed"}));
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"FR-Designer_M-SwitchWorkspace", "Failed"}),
null, 0, UIManager.getIcon("OptionPane.errorIcon"));
return false;
}
WorkContext.switchTo(workspace, new WorkContextCallback() {
@ -152,8 +152,8 @@ public class TemplatePane extends JPanel implements MouseListener {
template.refreshToolArea();
}
setJLabel(selectedName);
} catch (Exception e) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"}),
} catch (AuthException e) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"Fine-Designer_Basic_Remote_Connect_Auth_Failed", "Failed"}),
null, 0, UIManager.getIcon("OptionPane.errorIcon"));
return false;
}

3
designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java

@ -55,7 +55,6 @@ public class DesignerSocketIO {
status = Status.Disconnecting;
socketIO.get().close();
socketIO = Optional.absent();
status = Status.Disconnected;
}
}
@ -82,8 +81,8 @@ public class DesignerSocketIO {
if (status != Status.Disconnecting) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"Fine-Designer_Basic_Remote_Disconnected"}),
null, 0, UIManager.getIcon("OptionPane.errorIcon"));
status = Status.Disconnected;
}
status = Status.Disconnected;
}
});
socketIO.get().connect();

Loading…
Cancel
Save