Browse Source

Merge pull request #414 in DESIGN/design from ~YAOH.WU/design:feature/10.0 to feature/10.0

* commit '3752c38f176805e9c3c4defed6b3b5310b7a7a7a':
  REPORT-10689 远程设计新建删除和重命名
research/10.0
yaoh.wu 6 years ago
parent
commit
869fb69161
  1. 36
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 75
      designer-base/src/main/java/com/fr/design/file/FileOperations.java
  3. 291
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  4. 445
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java
  5. 225
      designer-base/src/main/java/com/fr/design/file/NodeAuthProcessor.java
  6. 334
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  7. 128
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java
  8. 666
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  9. 68
      designer-base/src/main/java/com/fr/design/menu/KeySetUtils.java
  10. 51
      designer-base/src/main/java/com/fr/file/FILE.java
  11. 787
      designer-base/src/main/java/com/fr/file/FILEChooserPane.java
  12. 4
      designer-base/src/main/java/com/fr/file/FILEFactory.java
  13. 45
      designer-base/src/main/java/com/fr/file/FileFILE.java
  14. 89
      designer-base/src/main/java/com/fr/file/FileNodeFILE.java
  15. 7
      designer-base/src/main/java/com/fr/file/MemFILE.java
  16. BIN
      designer-base/src/main/resources/com/fr/design/images/icon_NewFolderIcon_normal.png

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

@ -41,9 +41,10 @@ import com.fr.stable.xml.XMLableReader;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback; import com.fr.workspace.WorkContextCallback;
import javax.swing.*; import javax.swing.SwingWorker;
import javax.swing.SwingWorker.StateValue; import javax.swing.SwingWorker.StateValue;
import java.awt.*; import java.awt.Color;
import java.awt.Rectangle;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.FileReader; import java.io.FileReader;
@ -57,6 +58,7 @@ import java.util.GregorianCalendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.ListIterator;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -544,7 +546,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
DesignerEnvManager.getEnvManager().setCurEnvName(envName); DesignerEnvManager.getEnvManager().setCurEnvName(envName);
DesignUtils.refreshDesignerFrame(); DesignUtils.refreshDesignerFrame();
if(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate() != null) { if (HistoryTemplateListPane.getInstance().getCurrentEditingTemplate() != null) {
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea(); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea();
} }
DesignTableDataManager.fireDSChanged(new HashMap<String, String>()); DesignTableDataManager.fireDSChanged(new HashMap<String, String>());
@ -866,10 +868,36 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
public void replaceRecentOpenedFilePath(String oldPath, String newPath) { public void replaceRecentOpenedFilePath(String oldPath, String newPath) {
List<String> list = getRecentOpenedFilePathList(); List<String> list = getRecentOpenedFilePathList();
if (list.contains(oldPath)) { if (list.contains(oldPath)) {
int index = getRecentOpenedFilePathList().indexOf(oldPath); int index = list.indexOf(oldPath);
list.remove(oldPath); list.remove(oldPath);
list.add(index, newPath); list.add(index, newPath);
} }
oldPath = oldPath.replaceAll("\\\\", "/");
if (list.contains(oldPath)) {
int index = list.indexOf(oldPath);
list.remove(oldPath);
list.add(index, newPath);
}
}
/**
* 替换近期打开的文件路径
*
* @param type 文件类型,文件夹true,文件false
* @param oldPath 旧的路径 使用反斜杠分割
* @param newPath 新的路径 使用反斜杠分割
*/
public void replaceRecentOpenedFilePath(boolean type, String oldPath, String newPath) {
List<String> list = getRecentOpenedFilePathList();
ListIterator<String> iterator = list.listIterator();
while (iterator.hasNext()) {
String s = iterator.next().replaceAll("/", "\\\\");
if (type ? s.contains(oldPath + "\\") : s.equals(oldPath)) {
s = s.replace(oldPath, newPath);
iterator.set(s);
}
}
} }
private void checkRecentOpenedFileNum() { private void checkRecentOpenedFileNum() {

75
designer-base/src/main/java/com/fr/design/file/FileOperations.java

@ -1,45 +1,88 @@
package com.fr.design.file; package com.fr.design.file;
import com.fr.file.FILE;
import com.fr.file.filetree.FileNode;
public interface FileOperations { public interface FileOperations {
/**
* 新建文件夹
*
* @param name 文件夹名称
* @return 是否成功
*/
boolean mkdir(String name);
/**
* 打开报表文件
*/
void openFile();
/**
* 打开文件夹
*/
void showInExplorer();
/**
* 刷新
*/
void refresh();
/** /**
*打开选中的报表文件 * 删除文件
*/ */
public void openSelectedReport(); void deleteFile();
/** /**
*打开文件夹 * 加上文件锁
*/ */
public void openContainerFolder(); void lockFile();
/** /**
*刷新 * 文件解锁
*/ */
public void refresh(); void unlockFile();
/**
* 选中的模板路径
*
* @return 选中的模板路径
*/
String getFilePath();
/** /**
*删除文件 * 选中的文件节点
*
* @return 文件节点
*/ */
public void deleteFile(); FileNode getFileNode();
/** /**
*加上文件锁 * 是否有完整权限
*
* @return 是否有完整权限
*/ */
public void lockFile(); boolean access();
/** /**
*文件解锁 * 重命名
*
* @param tplFile 旧文件
* @param to 新文件名
* @param from 旧文件名
* @return 是否成功
*/ */
public void unLockFile(); boolean rename(FILE tplFile, String from, String to);
public String getSelectedTemplatePath();
/** /**
*文件名是否存在 * 文件名是否存在
*
* @param newName 原名 * @param newName 原名
* @param oldName 新的文件名
* @param suffix 后缀名 * @param suffix 后缀名
* @return 是否存在 * @return 是否存在
*/ */
public boolean isNameAlreadyExist(String newName, String oldName, String suffix); boolean duplicated(String newName, String suffix);
} }

291
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java

@ -0,0 +1,291 @@
package com.fr.design.file;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.design.DesignerEnvManager;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.module.DesignModuleFactory;
import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ListIterator;
/**
* 历史模板缓存
*
* @see HistoryTemplateListPane
*/
public class HistoryTemplateListCache implements CallbackEvent {
//最大保存内存中面板数,为0时关闭优化内存
private static final int DEAD_LINE = DesignerEnvManager.getEnvManager().getCachingTemplateLimit();
private List<JTemplate<?, ?>> historyList;
private JTemplate<?, ?> editingTemplate;
private static volatile HistoryTemplateListCache THIS;
public static HistoryTemplateListCache getInstance() {
if (THIS == null) {
synchronized (HistoryTemplateListCache.class) {
if (THIS == null) {
THIS = new HistoryTemplateListCache();
}
}
}
return THIS;
}
private HistoryTemplateListCache() {
historyList = new ArrayList<>();
}
/**
* 关闭选择的文件
*
* @param selected 选择的
*/
public void closeSelectedReport(JTemplate<?, ?> selected) {
DesignModuleFactory.clearChartPropertyPane();
DesignTableDataManager.closeTemplate(selected);
if (contains(selected) == -1) {
return;
}
selected.fireJTemplateClosed();
selected.stopEditing();
try {
historyList.remove(contains(selected));
selected.getEditingFILE().closeTemplate();
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Closed_Warn_Text", selected.getEditingFILE().getName()));
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
/**
* 临时关闭选择的文件
*
* @param selected 选择的
*/
public void closeVirtualSelectedReport(JTemplate<?, ?> selected) {
DesignModuleFactory.clearChartPropertyPane();
DesignTableDataManager.closeTemplate(selected);
if (contains(selected) == -1) {
return;
}
selected.fireJTemplateClosed();
selected.stopEditing();
try {
selected.getEditingFILE().closeTemplate();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
public JTemplate<?, ?> getCurrentEditingTemplate() {
return this.editingTemplate;
}
public void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
this.editingTemplate = jt;
//如果当前历史面板中没有
if (contains(jt) == -1) {
addHistory();
}
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList);
//设置tab栏为当前选中的那一栏
if (editingTemplate != null) {
MutilTempalteTabPane.getInstance().setSelectedIndex(contains(jt));
}
}
/**
* 添加历史记录
*/
public void addHistory() {
if (editingTemplate == null) {
return;
}
DesignerEnvManager.getEnvManager().addRecentOpenedFilePath(editingTemplate.getPath());
historyList.add(editingTemplate);
closeOverLineTemplate();
}
public List<JTemplate<?, ?>> getHistoryList() {
return historyList;
}
/**
* 清空历史记录
*/
public void removeAllHistory() {
historyList.clear();
this.editingTemplate = null;
}
public int getHistoryCount() {
return historyList.size();
}
public JTemplate<?, ?> get(int index) {
if (index > historyList.size() - 1 || index < 0) {
return null;
}
Collections.reverse(historyList);
JTemplate<?, ?> select = historyList.get(index);
Collections.reverse(historyList);
return select;
}
public JTemplate<?, ?> getTemplate(int index) {
return historyList.get(index);
}
/**
* 获取模板的index
*
* @param jt 模板
* @return 位置
*/
public int contains(JTemplate<?, ?> jt) {
for (int i = 0; i < historyList.size(); i++) {
if (ComparatorUtils.equals(historyList.get(i).getEditingFILE(), jt.getEditingFILE())) {
return i;
}
}
return -1;
}
/**
* 判断是否打开过该模板
*
* @param filename 文件名
* @return 文件位置
*/
public int contains(String filename) {
for (int i = 0; i < historyList.size(); i++) {
String historyPath = historyList.get(i).getPath().replaceAll("/", "\\\\");
//文件路径是全路径,历史路径是reportlets/模板名
if (filename.endsWith(historyPath)) {
return i;
}
}
return -1;
}
/**
* 是否是当前编辑的文件
*
* @param filename 文件名
* @return 是则返回TRUE
*/
public boolean isCurrentEditingFile(String filename) {
String editingFileName = editingTemplate.getPath();
return ComparatorUtils.equals(filename, editingFileName);
}
@Override
public void callback() {
getCurrentEditingTemplate().repaint();
}
/**
* 打开new模板的同时关闭old模板,优先关已保存的先打开的
*/
public void closeOverLineTemplate() {
int size = historyList.size();
int vCount = size - DEAD_LINE;
if (DEAD_LINE == 0 || vCount <= 0) {
return;
}
for (int i = 0; i < vCount; i++) {
JTemplate overTemplate = historyList.get(i);
if (overTemplate.getEditingFILE().exists() && overTemplate.isALLSaved() && overTemplate != editingTemplate) {
historyList.get(i).closeOverLineTemplate(i);
}
}
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList);
}
public void deleteFile(FileNodeFILE file) {
boolean isDir = file.isDirectory();
String suffix = isDir ? "\\" : StringUtils.EMPTY;
// path like reportlets/xx/xxx/xxx
String path = file.getPath().replaceAll("/", "\\\\") + suffix;
ListIterator<JTemplate<?, ?>> iterator = historyList.listIterator();
while (iterator.hasNext()) {
JTemplate<?, ?> template = iterator.next();
String tPath = template.getPath().replaceAll("/", "\\\\");
if (isDir ? tPath.startsWith(path) : tPath.equals(path)) {
iterator.remove();
int index = iterator.nextIndex();
int size = getHistoryCount();
if (size == index + 1 && index > 0) {
//如果删除的是后一个Tab,则定位到前一个
MutilTempalteTabPane.getInstance().setSelectedIndex(index - 1);
JTemplate selectedFile = MutilTempalteTabPane.getInstance().getSelectedFile();
if (!isCurrentEditingFile(selectedFile.getPath())) {
//如果此时面板上的实时刷新的selectedIndex得到的和历史的不一样
DesignerContext.getDesignerFrame().activateJTemplate(selectedFile);
}
}
}
}
//如果打开过,则删除,实时刷新多tab面板
int openFileCount = getHistoryCount();
if (openFileCount == 0) {
DesignerContext.getDesignerFrame().addAndActivateJTemplate();
}
MutilTempalteTabPane.getInstance().repaint();
}
public boolean rename(FILE tplFile, String from, String to) {
boolean isDir = tplFile.isDirectory();
JTemplate<?, ?> template;
template = this.getCurrentEditingTemplate();
if (template != null) {
String editingPath = template.getEditingFILE().getPath().replaceAll("/", "\\\\");
if (isDir ? editingPath.contains(from + "\\") : editingPath.equals(from)) {
FILE renameFile = template.getEditingFILE();
renameFile.setPath(editingPath.replace(from, to));
}
}
for (int i = 0; i < this.getHistoryCount(); i++) {
template = this.get(i);
String editingPath = template.getEditingFILE().getPath().replaceAll("/", "\\\\");
if (isDir ? editingPath.contains(from + "\\") : editingPath.equals(from)) {
FILE renameFile = template.getEditingFILE();
renameFile.setPath(editingPath.replace(from, to));
}
}
return true;
}
}

445
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java

@ -1,443 +1,16 @@
package com.fr.design.file; package com.fr.design.file;
import com.fr.base.FRContext; /**
import com.fr.base.chart.chartdata.CallbackEvent; * 历史模板缓存
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ilist.UIList;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class HistoryTemplateListPane extends JPanel implements FileOperations, CallbackEvent {
//最大保存内存中面板数,为0时关闭优化内存
private static final int DEAD_LINE = DesignerEnvManager.getEnvManager().getCachingTemplateLimit();;
private static final int LIST_BORDER = 4;
private List<JTemplate<?, ?>> historyList;
private JTemplate<?, ?> editingTemplate;
private FileToolbarStateChangeListener toobarStateChangeListener;
private static volatile HistoryTemplateListPane THIS;
private UIList list;
public static final HistoryTemplateListPane getInstance() {
if (THIS == null) {
synchronized (HistoryTemplateListPane.class) {
if (THIS == null) {
THIS = new HistoryTemplateListPane();
}
}
}
return THIS;
}
private HistoryTemplateListPane() {
setLayout(new BorderLayout());
historyList = new ArrayList<JTemplate<?, ?>>();
list = new UIList(new HistoryListDataMode()) {
public int locationToIndex(Point location) {
int rowCount = getModel().getSize();
int height = getPreferredSize().height - 2 * LIST_BORDER;
int rowHeight = height / rowCount;
int index = (location.y - LIST_BORDER) / rowHeight;
if (location.y < LIST_BORDER || index > rowCount - 1) {
return -1;
} else {
return index;
}
}
};
ToolTipManager.sharedInstance().registerComponent(list);
list.setBackground(UIConstants.NORMAL_BACKGROUND);
list.setCellRenderer(new HistoryListCellRender());
list.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() < 2) {
return;
}
openSelectedReport();
}
});
list.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (toobarStateChangeListener != null) {
toobarStateChangeListener.stateChange();
}
}
});
list.setBorder(BorderFactory.createEmptyBorder(LIST_BORDER, LIST_BORDER, LIST_BORDER, LIST_BORDER));
UIScrollPane scrollPane = new UIScrollPane(list);
scrollPane.setBorder(null);
this.add(scrollPane, BorderLayout.CENTER);
}
/**
* 关闭选择的文件
*
* @param selected 选择的
*/
public void closeSelectedReport(JTemplate<?, ?> selected) {
DesignModuleFactory.clearChartPropertyPane();
DesignTableDataManager.closeTemplate(selected);
if (contains(selected) == -1) {
return;
}
selected.fireJTemplateClosed();
selected.stopEditing();
try {
historyList.remove(contains(selected));
selected.getEditingFILE().closeTemplate();
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Closed_Warn_Text", selected.getEditingFILE().getName()));
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
/**
* 临时关闭选择的文件
*
* @param selected 选择的
*/
public void closeVirtualSelectedReport(JTemplate<?, ?> selected) {
DesignModuleFactory.clearChartPropertyPane();
DesignTableDataManager.closeTemplate(selected);
if (contains(selected) == -1) {
return;
}
selected.fireJTemplateClosed();
selected.stopEditing();
try {
selected.getEditingFILE().closeTemplate();
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
/**
* 关闭选择的文件
*/
public void selectedReportToVirtual(int i) {
closeOverLineTemplate();
}
public JTemplate<?, ?> getCurrentEditingTemplate() {
return this.editingTemplate;
}
public void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
this.editingTemplate = jt;
//如果当前历史面板中没有
if (contains(jt) == -1) {
addHistory();
}
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList);
//设置tab栏为当前选中的那一栏
if (editingTemplate != null) {
MutilTempalteTabPane.getInstance().setSelectedIndex(contains(jt));
}
}
/**
* 添加历史记录
*/
public void addHistory() {
if (editingTemplate == null) {
return;
}
DesignerEnvManager.getEnvManager().addRecentOpenedFilePath(editingTemplate.getPath());
((HistoryListDataMode) list.getModel()).add(editingTemplate);
}
public List<JTemplate<?, ?>> getHistoryList() {
return historyList;
}
/**
* 清空历史记录
*/
public void removeAllHistory() {
historyList.clear();
this.editingTemplate = null;
}
public int getHistoryCount() {
return list.getModel().getSize();
}
public UIList getList() {
return list;
}
public JTemplate<?, ?> get(int index) {
return (JTemplate<?, ?>) list.getModel().getElementAt(index);
}
public JTemplate<?, ?> getTemplate(int index) {
return historyList.get(index);
}
/**
* 获取模板的index
*
* @param jt 模板
* @return 位置
*/
public int contains(JTemplate<?, ?> jt) {
for (int i = 0; i < historyList.size(); i++) {
if (ComparatorUtils.equals(historyList.get(i).getEditingFILE(), jt.getEditingFILE())) {
return i;
}
}
return -1;
}
/**
* 判断是否打开过该模板
* *
* @param filename 文件名 * 为可能存在的插件做兼容处理
* @return 文件位置
*/
public int contains(String filename) {
for (int i = 0; i < historyList.size(); i++) {
String historyPath = historyList.get(i).getPath().replaceAll("/", "\\\\");
//文件路径是全路径,历史路径是reportlets/模板名
if (filename.endsWith(historyPath)) {
return i;
}
}
return -1;
}
/**
* 是否是当前编辑的文件
* *
* @param filename 文件名 * @see HistoryTemplateListCache
* @return 是则返回TRUE * @deprecated use HistoryTemplateListCache instead
*/
public boolean isCurrentEditingFile(String filename) {
String editingFileName = editingTemplate.getPath();
return ComparatorUtils.equals(filename, editingFileName);
}
@Override
public void callback() {
getCurrentEditingTemplate().repaint();
}
private class HistoryListCellRender extends DefaultListCellRenderer {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, final boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
JTemplate<?, ?> jt = (JTemplate<?, ?>) value;
UILabel nameLabel = new UILabel(jt.getEditingFILE().getName());
final int nameWidth = nameLabel.getPreferredSize().width;
UILabel uiLabel = new UILabel() {
public void paint(Graphics g) {
GUIPaintUtils.fillPaint((Graphics2D) g, 18, 0, nameWidth + 2, getHeight(), true, Constants.NULL, isSelected ? UIConstants.FLESH_BLUE : UIConstants.NORMAL_BACKGROUND, UIConstants.ARC);
super.paint(g);
}
};
uiLabel.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));
uiLabel.setIcon(jt.getIcon());
uiLabel.setText(jt.getEditingFILE().getName());
return uiLabel;
}
}
private class HistoryListDataMode extends AbstractListModel {
@Override
public int getSize() {
return historyList.size();
}
@Override
public JTemplate<?, ?> getElementAt(int index) {
if (index > getSize() - 1 || index < 0) {
return null;
}
Collections.reverse(historyList);
JTemplate<?, ?> select = historyList.get(index);
Collections.reverse(historyList);
return select;
}
public void remove(int index) {
boolean outofindex = index >= historyList.size() || index < 0;
if (historyList.isEmpty() || outofindex) {
return;
}
historyList.remove(index);
}
public void add(JTemplate<?, ?> jt) {
historyList.add(jt);
closeOverLineTemplate();
refresh();
}
}
/**
* 打开new模板的同时关闭old模板,优先关已保存的先打开的
*/ */
public void closeOverLineTemplate() { @Deprecated
int size = historyList.size(); public class HistoryTemplateListPane {
int vCount = size - DEAD_LINE; public static HistoryTemplateListCache getInstance() {
if (DEAD_LINE == 0 || vCount <= 0) { return HistoryTemplateListCache.getInstance();
return;
}
for (int i = 0; i < vCount; i++) {
JTemplate overTemplate = historyList.get(i);
if (overTemplate.getEditingFILE().exists() && overTemplate.isALLSaved() && overTemplate != editingTemplate) {
historyList.get(i).closeOverLineTemplate(i);
}
}
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList);
}
/**
* 刷新
*/
public void refresh() {
list.removeAll();
list.setModel(new HistoryListDataMode());
list.setSelectedIndex(list.getSelectedIndex());
}
/**
* 打开选择的文件
*/
public void openSelectedReport() {
DesignerContext.getDesignerFrame().addAndActivateJTemplate((JTemplate<?, ?>) list.getSelectedValue());
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
refresh();
}
/**
* 打开文件所在文件夹
*/
public void openContainerFolder() {
FileNode fileNode = new FileNode(((JTemplate<?, ?>) list.getSelectedValue()).getEditingFILE().getPath(), false);
if (WorkContext.getCurrent().isLocal()) {
IOUtils.openWindowsFolder(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), fileNode.getEnvPath()));
}
}
/**
* 删除文件
*/
public void deleteFile() {
// TODO Auto-generated method stub
}
/***
* 琐文件
*/
public void lockFile() {
// TODO Auto-generated method stub
}
/**
* 解锁
*/
public void unLockFile() {
// TODO Auto-generated method stub
}
/**
* 路径
*
* @return 路径
*/
public String getSelectedTemplatePath() {
if (list.getSelectedIndex() < 0 || list.getSelectedIndex() > list.getModel().getSize() - 1) {
return null;
}
;
String path = ((HistoryListDataMode) list.getModel()).getElementAt(list.getSelectedIndex()).getEditingFILE().getPath();
if (path.startsWith(ProjectConstants.REPORTLETS_NAME)) {
return path.substring(ProjectConstants.REPORTLETS_NAME.length());
}
return path;
}
public void setToobarStateChangeListener(FileToolbarStateChangeListener toobarStateChangeListener) {
this.toobarStateChangeListener = toobarStateChangeListener;
}
/**
* 文件是否存在
*
* @param newName 文件名
* @param oldName 原名
* @param suffix 后缀名
* @return 文件是否存在
*/
public boolean isNameAlreadyExist(String newName, String oldName, String suffix) {
boolean isNameAreadyExist = false;
for (int i = 0; i < getHistoryCount(); i++) {
JTemplate<?, ?> jt = ((HistoryListDataMode) list.getModel()).getElementAt(i);
if (ComparatorUtils.equals(jt.getEditingFILE().getName(), newName + suffix)) {
isNameAreadyExist = true;
break;
}
}
if (ComparatorUtils.equals(newName, oldName)) {
isNameAreadyExist = false;
}
return isNameAreadyExist;
} }
} }

225
designer-base/src/main/java/com/fr/design/file/NodeAuthProcessor.java

@ -0,0 +1,225 @@
package com.fr.design.file;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.report.DesignAuthority;
import com.fr.stable.CoreConstants;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.authority.AuthorityOperator;
import java.util.ArrayList;
public class NodeAuthProcessor {
public static NodeAuthProcessor getInstance() {
return NodeAuthProcessor.HOLDER.singleton;
}
private static class HOLDER {
private static NodeAuthProcessor singleton = new NodeAuthProcessor();
}
/**
* 远程设计拥有全部权限的文件夹路径
*/
private ArrayList<String> authPaths = new ArrayList<>();
private NodeAuthProcessor() {
}
public void refresh() {
authPaths.clear();
if (!WorkContext.getCurrent().isLocal()) {
try {
String username = WorkContext.getConnector().currentUser();
// 远程设计获取全部设计成员的权限列表
DesignAuthority[] authorities = WorkContext.getCurrent().get(AuthorityOperator.class).getAuthorities();
DesignAuthority authority = null;
if (authorities != null) {
for (DesignAuthority designAuthority : authorities) {
if (ComparatorUtils.equals(designAuthority.getUsername(), username)) {
authority = designAuthority;
}
}
}
if (authority != null) {
for (DesignAuthority.Item item : authority.getItems()) {
if (item.getType()) {
authPaths.add(item.getPath());
}
}
}
} catch (Exception exception) {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
}
}
}
public void clear() {
authPaths.clear();
}
/**
* 生成带权限信息的文件节点供另存对话框使用
*
* @param fileNodes file nodes
* @return 带权限信息的文件节点
*/
public FILE[] parser2FILEArray(FileNode[] fileNodes, String envPath) {
boolean isLocal = WorkContext.getCurrent().isLocal();
boolean isRoot = WorkContext.getCurrent().isRoot();
FILE[] res = new FILE[fileNodes.length];
for (int i = 0; i < res.length; i++) {
FileNode fn = fileNodes[i];
if (fn.isDirectory()) {
if (isLocal || isRoot) {
res[i] = new FileNodeFILE(fileNodes[i], envPath);
} else {
boolean hasFullAuthority = isContained(fn);
res[i] = new FileNodeFILE(fileNodes[i], envPath, hasFullAuthority);
}
} else {
res[i] = new FileNodeFILE(fileNodes[i], envPath);
}
}
return res;
}
/**
* 生成带权限信息的文件节点供另存对话框使用
*
* @param fileNode file nodes
* @return 带权限信息的文件节点
*/
public FILE fixFILENodeAuth(FileNode fileNode) {
boolean isLocal = WorkContext.getCurrent().isLocal();
boolean isRoot = WorkContext.getCurrent().isRoot();
if (fileNode.isDirectory()) {
if (isLocal || isRoot) {
return new FileNodeFILE(fileNode);
} else {
boolean hasFullAuthority = isContained(fileNode);
return new FileNodeFILE(fileNode, hasFullAuthority);
}
} else {
return new FileNodeFILE(fileNode);
}
}
/**
* 生成带权限信息的文件节点供另存对话框使用
*
* @param fileNode file nodes
* @return 带权限信息的文件节点
*/
public boolean fixFileNodeAuth(FileNode fileNode) {
boolean isLocal = WorkContext.getCurrent().isLocal();
boolean isRoot = WorkContext.getCurrent().isRoot();
if (fileNode.isDirectory()) {
if (isLocal || isRoot) {
return true;
} else {
return isContained(fileNode);
}
} else {
return true;
}
}
/**
* 生成带权限信息的目录树节点
* 提供给目录树使用
*
* @param fileNodes file nodes
* @return 带权限信息的目录树节点
*/
public ExpandMutableTreeNode[] parser2TreeNodeArray(FileNode[] fileNodes) {
boolean isLocal = WorkContext.getCurrent().isLocal();
boolean isRoot = WorkContext.getCurrent().isRoot();
ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[fileNodes.length];
for (int i = 0; i < res.length; i++) {
FileNode fn = fileNodes[i];
res[i] = new ExpandMutableTreeNode(fn);
if (fn.isDirectory()) {
res[i].add(new ExpandMutableTreeNode());
if (isLocal || isRoot) {
res[i].setFullAuthority(true);
} else {
boolean hasFullAuthority = isContained(fn);
res[i].setFullAuthority(hasFullAuthority);
}
}
}
return res;
}
public void fixTreeNodeAuth(ExpandMutableTreeNode treeNode) {
if (treeNode == null) {
return;
}
Object object = treeNode.getUserObject();
if (object instanceof FileNode) {
boolean isLocal = WorkContext.getCurrent().isLocal();
boolean isRoot = WorkContext.getCurrent().isRoot();
if (((FileNode) object).isDirectory()) {
if (isLocal || isRoot) {
treeNode.setFullAuthority(true);
} else {
boolean hasFullAuthority = isContained((FileNode) object);
treeNode.setFullAuthority(hasFullAuthority);
}
}
}
}
private boolean isContained(FileNode fileNode) {
for (String auPath : authPaths) {
if (isContained(auPath, fileNode)) {
return true;
}
}
return false;
}
private boolean isContained(String auPath, FileNode fileNode) {
auPath = ProjectConstants.REPORTLETS_NAME + CoreConstants.SEPARATOR + auPath;
String fileName = fileNode.getEnvPath();
String[] auPaths = auPath.split(CoreConstants.SEPARATOR);
String[] nodePaths = fileName.split(CoreConstants.SEPARATOR);
// 待判断目录是有权限目录或者有权限目录的子目录,全部权限
if (auPaths.length <= nodePaths.length) {
for (int i = 0; i < auPaths.length; i++) {
if (!auPaths[i].equals(nodePaths[i])) {
return false;
}
}
return fileNode.isDirectory();
}
// 其他情况半权限
else {
return false;
}
}
}

334
designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java

@ -7,18 +7,18 @@ import com.fr.base.FRContext;
import com.fr.base.io.FileAssistUtilsOperator; import com.fr.base.io.FileAssistUtilsOperator;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; 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.file.filetree.IOFileNodeFilter; import com.fr.file.filetree.IOFileNodeFilter;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.CoreConstants; import com.fr.stable.CoreConstants;
import com.fr.stable.ProductConstants;
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;
@ -26,7 +26,10 @@ import com.fr.workspace.WorkContext;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.ToolTipManager; import javax.swing.ToolTipManager;
import javax.swing.UIManager;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Desktop; import java.awt.Desktop;
import java.awt.Dimension; import java.awt.Dimension;
@ -37,6 +40,11 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Enumeration;
import static javax.swing.JOptionPane.YES_NO_OPTION;
public class TemplateTreePane extends JPanel implements FileOperations { public class TemplateTreePane extends JPanel implements FileOperations {
@ -49,7 +57,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
} }
private TemplateFileTree reportletsTree; private TemplateFileTree reportletsTree;
private FileToolbarStateChangeListener toobarStateChangeListener; private FileToolbarStateChangeListener toolBarStateChangeListener;
private TemplateTreePane() { private TemplateTreePane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
@ -71,14 +79,14 @@ public class TemplateTreePane extends JPanel implements FileOperations {
@Override @Override
public void mousePressed(MouseEvent evt) { public void mousePressed(MouseEvent evt) {
if (evt.getClickCount() == 2) { if (evt.getClickCount() == 2) {
openSelectedReport(); openFile();
} }
} }
@Override @Override
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
if (toobarStateChangeListener != null) { if (toolBarStateChangeListener != null) {
toobarStateChangeListener.stateChange(); toolBarStateChangeListener.stateChange();
} }
} }
}; };
@ -89,24 +97,24 @@ public class TemplateTreePane extends JPanel implements FileOperations {
@Override @Override
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (e.getKeyCode() == KeyEvent.VK_ENTER) {
openSelectedReport(); openFile();
} }
} }
@Override @Override
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (e.getKeyCode() == KeyEvent.VK_ENTER) {
openSelectedReport(); openFile();
} }
if (toobarStateChangeListener != null) { if (toolBarStateChangeListener != null) {
toobarStateChangeListener.stateChange(); toolBarStateChangeListener.stateChange();
} }
} }
@Override @Override
public void keyTyped(KeyEvent e) { public void keyTyped(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (e.getKeyCode() == KeyEvent.VK_ENTER) {
openSelectedReport(); openFile();
} }
} }
}); });
@ -116,6 +124,49 @@ public class TemplateTreePane extends JPanel implements FileOperations {
return this.reportletsTree; return this.reportletsTree;
} }
/**
* 选中的路径数
*
* @return 选中的路径数
*/
public int countSelectedPath() {
TreePath[] treePaths = reportletsTree.getSelectionPaths();
if (treePaths == null) {
return 0;
}
return treePaths.length;
}
/**
* 选中的文件夹个数
*
* @return 选中的文件夹个数
*/
public int countSelectedFolder() {
if (reportletsTree.getSelectedFolderPaths() == null) {
return 0;
}
return reportletsTree.getSelectedFolderPaths().length;
}
/**
* 选中的文件个数
*
* @return 选中的文件
*/
public int countSelectedFile() {
if (reportletsTree.getSelectionPaths() == null) {
return 0;
}
return reportletsTree.getSelectedTemplatePaths().length;
}
/** /**
* 刷新 * 刷新
*/ */
@ -125,11 +176,16 @@ public class TemplateTreePane extends JPanel implements FileOperations {
} }
@Override
public boolean mkdir(String path) {
return WorkContext.getWorkResource().createDirectory(path);
}
/** /**
* 打开选中的报表文件 * 打开选中的报表文件
*/ */
@Override @Override
public void openSelectedReport() { public void openFile() {
String reportPath = reportletsTree.getSelectedTemplatePath(); String reportPath = reportletsTree.getSelectedTemplatePath();
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath); final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath);
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false))); DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false)));
@ -139,7 +195,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
* 打开文件夹 * 打开文件夹
*/ */
@Override @Override
public void openContainerFolder() { public void showInExplorer() {
FileNode fn = TemplateTreePane.this.reportletsTree.getSelectedFileNode(); FileNode fn = TemplateTreePane.this.reportletsTree.getSelectedFileNode();
String filePath = StableUtils.pathJoin(WorkContext.getCurrent().getPath(), fn.getEnvPath()); String filePath = StableUtils.pathJoin(WorkContext.getCurrent().getPath(), fn.getEnvPath());
filePath = filePath.substring(0, filePath.lastIndexOf(CoreConstants.SEPARATOR)); filePath = filePath.substring(0, filePath.lastIndexOf(CoreConstants.SEPARATOR));
@ -156,134 +212,232 @@ public class TemplateTreePane extends JPanel implements FileOperations {
@Override @Override
public void refresh() { public void refresh() {
reportletsTree.refresh(); reportletsTree.refresh();
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_File_Tree_Refresh_Successfully") + "!"); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_File_Tree_Refresh_Successfully") + "!");
} }
/** /**
* 删除文件 * 删除文件
* 文件夹和文件均可删除
* <p>
* 当文件被锁时不能删除
* 当文件夹中包含被锁文件时不能删除
*/ */
@Override @Override
public void deleteFile() { public void deleteFile() {
String[] reportPaths = reportletsTree.getSelectedTemplatePaths();
if (reportPaths.length == 0) {
return; String tipContent =
countSelectedFolder() > 0
? Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_Folder")
: Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_File");
ExpandMutableTreeNode[] treeNodes = reportletsTree.getSelectedTreeNodes();
// 筛选可以删除的文件
ArrayList<ExpandMutableTreeNode> deletableNodes = new ArrayList<>();
ArrayList<ExpandMutableTreeNode> lockedNodes = new ArrayList<>();
for (ExpandMutableTreeNode treeNode : treeNodes) {
checkFreeOrLock(treeNode, deletableNodes, lockedNodes);
}
boolean success = false;
if (lockedNodes.isEmpty()) {
if (JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
tipContent,
UIManager.getString("OptionPane.titleText"),
YES_NO_OPTION)
== JOptionPane.OK_OPTION) {
// 删除所有选中的即可
success = deleteNodes(Arrays.asList(treeNodes));
}
} else {
if (JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_Unlock_File"),
UIManager.getString("OptionPane.titleText"),
YES_NO_OPTION)
== JOptionPane.YES_OPTION) {
// 删除其他
success = deleteNodes(deletableNodes);
} }
if (JOptionPane.showConfirmDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_File")) != JOptionPane.OK_OPTION) {
return;
} }
for (String reportPath : reportPaths) {
FileNodeFILE nodeFile = new FileNodeFILE(new FileNode(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath), false));
if (nodeFile.isLocked()) { if (!success) {
if (JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FileLocked_Undeleted"), JOptionPane.showConfirmDialog(null,
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.YES_OPTION, JOptionPane.ERROR_MESSAGE) == JOptionPane.YES_OPTION) { Toolkit.i18nText("Fine-Design_Basic_Delete_Failure"),
refreshDockingView(); UIManager.getString("OptionPane.titleText"),
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE);
} }
break;
reportletsTree.refresh();
} }
if (nodeFile.exists()) {
String path = StableUtils.pathJoin(nodeFile.getEnvPath(), nodeFile.getPath()); private boolean deleteNodes(Collection<ExpandMutableTreeNode> nodes) {
boolean success = true;
for (ExpandMutableTreeNode treeNode : nodes) {
Object node = treeNode.getUserObject();
if (node instanceof FileNode) {
FileNodeFILE nodeFILE = new FileNodeFILE((FileNode) node);
if (nodeFILE.exists()) {
FileAssistUtilsOperator fileAssistUtils = WorkContext.getCurrent().get(FileAssistUtilsOperator.class); FileAssistUtilsOperator fileAssistUtils = WorkContext.getCurrent().get(FileAssistUtilsOperator.class);
fileAssistUtils.moveToTrash(nodeFile.getPath()); success = fileAssistUtils.moveToTrash(nodeFILE.getPath()) && success;
deleteHistory(path.replaceAll("/", "\\\\")); HistoryTemplateListCache.getInstance().deleteFile(nodeFILE);
}
}
}
return success;
}
private boolean checkFreeOrLock(ExpandMutableTreeNode node, ArrayList<ExpandMutableTreeNode> dNodes, ArrayList<ExpandMutableTreeNode> lNodes) {
// 自己没锁
boolean selfEmptyLock = false;
Object userObj = node.getUserObject();
if (userObj instanceof FileNode) {
String lock = ((FileNode) userObj).getLock();
selfEmptyLock = lock == null || ((FileNode) userObj).getUserID().equals(lock);
}
if (node.isLeaf()) {
if (selfEmptyLock) {
dNodes.add(node);
} else { } else {
JOptionPane.showMessageDialog(this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit"), ProductConstants.PRODUCT_NAME, lNodes.add(node);
JOptionPane.INFORMATION_MESSAGE);
} }
return selfEmptyLock;
} }
reportletsTree.refresh();
ExpandMutableTreeNode[] children = reportletsTree.loadChildTreeNodes(node);
boolean childrenEmptyLock = true;
for (ExpandMutableTreeNode child : children) {
boolean childEmptyLock = checkFreeOrLock(child, dNodes, lNodes);
if (childEmptyLock) {
dNodes.add(child);
} else {
lNodes.add(child);
} }
childrenEmptyLock = childrenEmptyLock && childEmptyLock;
}
boolean emptyLock = childrenEmptyLock && selfEmptyLock;
if (emptyLock) {
dNodes.add(node);
} else {
lNodes.add(node);
}
return emptyLock;
}
@Override @Override
public void lockFile() { public void lockFile() {
throw new UnsupportedOperationException("unsupport now"); throw new UnsupportedOperationException("unsupport now");
} }
@Override @Override
public void unLockFile() { public void unlockFile() {
throw new UnsupportedOperationException("unsupport now"); throw new UnsupportedOperationException("unsupport now");
} }
private void deleteHistory(String fileName) {
int index = HistoryTemplateListPane.getInstance().contains(fileName); @Override
int size = HistoryTemplateListPane.getInstance().getHistoryCount(); public String getFilePath() {
if (index == -1) { return reportletsTree.getSelectedTemplatePath();
return;
} }
//如果打开过,则删除,实时刷新多tab面板
HistoryTemplateListPane.getInstance().getHistoryList().remove(index); @Override
int openfileCount = HistoryTemplateListPane.getInstance().getHistoryCount(); public boolean access() {
if (openfileCount == 0) {
DesignerContext.getDesignerFrame().addAndActivateJTemplate(); TreePath[] selectedTreePaths = reportletsTree.getSelectionPaths();
if (selectedTreePaths == null || selectedTreePaths.length != 1) {
return false;
} }
MutilTempalteTabPane.getInstance().repaint(); // 选中的是文件夹
if (size == index + 1 && index != 0) { TreePath treePath = selectedTreePaths[0];
//如果删除的是最后一个Tab,则定位到前一个 ExpandMutableTreeNode currentTreeNode = (ExpandMutableTreeNode) treePath.getLastPathComponent();
MutilTempalteTabPane.getInstance().setSelectedIndex(index - 1);
ExpandMutableTreeNode parentTreeNode = (ExpandMutableTreeNode) currentTreeNode.getParent();
return parentTreeNode != null && parentTreeNode.hasFullAuthority();
} }
JTemplate selectedfile = MutilTempalteTabPane.getInstance().getSelectedFile();
if (!HistoryTemplateListPane.getInstance().isCurrentEditingFile(selectedfile.getPath())) { @Override
//如果此时面板上的实时刷新的selectedIndex得到的和历史的不一样 public boolean rename(FILE tplFile, String from, String to) {
DesignerContext.getDesignerFrame().activateJTemplate(selectedfile);
// 多人协作时判断是否有锁定的文件
ExpandMutableTreeNode[] treeNodes = reportletsTree.getSelectedTreeNodes();
// 筛选可以重命名的文件
ArrayList<ExpandMutableTreeNode> unlockedNodes = new ArrayList<>();
ArrayList<ExpandMutableTreeNode> lockedNodes = new ArrayList<>();
for (ExpandMutableTreeNode treeNode : treeNodes) {
checkFreeOrLock(treeNode, unlockedNodes, lockedNodes);
} }
MutilTempalteTabPane.getInstance().repaint();
if (!lockedNodes.isEmpty()) {
JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Warn_Rename_Lock_File"),
UIManager.getString("OptionPane.titleText"),
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE);
return true;
} }
try {
// com.fr.io.utils.ResourceIOUtils 接收的是WEB-INF下的路径
return WorkContext.getWorkResource().rename(from, to);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;
}
}
@Override @Override
public String getSelectedTemplatePath() { public FileNode getFileNode() {
return reportletsTree.getSelectedTemplatePath(); return reportletsTree.getSelectedFileNode();
} }
public void setToobarStateChangeListener(FileToolbarStateChangeListener toobarStateChangeListener) { public void setToolbarStateChangeListener(FileToolbarStateChangeListener listener) {
this.toobarStateChangeListener = toobarStateChangeListener; this.toolBarStateChangeListener = listener;
} }
/** /**
* 文件名是否存在 * 仅支持在拥有完整权限的文件夹下进行新建和重命名操作那么是可以看到改文件夹下所有文件的
* *
* @param newName 原名 * @param newName 原名
* @param oldName 新的文件名
* @param suffix 后缀名 * @param suffix 后缀名
* @return 是否存在 * @return 是否有重名的
*/ */
@Override @Override
public boolean isNameAlreadyExist(String newName, String oldName, String suffix) { public boolean duplicated(String newName, String suffix) {
boolean isNameAlreadyExist = false;
TemplateFileTree tt = reportletsTree;
DefaultMutableTreeNode gen = (DefaultMutableTreeNode) tt.getModel().getRoot();
ArrayList<String> al = new ArrayList<String>();
findFiles(gen, al);
for (int i = 0; i < al.size(); i++) { // 选中的节点
if (ComparatorUtils.equals(al.get(i), newName + suffix)) { TreePath treePath = reportletsTree.getSelectionPath();
isNameAlreadyExist = true; if (treePath == null) {
break; return false;
}
} }
DefaultMutableTreeNode currentTreeNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();
TreeNode parentTreeNode = currentTreeNode.getParent();
if (ComparatorUtils.equals(newName, oldName)) { Enumeration children = parentTreeNode.children();
isNameAlreadyExist = false;
}
return isNameAlreadyExist; while (children.hasMoreElements()) {
DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) children.nextElement();
Object object = childNode.getUserObject();
if (object instanceof FileNode) {
if (ComparatorUtils.equals(((FileNode) object).getName(), newName + suffix)) {
return true;
} }
private void findFiles(DefaultMutableTreeNode node, ArrayList<String> al) {
String[] str = new String[node.getChildCount()];
for (int j = 0; j < node.getChildCount(); j++) {
DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) node.getChildAt(j);
if (childNode.getChildCount() > 0) {
findFiles(childNode, al);
} else { } else {
str[j] = node.getChildAt(j).toString(); return false;
if (str[j].contains(".")) {
al.add(str[j]);
}
} }
} }
return false;
} }
} }

128
designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java

@ -2,17 +2,13 @@ package com.fr.design.gui.itree.filetree;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.extension.FileExtension; import com.fr.base.extension.FileExtension;
import com.fr.design.file.NodeAuthProcessor;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.report.DesignAuthority;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
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.server.authority.AuthorityOperator;
import javax.swing.text.Position; import javax.swing.text.Position;
import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.DefaultTreeModel;
@ -26,12 +22,6 @@ import java.util.List;
*/ */
public class TemplateFileTree extends EnvFileTree { public class TemplateFileTree extends EnvFileTree {
/**
* 远程设计拥有全部权限的文件夹路径
*/
private ArrayList<String> paths = new ArrayList<>();
public TemplateFileTree() { public TemplateFileTree() {
super(ProjectConstants.REPORTLETS_NAME, null, null); super(ProjectConstants.REPORTLETS_NAME, null, null);
} }
@ -79,10 +69,32 @@ public class TemplateFileTree extends EnvFileTree {
} }
} }
return selectedPathList.toArray(new String[0]);
}
public String[] getSelectedFolderPaths() {
TreePath[] selectedTreePaths = this.getSelectionPaths();
if (ArrayUtils.isEmpty(selectedTreePaths)) {
return ArrayUtils.EMPTY_STRING_ARRAY;
}
List<String> selectedPathList = new ArrayList<String>();
for (TreePath treepath : selectedTreePaths) {
ExpandMutableTreeNode currentTreeNode = (ExpandMutableTreeNode) treepath.getLastPathComponent();
Object userObject = currentTreeNode.getUserObject();
if (userObject instanceof FileNode) {
FileNode fn = (FileNode) userObject;
if (fn.isDirectory()) {
String envPath = fn.getEnvPath();
if (envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) {
selectedPathList.add(envPath.substring(ProjectConstants.REPORTLETS_NAME.length()));
}
}
}
}
return selectedPathList.toArray(new String[0]); return selectedPathList.toArray(new String[0]);
} }
@Override @Override
public TreePath getNextMatch(String prefix, int startingRow, Position.Bias bias) { public TreePath getNextMatch(String prefix, int startingRow, Position.Bias bias) {
@ -122,37 +134,11 @@ public class TemplateFileTree extends EnvFileTree {
*/ */
@Override @Override
public void refreshEnv() { public void refreshEnv() {
paths.clear(); NodeAuthProcessor.getInstance().refresh();
if (!WorkContext.getCurrent().isLocal()) {
try {
String username = WorkContext.getConnector().currentUser();
// 远程设计获取全部设计成员的权限列表
DesignAuthority[] authorities = WorkContext.getCurrent().get(AuthorityOperator.class).getAuthorities();
DesignAuthority authority = null;
if (authorities != null) {
for (DesignAuthority designAuthority : authorities) {
if (ComparatorUtils.equals(designAuthority.getUsername(), username)) {
authority = designAuthority;
}
}
}
if (authority != null) {
for (DesignAuthority.Item item : authority.getItems()) {
if (item.getType()) {
paths.add(item.getPath());
}
}
}
} catch (Exception exception) {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
}
}
DefaultTreeModel defaultTreeModel = (DefaultTreeModel) this.getModel(); DefaultTreeModel defaultTreeModel = (DefaultTreeModel) this.getModel();
ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot(); ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot();
NodeAuthProcessor.getInstance().fixTreeNodeAuth(rootTreeNode);
rootTreeNode.removeAllChildren(); rootTreeNode.removeAllChildren();
FileNode[] fns; FileNode[] fns;
@ -178,64 +164,34 @@ public class TemplateFileTree extends EnvFileTree {
} }
@Override @Override
protected ExpandMutableTreeNode[] loadChildTreeNodes(ExpandMutableTreeNode treeNode) { public ExpandMutableTreeNode[] loadChildTreeNodes(ExpandMutableTreeNode treeNode) {
FileNode[] fnArray = listFileNodes(treeNode); FileNode[] fnArray = listFileNodes(treeNode);
return fileNodeArray2TreeNodeArray(fnArray); return fileNodeArray2TreeNodeArray(fnArray);
} }
/*
* 把FileNode[]转成ExpandMutableTreeNode[]
*/
private ExpandMutableTreeNode[] fileNodeArray2TreeNodeArray(FileNode[] fileNodes) {
boolean isLocal = WorkContext.getCurrent().isLocal();
boolean isRoot = WorkContext.getCurrent().isRoot();
ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[fileNodes.length];
for (int i = 0; i < res.length; i++) {
FileNode fn = fileNodes[i];
res[i] = new ExpandMutableTreeNode(fn);
if (fn.isDirectory()) {
res[i].add(new ExpandMutableTreeNode());
if (isLocal || isRoot) {
res[i].setFullAuthority(true);
} else {
boolean hasFullAuthority = isContained(fn);
res[i].setFullAuthority(hasFullAuthority);
}
}
}
return res;
}
private boolean isContained(FileNode fileNode) { public ExpandMutableTreeNode[] getSelectedTreeNodes() {
TreePath[] paths = this.getSelectionPaths();
for (String auPath : paths) { if (paths == null) {
if (isContained(auPath, fileNode)) { return new ExpandMutableTreeNode[0];
return true;
}
}
return false;
} }
private boolean isContained(String auPath, FileNode fileNode) { ArrayList<ExpandMutableTreeNode> res = new ArrayList<>();
auPath = ProjectConstants.REPORTLETS_NAME + CoreConstants.SEPARATOR + auPath;
String fileName = fileNode.getEnvPath(); for (TreePath path : paths) {
String[] auPaths = auPath.split(CoreConstants.SEPARATOR); res.add((ExpandMutableTreeNode) path.getLastPathComponent());
String[] nodePaths = fileName.split(CoreConstants.SEPARATOR);
// 待判断目录是有权限目录或者有权限目录的子目录,全部权限
if (auPaths.length <= nodePaths.length) {
for (int i = 0; i < auPaths.length; i++) {
if (!auPaths[i].equals(nodePaths[i])) {
return false;
}
}
return fileNode.isDirectory();
} }
// 其他情况半权限 return res.toArray(new ExpandMutableTreeNode[res.size()]);
else {
return false;
} }
/*
* 把FileNode[]转成ExpandMutableTreeNode[]
*/
private ExpandMutableTreeNode[] fileNodeArray2TreeNodeArray(FileNode[] fileNodes) {
return NodeAuthProcessor.getInstance().parser2TreeNodeArray(fileNodes);
} }
@ -284,6 +240,4 @@ public class TemplateFileTree extends EnvFileTree {
return new FileNode[0]; return new FileNode[0];
} }
} }

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

@ -1,7 +1,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.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
@ -13,6 +12,7 @@ import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.data.tabledata.ResponseDataSourceChange; import com.fr.design.data.tabledata.ResponseDataSourceChange;
import com.fr.design.file.FileOperations; import com.fr.design.file.FileOperations;
import com.fr.design.file.FileToolbarStateChangeListener; import com.fr.design.file.FileToolbarStateChangeListener;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.file.TemplateTreePane; import com.fr.design.file.TemplateTreePane;
@ -21,66 +21,66 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.imenu.UIMenuHighLight; import com.fr.design.gui.imenu.UIMenuHighLight;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef; import com.fr.design.menu.ToolBarDef;
import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
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.log.FineLoggerFactory;
import com.fr.stable.CoreConstants; import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import javax.swing.UIManager;
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.BorderLayout;
import java.awt.CardLayout; import java.awt.CardLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.GridLayout; import java.awt.FlowLayout;
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.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import static javax.swing.JOptionPane.WARNING_MESSAGE;
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 volatile DesignerFrameFileDealerPane THIS; private static volatile DesignerFrameFileDealerPane THIS;
private CardLayout card; private List<FileToolbarStateChangeListener> otherToolbarStateChangeListeners = new ArrayList<>();
private JPanel cardPane;
private java.util.List<FileToolbarStateChangeListener> otherToobarStateChangeListeners = new ArrayList<>();
private FileOperations selectedOperation; private FileOperations selectedOperation;
private UIToolbar toolBar; private UIToolbar toolBar;
private OpenReportAction openReportAction = new OpenReportAction(); private NewFolderAction newFolderAction = new NewFolderAction();
private RefreshTreeAction refreshTreeAction = new RefreshTreeAction(); private RefreshTreeAction refreshTreeAction = new RefreshTreeAction();
private OpenFolderAction openFolderAction = new OpenFolderAction(); private ShowInExplorerAction showInExplorerAction = new ShowInExplorerAction();
private RenameAction renameAction = new RenameAction(); private RenameAction renameAction = new RenameAction();
@ -91,11 +91,10 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
* 刷新 * 刷新
*/ */
public void refresh() { public void refresh() {
selectedOperation.refresh(); selectedOperation.refresh();
} }
public static final DesignerFrameFileDealerPane getInstance() { public static DesignerFrameFileDealerPane getInstance() {
if (THIS == null) { if (THIS == null) {
synchronized (DesignerFrameFileDealerPane.class) { synchronized (DesignerFrameFileDealerPane.class) {
@ -121,13 +120,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
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()); CardLayout card;
JPanel 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().setToolbarStateChangeListener(this);
add(cardPane, BorderLayout.CENTER); add(cardPane, BorderLayout.CENTER);
stateChange(); stateChange();
@ -136,7 +136,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
public final void setCurrentEditingTemplate(JTemplate<?, ?> jt) { public final void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
DesignModelAdapter.setCurrentModelAdapter(jt == null ? null : jt.getModel()); DesignModelAdapter.setCurrentModelAdapter(jt.getModel());
fireDSChanged(); fireDSChanged();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
HistoryTemplateListPane.getInstance().setCurrentEditingTemplate(jt); HistoryTemplateListPane.getInstance().setCurrentEditingTemplate(jt);
@ -152,7 +152,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
jt.requestFocus(); jt.requestFocus();
jt.revert(); jt.revert();
FRContext.getLogger().info("\"" + jt.getEditingFILE().getName() + "\"" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_LOG_Has_Been_Openned") + "!"); FineLoggerFactory.getLogger().info(
"\"" + jt.getEditingFILE().getName() + "\""
+ Toolkit.i18nText("Fine-Design_Basic_LOG_Has_Been_Openned") + "!");
} }
/** /**
@ -161,27 +163,26 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
public void refreshDockingView() { public void refreshDockingView() {
ToolBarDef toolbarDef = new ToolBarDef(); ToolBarDef toolbarDef = new ToolBarDef();
toolbarDef.addShortCut(openReportAction, refreshTreeAction); toolbarDef.addShortCut(newFolderAction, refreshTreeAction);
if (WorkContext.getCurrent().isLocal()) { if (WorkContext.getCurrent().isLocal()) {
toolbarDef.addShortCut(openFolderAction, renameAction); toolbarDef.addShortCut(showInExplorerAction);
} }
toolbarDef.addShortCut(delFileAction); toolbarDef.addShortCut(renameAction, 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(); resetActionStatus();
refresh(); refresh();
} }
private void refreshActions() { private void resetActionStatus() {
openReportAction.setEnabled(false); newFolderAction.setEnabled(false);
refreshTreeAction.setEnabled(true); refreshTreeAction.setEnabled(true);
openFolderAction.setEnabled(false); showInExplorerAction.setEnabled(false);
renameAction.setEnabled(false); renameAction.setEnabled(false);
delFileAction.setEnabled(false); delFileAction.setEnabled(false);
this.repaint(); this.repaint();
@ -206,28 +207,53 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
} }
public void addToolbarStateChangeListener(FileToolbarStateChangeListener listener) {
this.otherToolbarStateChangeListeners.add(listener);
}
public void removeToolbarStateChangeListener(FileToolbarStateChangeListener listener) {
this.otherToolbarStateChangeListeners.remove(listener);
}
private void otherStateChange() {
for (FileToolbarStateChangeListener listener : otherToolbarStateChangeListeners) {
listener.stateChange();
}
}
/* /*
* Open Report Action * 新建文件夹
*/ */
private class OpenReportAction extends UpdateAction { private class NewFolderAction extends UpdateAction {
public OpenReportAction() { public NewFolderAction() {
this.setName(KeySetUtils.OPEN_TEMPLATE.getMenuKeySetName()); this.setName(KeySetUtils.NEW_FOLDER.getMenuKeySetName());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/open.png")); this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/icon_NewFolderIcon_normal.png"));
} }
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
selectedOperation.openSelectedReport(); if (!selectedOperation.access()) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
WARNING_MESSAGE);
return;
}
new MkdirDialog();
} }
} }
private class OpenFolderAction extends UpdateAction { /**
* 在系统资源管理器中打开
*/
private class ShowInExplorerAction extends UpdateAction {
public OpenFolderAction() { public ShowInExplorerAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Show_In_Containing_Folder")); this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_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"));
@ -236,7 +262,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
selectedOperation.openContainerFolder(); selectedOperation.showInExplorer();
} }
} }
@ -247,7 +273,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
public RefreshTreeAction() { public RefreshTreeAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh")); this.setName(Toolkit.i18nText("Fine-Design_Basic_Refresh"));
this.setSmallIcon(UIConstants.REFRESH_ICON); this.setSmallIcon(UIConstants.REFRESH_ICON);
} }
@ -260,20 +286,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
} }
} }
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();
}
}
/* /*
* 重命名文件 * 重命名文件
*/ */
@ -281,14 +293,22 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
public RenameAction() { public RenameAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Rename")); this.setName(Toolkit.i18nText("Fine-Design_Basic_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) {
if (!selectedOperation.access()) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
WARNING_MESSAGE);
return;
}
new RenameDialog(); FileNode node = selectedOperation.getFileNode();
new FileRenameDialog(node);
MutilTempalteTabPane.getInstance().repaint(); MutilTempalteTabPane.getInstance().repaint();
} }
@ -301,13 +321,21 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
public DelFileAction() { public DelFileAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove")); this.setName(Toolkit.i18nText("Fine-Design_Basic_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) {
if (!selectedOperation.access()) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
WARNING_MESSAGE);
return;
}
selectedOperation.deleteFile(); selectedOperation.deleteFile();
} }
} }
@ -318,295 +346,411 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
@Override @Override
public void stateChange() { public void stateChange() {
if (selectedOperation.getSelectedTemplatePath() != null) { int selectedPathNum = TemplateTreePane.getInstance().countSelectedPath();
openReportAction.setEnabled(true);
renameAction.setEnabled(true);
delFileAction.setEnabled(true);
} else {
openReportAction.setEnabled(false);
renameAction.setEnabled(false);
delFileAction.setEnabled(false);
}
openFolderAction.setEnabled(containsFolderNums() + seletedTemplateNums() != 0);
// 新建文件夹,重命名操作,在explorer中打开三个操作在选中单个文件夹或者文件时可用,其他情况不可用
boolean singleSelected = selectedPathNum == 1;
newFolderAction.setEnabled(singleSelected);
renameAction.setEnabled(singleSelected);
showInExplorerAction.setEnabled(singleSelected);
// 删除操作在至少选中一个时可用
boolean selected = selectedPathNum > 0;
delFileAction.setEnabled(selected);
// 刷新操作始终可用
refreshTreeAction.setEnabled(true); refreshTreeAction.setEnabled(true);
if (containsFolderNums() > 0 && (containsFolderNums() + seletedTemplateNums() > 1)) {
refreshActions();
} else if (containsFolderNums() == 0 && seletedTemplateNums() > 1) {
openReportAction.setEnabled(false);
refreshTreeAction.setEnabled(true);
openFolderAction.setEnabled(false);
renameAction.setEnabled(false);
delFileAction.setEnabled(true);
}
// 其他状态
otherStateChange(); otherStateChange();
} }
public FileOperations getSelectedOperation() {
return selectedOperation;
}
/** /**
* 是否包含文件夹 * 重命名对话框
* * 支持快捷键EnterESC
* @return
*/ */
private class FileRenameDialog extends JDialog {
private int containsFolderNums() { private UITextField nameField;
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree(); private UILabel warnLabel;
if (fileTree.getSelectionPaths() == null) {
return 0;
}
//选择的包含文件和文件夹的数目 private UIButton confirmButton;
if (fileTree.getSelectionPaths().length == 0) {
return 0;
}
//所有的num减去模板的num,得到文件夹的num
return fileTree.getSelectionPaths().length - fileTree.getSelectedTemplatePaths().length;
}
/** /**
* 是否选择了多个模板 * 操作的节点
*
* @return
*/ */
private int seletedTemplateNums() { private FileNodeFILE fnf;
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) {
return 0;
}
return fileTree.getSelectedTemplatePaths().length; private FileRenameDialog(FileNode node) {
if (node == null) {
return;
} }
fnf = new FileNodeFILE(node);
String oldName = fnf.getName();
String suffix = fnf.isDirectory() ? "" : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replaceAll(suffix, "");
// js: 重命名对话框,模仿Eclipse的重命名,支持快捷键F2,Enter,ESC this.setLayout(new BorderLayout());
private class RenameDialog { this.setModal(true);
private UITextField jt; // 输入框前提示
UILabel newNameLabel = new UILabel(Toolkit.i18nText(
fnf.isDirectory() ?
"Fine-Design_Basic_Enter_New_Folder_Name" : "Fine-Design_Basic_Enter_New_File_Name")
);
newNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
newNameLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
newNameLabel.setPreferredSize(new Dimension(118, 15));
private String userInput; // 重命名输入框
nameField = new UITextField(oldName);
nameField.getDocument().addDocumentListener(new DocumentListener() {
private String oldName; public void changedUpdate(DocumentEvent e) {
validInput();
}
private UILabel hintsLabel; public void insertUpdate(DocumentEvent e) {
validInput();
}
private UIButton confirmButton; public void removeUpdate(DocumentEvent e) {
validInput();
}
});
nameField.selectAll();
nameField.setPreferredSize(new Dimension(180, 20));
private JDialog jd; JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 5));
topPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 0, 15));
topPanel.add(newNameLabel);
topPanel.add(nameField);
private String suffix; // 增加enter以及esc快捷键的支持
nameField.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
dispose();
} else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
if (confirmButton.isEnabled()) {
confirmClose();
}
}
}
});
// 重名提示
warnLabel = new UILabel();
warnLabel.setPreferredSize(new Dimension(300, 30));
warnLabel.setHorizontalAlignment(SwingConstants.LEFT);
warnLabel.setForeground(Color.RED);
warnLabel.setVisible(false);
JPanel midPanel = new JPanel(new BorderLayout());
midPanel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15));
midPanel.add(warnLabel, BorderLayout.WEST);
// 确认按钮
confirmButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Confirm"));
confirmButton.setPreferredSize(new Dimension(60, 25));
confirmButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
confirmClose();
}
});
public RenameDialog() { // 取消按钮
UIButton cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel"));
cancelButton.setPreferredSize(new Dimension(60, 25));
final String reportPath = selectedOperation.getSelectedTemplatePath(); cancelButton.addActionListener(new ActionListener() {
if (reportPath == null) {
return; public void actionPerformed(ActionEvent e) {
dispose();
} }
});
final FileNodeFILE nodeFile = new FileNodeFILE(new FileNode(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath), false)); JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
final String path = nodeFile.getPath(); bottomPanel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15));
oldName = nodeFile.getName(); bottomPanel.add(confirmButton);
suffix = oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length()); bottomPanel.add(cancelButton);
oldName = oldName.replaceAll(suffix, "");
jd = new JDialog(); this.add(
jd.setLayout(new GridLayout(2, 2)); TableLayoutHelper.createTableLayoutPane(
jd.setModal(true); new Component[][]{
UILabel newNameLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Enter_New_File_Name")); new Component[]{topPanel},
newNameLabel.setMinimumSize(new Dimension(150, 27)); new Component[]{midPanel},
newNameLabel.setHorizontalAlignment(SwingConstants.RIGHT); new Component[]{bottomPanel}
jt = new UITextField(oldName); },
jt.getDocument().addDocumentListener(getdoDocumentListener()); new double[]{TableLayout.FILL, TableLayout.FILL, TableLayout.FILL},
jt.selectAll(); new double[]{TableLayout.FILL}
jt.setPreferredSize(new Dimension(150, 20)); ),
BorderLayout.CENTER);
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());
containJt.add(jt, BorderLayout.WEST);
containJt.setMaximumSize(new Dimension(200, 20));
jtPanel.add(Box.createVerticalGlue());
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(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_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); this.setSize(340, 180);
this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Rename"));
this.setResizable(false);
this.setAlwaysOnTop(true);
this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png"));
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
GUICoreUtils.centerWindow(this);
this.setVisible(true);
} }
});
UIButton cancelButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cancel")); private void confirmClose() {
cancelButton.setPreferredSize(new Dimension(80, 25));
cancelButton.setMinimumSize(new Dimension(80, 25));
cancelButton.setMaximumSize(new Dimension(80, 25));
cancelButton.addActionListener(new ActionListener() { String userInput = nameField.getText().trim();
public void actionPerformed(ActionEvent e) { String path = fnf.getPath();
jd.dispose(); String oldName = fnf.getName();
String suffix = fnf.isDirectory() ? "" : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replaceAll(suffix, "");
// 输入为空或者没有修改
if (ComparatorUtils.equals(userInput, oldName)) {
this.dispose();
return;
} }
});
JPanel hintsPanel = new JPanel(); String oldPath = path.replaceAll(CoreConstants.SEPARATOR, "\\\\");
hintsPanel.setLayout(new BorderLayout());
hintsPanel.add(hintsLabel, BorderLayout.EAST); String parentPath = fnf.getParent().getPath().replaceAll(CoreConstants.SEPARATOR, "\\\\");
jd.add(hintsLabel);
// 简单执行old new 替换是不可行的,例如 /abc/abc/abc/abc/
JPanel btPanel = new JPanel(new BorderLayout()); String newPath = parentPath + "\\" + userInput + suffix;
btPanel.setLayout(new BoxLayout(btPanel, BoxLayout.X_AXIS));
btPanel.add(Box.createHorizontalGlue()); HistoryTemplateListCache.getInstance().rename(fnf, oldPath, newPath);
btPanel.add(confirmButton); DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(fnf.isDirectory(), oldPath, newPath);
btPanel.add(Box.createHorizontalStrut(5));
btPanel.add(cancelButton);
btPanel.add(Box.createHorizontalStrut(20));
jd.add(btPanel);
jd.setSize(380, 200);
jd.setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Rename"));
jd.setResizable(false);
jd.setAlwaysOnTop(true);
jd.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png"));
jd.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
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); boolean success = selectedOperation.rename(fnf, oldPath, newPath);
selectedOperation.refresh(); selectedOperation.refresh();
DesignerContext.getDesignerFrame().setTitle(); DesignerContext.getDesignerFrame().setTitle();
jd.dispose(); this.dispose();
if (!success) {
JOptionPane.showConfirmDialog(null,
Toolkit.i18nText("Fine-Design_Basic_Rename_Failure"),
UIManager.getString("OptionPane.titleText"),
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE);
}
} }
private void renameTemplateInMemory(FILE tplFile, String newName, String oldName) {
JTemplate<?, ?> dPane = getSpecialTemplateByFILE(tplFile); private void validInput() {
if (dPane == null) {
String userInput = nameField.getText().trim();
String oldName = fnf.getName();
String suffix = fnf.isDirectory() ? "" : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replaceAll(suffix, "");
if (StringUtils.isEmpty(userInput)) {
confirmButton.setEnabled(false);
}
if (ComparatorUtils.equals(userInput, oldName)) {
warnLabel.setVisible(false);
confirmButton.setEnabled(true);
return; return;
} }
FILE renameFile = dPane.getEditingFILE();
renameFile.setPath(renameFile.getPath().replace(oldName, newName)); if (selectedOperation.duplicated(userInput, suffix)) {
nameField.selectAll();
// 如果文件名已存在,则灰掉确认按钮
warnLabel.setText(
Toolkit.i18nText(fnf.isDirectory() ?
"Fine-Design_Basic_Folder_Name_Duplicate" :
"Fine-Design_Basic_Template_File_Name_Duplicate",
userInput));
warnLabel.setVisible(true);
confirmButton.setEnabled(false);
} else {
warnLabel.setVisible(false);
confirmButton.setEnabled(true);
}
}
} }
// 增加enter以及esc快捷键的支持
public void addUITextFieldListener(final FileNodeFILE nodeFile, final String path) {
jt.addKeyListener(new KeyAdapter() { /**
* 新建文件夹对话框
* 支持快捷键EnterESC
*/
private class MkdirDialog extends JDialog {
private UITextField nameField;
public void keyPressed(KeyEvent e) { private UILabel warnLabel;
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { private UIButton confirmButton;
jd.dispose();
private MkdirDialog() {
this.setLayout(new BorderLayout());
this.setModal(true);
// 输入框前提示
UILabel newNameLabel = new UILabel(Toolkit.i18nText(
"Fine-Design_Basic_Enter_New_Folder_Name")
);
newNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
newNameLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
newNameLabel.setPreferredSize(new Dimension(118, 15));
// 文件名输入框
nameField = new UITextField();
nameField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
validInput();
} }
public void insertUpdate(DocumentEvent e) {
validInput();
}
public void removeUpdate(DocumentEvent e) {
validInput();
} }
}); });
nameField.selectAll();
nameField.setPreferredSize(new Dimension(180, 20));
jt.addKeyListener(new KeyAdapter() { JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 5));
topPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 0, 15));
topPanel.add(newNameLabel);
topPanel.add(nameField);
// 增加enter以及esc快捷键的支持
nameField.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) { dispose();
} else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
if (confirmButton.isEnabled()) { if (confirmButton.isEnabled()) {
confirmClose(nodeFile, path); confirmClose();
} }
} }
} }
}); });
// 重名提示
warnLabel = new UILabel();
warnLabel.setPreferredSize(new Dimension(300, 30));
warnLabel.setHorizontalAlignment(SwingConstants.LEFT);
warnLabel.setForeground(Color.RED);
warnLabel.setVisible(false);
JPanel midPanel = new JPanel(new BorderLayout());
midPanel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15));
midPanel.add(warnLabel, BorderLayout.WEST);
// 确认按钮
confirmButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Confirm"));
confirmButton.setPreferredSize(new Dimension(60, 25));
confirmButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
confirmClose();
} }
});
// UITextField的输入监听 // 取消按钮
public DocumentListener getdoDocumentListener() { UIButton cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel"));
cancelButton.setPreferredSize(new Dimension(60, 25));
DocumentListener dl = new DocumentListener() {
public void changedUpdate(DocumentEvent e) { cancelButton.addActionListener(new ActionListener() {
isNameAlreadyExist(); public void actionPerformed(ActionEvent e) {
dispose();
} }
});
public void insertUpdate(DocumentEvent e) { JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
bottomPanel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15));
bottomPanel.add(confirmButton);
bottomPanel.add(cancelButton);
this.add(
TableLayoutHelper.createTableLayoutPane(
new Component[][]{
new Component[]{topPanel},
new Component[]{midPanel},
new Component[]{bottomPanel}
},
new double[]{TableLayout.FILL, TableLayout.FILL, TableLayout.FILL},
new double[]{TableLayout.FILL}
),
BorderLayout.CENTER);
this.setSize(340, 180);
this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Mkdir"));
this.setResizable(false);
this.setAlwaysOnTop(true);
this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png"));
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
GUICoreUtils.centerWindow(this);
this.setVisible(true);
}
private void confirmClose() {
String userInput = nameField.getText().trim();
if (StringUtils.isEmpty(userInput)) {
return;
}
isNameAlreadyExist(); //新建文件夹
boolean success = selectedOperation.mkdir(
selectedOperation.getFileNode().getParent() + CoreConstants.SEPARATOR + userInput
);
selectedOperation.refresh();
this.dispose();
if (!success) {
JOptionPane.showConfirmDialog(null,
Toolkit.i18nText("Fine-Design_Basic_Make_Failure"),
UIManager.getString("OptionPane.titleText"),
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE);
}
} }
public void removeUpdate(DocumentEvent e) {
isNameAlreadyExist(); private void validInput() {
} String userInput = nameField.getText().trim();
};
return dl;
}
private void isNameAlreadyExist() { if (StringUtils.isEmpty(userInput)) {
confirmButton.setEnabled(false);
}
userInput = jt.getText().trim(); if (selectedOperation.duplicated(userInput, StringUtils.EMPTY)) {
if (selectedOperation.isNameAlreadyExist(userInput, oldName, suffix)) { nameField.selectAll();
jt.selectAll();
// 如果文件名已存在,则灰掉确认按钮 // 如果文件名已存在,则灰掉确认按钮
hintsLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_File_Name_Duplicate", userInput)); warnLabel.setText(
hintsLabel.setVisible(true); Toolkit.i18nText(
"Fine-Design_Basic_Folder_Name_Duplicate",
userInput));
warnLabel.setVisible(true);
confirmButton.setEnabled(false); confirmButton.setEnabled(false);
} else { } else {
hintsLabel.setVisible(false); warnLabel.setVisible(false);
confirmButton.setEnabled(true); confirmButton.setEnabled(true);
} }
} }
} }
/**
* @param tplFile
* @return 内存中的template重命名一下
*/
private JTemplate<?, ?> getSpecialTemplateByFILE(FILE tplFile) {
HistoryTemplateListPane historyHandle = HistoryTemplateListPane.getInstance();
if (ComparatorUtils.equals(historyHandle.getCurrentEditingTemplate().getEditingFILE(), tplFile)) {
return historyHandle.getCurrentEditingTemplate();
}
for (int i = 0; i < historyHandle.getHistoryCount(); i++) {
if (ComparatorUtils.equals(historyHandle.get(i).getEditingFILE(), tplFile)) {
return historyHandle.get(i);
}
}
return null;
}
public FileOperations getSelectedOperation() {
return selectedOperation;
}
} }

68
designer-base/src/main/java/com/fr/design/menu/KeySetUtils.java

@ -5,7 +5,7 @@
package com.fr.design.menu; package com.fr.design.menu;
import javax.swing.*; import javax.swing.KeyStroke;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
@ -20,6 +20,23 @@ import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_M
public class KeySetUtils { public class KeySetUtils {
public static final MenuKeySet NEW_FOLDER = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'I';
}
@Override
public String getMenuName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_New_Folder");
}
@Override
public KeyStroke getKeyStroke() {
return KeyStroke.getKeyStroke(KeyEvent.VK_I, DEFAULT_MODIFIER);
}
};
public static final MenuKeySet OPEN_TEMPLATE = new MenuKeySet() { public static final MenuKeySet OPEN_TEMPLATE = new MenuKeySet() {
@Override @Override
@ -547,7 +564,9 @@ public class KeySetUtils {
public static final MenuKeySet REPORT_WATERMARK = new MenuKeySet() { public static final MenuKeySet REPORT_WATERMARK = new MenuKeySet() {
@Override @Override
public char getMnemonic() { return 'M'; } public char getMnemonic() {
return 'M';
}
@Override @Override
public String getMenuName() { public String getMenuName() {
@ -974,14 +993,6 @@ public class KeySetUtils {
}; };
public static final MenuKeySet INSERT_FLOAT = new MenuKeySet() { public static final MenuKeySet INSERT_FLOAT = new MenuKeySet() {
@Override @Override
public char getMnemonic() { public char getMnemonic() {
@ -1000,41 +1011,4 @@ public class KeySetUtils {
}; };
} }

51
designer-base/src/main/java/com/fr/file/FILE.java

@ -1,93 +1,106 @@
package com.fr.file; package com.fr.file;
import javax.swing.Icon; import javax.swing.Icon;
import java.io.InputStream;
import java.io.OutputStream;
public interface FILE { public interface FILE {
/** /**
* 后缀 * 前缀
* @return 后缀 *
* @return 前缀
*/ */
public String prefix(); String prefix();
/** /**
* 是否是目录 * 是否是目录
*
* @return 是则返回true * @return 是则返回true
*/ */
public boolean isDirectory(); boolean isDirectory();
// Name // Name
public String getName(); String getName();
// Icon // Icon
public Icon getIcon(); Icon getIcon();
// 当前目录的Path // 当前目录的Path
public String getPath(); String getPath();
public void setPath(String path); void setPath(String path);
// 取当前目录的上级目录 // 取当前目录的上级目录
public FILE getParent(); FILE getParent();
/** /**
* 列出当前目录下所有的文件及文件夹 * 列出当前目录下所有的文件及文件夹
*
* @return 文件 * @return 文件
*/ */
public FILE[] listFiles(); FILE[] listFiles();
/** /**
* 新建一个目录 * 新建一个目录
*
* @param name 名字 * @param name 名字
* @return 新建目录 * @return 新建目录
*/ */
public boolean createFolder(String name); boolean createFolder(String name);
/** /**
* 新建文件 * 新建文件
*
* @return 是否新建成功 * @return 是否新建成功
* @throws Exception 异常 * @throws Exception 异常
*/ */
public boolean mkfile() throws Exception; boolean mkfile() throws Exception;
/** /**
* 是否存在 * 是否存在
*
* @return 是否存在 * @return 是否存在
*/ */
public boolean exists(); boolean exists();
/** /**
* 关闭文件 * 关闭文件
*
* @throws Exception 异常 * @throws Exception 异常
*/ */
public void closeTemplate() throws Exception; void closeTemplate() throws Exception;
/** /**
* 作为输入流 * 作为输入流
*
* @return 输入流 * @return 输入流
* @throws Exception 异常 * @throws Exception 异常
*/ */
public java.io.InputStream asInputStream() throws Exception; InputStream asInputStream() throws Exception;
/** /**
* 作为输出流 * 作为输出流
*
* @return 输出流 * @return 输出流
* @throws Exception 异常 * @throws Exception 异常
*/ */
public java.io.OutputStream asOutputStream() throws Exception; OutputStream asOutputStream() throws Exception;
public String getEnvFullName(); String getEnvFullName();
/** /**
* 是否是内存文件 * 是否是内存文件
*
* @return 是则返回true * @return 是则返回true
*/ */
public boolean isMemFile(); boolean isMemFile();
/** /**
* 是否是环境文件 * 是否是环境文件
*
* @return 是则返回true * @return 是则返回true
*/ */
public boolean isEnvFile(); boolean isEnvFile();
} }

787
designer-base/src/main/java/com/fr/file/FILEChooserPane.java

File diff suppressed because it is too large Load Diff

4
designer-base/src/main/java/com/fr/file/FILEFactory.java

@ -1,6 +1,7 @@
package com.fr.file; package com.fr.file;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.file.NodeAuthProcessor;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
@ -45,7 +46,8 @@ public class FILEFactory {
} else if (path.startsWith(MEM_PREFIX)) { } else if (path.startsWith(MEM_PREFIX)) {
return new MemFILE(path.substring(MEM_PREFIX.length())); return new MemFILE(path.substring(MEM_PREFIX.length()));
} else if (path.startsWith(ENV_PREFIX)) { } else if (path.startsWith(ENV_PREFIX)) {
return new FileNodeFILE(new FileNode(path.substring(ENV_PREFIX.length()), true)); return NodeAuthProcessor.getInstance().
fixFILENodeAuth(new FileNode(path.substring(ENV_PREFIX.length()), true));
} else if (path.startsWith(WEBREPORT_PREFIX)) { } else if (path.startsWith(WEBREPORT_PREFIX)) {
return new FileNodeFILE(new FileNode(path.substring(WEBREPORT_PREFIX.length()), true), return new FileNodeFILE(new FileNode(path.substring(WEBREPORT_PREFIX.length()), true),
FRContext.getCommonOperator().getWebRootPath()); FRContext.getCommonOperator().getWebRootPath());

45
designer-base/src/main/java/com/fr/file/FileFILE.java

@ -4,11 +4,11 @@ import com.fr.base.io.XMLEncryptUtils;
import com.fr.design.gui.itree.filetree.FileComparator; import com.fr.design.gui.itree.filetree.FileComparator;
import com.fr.design.gui.itree.filetree.FileTreeIcon; import com.fr.design.gui.itree.filetree.FileTreeIcon;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.web.session.SessionLocalManager;
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.web.session.SessionLocalManager;
import javax.swing.*; import javax.swing.Icon;
import javax.swing.filechooser.FileSystemView; import javax.swing.filechooser.FileSystemView;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -16,6 +16,8 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class FileFILE implements FILE { public class FileFILE implements FILE {
@ -30,9 +32,9 @@ public class FileFILE implements FILE {
} }
/** /**
* *
* *
* @return * @return
*/ */
public String prefix() { public String prefix() {
return FILEFactory.FILE_PREFIX; return FILEFactory.FILE_PREFIX;
@ -44,7 +46,7 @@ public class FileFILE implements FILE {
* @returns 是则返回true * @returns 是则返回true
*/ */
public boolean isDirectory() { public boolean isDirectory() {
return file == null ? false : file.isDirectory(); return file != null && file.isDirectory();
} }
@Override @Override
@ -118,22 +120,22 @@ public class FileFILE implements FILE {
return new FILE[]{this}; return new FILE[]{this};
} }
File[] file_array = file.listFiles(); File[] fileArray = file.listFiles();
if (file_array == null) { if (fileArray == null) {
return new FILE[0]; return new FILE[0];
} }
java.util.Arrays.sort(file_array, new FileComparator()); Arrays.sort(fileArray, new FileComparator());
java.util.List<FILE> res_list = new ArrayList<FILE>(file_array.length); List<FILE> resList = new ArrayList<FILE>(fileArray.length);
for (int i = 0; i < file_array.length; i++) { for (int i = 0; i < fileArray.length; i++) {
// 因为有一些系统文件,比如虚拟内存等,会在listFiles的时候出现,但却not exists // 因为有一些系统文件,比如虚拟内存等,会在listFiles的时候出现,但却not exists
if (file_array[i].exists()) { if (fileArray[i].exists()) {
res_list.add(new FileFILE(file_array[i])); resList.add(new FileFILE(fileArray[i]));
} }
} }
return res_list.toArray(new FILE[res_list.size()]); return resList.toArray(new FILE[resList.size()]);
} }
/** /**
@ -147,9 +149,7 @@ public class FileFILE implements FILE {
return false; return false;
} }
File new_file = new File(StableUtils.pathJoin(new String[]{ File new_file = new File(StableUtils.pathJoin(file.getAbsolutePath(), name));
file.getAbsolutePath(), name
}));
if (new_file.exists()) { if (new_file.exists()) {
return false; return false;
@ -164,7 +164,7 @@ public class FileFILE implements FILE {
* @return 是否存在 * @return 是否存在
*/ */
public boolean exists() { public boolean exists() {
return file == null ? false : file.exists(); return file != null && file.exists();
} }
/** /**
@ -192,13 +192,12 @@ public class FileFILE implements FILE {
* 作为输出流 * 作为输出流
* *
* @return 输出流 * @return 输出流
* @throws Exception 异常
*/ */
public OutputStream asOutputStream() throws Exception { public OutputStream asOutputStream() {
if (file == null || !file.exists()) { if (file == null || !file.exists()) {
return null; return null;
} }
java.io.OutputStream out = null; OutputStream out;
try { try {
out = new FileOutputStream(file); out = new FileOutputStream(file);
} catch (Exception e) { } catch (Exception e) {
@ -209,10 +208,8 @@ public class FileFILE implements FILE {
/** /**
* 关闭文件 * 关闭文件
*
* @throws Exception 异常
*/ */
public void closeTemplate() throws Exception { public void closeTemplate() {
} }
@Override @Override
@ -252,6 +249,7 @@ public class FileFILE implements FILE {
/** /**
* 是否是内存文件 * 是否是内存文件
*
* @return 是则返回true * @return 是则返回true
*/ */
public boolean isMemFile() { public boolean isMemFile() {
@ -260,6 +258,7 @@ public class FileFILE implements FILE {
/** /**
* 是否是环境文件 * 是否是环境文件
*
* @return 是则返回true * @return 是则返回true
*/ */
public boolean isEnvFile() { public boolean isEnvFile() {

89
designer-base/src/main/java/com/fr/file/FileNodeFILE.java

@ -3,30 +3,37 @@ package com.fr.file;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.io.XMLEncryptUtils; import com.fr.base.io.XMLEncryptUtils;
import com.fr.design.file.NodeAuthProcessor;
import com.fr.design.gui.itree.filetree.FileNodeComparator; import com.fr.design.gui.itree.filetree.FileNodeComparator;
import com.fr.design.gui.itree.filetree.FileTreeIcon; import com.fr.design.gui.itree.filetree.FileTreeIcon;
import com.fr.design.i18n.Toolkit;
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.workspace.resource.WorkResourceOutputStream;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
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 com.fr.workspace.resource.WorkResourceOutputStream;
import javax.swing.*; import javax.swing.Icon;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Arrays;
public class FileNodeFILE implements FILE { public class FileNodeFILE implements FILE {
private FileNode node; private FileNode node;
// carl:记录下FILE对应的运行环境,每次创建都设置下当前的运行环境 //记录下FILE对应的运行环境,每次创建都设置下当前的运行环境
private String envPath; private String envPath;
/**
* 是否有全部权限
*/
private boolean hasFullAuth = true;
public FileNodeFILE(FileNodeFILE parent, String name, boolean isDir) { public FileNodeFILE(FileNodeFILE parent, String name, boolean isDir) {
FileNode fn = parent.node; FileNode fn = parent.node;
@ -39,31 +46,51 @@ public class FileNodeFILE implements FILE {
this.node = new FileNode(StableUtils.pathJoin(parentDir, name), isDir); this.node = new FileNode(StableUtils.pathJoin(parentDir, name), isDir);
this.envPath = WorkContext.getCurrent().getPath(); this.envPath = WorkContext.getCurrent().getPath();
this.hasFullAuth = NodeAuthProcessor.getInstance().fixFileNodeAuth(node);
} }
public FileNodeFILE(FileNode node) {
public FileNodeFILE(FileNode node) {
this.node = node; this.node = node;
this.envPath = WorkContext.getCurrent().getPath(); this.envPath = WorkContext.getCurrent().getPath();
this.hasFullAuth = NodeAuthProcessor.getInstance().fixFileNodeAuth(node);
} }
public FileNodeFILE(String envPath) { public FileNodeFILE(FileNode node, boolean hasFullAuth) {
this(node);
this.hasFullAuth = hasFullAuth;
}
public FileNodeFILE(String envPath) {
this.node = null; this.node = null;
this.envPath = envPath; this.envPath = envPath;
} }
public FileNodeFILE(FileNode node, String envPath) { public FileNodeFILE(FileNode node, String envPath) {
this.node = node; this.node = node;
this.envPath = envPath; this.envPath = envPath;
this.hasFullAuth = NodeAuthProcessor.getInstance().fixFileNodeAuth(node);
}
public FileNodeFILE(FileNode node, String envPath, boolean hasFullAuth) {
this(node, envPath);
this.hasFullAuth = hasFullAuth;
} }
/** /**
* prefix 后缀 * @return 是否有完整权限
*/
public boolean hasFullAuth() {
return hasFullAuth;
}
/**
* 前缀
* *
* @return 返回后缀 * @return
*/ */
@Override
public String prefix() { public String prefix() {
if (ComparatorUtils.equals(getEnvPath(), FRContext.getCommonOperator().getWebRootPath())) { if (ComparatorUtils.equals(getEnvPath(), FRContext.getCommonOperator().getWebRootPath())) {
@ -85,14 +112,16 @@ public class FileNodeFILE implements FILE {
* *
* @return 是则返回true * @return 是则返回true
*/ */
@Override
public boolean isDirectory() { public boolean isDirectory() {
return ComparatorUtils.equals(node, null) ? true : node.isDirectory(); return ComparatorUtils.equals(node, null) || node.isDirectory();
} }
/** /**
* @return * @return
*/ */
@Override
public String getName() { public String getName() {
if (node == null) { if (node == null) {
@ -100,7 +129,7 @@ public class FileNodeFILE implements FILE {
} }
if (ComparatorUtils.equals(node.getEnvPath(), ProjectConstants.REPORTLETS_NAME)) { if (ComparatorUtils.equals(node.getEnvPath(), ProjectConstants.REPORTLETS_NAME)) {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Report_Runtime_Env"); return Toolkit.i18nText("Fine-Design_Basic_Utils_Report_Runtime_Env");
} else { } else {
return node.getName(); return node.getName();
} }
@ -109,6 +138,7 @@ public class FileNodeFILE implements FILE {
/** /**
* @return * @return
*/ */
@Override
public Icon getIcon() { public Icon getIcon() {
if (node == null) { if (node == null) {
@ -118,6 +148,11 @@ public class FileNodeFILE implements FILE {
if (ComparatorUtils.equals(node.getEnvPath(), ProjectConstants.REPORTLETS_NAME)) { if (ComparatorUtils.equals(node.getEnvPath(), ProjectConstants.REPORTLETS_NAME)) {
return BaseUtils.readIcon("/com/fr/base/images/oem/logo.png"); return BaseUtils.readIcon("/com/fr/base/images/oem/logo.png");
} else { } else {
if (!hasFullAuth) {
return FileTreeIcon.getFolderHalfImageIcon();
}
return FileTreeIcon.getIcon(node); return FileTreeIcon.getIcon(node);
} }
} }
@ -125,6 +160,7 @@ public class FileNodeFILE implements FILE {
/** /**
* @return * @return
*/ */
@Override
public String getPath() { public String getPath() {
if (node == null) { if (node == null) {
@ -137,6 +173,7 @@ public class FileNodeFILE implements FILE {
/** /**
* @param path * @param path
*/ */
@Override
public void setPath(String path) { public void setPath(String path) {
node.setEnvPath(path); node.setEnvPath(path);
@ -145,6 +182,7 @@ public class FileNodeFILE implements FILE {
/** /**
* @return * @return
*/ */
@Override
public FILE getParent() { public FILE getParent() {
if (node == null) { if (node == null) {
@ -159,33 +197,33 @@ public class FileNodeFILE implements FILE {
* *
* @return 文件组 * @return 文件组
*/ */
@Override
public FILE[] listFiles() { public FILE[] listFiles() {
if (ComparatorUtils.equals(node, null)) { if (ComparatorUtils.equals(node, null)) {
node = new FileNode(CoreConstants.SEPARATOR, true); node = new FileNode(CoreConstants.SEPARATOR, true);
//return new FILE[0];
} }
if (!node.isDirectory()) { if (!node.isDirectory()) {
return new FILE[]{this}; return new FILE[]{this};
} }
try { try {
FileNode[] node_array; FileNode[] nodeArray;
node_array = listFile(node.getEnvPath()); nodeArray = listFile(node.getEnvPath());
java.util.Arrays.sort(node_array, new FileNodeComparator()); Arrays.sort(nodeArray, new FileNodeComparator());
FILE[] res_array = new FILE[node_array.length];
for (int i = 0; i < node_array.length; i++) {
res_array[i] = new FileNodeFILE(node_array[i], envPath);
}
return res_array; return fileNodeArray2FILEArray(nodeArray, envPath);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
return new FILE[0]; return new FILE[0];
} }
} }
private FILE[] fileNodeArray2FILEArray(FileNode[] nodeArray, String envPath) {
return NodeAuthProcessor.getInstance().parser2FILEArray(nodeArray, envPath);
}
/** /**
* 根目录文件地址 * 根目录文件地址
* *
@ -212,6 +250,7 @@ public class FileNodeFILE implements FILE {
* @param name 文件夹名字 * @param name 文件夹名字
* @return 创建成功返回true * @return 创建成功返回true
*/ */
@Override
public boolean createFolder(String name) { public boolean createFolder(String name) {
if (ComparatorUtils.equals(node, null) || !node.isDirectory()) { if (ComparatorUtils.equals(node, null) || !node.isDirectory()) {
@ -250,6 +289,7 @@ public class FileNodeFILE implements FILE {
* *
* @return 文件存在返回 true * @return 文件存在返回 true
*/ */
@Override
public boolean exists() { public boolean exists() {
if (node == null) { if (node == null) {
@ -283,6 +323,7 @@ public class FileNodeFILE implements FILE {
* *
* @return 成功返回true * @return 成功返回true
*/ */
@Override
public boolean mkfile() { public boolean mkfile() {
if (node == null) { if (node == null) {
@ -303,6 +344,7 @@ public class FileNodeFILE implements FILE {
* @return 输入流 * @return 输入流
* @throws Exception * @throws Exception
*/ */
@Override
public InputStream asInputStream() throws Exception { public InputStream asInputStream() throws Exception {
if (node == null) { if (node == null) {
@ -327,6 +369,7 @@ public class FileNodeFILE implements FILE {
* @return 返回输出流 * @return 返回输出流
* @throws Exception * @throws Exception
*/ */
@Override
public OutputStream asOutputStream() throws Exception { public OutputStream asOutputStream() throws Exception {
if (ComparatorUtils.equals(node, null)) { if (ComparatorUtils.equals(node, null)) {
@ -346,6 +389,7 @@ public class FileNodeFILE implements FILE {
* *
* @throws Exception * @throws Exception
*/ */
@Override
public void closeTemplate() throws Exception { public void closeTemplate() throws Exception {
if (node == null) { if (node == null) {
@ -367,6 +411,7 @@ public class FileNodeFILE implements FILE {
* *
* @return * @return
*/ */
@Override
public String getEnvFullName() { public String getEnvFullName() {
return this.node.getEnvPath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1); return this.node.getEnvPath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1);
@ -377,6 +422,7 @@ public class FileNodeFILE implements FILE {
* *
* @return 是则返回true * @return 是则返回true
*/ */
@Override
public boolean isMemFile() { public boolean isMemFile() {
return false; return false;
@ -387,6 +433,7 @@ public class FileNodeFILE implements FILE {
* *
* @return 是则返回true * @return 是则返回true
*/ */
@Override
public boolean isEnvFile() { public boolean isEnvFile() {
return true; return true;

7
designer-base/src/main/java/com/fr/file/MemFILE.java

@ -1,10 +1,9 @@
package com.fr.file; package com.fr.file;
import javax.swing.Icon;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import javax.swing.Icon;
public class MemFILE implements FILE { public class MemFILE implements FILE {
private String name; private String name;
@ -103,9 +102,9 @@ public class MemFILE implements FILE {
} }
/** /**
* *
* *
* @return * @return
*/ */
public String prefix() { public String prefix() {
return FILEFactory.MEM_PREFIX; return FILEFactory.MEM_PREFIX;

BIN
designer-base/src/main/resources/com/fr/design/images/icon_NewFolderIcon_normal.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

Loading…
Cancel
Save