* commit 'd6d4e7a0ff67cb3831de34821f03436e71a5a27c': (107 commits) REPORT-11448 & REPORT-10678 原先的判断网络断开的逻辑,用swingworker搜索的时候,偶现性的会卡住。 UT暂时不提交 UT REPORT-11403 查询结果出来的横向滚动条位置偏上了 调整下纵向滚动条位置 REPORT-11445 @plough:打印设置中打印份数可以为0不合理 CHART-3011 地球默认背景 REPORT-11403 @Sung:查询结果出来的横向滚动条位置偏上了 调整高度 无JIRA任务,多线程问题 删除重复代码 关闭未保存的文件交互修订 在getNoConnectList里判断isNetworkOk, 对外就一个方法getNoConnectList REPORT-10946 @Sung:离线状态下(断网)alphafine都打不开了 之前的断网情况逻辑耦合太严重了,剥离出来 REPORT-11395 用户搜索交互修订 REPORT-11394 二次选择某些场景下可能删除失败 REPORT-11107【10.0插件】插件-输出离线HTML插件-工具栏使用该按钮报错 删除老的“输出离线html报表”代码 REPORT-11352 远程设计去除socketio的适配,部分代码质量 REPORT-11328 & REPORT-10946 & REPORT-10928 & REPORT-11196 1.修复右侧预览内容过宽,没有横向滚动条的问题 2.处理断网时,显示链接失败的一处错误逻辑 3.list中重复元素去重 4.原先写法不规范,应申明为private,set,get取存值 REPORT-11155 10.0 丢失功能点补充 REPORT-11216 10.0远程设计问题解决 模板锁现在是用socketio做的关闭解锁,如果socketio没连上的话,模板就永远没办法解锁了 加心跳来处理模板锁异常关闭的情况 ...final/10.0
@ -0,0 +1,173 @@
|
||||
package com.fr.design; |
||||
|
||||
import com.fr.design.data.DesignTableDataManager; |
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.env.DesignerWorkspaceGenerator; |
||||
import com.fr.design.env.DesignerWorkspaceInfo; |
||||
import com.fr.design.file.HistoryTemplateListCache; |
||||
import com.fr.design.file.TemplateTreePane; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.design.utils.DesignUtils; |
||||
import com.fr.env.EnvListPane; |
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.license.exception.RegistEditionException; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.EnvChangedListener; |
||||
import com.fr.workspace.WorkContext; |
||||
import com.fr.workspace.WorkContextCallback; |
||||
import com.fr.workspace.Workspace; |
||||
import com.fr.workspace.connect.AuthException; |
||||
|
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.SwingUtilities; |
||||
import javax.swing.UIManager; |
||||
import java.util.HashMap; |
||||
|
||||
import static javax.swing.JOptionPane.ERROR_MESSAGE; |
||||
|
||||
public class EnvChangeEntrance { |
||||
|
||||
private String currentEnvName = ""; |
||||
|
||||
public static EnvChangeEntrance getInstance() { |
||||
return HOLDER.singleton; |
||||
} |
||||
|
||||
private static class HOLDER { |
||||
private static EnvChangeEntrance singleton = new EnvChangeEntrance(); |
||||
} |
||||
|
||||
|
||||
private EnvChangeEntrance() { |
||||
currentEnvName = DesignerEnvManager.getEnvManager().getCurEnvName(); |
||||
GeneralContext.addEnvChangedListener(new EnvChangedListener() { |
||||
@Override |
||||
public void envChanged() { |
||||
currentEnvName = DesignerEnvManager.getEnvManager().getCurEnvName(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private boolean envListOkAction(EnvListPane envListPane) { |
||||
final String selectedName = envListPane.updateEnvManager(); |
||||
return switch2Env(selectedName); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 切换到新环境 |
||||
* |
||||
* @param envName 新工作环境名称 |
||||
* @return 是否成功 |
||||
*/ |
||||
public boolean switch2Env(final String envName) { |
||||
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); |
||||
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName); |
||||
|
||||
try { |
||||
Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv); |
||||
boolean checkValid = workspace != null && selectedEnv.checkValid(); |
||||
if (!checkValid) { |
||||
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), |
||||
UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); |
||||
return false; |
||||
} |
||||
WorkContext.switchTo(workspace, new WorkContextCallback() { |
||||
@Override |
||||
public void done() { |
||||
DesignerEnvManager.getEnvManager().setCurEnvName(envName); |
||||
DesignUtils.refreshDesignerFrame(); |
||||
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
||||
if (template != null) { |
||||
template.refreshToolArea(); |
||||
} |
||||
DesignTableDataManager.fireDSChanged(new HashMap<String, String>()); |
||||
} |
||||
}); |
||||
|
||||
} catch (AuthException | RegistEditionException e) { |
||||
// String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed");
|
||||
// String title = Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote");
|
||||
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), |
||||
UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); |
||||
return false; |
||||
} catch (Exception exception) { |
||||
FineLoggerFactory.getLogger().error(exception.getMessage(), exception); |
||||
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), |
||||
UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); |
||||
return false; |
||||
} |
||||
TemplateTreePane.getInstance().refreshDockingView(); |
||||
DesignModelAdapter<?, ?> model = DesignModelAdapter.getCurrentModelAdapter(); |
||||
if (model != null) { |
||||
model.envChanged(); |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* 编辑items |
||||
* |
||||
* @see EnvChangeEntrance#chooseEnv() |
||||
* @deprecated use {@link EnvChangeEntrance#chooseEnv()} |
||||
*/ |
||||
@Deprecated |
||||
public void editItems() { |
||||
chooseEnv(); |
||||
} |
||||
|
||||
/** |
||||
* 出现对话框,选择使用的工作环境 |
||||
*/ |
||||
public void chooseEnv() { |
||||
final EnvListPane envListPane = new EnvListPane(); |
||||
final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); |
||||
|
||||
envListPane.populateEnvManager(currentEnvName); |
||||
envListDialog.addDialogActionListener(new DialogActionAdapter() { |
||||
|
||||
@Override |
||||
public void doOk() { |
||||
envListDialog.dispose(); |
||||
envListOkAction(envListPane); |
||||
} |
||||
|
||||
@Override |
||||
public void doCancel() { |
||||
|
||||
envListDialog.dispose(); |
||||
} |
||||
}); |
||||
envListDialog.setVisible(true); |
||||
} |
||||
|
||||
/** |
||||
* 处理异常 |
||||
*/ |
||||
public void dealEvnExceptionWhenStartDesigner() { |
||||
final EnvListPane envListPane = new EnvListPane(); |
||||
envListPane.populateEnvManager(currentEnvName); |
||||
BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); |
||||
envListDialog.addDialogActionListener(new DialogActionAdapter() { |
||||
|
||||
@Override |
||||
public void doOk() { |
||||
|
||||
if (!envListOkAction(envListPane)) { |
||||
System.exit(0); |
||||
} |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void doCancel() { |
||||
System.exit(0); |
||||
} |
||||
}); |
||||
envListDialog.setVisible(true); |
||||
} |
||||
|
||||
} |
@ -1,45 +1,88 @@
|
||||
package com.fr.design.file; |
||||
|
||||
|
||||
import com.fr.file.FILE; |
||||
import com.fr.file.filetree.FileNode; |
||||
|
||||
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 oldName 新的文件名 |
||||
* @param suffix 后缀名 |
||||
* @param suffix 后缀名 |
||||
* @return 是否存在 |
||||
*/ |
||||
public boolean isNameAlreadyExist(String newName, String oldName, String suffix); |
||||
boolean duplicated(String newName, String suffix); |
||||
} |
@ -0,0 +1,295 @@
|
||||
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.mainframe.JVirtualTemplate; |
||||
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.CoreConstants; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.org.apache.commons.io.FilenameUtils; |
||||
|
||||
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(); |
||||
//文件路径和历史路径都是 reportlets/xxx/xxx/xxx/xx.suffix
|
||||
if (filename.equals(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) { |
||||
closeVirtualSelectedReport(overTemplate); |
||||
historyList.set(i, new JVirtualTemplate(overTemplate.getEditingFILE())); |
||||
} |
||||
} |
||||
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList); |
||||
} |
||||
|
||||
|
||||
public void deleteFile(FileNodeFILE file) { |
||||
boolean isDir = file.isDirectory(); |
||||
|
||||
String suffix = isDir ? CoreConstants.SEPARATOR : StringUtils.EMPTY; |
||||
|
||||
// path like reportlets/xx/xxx/xxx
|
||||
String path = file.getPath() + suffix; |
||||
|
||||
ListIterator<JTemplate<?, ?>> iterator = historyList.listIterator(); |
||||
|
||||
while (iterator.hasNext()) { |
||||
JTemplate<?, ?> template = iterator.next(); |
||||
String tPath = template.getPath(); |
||||
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 = FilenameUtils.standard(template.getEditingFILE().getPath()); |
||||
if (isDir ? editingPath.contains(from + CoreConstants.SEPARATOR) : 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 = FilenameUtils.standard(template.getEditingFILE().getPath()); |
||||
if (isDir ? editingPath.contains(from + CoreConstants.SEPARATOR) : editingPath.equals(from)) { |
||||
FILE renameFile = template.getEditingFILE(); |
||||
renameFile.setPath(editingPath.replace(from, to)); |
||||
} |
||||
|
||||
} |
||||
return true; |
||||
} |
||||
} |
@ -1,443 +1,16 @@
|
||||
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 文件名 |
||||
* @return 是则返回TRUE |
||||
*/ |
||||
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() { |
||||
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 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; |
||||
/** |
||||
* 历史模板缓存 |
||||
* |
||||
* 为可能存在的插件做兼容处理 |
||||
* |
||||
* @see HistoryTemplateListCache |
||||
* @deprecated use HistoryTemplateListCache instead |
||||
*/ |
||||
@Deprecated |
||||
public class HistoryTemplateListPane { |
||||
public static HistoryTemplateListCache getInstance() { |
||||
return HistoryTemplateListCache.getInstance(); |
||||
} |
||||
} |
||||
|
@ -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.getCurrent().getConnection().getUserName(); |
||||
// 远程设计获取全部设计成员的权限列表
|
||||
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; |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
@ -1,344 +1,19 @@
|
||||
package com.fr.design.mainframe; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.DesignModelAdapter; |
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.env.DesignerWorkspaceGenerator; |
||||
import com.fr.design.env.DesignerWorkspaceInfo; |
||||
import com.fr.design.file.HistoryTemplateListPane; |
||||
import com.fr.design.file.TemplateTreePane; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.utils.DesignUtils; |
||||
import com.fr.env.EnvListPane; |
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.license.exception.RegistEditionException; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.EnvChangedListener; |
||||
import com.fr.workspace.WorkContext; |
||||
import com.fr.workspace.WorkContextCallback; |
||||
import com.fr.workspace.Workspace; |
||||
import com.fr.workspace.connect.AuthException; |
||||
import com.fr.design.EnvChangeEntrance; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.Icon; |
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.SwingUtilities; |
||||
import javax.swing.UIManager; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Color; |
||||
import java.awt.Cursor; |
||||
import java.awt.Dimension; |
||||
import java.awt.GradientPaint; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.Point; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.MouseEvent; |
||||
import java.awt.event.MouseListener; |
||||
/** |
||||
* @see EnvChangeEntrance |
||||
* @deprecated use {@link EnvChangeEntrance} |
||||
*/ |
||||
@Deprecated |
||||
public class TemplatePane { |
||||
|
||||
//TODO: august TemplatePane和TemplateTreePane最好合并成一个类
|
||||
public class TemplatePane extends JPanel implements MouseListener { |
||||
|
||||
private static final long NUM = 1L; |
||||
|
||||
private static int NUM200 = 200; |
||||
|
||||
public static TemplatePane getInstance() { |
||||
|
||||
return HOLDER.singleton; |
||||
public static EnvChangeEntrance getInstance() { |
||||
return EnvChangeEntrance.getInstance(); |
||||
} |
||||
|
||||
private static class HOLDER { |
||||
|
||||
private static TemplatePane singleton = new TemplatePane(); |
||||
} |
||||
|
||||
private static final long serialVersionUID = 2108412478281713143L; |
||||
|
||||
public static final int HEIGHT = 23;// 最好和日志的高度统一 用同一个变量
|
||||
|
||||
private static javax.swing.Icon leftIcon = BaseUtils.readIcon("/com/fr/design/images/docking/left.png"); |
||||
|
||||
private static javax.swing.Icon rightIcon = BaseUtils.readIcon("/com/fr/design/images/docking/right.png"); |
||||
|
||||
private boolean isExpanded = false; |
||||
|
||||
private UIButton editButton; |
||||
|
||||
private UILabel envLabel; |
||||
|
||||
private TemplatePane() { |
||||
|
||||
super(); |
||||
this.initComponents(); |
||||
this.setFocusable(true); |
||||
this.addMouseListener(this); |
||||
isExpanded = DesignerEnvManager.getEnvManager().isTemplateTreePaneExpanded(); |
||||
TemplateTreePane.getInstance().setVisible(isExpanded); |
||||
TemplateTreePane.getInstance().setVisible(true); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
|
||||
GeneralContext.addEnvChangedListener(new EnvChangedListener() { |
||||
|
||||
public void envChanged() { |
||||
|
||||
setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName()); |
||||
} |
||||
}); |
||||
this.setLayout(new BorderLayout(25, 0)); |
||||
editButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/control/control-center2.png")) { |
||||
|
||||
private static final long serialVersionUID = NUM; |
||||
|
||||
@Override |
||||
public Point getToolTipLocation(MouseEvent event) { |
||||
|
||||
return new Point(25, 2); |
||||
} |
||||
}; |
||||
editButton.setOpaque(false); |
||||
editButton.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 10)); |
||||
editButton.setMargin(null); |
||||
editButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
||||
editButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Env_Configure_Workspace")); |
||||
this.add(new UILabel(" "), BorderLayout.WEST); |
||||
this.add(editButton, BorderLayout.EAST); |
||||
editButton.addActionListener(new ActionListener() { |
||||
|
||||
public void actionPerformed(ActionEvent evt) { |
||||
|
||||
editItems(); |
||||
} |
||||
}); |
||||
envLabel = new UILabel(); |
||||
envLabel.setForeground(new Color(102, 102, 102)); |
||||
setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName()); |
||||
this.add(envLabel, BorderLayout.CENTER); |
||||
} |
||||
|
||||
/** |
||||
* 是否可扩展 |
||||
* |
||||
* @return 同上 |
||||
*/ |
||||
public boolean IsExpanded() { |
||||
|
||||
return this.isExpanded; |
||||
} |
||||
|
||||
public void setExpand(boolean b) { |
||||
|
||||
this.isExpanded = b; |
||||
this.repaint(); |
||||
} |
||||
|
||||
private boolean envListOkAction(EnvListPane envListPane) { |
||||
|
||||
final String selectedName = envListPane.updateEnvManager(); |
||||
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); |
||||
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(selectedName); |
||||
try { |
||||
Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv); |
||||
boolean checkValid = workspace == null ? false : selectedEnv.checkValid(); |
||||
if (!checkValid) { |
||||
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), |
||||
null, 0, UIManager.getIcon("OptionPane.errorIcon")); |
||||
return false; |
||||
} |
||||
WorkContext.switchTo(workspace, new WorkContextCallback() { |
||||
@Override |
||||
public void done() { |
||||
DesignerEnvManager.getEnvManager().setCurEnvName(selectedName); |
||||
DesignUtils.refreshDesignerFrame(); |
||||
} |
||||
}); |
||||
JTemplate template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); |
||||
if (template != null) { |
||||
template.refreshToolArea(); |
||||
} |
||||
setJLabel(selectedName); |
||||
} catch (AuthException e) { |
||||
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"), |
||||
null, 0, UIManager.getIcon("OptionPane.errorIcon")); |
||||
return false; |
||||
} catch (RegistEditionException e) { |
||||
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote"), |
||||
null, 0, UIManager.getIcon("OptionPane.errorIcon")); |
||||
} catch (Exception exception) { |
||||
FineLoggerFactory.getLogger().error(exception.getMessage(), exception); |
||||
} |
||||
TemplateTreePane.getInstance().refreshDockingView(); |
||||
DesignModelAdapter<?, ?> model = DesignModelAdapter.getCurrentModelAdapter(); |
||||
if (model != null) { |
||||
model.envChanged(); |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* 编辑items |
||||
*/ |
||||
public void editItems() { |
||||
|
||||
final EnvListPane envListPane = new EnvListPane(); |
||||
final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); |
||||
|
||||
envListPane.populateEnvManager(envLabel.getText()); |
||||
envListDialog.addDialogActionListener(new DialogActionAdapter() { |
||||
|
||||
public void doOk() { |
||||
|
||||
envListOkAction(envListPane); |
||||
} |
||||
|
||||
public void doCancel() { |
||||
|
||||
envListDialog.setVisible(false); |
||||
} |
||||
}); |
||||
envListDialog.setVisible(true); |
||||
} |
||||
|
||||
private void setJLabel(String name) { |
||||
|
||||
DesignerWorkspaceInfo config = DesignerEnvManager.getEnvManager().getWorkspaceInfo(name); |
||||
if (config != null) { |
||||
switch (config.getType()) { |
||||
case Remote: { |
||||
envLabel.setIcon(IOUtils.readIcon("com/fr/design/images/data/bind/localconnect.png")); |
||||
break; |
||||
} |
||||
case Local: { |
||||
envLabel.setIcon(IOUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png")); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
envLabel.setText(name); |
||||
envLabel.repaint(); |
||||
} |
||||
|
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
|
||||
return new Dimension(250, HEIGHT); |
||||
} |
||||
|
||||
@Override |
||||
public void paintComponent(Graphics g) { |
||||
|
||||
super.paintComponent(g); |
||||
paintBackgroundIcon(g); |
||||
} |
||||
|
||||
private void paintBackgroundIcon(Graphics g) { |
||||
|
||||
int w = this.getWidth(); |
||||
int h = this.getHeight(); |
||||
Graphics2D g2d = (Graphics2D) g; |
||||
Color lightColor = new Color(226, 230, 234); |
||||
Color darkColor = new Color(183, 188, 195); |
||||
GradientPaint gp = new GradientPaint(1, 1, lightColor, 1, h - 1, darkColor); |
||||
g2d.setPaint(gp); |
||||
g2d.fillRect(1, 1, w - 2, h - 1); |
||||
g2d.setColor(lightColor); |
||||
g2d.drawLine(0, 2, 0, h - 1); |
||||
g2d.setColor(darkColor); |
||||
g2d.drawLine(w - 1, 2, w - 1, h - 1); |
||||
Icon icon = !isExpanded ? leftIcon : rightIcon; |
||||
icon.paintIcon(this, g2d, 4, 4); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 鼠标点击 |
||||
* |
||||
* @param e 事件 |
||||
*/ |
||||
@Override |
||||
public void mouseClicked(MouseEvent e) { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 鼠标按下 |
||||
* |
||||
* @param e 事件 |
||||
*/ |
||||
@Override |
||||
public void mousePressed(MouseEvent e) { |
||||
|
||||
if (e.getX() < NUM200) { |
||||
isExpanded = !isExpanded; |
||||
TemplateTreePane.getInstance().setVisible(isExpanded); |
||||
this.setExpand(isExpanded); |
||||
DesignerEnvManager.getEnvManager().setTemplateTreePaneExpanded(isExpanded); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 鼠标放开 |
||||
* |
||||
* @param e 事件 |
||||
*/ |
||||
@Override |
||||
public void mouseReleased(MouseEvent e) { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 鼠标进入 |
||||
* |
||||
* @param e 事件 |
||||
*/ |
||||
@Override |
||||
public void mouseEntered(MouseEvent e) { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 鼠标离开 |
||||
* |
||||
* @param e 事件 |
||||
*/ |
||||
@Override |
||||
public void mouseExited(MouseEvent e) { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 处理异常 |
||||
*/ |
||||
public void dealEvnExceptionWhenStartDesigner() { |
||||
|
||||
final EnvListPane envListPane = new EnvListPane(); |
||||
envListPane.populateEnvManager(envLabel.getText()); |
||||
BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); |
||||
envListDialog.addDialogActionListener(new DialogActionAdapter() { |
||||
|
||||
public void doOk() { |
||||
|
||||
if (!envListOkAction(envListPane)) { |
||||
System.exit(0); |
||||
} |
||||
|
||||
} |
||||
|
||||
public void doCancel() { |
||||
|
||||
System.exit(0); |
||||
} |
||||
}); |
||||
envListDialog.setVisible(true); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
@ -1 +1,38 @@
|
||||
package com.fr.design.roleAuthority;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.mainframe.JTemplate;
import com.fr.general.NameObject;
import com.fr.privilege.PrivilegeEditedRoleProvider;
/**
* Author : daisy
* Date: 13-9-25
* Time: 下午4:57
*/
public class RolesEditedSourceOP extends RoleSourceOP {
/**
* 获取报表平台的角色
*/
protected void addReportRoles(Map<String, RoleDataWrapper> report_roles) {
RoleDataWrapper tdw = new RoleDataWrapper(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Server_Platform_Manager"));
report_roles.put(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Server_Platform_Manager"), tdw);
}
/**
* 获取数据决策系统的角色
*/
protected void addFSRoles(Map<String, RoleDataWrapper> FS_roles) {
RoleDataWrapper tdw = new RoleDataWrapper(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FS_Name_Duplicate"));
FS_roles.put(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FS_Name_Duplicate"), tdw);
}
/**
* 生成子节点
*
* @return
*/
@Override
public ExpandMutableTreeNode[] load() {
Map<String, RoleDataWrapper> report_roles = null;
// Map<String, RoleDataWrapper> FS_roles = null;
if (this != null) {
report_roles = this.init().get(0);
// FS_roles = this.init().get(1);
} else {
report_roles = Collections.emptyMap();
// FS_roles = Collections.emptyMap();
}
List<ExpandMutableTreeNode> list = new ArrayList<ExpandMutableTreeNode>(); //所有的角色
List<ExpandMutableTreeNode> reportlist = new ArrayList<ExpandMutableTreeNode>(); //报表平台橘色
// List<ExpandMutableTreeNode> FSlist = new ArrayList<ExpandMutableTreeNode>(); //数据决策系统角色
list.add(initReportRolseNode(report_roles));
addNodeToList(report_roles, reportlist);
// list.add(initFSRolseNode(FS_roles));
// addNodeToList(FS_roles, FSlist);
return list.toArray(new ExpandMutableTreeNode[list.size()]);
}
protected ExpandMutableTreeNode initReportRolseNode(Map<String, RoleDataWrapper> report_roles) {
ExpandMutableTreeNode templateNode = new ExpandMutableTreeNode(new NameObject(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Roles_Already_Authority_Edited"), 0), true);
templateNode.addChildTreeNodes(getNodeArrayFromMap(report_roles));
return templateNode;
}
protected ExpandMutableTreeNode[] getNodeArrayFromMap(Map<String, RoleDataWrapper> map) {
List<ExpandMutableTreeNode> roleList = new ArrayList<ExpandMutableTreeNode>();
Iterator<Map.Entry<String, RoleDataWrapper>> entryIt = map.entrySet().iterator();
while (entryIt.hasNext()) {
Map.Entry<String, RoleDataWrapper> entry = entryIt.next();
String name = entry.getKey();
RoleDataWrapper t = entry.getValue();
JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
PrivilegeEditedRoleProvider pe = (PrivilegeEditedRoleProvider) jt.getTarget();
ExpandMutableTreeNode[] expand = t.load(Arrays.asList(pe.getAllEditedRoleSet()));
for (ExpandMutableTreeNode expandMutableTreeNode : expand) {
roleList.add(expandMutableTreeNode);
}
}
return roleList.toArray(new ExpandMutableTreeNode[roleList.size()]);
}
} |
||||
package com.fr.design.roleAuthority; |
||||
|
||||
import com.fr.design.file.HistoryTemplateListCache; |
||||
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.privilege.PrivilegeEditedRoleProvider; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.Iterator; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Author : daisy |
||||
* Date: 13-9-25 |
||||
* Time: 下午4:57 |
||||
*/ |
||||
public class RolesEditedSourceOP extends RoleSourceOP { |
||||
|
||||
protected ExpandMutableTreeNode[] getNodeArrayFromMap(Map<String, RoleDataWrapper> map) { |
||||
List<ExpandMutableTreeNode> roleList = new ArrayList<ExpandMutableTreeNode>(); |
||||
Iterator<Map.Entry<String, RoleDataWrapper>> entryIt = map.entrySet().iterator(); |
||||
while (entryIt.hasNext()) { |
||||
Map.Entry<String, RoleDataWrapper> entry = entryIt.next(); |
||||
RoleDataWrapper t = entry.getValue(); |
||||
|
||||
JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
||||
PrivilegeEditedRoleProvider pe = (PrivilegeEditedRoleProvider) jt.getTarget(); |
||||
|
||||
ExpandMutableTreeNode[] expand = t.load(Arrays.asList(pe.getAllEditedRoleSet())); |
||||
for (ExpandMutableTreeNode expandMutableTreeNode : expand) { |
||||
roleList.add(expandMutableTreeNode); |
||||
} |
||||
} |
||||
return roleList.toArray(new ExpandMutableTreeNode[roleList.size()]); |
||||
} |
||||
} |
@ -1,185 +0,0 @@
|
||||
//package com.fr.env;
|
||||
//
|
||||
//import com.fr.design.beans.BasicBeanPane;
|
||||
//import com.fr.design.border.UITitledBorder;
|
||||
//import com.fr.design.env.DesignerWorkspaceInfo;
|
||||
//import com.fr.design.env.DesignerWorkspaceType;
|
||||
//import com.fr.design.gui.ibutton.UIButton;
|
||||
//import com.fr.design.gui.ilable.UILabel;
|
||||
//import com.fr.design.gui.ipasswordfield.UIPassWordField;
|
||||
//import com.fr.design.gui.itextfield.UIIntNumberField;
|
||||
//import com.fr.design.gui.itextfield.UITextField;
|
||||
//import com.fr.design.layout.TableLayout;
|
||||
//import com.fr.design.layout.TableLayoutHelper;
|
||||
//import com.fr.design.utils.gui.GUICoreUtils;
|
||||
//
|
||||
//import com.fr.workspace.WorkContext;
|
||||
//import com.fr.workspace.connect.WorkspaceConnection;
|
||||
//
|
||||
//import javax.swing.*;
|
||||
//import javax.swing.border.EmptyBorder;
|
||||
//import java.awt.*;
|
||||
//import java.awt.event.ActionEvent;
|
||||
//import java.awt.event.ActionListener;
|
||||
//import java.awt.event.WindowAdapter;
|
||||
//import java.awt.event.WindowEvent;
|
||||
//
|
||||
///**
|
||||
// * 远程环境设置界面,暂时命名为2,待做完功能直接替代掉老的RemoteEnvPane
|
||||
// */
|
||||
//public class RemoteEnvPane2 extends BasicBeanPane<DesignerWorkspaceInfo> {
|
||||
//
|
||||
// private UITextField urlTextField;
|
||||
// private UITextField usernameTextField;
|
||||
// private UIPassWordField passwordTextField;
|
||||
// private JDialog dialog;
|
||||
// private UILabel message;
|
||||
// private UIButton okButton;
|
||||
// private UIButton cancelButton;
|
||||
//
|
||||
// public RemoteEnvPane2() {
|
||||
// initComponents();
|
||||
// }
|
||||
//
|
||||
// private void initComponents() {
|
||||
// setLayout(new BorderLayout());
|
||||
//
|
||||
// JPanel contentPanel = new JPanel(new BorderLayout());
|
||||
// add(contentPanel, BorderLayout.CENTER);
|
||||
//
|
||||
// contentPanel.setBorder(
|
||||
// BorderFactory.createCompoundBorder(
|
||||
// new EmptyBorder(6, 0, 0, 0),
|
||||
// UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_Config")))
|
||||
// );
|
||||
//
|
||||
// double p = TableLayout.PREFERRED;
|
||||
// double f = TableLayout.FILL;
|
||||
// double[] rowSize = new double[]{p, p, p, p};
|
||||
// double[] columnSize = new double[]{p, f};
|
||||
// UIButton testConnectionButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_Try"));
|
||||
// urlTextField = new UITextField();
|
||||
// urlTextField.setPlaceholder("http://192.168.100.200/webroot/decision");
|
||||
// JPanel valuePane = TableLayoutHelper.createTableLayoutPane(
|
||||
// new Component[][]{
|
||||
// {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_Host") + ":", SwingConstants.RIGHT), urlTextField},
|
||||
// {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_User") + ":", SwingConstants.RIGHT), usernameTextField = new UITextField()},
|
||||
// {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_Password") + ":", SwingConstants.RIGHT), passwordTextField = new UIPassWordField()},
|
||||
// {null, GUICoreUtils.createFlowPane(testConnectionButton, FlowLayout.LEFT)}
|
||||
// },
|
||||
// rowSize, columnSize
|
||||
// );
|
||||
// testConnectionButton.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// tryConnectRemoteEnv();
|
||||
// }
|
||||
// });
|
||||
// contentPanel.add(valuePane, BorderLayout.CENTER);
|
||||
//
|
||||
// message = new UILabel();
|
||||
// okButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("OK"));
|
||||
// cancelButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Cancel"));
|
||||
// }
|
||||
//
|
||||
// private void tryConnectRemoteEnv() {
|
||||
// final SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
|
||||
//
|
||||
// @Override
|
||||
// protected Void doInBackground() throws Exception {
|
||||
//
|
||||
// final DesignerWorkspaceInfo remoteEnv = updateBean();
|
||||
// WorkContext.getConnector().testConnection(remoteEnv.getConnection());
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void done() {
|
||||
// okButton.setEnabled(true);
|
||||
// try {
|
||||
// get();
|
||||
// message.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Connect_Successful"));
|
||||
// } catch (Exception e) {
|
||||
// message.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Connect_Failed"));
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
// worker.execute();
|
||||
// initMessageDialog();
|
||||
// okButton.addActionListener(new ActionListener() {
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// dialog.dispose();
|
||||
// }
|
||||
// });
|
||||
// cancelButton.addActionListener(new ActionListener() {
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// dialog.dispose();
|
||||
// worker.cancel(true);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// dialog.addWindowListener(new WindowAdapter() {
|
||||
// public void windowClosed(WindowEvent e) {
|
||||
// worker.cancel(true);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// dialog.setVisible(true);
|
||||
// dialog.dispose();
|
||||
// }
|
||||
//
|
||||
// private void initMessageDialog() {
|
||||
// message.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_Try") + "...");
|
||||
// message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0));
|
||||
// okButton.setEnabled(false);
|
||||
//
|
||||
// dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane2.this), com.fr.design.i18n.Toolkit.i18nText("Datasource-Test_Connection"), true);
|
||||
//
|
||||
// dialog.setSize(new Dimension(268, 118));
|
||||
// okButton.setEnabled(false);
|
||||
// JPanel jp = new JPanel();
|
||||
// JPanel upPane = new JPanel();
|
||||
// JPanel downPane = new JPanel();
|
||||
// UILabel uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon"));
|
||||
// upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
|
||||
// upPane.add(uiLabel);
|
||||
// upPane.add(message);
|
||||
// downPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0));
|
||||
// downPane.add(okButton);
|
||||
// downPane.add(cancelButton);
|
||||
// jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS));
|
||||
// jp.add(upPane);
|
||||
// jp.add(downPane);
|
||||
// dialog.add(jp);
|
||||
// dialog.setResizable(false);
|
||||
// dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(RemoteEnvPane2.this));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected String title4PopupWindow() {
|
||||
// return "RemoteEnv";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void populateBean(DesignerWorkspaceInfo config) {
|
||||
// if (config == null) {
|
||||
// return;
|
||||
// }
|
||||
// WorkspaceConnection connection = config.getConnection();
|
||||
// if (connection != null) {
|
||||
// urlTextField.setText(connection.getUrl());
|
||||
// usernameTextField.setText(connection.getUserName());
|
||||
// passwordTextField.setText(connection.getPassword());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public DesignerWorkspaceInfo updateBean() {
|
||||
//
|
||||
// DesignerWorkspaceInfo config = new DesignerWorkspaceInfo();
|
||||
// WorkspaceConnection connection = new WorkspaceConnection(urlTextField.getText(), usernameTextField.getText(), passwordTextField.getText());
|
||||
// config.setConnection(connection);
|
||||
// config.setType(DesignerWorkspaceType.Remote);
|
||||
// return config;
|
||||
// }
|
||||
//}
|
@ -1,167 +0,0 @@
|
||||
//package com.fr.env;
|
||||
//
|
||||
//import com.fr.base.EnvException;
|
||||
//import com.fr.base.FRContext;
|
||||
//import com.fr.report.DesignAuthority;
|
||||
//import com.fr.report.util.AuthorityXMLUtils;
|
||||
//import com.fr.stable.EncodeConstants;
|
||||
//import com.fr.third.org.apache.commons.io.IOUtils;
|
||||
//import com.fr.third.org.apache.http.HttpResponse;
|
||||
//import com.fr.third.org.apache.http.HttpStatus;
|
||||
//import com.fr.third.org.apache.http.client.ClientProtocolException;
|
||||
//import com.fr.third.org.apache.http.client.ResponseHandler;
|
||||
//import com.fr.third.org.apache.http.client.methods.HttpUriRequest;
|
||||
//import com.fr.third.org.apache.http.client.methods.RequestBuilder;
|
||||
//import com.fr.third.org.apache.http.entity.ContentType;
|
||||
//import com.fr.third.org.apache.http.entity.InputStreamEntity;
|
||||
//import com.fr.third.org.apache.http.impl.client.CloseableHttpClient;
|
||||
//import com.fr.third.org.apache.http.impl.client.HttpClients;
|
||||
//
|
||||
//import java.io.ByteArrayInputStream;
|
||||
//import java.io.ByteArrayOutputStream;
|
||||
//import java.io.IOException;
|
||||
//import java.io.InputStream;
|
||||
//import java.net.URLEncoder;
|
||||
//import java.util.Map;
|
||||
//
|
||||
//public class RemoteEnvUtils {
|
||||
//
|
||||
// private RemoteEnvUtils() {
|
||||
// }
|
||||
//
|
||||
// private static ResponseHandler<InputStream> responseHandler = new ResponseHandler<InputStream>() {
|
||||
// @Override
|
||||
// public InputStream handleResponse(HttpResponse response) throws IOException {
|
||||
// int statusCode = response.getStatusLine().getStatusCode();
|
||||
// if (statusCode != HttpStatus.SC_OK) {
|
||||
// throw new ClientProtocolException("Method failed: " + response.getStatusLine().toString());
|
||||
// }
|
||||
// InputStream in = response.getEntity().getContent();
|
||||
// if (in == null) {
|
||||
// return null;
|
||||
// }
|
||||
// // 读取并返回
|
||||
// ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
// IOUtils.copy(in, out);
|
||||
// return new ByteArrayInputStream(out.toByteArray());
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// public static InputStream simulateRPCByHttpPost(byte[] bytes, Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException {
|
||||
// String path = env.getPath();
|
||||
// RequestBuilder builder = RequestBuilder.post(path);
|
||||
//
|
||||
// InputStream inputStream = null;
|
||||
//
|
||||
// for (Map.Entry<String, String> entry : parameters.entrySet()) {
|
||||
// builder.addParameter(entry.getKey(), entry.getValue());
|
||||
// }
|
||||
// if (!isSignIn) {
|
||||
// builder.addParameter("id", env.getUserID());
|
||||
// }
|
||||
// InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(bytes));
|
||||
//
|
||||
// try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
|
||||
// HttpUriRequest request = builder
|
||||
// .setEntity(reqEntity)
|
||||
// .build();
|
||||
// inputStream = httpClient.execute(request, responseHandler);
|
||||
// } catch (IOException e) {
|
||||
// FRContext.getLogger().error(e.getMessage());
|
||||
// }
|
||||
// return inputStream;
|
||||
// }
|
||||
//
|
||||
// public static InputStream simulateRPCByHttpPost(Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException {
|
||||
// String path = env.getPath();
|
||||
// RequestBuilder builder = RequestBuilder.post(path);
|
||||
//
|
||||
// InputStream inputStream = null;
|
||||
//
|
||||
// for (Map.Entry<String, String> entry : parameters.entrySet()) {
|
||||
// builder.addParameter(entry.getKey(), entry.getValue());
|
||||
// }
|
||||
// if (!isSignIn) {
|
||||
// builder.addParameter("id", env.getUserID());
|
||||
// }
|
||||
//
|
||||
// try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
|
||||
// HttpUriRequest request = builder
|
||||
// .build();
|
||||
// inputStream = httpClient.execute(request, responseHandler);
|
||||
// } catch (IOException e) {
|
||||
// FRContext.getLogger().error(e.getMessage());
|
||||
// }
|
||||
// return inputStream;
|
||||
// }
|
||||
//
|
||||
// public static InputStream simulateRPCByHttpGet(Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException {
|
||||
// String path = env.getPath();
|
||||
// RequestBuilder builder = RequestBuilder.get(path);
|
||||
//
|
||||
// InputStream inputStream = null;
|
||||
//
|
||||
// for (Map.Entry<String, String> entry : parameters.entrySet()) {
|
||||
// builder.addParameter(entry.getKey(), entry.getValue());
|
||||
// }
|
||||
// if (!isSignIn) {
|
||||
// builder.addParameter("id", env.getUserID());
|
||||
// }
|
||||
// try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
|
||||
// HttpUriRequest request = builder.build();
|
||||
// inputStream = httpClient.execute(request, responseHandler);
|
||||
//
|
||||
// } catch (IOException e) {
|
||||
// FRContext.getLogger().error(e.getMessage());
|
||||
// }
|
||||
// return inputStream;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public static InputStream updateAuthorities(DesignAuthority[] authorities, RemoteEnv env) {
|
||||
// String path = env.getPath();
|
||||
// // 远程设计临时用户id
|
||||
// String userID = env.getUserID();
|
||||
// InputStream inputStream = null;
|
||||
//
|
||||
// ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
// AuthorityXMLUtils.writeDesignAuthoritiesXML(authorities, outputStream);
|
||||
// InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(outputStream.toByteArray()), ContentType.TEXT_XML);
|
||||
//
|
||||
// try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
|
||||
// HttpUriRequest request = RequestBuilder.post(path)
|
||||
// .addParameter("id", userID)
|
||||
// .addParameter("op", "remote_design_authority")
|
||||
// .addParameter("cmd", "update_authorities")
|
||||
// .setEntity(reqEntity)
|
||||
// .build();
|
||||
// inputStream = httpClient.execute(request, responseHandler);
|
||||
// } catch (IOException e) {
|
||||
// FRContext.getLogger().error(e.getMessage());
|
||||
// }
|
||||
//
|
||||
// return inputStream;
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public static InputStream getAuthorities(RemoteEnv env) throws EnvException {
|
||||
// String path = env.getPath();
|
||||
// // 远程设计临时用户id
|
||||
// String userID = env.getUserID();
|
||||
// InputStream inputStream = null;
|
||||
//
|
||||
// try (CloseableHttpClient httpClient = HttpClients.createSystem();) {
|
||||
// HttpUriRequest request = RequestBuilder.get(path)
|
||||
// .addParameter("id", userID)
|
||||
// .addParameter("op", "remote_design_authority")
|
||||
// .addParameter("cmd", "get_authorities")
|
||||
// .build();
|
||||
// inputStream = httpClient.execute(request, responseHandler);
|
||||
// } catch (IOException e) {
|
||||
// FRContext.getLogger().error(e.getMessage());
|
||||
// }
|
||||
// return inputStream;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
@ -1,93 +1,106 @@
|
||||
package com.fr.file; |
||||
|
||||
import javax.swing.Icon; |
||||
import java.io.InputStream; |
||||
import java.io.OutputStream; |
||||
|
||||
public interface FILE { |
||||
|
||||
/** |
||||
* 后缀 |
||||
* @return 后缀 |
||||
* 前缀 |
||||
* |
||||
* @return 前缀 |
||||
*/ |
||||
public String prefix(); |
||||
String prefix(); |
||||
|
||||
/** |
||||
* 是否是目录 |
||||
* |
||||
* @return 是则返回true |
||||
*/ |
||||
public boolean isDirectory(); |
||||
|
||||
// Name
|
||||
public String getName(); |
||||
|
||||
// Icon
|
||||
public Icon getIcon(); |
||||
|
||||
// 当前目录的Path
|
||||
public String getPath(); |
||||
|
||||
public void setPath(String path); |
||||
|
||||
// 取当前目录的上级目录
|
||||
public FILE getParent(); |
||||
boolean isDirectory(); |
||||
|
||||
// Name
|
||||
String getName(); |
||||
|
||||
// Icon
|
||||
Icon getIcon(); |
||||
|
||||
// 当前目录的Path
|
||||
String getPath(); |
||||
|
||||
void setPath(String path); |
||||
|
||||
// 取当前目录的上级目录
|
||||
FILE getParent(); |
||||
|
||||
/** |
||||
* 列出当前目录下所有的文件及文件夹 |
||||
* |
||||
* @return 文件 |
||||
*/ |
||||
public FILE[] listFiles(); |
||||
FILE[] listFiles(); |
||||
|
||||
/** |
||||
* 新建一个目录 |
||||
* |
||||
* @param name 名字 |
||||
* @return 新建目录 |
||||
*/ |
||||
public boolean createFolder(String name); |
||||
boolean createFolder(String name); |
||||
|
||||
/** |
||||
* 新建文件 |
||||
* |
||||
* @return 是否新建成功 |
||||
* @throws Exception 异常 |
||||
*/ |
||||
public boolean mkfile() throws Exception; |
||||
boolean mkfile() throws Exception; |
||||
|
||||
/** |
||||
* 是否存在 |
||||
* |
||||
* @return 是否存在 |
||||
*/ |
||||
public boolean exists(); |
||||
boolean exists(); |
||||
|
||||
/** |
||||
* 关闭文件 |
||||
* |
||||
* @throws Exception 异常 |
||||
*/ |
||||
public void closeTemplate() throws Exception; |
||||
void closeTemplate() throws Exception; |
||||
|
||||
/** |
||||
* 作为输入流 |
||||
* |
||||
* @return 输入流 |
||||
* @throws Exception 异常 |
||||
*/ |
||||
public java.io.InputStream asInputStream() throws Exception; |
||||
InputStream asInputStream() throws Exception; |
||||
|
||||
/** |
||||
* 作为输出流 |
||||
* |
||||
* @return 输出流 |
||||
* @throws Exception 异常 |
||||
*/ |
||||
public java.io.OutputStream asOutputStream() throws Exception; |
||||
|
||||
public String getEnvFullName(); |
||||
OutputStream asOutputStream() throws Exception; |
||||
|
||||
String getEnvFullName(); |
||||
|
||||
|
||||
/** |
||||
* 是否是内存文件 |
||||
* |
||||
* @return 是则返回true |
||||
*/ |
||||
public boolean isMemFile(); |
||||
boolean isMemFile(); |
||||
|
||||
/** |
||||
* 是否是环境文件 |
||||
* |
||||
* @return 是则返回true |
||||
*/ |
||||
public boolean isEnvFile(); |
||||
boolean isEnvFile(); |
||||
} |
@ -0,0 +1,90 @@
|
||||
package com.fr.start.server; |
||||
|
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.event.Event; |
||||
import com.fr.event.EventDispatcher; |
||||
import com.fr.event.Listener; |
||||
import com.fr.event.Null; |
||||
|
||||
import java.util.concurrent.ExecutorService; |
||||
import java.util.concurrent.Executors; |
||||
|
||||
/** |
||||
* 内置服务器启动监视器 |
||||
* Created by zack on 2018/8/21. |
||||
*/ |
||||
public class FineEmbedServerMonitor { |
||||
private int progress; |
||||
private static final int COMPLETE = 100;//启动完成
|
||||
private static final int STEP = 5;//随便设置一个假的进度条
|
||||
private static final int STEP_HEARTBEAT = 2000;//2秒更新进度
|
||||
private static volatile FineEmbedServerMonitor monitor; |
||||
|
||||
private FineEmbedServerMonitor() { |
||||
} |
||||
|
||||
static { |
||||
EventDispatcher.listen(EmbedServerEvent.AfterStop, new Listener<Null>() { |
||||
@Override |
||||
public void on(Event event, Null aNull) { |
||||
getInstance().reset(); |
||||
DesignerContext.getDesignerFrame().hideProgressDialog(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public static FineEmbedServerMonitor getInstance() { |
||||
if (monitor == null) { |
||||
synchronized (FineEmbedServerMonitor.class) { |
||||
if (monitor == null) { |
||||
monitor = new FineEmbedServerMonitor(); |
||||
} |
||||
} |
||||
} |
||||
return monitor; |
||||
} |
||||
|
||||
public int getProgress() { |
||||
if (progress == COMPLETE) { |
||||
return progress; |
||||
} else { |
||||
progress += STEP; |
||||
return progress; |
||||
} |
||||
} |
||||
|
||||
public void setComplete() { |
||||
this.progress = COMPLETE; |
||||
} |
||||
|
||||
public void reset() { |
||||
this.progress = 0; |
||||
} |
||||
|
||||
public boolean isComplete() { |
||||
return this.progress == COMPLETE; |
||||
} |
||||
|
||||
public void monitor() { |
||||
ExecutorService service = Executors.newSingleThreadExecutor(); |
||||
service.submit(new Runnable() { |
||||
|
||||
@Override |
||||
public void run() { |
||||
while (!isComplete()) { |
||||
if (!DesignerContext.getDesignerFrame().getProgressDialog().isVisible()) { |
||||
DesignerContext.getDesignerFrame().showProgressDialog(); |
||||
DesignerContext.getDesignerFrame().getProgressDialog().updateLoadingText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Embed_Server")); |
||||
} |
||||
DesignerContext.getDesignerFrame().updateProgress(getProgress()); |
||||
try { |
||||
Thread.sleep(STEP_HEARTBEAT); |
||||
} catch (InterruptedException ignore) { |
||||
} |
||||
} |
||||
DesignerContext.getDesignerFrame().hideProgressDialog(); |
||||
} |
||||
}); |
||||
service.shutdown(); |
||||
} |
||||
} |
Before Width: | Height: | Size: 350 B After Width: | Height: | Size: 272 B |
Before Width: | Height: | Size: 560 B After Width: | Height: | Size: 352 B |
Before Width: | Height: | Size: 217 B After Width: | Height: | Size: 199 B |
Before Width: | Height: | Size: 505 B After Width: | Height: | Size: 379 B |
Before Width: | Height: | Size: 348 B After Width: | Height: | Size: 225 B |
Before Width: | Height: | Size: 362 B After Width: | Height: | Size: 326 B |
Before Width: | Height: | Size: 543 B After Width: | Height: | Size: 600 B |
Before Width: | Height: | Size: 340 B After Width: | Height: | Size: 388 B |
Before Width: | Height: | Size: 407 B After Width: | Height: | Size: 309 B |
Before Width: | Height: | Size: 450 B After Width: | Height: | Size: 449 B |
After Width: | Height: | Size: 444 B |
After Width: | Height: | Size: 844 B |
After Width: | Height: | Size: 288 B |
Before Width: | Height: | Size: 423 B After Width: | Height: | Size: 473 B |
Before Width: | Height: | Size: 185 B After Width: | Height: | Size: 143 B |
Before Width: | Height: | Size: 381 B After Width: | Height: | Size: 379 B |
Before Width: | Height: | Size: 527 B After Width: | Height: | Size: 643 B |
Before Width: | Height: | Size: 314 B After Width: | Height: | Size: 314 B |
Before Width: | Height: | Size: 204 B After Width: | Height: | Size: 156 B |
Before Width: | Height: | Size: 800 B After Width: | Height: | Size: 638 B |
Before Width: | Height: | Size: 559 B After Width: | Height: | Size: 629 B |
Before Width: | Height: | Size: 424 B After Width: | Height: | Size: 576 B |
Before Width: | Height: | Size: 1002 B After Width: | Height: | Size: 808 B |
Before Width: | Height: | Size: 237 B After Width: | Height: | Size: 188 B |
Before Width: | Height: | Size: 221 B After Width: | Height: | Size: 172 B |