Browse Source

无JIRA任务 继续一波删减方法

master
richie 7 years ago
parent
commit
1888af55de
  1. 9
      designer-base/src/com/fr/design/file/HistoryTemplateListPane.java
  2. 6
      designer-base/src/com/fr/design/file/TemplateTreePane.java
  3. 2
      designer-base/src/com/fr/design/formula/JavaEditorPane.java
  4. 5
      designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java
  5. 21
      designer-base/src/com/fr/design/mainframe/JTemplate.java
  6. 2
      designer-base/src/com/fr/design/roleAuthority/RoleDataWrapper.java
  7. 132
      designer-base/src/com/fr/env/RemoteEnv.java
  8. 50
      designer-base/src/com/fr/file/FILEChooserPane.java

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

@ -1,5 +1,6 @@
package com.fr.design.file;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.dav.LocalEnv;
@ -18,9 +19,11 @@ import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import javax.swing.*;
@ -363,8 +366,10 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C
*/
public void openContainerFolder() {
FileNode fileNode = new FileNode(((JTemplate<?, ?>) list.getSelectedValue()).getEditingFILE().getPath(), false);
LocalEnv localEnv = (LocalEnv) FRContext.getCurrentEnv();
localEnv.openContainerFolder(fileNode);
Env env = FRContext.getCurrentEnv();
if (env.isLocalEnv()) {
IOUtils.openWindowsFolder(StableUtils.pathJoin(env.getEnvConfig().getPath(), fileNode.getEnvPath()));
}
}
/**

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

@ -3,6 +3,7 @@
*/
package com.fr.design.file;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.base.io.FileAssistUtils;
import com.fr.dav.LocalEnv;
@ -15,6 +16,7 @@ import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.file.filetree.IOFileNodeFilter;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CoreConstants;
@ -139,13 +141,13 @@ public class TemplateTreePane extends JPanel implements FileOperations {
*/
public void openContainerFolder() {
FileNode fn = TemplateTreePane.this.reportletsTree.getSelectedFileNode();
LocalEnv localEnv = (LocalEnv) FRContext.getCurrentEnv();
Env localEnv = FRContext.getCurrentEnv();
String filePath = StableUtils.pathJoin(localEnv.getPath(), fn.getEnvPath());
filePath = filePath.substring(0, filePath.lastIndexOf(CoreConstants.SEPARATOR));
try {
Desktop.getDesktop().open(new File(filePath));
} catch (Exception e) {
localEnv.openContainerFolder(fn);
IOUtils.openWindowsFolder(StableUtils.pathJoin(localEnv.getEnvConfig().getPath(), fn.getEnvPath()));
}
}

2
designer-base/src/com/fr/design/formula/JavaEditorPane.java

@ -176,7 +176,7 @@ public class JavaEditorPane extends BasicPane {
@Override
protected JavaCompileInfo doInBackground() throws Exception {
Env env = FRContext.getCurrentEnv();
return env.compilerSourceCode(javaText.getText());
return env.getCommonOperator().compile(javaText.getText());
}
public void done() {

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

@ -2,6 +2,7 @@ package com.fr.design.gui.itree.filetree;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.base.extension.FileExtension;
import com.fr.base.operator.file.FileOperator;
import com.fr.core.env.proxy.EnvProxy;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
@ -104,7 +105,9 @@ public class TemplateFileTree extends EnvFileTree {
}
public FileNode[] listFile(String path) throws Exception {
return FRContext.getCurrentEnv().getFileOperator().list(path);
return FRContext.getCurrentEnv().getFileOperator().list(
path,
new FileExtension[]{FileExtension.CPT, FileExtension.FRM, FileExtension.CPTX, FileExtension.FRMX});
}
/*

21
designer-base/src/com/fr/design/mainframe/JTemplate.java

@ -45,8 +45,8 @@ import com.fr.file.MemFILE;
import com.fr.form.ui.NoneWidget;
import com.fr.form.ui.Widget;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory;
import com.fr.report.cell.Elem;
import com.fr.report.cell.cellattr.CellImage;
import com.fr.stable.ArrayUtils;
@ -539,7 +539,14 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
if (!editingFILE.exists()) {
return saveAsTemplate(isShowLoc);
}
if (!FRContext.getCurrentEnv().hasFileFolderAllow(this.getEditingFILE().getPath())) {
boolean access = false;
try {
access = FRContext.getCurrentEnv().getOrganizationOperator().canAccess(this.getEditingFILE().getPath());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (!access) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_No-Privilege") + "!", Inter.getLocText("FR-Designer_Message"), JOptionPane.WARNING_MESSAGE);
return false;
}
@ -579,18 +586,22 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
int chooseResult = fileChooser.showSaveDialog(DesignerContext.getDesignerFrame(), this.suffix());
if (isCancelOperation(chooseResult)) {
fileChooser = null;
return false;
}
if (isOkOperation(chooseResult)) {
if (!FRContext.getCurrentEnv().hasFileFolderAllow(fileChooser.getSelectedFILE().getPath()) ) {
boolean access = false;
try {
access = FRContext.getCurrentEnv().getOrganizationOperator().canAccess(fileChooser.getSelectedFILE().getPath());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (!access) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_No-Privilege") + "!", Inter.getLocText("FR-Designer_Message"), JOptionPane.WARNING_MESSAGE);
return false;
}
editingFILE = fileChooser.getSelectedFILE();
mkNewFile(editingFILE);
fileChooser = null;
}
return saveNewFile(editingFILE, oldName);

2
designer-base/src/com/fr/design/roleAuthority/RoleDataWrapper.java

@ -1 +1 @@
package com.fr.design.roleAuthority; import com.fr.base.FRContext; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.loader.ChildrenNodesLoader; import com.fr.general.Inter; import java.util.ArrayList; import java.util.List; /** * 将权限细粒度的角色数据包装一下,区分报表平台管理角色和数据决策系统角色 * <p/> * Author : daisy * Date: 13-8-30 import java.util.ArrayList; import java.util.List; private String roleTypename = null; /** roleTypename = roleName; * <p/> * Author : daisy * Date: 13-8-30 import java.util.ArrayList; import java.util.ArrayList; import java.util.ArrayList; import java.util.ArrayList; import java.util.ArrayList; import java.util.List; } //加载所有的角色列表 public ExpandMutableTreeNode[] load() { calculateRoleList(); return this.load(this.rolelist); } //从workbook中读取的角色列表 public ExpandMutableTreeNode[] load(List<String> rolelist) { this.rolelist = rolelist; ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[rolelist.size()]; for (int i = 0; i < res.length; i++) { res[i] = new ExpandMutableTreeNode(rolelist.get(i)); } return res; } public String getRoleTypename(){ return roleTypename; } }
package com.fr.design.roleAuthority; import com.fr.base.FRContext; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.loader.ChildrenNodesLoader; import com.fr.general.Inter; import java.util.ArrayList; import java.util.ArrayList; /** import java.util.ArrayList; * 将权限细粒度的角色数据包装一下,区分报表平台管理角色和数据决策系统角色 import java.util.ArrayList; * <p/> import java.util.ArrayList; * Author : daisy import java.util.ArrayList; * Date: 13-8-30 import java.util.List; import java.util.List; import java.util.List; import java.util.ArrayList; import java.util.List; import java.util.List; import java.util.List; */ public class RoleDataWrapper implements ChildrenNodesLoader { import java.util.ArrayList; /** import java.util.List; * <p/> import java.util.List; * Author : daisy import java.util.List; * Date: 13-8-30 import java.util.ArrayList; /** import java.util.ArrayList; /** import java.util.ArrayList; import java.util.List; */ private void calculateRoleList() { try { Collections.addAll(rolelist, FRContext.getCurrentEnv().getOrganizationOperator().getRoleGroup()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } //加载所有的角色列表 public ExpandMutableTreeNode[] load() { calculateRoleList(); return this.load(this.rolelist); } //从workbook中读取的角色列表 public ExpandMutableTreeNode[] load(List<String> rolelist) { this.rolelist = rolelist; ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[rolelist.size()]; for (int i = 0; i < res.length; i++) { res[i] = new ExpandMutableTreeNode(rolelist.get(i)); } return res; } public String getRoleTypename(){ return roleTypename; } }

132
designer-base/src/com/fr/env/RemoteEnv.java vendored

@ -5,6 +5,7 @@ import com.fr.base.TableData;
import com.fr.base.operator.common.CommonOperator;
import com.fr.base.operator.connect.ConnectOperator;
import com.fr.base.operator.file.FileOperator;
import com.fr.base.operator.org.OrganizationOperator;
import com.fr.base.remote.RemoteDeziConstants;
import com.fr.common.rpc.RemoteCallServerConfig;
import com.fr.common.rpc.netty.MessageSendExecutor;
@ -20,8 +21,6 @@ import com.fr.design.DesignerEnvManager;
import com.fr.design.env.RemoteEnvConfig;
import com.fr.design.mainframe.DesignerContext;
import com.fr.file.CacheManager;
import com.fr.file.ConnectionConfig;
import com.fr.file.TableDataConfig;
import com.fr.general.CommonIOUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
@ -37,7 +36,6 @@ import com.fr.share.ShareConstants;
import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants;
import com.fr.stable.Filter;
import com.fr.stable.JavaCompileInfo;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
@ -56,20 +54,17 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.awt.*;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import static com.fr.third.guava.base.Preconditions.checkArgument;
@ -126,6 +121,11 @@ public class RemoteEnv extends AbstractEnv<RemoteEnvConfig> implements DesignAut
return MessageSendExecutor.getInstance().execute(CommonOperator.class);
}
@Override
public OrganizationOperator getOrganizationOperator() throws Exception {
return MessageSendExecutor.getInstance().execute(OrganizationOperator.class);
}
@Override
public RemoteEnvConfig getEnvConfig() {
return config;
@ -427,45 +427,6 @@ public class RemoteEnv extends AbstractEnv<RemoteEnvConfig> implements DesignAut
return Boolean.valueOf(IOUtils.inputStream2String(input, EncodeConstants.ENCODING_UTF_8));
}
/**
* DataSource中去除当前角色没有权限访问的数据源
*/
@Override
public void removeNoPrivilegeConnection() {
refreshHttpSProperty();
TableDataConfig dm = TableDataConfig.getInstance();
try {
HashMap<String, String> para = new HashMap<>();
para.put("op", "fs_remote_design");
para.put("cmd", "env_get_role");
para.put("currentUsername", this.getUser());
para.put("currentPwd", this.getPassword());
InputStream input = filterInputStream(
RemoteEnvUtils.simulateRPCByHttpGet(para, false, this)
);
JSONArray ja = new JSONArray(stream2String(input));
ArrayList<String> toBeRemoveTDName = new ArrayList<>();
for (int i = 0; i < ja.length(); i++) {
String toBeRemoveConnName = (String) ((JSONObject) ja.get(i)).get("name");
ConnectionConfig.getInstance().removeConnection(toBeRemoveConnName);
Iterator it = dm.getTableDatas().keySet().iterator();
while (it.hasNext()) {
String tdName = (String) it.next();
TableData td = dm.getTableData(tdName);
td.registerNoPrivilege(toBeRemoveTDName, toBeRemoveConnName, tdName);
}
}
for (int i = 0; i < toBeRemoveTDName.size(); i++) {
dm.removeTableData(toBeRemoveTDName.get(i));
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
}
}
@Override
public EmbeddedTableData previewTableData(Object tableData, Map parameterMap, int rowCount) throws Exception {
return previewTableData(null, tableData, parameterMap, rowCount);
@ -713,63 +674,6 @@ public class RemoteEnv extends AbstractEnv<RemoteEnvConfig> implements DesignAut
return FILE_TYPE;
}
/**
* 判断是否有文件夹权限
*
* @param path 路径
* @return 有权限则返回true
*/
@Override
public boolean hasFileFolderAllow(String path) {
refreshHttpSProperty();
try {
HashMap<String, String> para = new HashMap<>();
para.put("op", "fs_remote_design");
para.put("cmd", "design_filefolder_allow");
para.put("current_uid", this.getUserID());
para.put(RemoteDeziConstants.TEMPLATE_PATH, path);
InputStream input = filterInputStream(
RemoteEnvUtils.simulateRPCByHttpGet(para, false, this)
);
if (input == null) {
return false;
}
return Boolean.valueOf(IOUtils.inputStream2String(input, EncodeConstants.ENCODING_UTF_8));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
return false;
}
}
@Override
public ArrayList getAllRole4Privilege(boolean isFS) {
refreshHttpSProperty();
ArrayList<String> allRoleList = new ArrayList<>();
try {
HashMap<String, String> para = new HashMap<>();
para.put("op", "fr_remote_design");
para.put("cmd", "get_all_role");
para.put("isFS", String.valueOf(isFS));
InputStream input = filterInputStream(
RemoteEnvUtils.simulateRPCByHttpGet(para, false, this)
);
JSONArray ja = new JSONArray(stream2String(input));
for (int i = 0; i < ja.length(); i++) {
String roleName = (String) ((JSONObject) ja.get(i)).get("name");
allRoleList.add(roleName);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
}
return allRoleList;
}
/**
* 获取当前env的build文件路径
*/
@ -786,30 +690,6 @@ public class RemoteEnv extends AbstractEnv<RemoteEnvConfig> implements DesignAut
this.buildFilePath = buildFilePath;
}
/**
* 编译Java源代码方便二次开发的进行
*
* @param sourceText 源代码
* @return 编译信息有可能是成功信息也有可能是出错或者警告信息
*/
@Override
public JavaCompileInfo compilerSourceCode(String sourceText) throws Exception {
HashMap<String, String> para = new HashMap<>();
para.put("op", "fr_remote_design");
para.put("cmd", "design_compile_source_code");
InputStream in = postBytes2ServerB(sourceText.getBytes(EncodeConstants.ENCODING_UTF_8), para);
BufferedReader br = new BufferedReader(new InputStreamReader(in, EncodeConstants.ENCODING_UTF_8));
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
}
JSONObject jo = new JSONObject(sb.toString());
JavaCompileInfo info = new JavaCompileInfo();
info.parseJSON(jo);
return info;
}
@Override
public String[] loadREUFile() {
refreshHttpSProperty();

50
designer-base/src/com/fr/file/FILEChooserPane.java

@ -1,8 +1,8 @@
package com.fr.file;
import com.fr.base.BaseUtils;
import com.fr.base.extension.FileExtension;
import com.fr.base.FRContext;
import com.fr.base.extension.FileExtension;
import com.fr.dav.LocalEnv;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.UpdateAction;
@ -26,6 +26,7 @@ import com.fr.file.filter.FILEFilter;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CoreConstants;
import com.fr.stable.OperatingSystem;
import com.fr.stable.ProductConstants;
@ -33,38 +34,13 @@ import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import javax.swing.AbstractAction;
import javax.swing.AbstractListModel;
import javax.swing.ActionMap;
import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.Icon;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.KeyStroke;
import javax.swing.ListCellRenderer;
import javax.swing.ListModel;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.filechooser.FileSystemView;
import javax.swing.plaf.basic.BasicArrowButton;
import javax.swing.plaf.basic.BasicButtonUI;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Window;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
@ -707,7 +683,14 @@ public class FILEChooserPane extends BasicPane {
}
returnValue = OK_OPTION;
FILE selectedFile = this.getSelectedFILE();
if (!FRContext.getCurrentEnv().hasFileFolderAllow(selectedFile.getPath())) {
boolean access = false;
try {
access = FRContext.getCurrentEnv().getOrganizationOperator().canAccess(selectedFile.getPath());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (!access) {
JOptionPane.showMessageDialog(FILEChooserPane.this, Inter.getLocText("FR-App-Privilege_No") + "!", Inter.getLocText("FR-App-File_Message"), JOptionPane.WARNING_MESSAGE);
return;
}
@ -1418,7 +1401,14 @@ public class FILEChooserPane extends BasicPane {
if (currentDirectory == null) {
return;
}
if (!FRContext.getCurrentEnv().hasFileFolderAllow(currentDirectory.getPath() + "/")) {
boolean access = false;
try {
access = FRContext.getCurrentEnv().getOrganizationOperator().canAccess(currentDirectory.getPath());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (!access) {
JOptionPane.showMessageDialog(FILEChooserPane.this, Inter.getLocText("FR-App-Privilege_No") + "!", Inter.getLocText("FR-App-File_Message"), JOptionPane.WARNING_MESSAGE);
return;
}

Loading…
Cancel
Save