|
|
|
@ -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 改变名字的数据集 |
|
|
|
|
*/ |
|
|
|
|
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,9 +282,7 @@ 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); |
|
|
|
@ -277,7 +293,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(); |
|
|
|
@ -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(); |
|
|
|
|