Browse Source

REPORT-20320 sonar问题修复

research/11.0
vito 5 years ago
parent
commit
518cd18776
  1. 8
      designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java
  2. 66
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataSourceOP.java
  3. 201
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java
  4. 48
      designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java
  5. 2
      designer-base/src/main/java/com/fr/design/extra/PluginControlPane.java
  6. 16
      designer-base/src/main/java/com/fr/design/extra/PluginFromStorePane.java

8
designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java

@ -46,6 +46,7 @@ import java.awt.event.KeyEvent;
import java.util.EventObject;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* Coder: zack
@ -70,6 +71,7 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
*
* @return 返回位置
*/
@Override
public Location preferredLocation() {
return Location.WEST_ABOVE;
}
@ -97,6 +99,7 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
/**
* 响应数据集改变
*/
@Override
public void fireDSChanged() {
fireDSChanged(new HashMap<String, String>());
}
@ -107,6 +110,7 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
*
* @param map 数据集变化Map
*/
@Override
public void fireDSChanged(Map<String, String> map) {
DesignTableDataManager.fireDSChanged(map);
}
@ -151,6 +155,7 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
public abstract TableDataTree getDataTree();
@Override
public abstract void refreshDockingView();
protected void checkButtonEnabled(UpdateAction editAction, UpdateAction previewTableDataAction, UpdateAction removeAction, TableDataSourceOP op, TableDataTree dataTree) {
@ -320,6 +325,7 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
this.setSmallIcon(this.getTDIcon());
}
@Override
public void actionPerformed(ActionEvent e) {
dgEdit(getTableDataInstance().creatTableDataPane(), createDsName(getNamePrefix()), false);
}
@ -400,7 +406,7 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
data = selectedNO.getObject();
}
try {
if (((TableDataWrapper) data).getTableData() instanceof StoreProcedure) {
if (((TableDataWrapper) Objects.requireNonNull(data)).getTableData() instanceof StoreProcedure) {
((StoreProcedure) (((TableDataWrapper) data).getTableData())).resetDataModelList();
if (data instanceof StoreProcedureDataWrapper) {
StoreProcedureDataWrapper oldSdw = ((StoreProcedureDataWrapper) data);

66
designer-base/src/main/java/com/fr/design/data/datapane/TableDataSourceOP.java

@ -56,14 +56,18 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
return DesignTableDataManager.getEditingDataSet(tc.getBook());
}
List<Map<String, TableDataWrapper>> empty = new ArrayList<Map<String, TableDataWrapper>>();
empty.add(Collections.<String, TableDataWrapper>emptyMap());//数据集
empty.add(Collections.<String, TableDataWrapper>emptyMap());//服务器数据集
empty.add(Collections.<String, TableDataWrapper>emptyMap());//存储过程
//数据集
empty.add(Collections.<String, TableDataWrapper>emptyMap());
//服务器数据集
empty.add(Collections.<String, TableDataWrapper>emptyMap());
//存储过程
empty.add(Collections.<String, TableDataWrapper>emptyMap());
return empty;
}
/**
* ButtonEnabled intercept
*
* @return interceptbuttonEnabled
*/
@Override
@ -73,8 +77,10 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
/**
* 移除名字是name的TableData
*
* @param name tabledata name
*/
@Override
public void removeAction(String name) {
if (tc != null) {
TableDataSource tds = tc.getBook();
@ -85,7 +91,7 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
}
protected ExpandMutableTreeNode[] getNodeArrayFromMap(Map<String, TableDataWrapper> map) {
List<ExpandMutableTreeNode> dataList = new ArrayList<ExpandMutableTreeNode>();
List<ExpandMutableTreeNode> dataList = new ArrayList<>();
Iterator<Entry<String, TableDataWrapper>> entryIt = map.entrySet().iterator();
while (entryIt.hasNext()) {
Entry<String, TableDataWrapper> entry = entryIt.next();
@ -96,7 +102,7 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
dataList.add(newChildTreeNode);
newChildTreeNode.add(new ExpandMutableTreeNode());
}
return dataList.toArray(new ExpandMutableTreeNode[dataList.size()]);
return dataList.toArray(new ExpandMutableTreeNode[0]);
}
private ExpandMutableTreeNode initTemplateDataNode(Map<String, TableDataWrapper> templateDataMap) {
@ -124,22 +130,20 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
*/
@Override
public ExpandMutableTreeNode[] load() {
Map<String, TableDataWrapper> templateDataMap = null;
Map<String, TableDataWrapper> serverDataMap = null;
Map<String, TableDataWrapper> storeProcedureMap = null;
if (this != null) {
templateDataMap = this.init().get(0);
serverDataMap = this.init().get(1);
storeProcedureMap = this.init().get(2);
} else {
templateDataMap = Collections.emptyMap();
serverDataMap = Collections.emptyMap();
storeProcedureMap = Collections.emptyMap();
}
List<ExpandMutableTreeNode> list = new ArrayList<ExpandMutableTreeNode>(); //所有的数据集
List<ExpandMutableTreeNode> templist = new ArrayList<ExpandMutableTreeNode>(); //模板数据集
List<ExpandMutableTreeNode> serverlist = new ArrayList<ExpandMutableTreeNode>(); //服务器数据集
Map<String, TableDataWrapper> templateDataMap;
Map<String, TableDataWrapper> serverDataMap;
Map<String, TableDataWrapper> storeProcedureMap;
templateDataMap = this.init().get(0);
serverDataMap = this.init().get(1);
storeProcedureMap = this.init().get(2);
//所有的数据集
List<ExpandMutableTreeNode> list = new ArrayList<>();
//模板数据集
List<ExpandMutableTreeNode> templist = new ArrayList<>();
//服务器数据集
List<ExpandMutableTreeNode> serverlist = new ArrayList<>();
list.add(initTemplateDataNode(templateDataMap));
addNodeToList(templateDataMap, templist);
@ -160,11 +164,11 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
}
switch (dataMode) {
case TEMPLATE_TABLE_DATA:
return templist.toArray(new ExpandMutableTreeNode[templist.size()]);
return templist.toArray(new ExpandMutableTreeNode[0]);
case SERVER_TABLE_DATA:
return serverlist.toArray(new ExpandMutableTreeNode[serverlist.size()]);
return serverlist.toArray(new ExpandMutableTreeNode[0]);
default:
return list.toArray(new ExpandMutableTreeNode[list.size()]);
return list.toArray(new ExpandMutableTreeNode[0]);
}
}
@ -182,7 +186,7 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
}
protected void setStoreProcedureTree(TableData tableData, ExpandMutableTreeNode tmpNode) {
ArrayList<String> nodeName = new ArrayList<String>();
ArrayList<String> nodeName = new ArrayList<>();
StoreProcedure storeProcedure = (StoreProcedure) tableData;
String name = ((NameObject) tmpNode.getUserObject()).getName();
StoreProcedureParameter[] parameters = StoreProcedure.getSortPara(storeProcedure.getParameters());
@ -208,13 +212,13 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
}
if (!resultNames.isEmpty()) {
for (int i = 0; i < resultNames.size(); i++) {
if (!nodeName.contains(resultNames.get(i))) {
nodeName.add(resultNames.get(i));
for (String resultName : resultNames) {
if (!nodeName.contains(resultName)) {
nodeName.add(resultName);
hasChild = true;
String parameterName = name + "_" + resultNames.get(i);
String parameterName = name + "_" + resultName;
TableDataWrapper newTwd = new StoreProcedureDataWrapper(storeProcedure, name, parameterName, false);
ExpandMutableTreeNode newChildNode = new ExpandMutableTreeNode(new NameObject(resultNames.get(i), newTwd));
ExpandMutableTreeNode newChildNode = new ExpandMutableTreeNode(new NameObject(resultName, newTwd));
newChildNode.add(new ExpandMutableTreeNode());
tmpNode.add(newChildNode);
}
@ -230,7 +234,7 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
public void setDataMode(int i) {
this.dataMode = i;
dataMode = i;
}
public int getDataMode() {

201
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java

@ -76,6 +76,7 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
private static final int TEXT = 0;
@ -126,12 +127,12 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
private static final int GAP = 23;
public FileTableDataPane(){
this(SETPANELWIDTH,WIDTH,HEIGHT,GAP);
public FileTableDataPane() {
this(SETPANELWIDTH, WIDTH, HEIGHT, GAP);
}
public FileTableDataPane(int setPanelWidth,int width,int height,int gap) {
this.setLayout(new BorderLayout(gap,0));
public FileTableDataPane(int setPanelWidth, int width, int height, int gap) {
this.setLayout(new BorderLayout(gap, 0));
JPanel northPanel = new JPanel(new BorderLayout());
JPanel type = new JPanel();
type.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_File_Type") + ":"));
@ -163,16 +164,16 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
southPanel.add(setPanel, BorderLayout.CENTER);
setPanel.setPreferredSize(new Dimension(setPanelWidth, 460));
setPanel.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set")));
JPanel controlPane = textSetPanel(width,height);
JPanel controlPane = textSetPanel(width, height);
setPanel.add(controlPane, BorderLayout.NORTH);
fileTypeComboBox.addActionListener(getFileTypeListener(setPanel,width,height));
fileTypeComboBox.addActionListener(getFileTypeListener(setPanel, width, height));
this.add(northPanel, BorderLayout.NORTH);
this.add(centerPanel, BorderLayout.CENTER);
this.add(southPanel, BorderLayout.EAST);
}
private void addToCenterPanel(JPanel centerPanel){
private void addToCenterPanel(JPanel centerPanel) {
localFileRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Local_File") + ":", true);
urlFileRadioButton = new UIRadioButton("URL:", false);
ButtonGroup bg = new ButtonGroup();
@ -217,8 +218,9 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
}
private ActionListener testConnectionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
String uri = ParameterHelper.analyze4Templatee( urlText.getText(), params);
String uri = ParameterHelper.analyze4Templatee(urlText.getText(), params);
if (!checkURL(uri)) {
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(FileTableDataPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Add_JS_warning"));
return;
@ -245,10 +247,11 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
}
};
private void previewPanel(JPanel jPanel){
private void previewPanel(JPanel jPanel) {
JPanel previewPanel = new JPanel(new BorderLayout());
UIButton preview = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"));
preview.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
preview();
}
@ -257,48 +260,47 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
jPanel.add(previewPanel, BorderLayout.SOUTH);
}
private JPanel xmlSetPanel(int width,int height) {
private JPanel xmlSetPanel(int width, int height) {
// xml设置pane
JPanel controlPane = new JPanel();
JPanel northPane = new JPanel(new BorderLayout(8,8));
JPanel northTopPane = new JPanel(new BorderLayout(8,8));
JPanel southPane = new JPanel(new BorderLayout(8,8));
JPanel southTopPane = new JPanel(new BorderLayout(8,8));
JPanel westPane = new JPanel(new BorderLayout());
controlPane.setLayout(new BorderLayout(8,8));
JPanel northPane = new JPanel(new BorderLayout(8, 8));
JPanel northTopPane = new JPanel(new BorderLayout(8, 8));
JPanel southPane = new JPanel(new BorderLayout(8, 8));
JPanel southTopPane = new JPanel(new BorderLayout(8, 8));
controlPane.setLayout(new BorderLayout(8, 8));
controlPane.setPreferredSize(new Dimension(width, height));
JPanel comboboxPanel = new JPanel(new BorderLayout(8,8));
JPanel comboboxPanel = new JPanel(new BorderLayout(8, 8));
encodeLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Encoding_Type") + ":");
encodingComboBox = new UIComboBox(EncodeConstants.ALL_ENCODING_ARRAY);
encodingComboBox.setSelectedIndex(4);
encodingComboBox.setPreferredSize(new Dimension(90, 20));
JPanel treeContainerPane = new JPanel();
treeContainerPane.setLayout(new BorderLayout(8,8));
treeContainerPane.setLayout(new BorderLayout(8, 8));
nodeTreePane = new XMLNodeTreePane();
treeContainerPane.add(nodeTreePane,BorderLayout.CENTER);
treeContainerPane.add(nodeTreePane, BorderLayout.CENTER);
comboboxPanel.add(encodeLabel, BorderLayout.WEST);
comboboxPanel.add(encodingComboBox, BorderLayout.CENTER);
northPane.add(comboboxPanel,BorderLayout.EAST);
northTopPane.add(northPane,BorderLayout.WEST);
southTopPane.add(southPane,BorderLayout.WEST);
southTopPane.add(treeContainerPane,BorderLayout.CENTER);
northPane.add(comboboxPanel, BorderLayout.EAST);
northTopPane.add(northPane, BorderLayout.WEST);
southTopPane.add(southPane, BorderLayout.WEST);
southTopPane.add(treeContainerPane, BorderLayout.CENTER);
controlPane.add(northTopPane, BorderLayout.NORTH);
controlPane.add(southTopPane,BorderLayout.CENTER);
controlPane.add(southTopPane, BorderLayout.CENTER);
previewPanel(controlPane);
return controlPane;
}
private JPanel excelSetPanel(int width,int height) {
private JPanel excelSetPanel(int width, int height) {
// excel设置pane
int checkBoxWidth = width - EIGHT;
JPanel controlPane = new JPanel();
JPanel northPane = new JPanel(new BorderLayout(8,8));
JPanel northPane = new JPanel(new BorderLayout(8, 8));
controlPane.setLayout(new BorderLayout());
controlPane.setPreferredSize(new Dimension(width,height));
controlPane.setPreferredSize(new Dimension(width, height));
needColumnNameCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FirstRow_IS_Column_Name"), false);
needColumnNameCheckBox.setPreferredSize(new Dimension(checkBoxWidth, 20));
northPane.add(needColumnNameCheckBox, BorderLayout.EAST);
@ -321,6 +323,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
*
* @throws Exception
*/
@Override
public void checkValid() throws Exception {
if (urlFileRadioButton.isSelected()) {
String url = urlText.getText().trim();
@ -331,33 +334,33 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
}
private boolean checkURL(String uri){
private boolean checkURL(String uri) {
try {
new URL(uri);
return true;
} catch (MalformedURLException e) {
return false;
}
// return (uri.matches("https*://.+|\\$\\{.+\\}.*"));
// return (uri.matches("https*://.+|\\$\\{.+\\}.*"));
}
private JPanel textSetPanel(int width,int height) {
private JPanel textSetPanel(int width, int height) {
// text设置pane
JPanel controlPane = new JPanel();
controlPane.setLayout(new BorderLayout());
controlPane.setPreferredSize(new Dimension(width,height));
JPanel northPane = new JPanel(new BorderLayout(8,8));
controlPane.setPreferredSize(new Dimension(width, height));
JPanel northPane = new JPanel(new BorderLayout(8, 8));
addToNorthPane(northPane);
controlPane.add(northPane,BorderLayout.WEST);
controlPane.add(northPane, BorderLayout.WEST);
previewPanel(controlPane);
return controlPane;
}
private void addToNorthPane(JPanel northPane){
private void addToNorthPane(JPanel northPane) {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double columnSize[] = {f, p, p};
double rowSize[] = {B, B, B, B, B, B, B};
double[] columnSize = {f, p, p};
double[] rowSize = {B, B, B, B, B, B, B};
needColumnNameCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FirstRow_IS_Column_Name"), true);
dismenberLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dismenber") + ":");
tableDismemberRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Table_Dismember"), false);
@ -390,18 +393,19 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
encodeLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Encoding_Type") + ":");
charsetComboBox = new UIComboBox(EncodeConstants.ALL_ENCODING_ARRAY);
Component[][] comps = {
{encodeLabel,charsetComboBox,null},
{needColumnNameCheckBox,null,null},
{dismenberLabel,tableDismemberRadioButton,null},
{null,spaceDismenberRadioButton,null},
{null,commaDismenberRadioButton,null},
{null,otherDismenberRadioButton,otherDismenberTextField},
{ignoreOneMoreDelimiterCheckBox,null,null}
{encodeLabel, charsetComboBox, null},
{needColumnNameCheckBox, null, null},
{dismenberLabel, tableDismemberRadioButton, null},
{null, spaceDismenberRadioButton, null},
{null, commaDismenberRadioButton, null},
{null, otherDismenberRadioButton, otherDismenberTextField},
{ignoreOneMoreDelimiterCheckBox, null, null}
};
northPane.add(TableLayoutHelper.createTableLayoutPane(comps, rowSize, columnSize),BorderLayout.EAST);
northPane.add(TableLayoutHelper.createTableLayoutPane(comps, rowSize, columnSize), BorderLayout.EAST);
}
private ActionListener radioActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (localFileRadioButton.isSelected()) {
localRadioSelectAction();
@ -456,8 +460,8 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
private String[] getFileSuffix() {
List<String> suffixList = new ArrayList<String>();
String suffix = fileTypeComboBox.getSelectedItem().toString().toLowerCase();
if (suffix.equalsIgnoreCase("excel")) {
String suffix = Objects.requireNonNull(fileTypeComboBox.getSelectedItem()).toString().toLowerCase();
if ("excel".equalsIgnoreCase(suffix)) {
suffixList.add("xls");
suffixList.add("xlsx");
} else {
@ -467,8 +471,8 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
}
private String getFileSuffixToString() {
String suffixToString = fileTypeComboBox.getSelectedItem().toString().toLowerCase();
if (suffixToString.equalsIgnoreCase("excel")) {
String suffixToString = Objects.requireNonNull(fileTypeComboBox.getSelectedItem()).toString().toLowerCase();
if ("excel".equalsIgnoreCase(suffixToString)) {
suffixToString = "xls";
}
return suffixToString;
@ -476,16 +480,17 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
private ActionListener getFileTypeListener(final JPanel setPanel, final int width, final int height) {
ActionListener fileTypeListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setPanel.removeAll();
localText.setText("");
urlText.setText("");
if (fileTypeComboBox.getSelectedIndex() == XML) {
setPanel.add(xmlSetPanel(width,height), BorderLayout.NORTH);
setPanel.add(xmlSetPanel(width, height), BorderLayout.NORTH);
} else if (fileTypeComboBox.getSelectedIndex() == EXCEL) {
setPanel.add(excelSetPanel(width,height), BorderLayout.NORTH);
setPanel.add(excelSetPanel(width, height), BorderLayout.NORTH);
} else {
setPanel.add(textSetPanel(width,height), BorderLayout.NORTH);
setPanel.add(textSetPanel(width, height), BorderLayout.NORTH);
}
String tipContent = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Type_Parameter") + "reportlets/excel/FineReport${abc}." + getFileSuffixToString() + "<br>"
+ "http://192.168.100.120:8080/XXServer/Report/excel${abc}.jsp<br>" + "&nbsp</body> </html> ";
@ -503,6 +508,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
String[] paramTexts = new String[1];
paramTexts[0] = getFilePathFromUrlOrLocal();
@ -545,25 +551,25 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
setTextField(xtd);
editorPane.populate(xtd.getParams());
encodingComboBox.setSelectedItem(xtd.getCharSet());
if (!ComparatorUtils.equals(xtd,new XMLTableData())) {
if (!ComparatorUtils.equals(xtd, new XMLTableData())) {
xmlNodeTree.initData();
String[] path = xtd.getXPath();
String[] paths;
if (path != null && path.length > 0) {
DefaultTreeModel treeModel = (DefaultTreeModel)xmlNodeTree.getModel();
DefaultTreeModel treeModel = (DefaultTreeModel) xmlNodeTree.getModel();
ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot();
if (treeModel != null) {
if(!ComparatorUtils.equals(treeModel.getRoot().toString(),"")){
paths = new String[path.length - 1];
for(int i = 1;i< path.length;i++){
paths[i -1] = path[i];
}
}else{
if (!ComparatorUtils.equals(treeModel.getRoot().toString(), "")) {
paths = new String[path.length - 1];
for (int i = 1; i < path.length; i++) {
paths[i - 1] = path[i];
}
} else {
paths = path;
root.setUserObject(ROOTTAG);
}
if (treeModel.getRoot() instanceof ExpandMutableTreeNode) {
selectNode((ExpandMutableTreeNode)treeModel.getRoot(), 0, paths);
selectNode((ExpandMutableTreeNode) treeModel.getRoot(), 0, paths);
if (selectedNode != null) {
TreePath treepath = new TreePath(treeModel.getPathToRoot(selectedNode));
xmlNodeTree.setSelectionPath(treepath);
@ -571,8 +577,8 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
}
}
//防止某种操作导致添加的tag作为root出现。
if(ComparatorUtils.equals(root.toString(),ROOTTAG)){
root.setUserObject(StringUtils.EMPTY);
if (ComparatorUtils.equals(root.toString(), ROOTTAG)) {
root.setUserObject(StringUtils.EMPTY);
}
}
}
@ -638,7 +644,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
ttd.setDelimiter(this.showDelimiter());
ttd.setIgnoreOneMoreDelimiter(ignoreOneMoreDelimiterCheckBox.isSelected());
ttd.setNeedColumnName(needColumnNameCheckBox.isSelected());
ttd.setCharset((String)charsetComboBox.getSelectedItem());
ttd.setCharset((String) charsetComboBox.getSelectedItem());
fileTableData = ttd;
return ttd;
}
@ -667,12 +673,12 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
xmlColumnsList.clear();
ExpandMutableTreeNode treeNode;
boolean flag = true;
for(int i = 0;i < selectedNode.getChildCount();i++){
for (int i = 0; i < selectedNode.getChildCount(); i++) {
treeNode = (ExpandMutableTreeNode) selectedNode.getChildAt(i);
if(treeNode.isLeaf()){
if (treeNode.isLeaf()) {
xmlColumnsList.add(treeNode.toString());
}else{
if(flag){
} else {
if (flag) {
flag = false;
finalSelectedNode = treeNode;
leafNode(treeNode);
@ -692,34 +698,34 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
}
//wikky:构建树时为了美观把添加的根节点值赋为空显示,现在还得该回去使得预览时能够顺利取到数据。
private String[] getPaths(){
private String[] getPaths() {
TreePath treePath = GUICoreUtils.getTreePath(finalSelectedNode);
String path = StringUtils.EMPTY;
if (treePath != null) {
Object[] paths = treePath.getPath();
for (int i = 0; i < paths.length; i++) {
path+="/" + paths[i];
path += "/" + paths[i];
}
}
if (path.startsWith("/")) {
path = path.substring(1);
}
String[] paths = path.split("/");
if(ComparatorUtils.equals(paths[0],StringUtils.EMPTY)){
if (ComparatorUtils.equals(paths[0], StringUtils.EMPTY)) {
paths[0] = ROOTTAG;
}
return paths;
}
private void leafNode(ExpandMutableTreeNode treeNode){
private void leafNode(ExpandMutableTreeNode treeNode) {
boolean flag = true;
ExpandMutableTreeNode firstNode;
for(int i = 0;i < treeNode.getChildCount();i++){
for (int i = 0; i < treeNode.getChildCount(); i++) {
firstNode = (ExpandMutableTreeNode) treeNode.getChildAt(i);
if(firstNode.isLeaf()){
if (firstNode.isLeaf()) {
xmlColumnsList.add(firstNode.toString());
}else{
if(flag){
} else {
if (flag) {
flag = false;
finalSelectedNode = treeNode;
leafNode(firstNode);
@ -729,16 +735,16 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
}
private void selectNode(ExpandMutableTreeNode node, int layer, String[] paths) {
if (selectedNode != null || node == null){
if (selectedNode != null || node == null) {
return;
}
if (layer < paths.length && paths[layer] != null && ComparatorUtils.equals(paths[layer],node.getUserObject())) {
if (layer == paths.length -1) {
if (layer < paths.length && paths[layer] != null && ComparatorUtils.equals(paths[layer], node.getUserObject())) {
if (layer == paths.length - 1) {
selectedNode = node;
return;
}
for (int i = 0; i < node.getChildCount(); i++) {
selectNode((ExpandMutableTreeNode)node.getChildAt(i), layer + 1, paths);
selectNode((ExpandMutableTreeNode) node.getChildAt(i), layer + 1, paths);
}
}
}
@ -800,8 +806,8 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
toolbarDef.addShortCut(refreshAction);
UIToolbar toolBar = ToolBarDef.createJToolBar();
toolbarDef.updateToolBar(toolBar);
toolbarPanel.add(keyPointLaber,BorderLayout.WEST);
toolbarPanel.add(toolBar,BorderLayout.EAST);
toolbarPanel.add(keyPointLaber, BorderLayout.WEST);
toolbarPanel.add(toolBar, BorderLayout.EAST);
this.add(toolbarPanel, BorderLayout.NORTH);
}
@ -817,6 +823,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
xmlNodeTree.waitRefresh();
xmlNodeTree.refreshData();
@ -845,8 +852,9 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
}
private MouseListener treeMouseListener = new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (XMLNodeTree.this.getModel() != treeModel){
if (XMLNodeTree.this.getModel() != treeModel) {
return;
}
int selRow = XMLNodeTree.this.getRowForLocation(e.getX(), e.getY());
@ -858,12 +866,12 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
return;//没有选中某个树节点,就直接返回啦
}
Object selObject = selPath.getLastPathComponent();
if (selObject instanceof ExpandMutableTreeNode ) {
if (selObject instanceof ExpandMutableTreeNode) {
ExpandMutableTreeNode expandMutableTreeNode = (ExpandMutableTreeNode) selObject;
if (!expandMutableTreeNode.isLeaf()) {
selectedNode = expandMutableTreeNode;
} else {
selectedNode = (ExpandMutableTreeNode)expandMutableTreeNode.getParent();
selectedNode = (ExpandMutableTreeNode) expandMutableTreeNode.getParent();
}
}
}
@ -906,7 +914,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
DataSource dataSource = null;
if (localFileRadioButton.isSelected()) {
String localTextString = StringUtils.trimToNull(localText.getText());
if(StringUtils.isEmpty(localTextString)){
if (StringUtils.isEmpty(localTextString)) {
FineLoggerFactory.getLogger().info("The file path is empty.");
loadedTreeModel();
return;
@ -914,7 +922,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
dataSource = new FileDataSource(localTextString, params);
} else {
String urlTextString = StringUtils.trimToNull(urlText.getText());
if (StringUtils.isEmpty(urlTextString)){
if (StringUtils.isEmpty(urlTextString)) {
FineLoggerFactory.getLogger().info("The url path is empty.");
loadedTreeModel();
return;
@ -922,7 +930,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
dataSource = new URLDataSource(urlTextString, params);
}
try {
InputStream in,input;
InputStream in, input;
if ((in = dataSource.getSourceStream(params)) != null) {
String xmlString = Utils.inputStream2String(in, (String) encodingComboBox.getSelectedItem());
String stringXml = addTag(xmlString);
@ -941,16 +949,20 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
loadedTreeModel();
}
if(treeModel.getChildCount(treeModel.getRoot()) == 1){
treeModel = new DefaultTreeModel((ExpandMutableTreeNode) treeModel.getChild(treeModel.getRoot(),0));
}else{
if (treeModel == null) {
FineLoggerFactory.getLogger().info("The file is wrong or bad, can not create the XMLReader.");
return;
}
if (treeModel.getChildCount(treeModel.getRoot()) == 1) {
treeModel = new DefaultTreeModel((ExpandMutableTreeNode) treeModel.getChild(treeModel.getRoot(), 0));
} else {
ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot();
root.setUserObject(StringUtils.EMPTY);
}
this.setModel(treeModel);
}
private void loadedTreeModel(){
private void loadedTreeModel() {
ExpandMutableTreeNode rootTreeNode = new ExpandMutableTreeNode(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loaded_Tree_Model"));
rootTreeNode.setExpanded(false);
rootTreeNode.setAllowsChildren(false);
@ -958,14 +970,14 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
XMLNodeTree.this.setModel(loadedTreeModel);
}
private String addTag(String string){
private String addTag(String string) {
String stringWithTag;
int beginIndex = 0;
int firstIndex = string.indexOf(">");
int endIndex = string.length();
String firstPart = string.substring(beginIndex,firstIndex + 1);
String firstPart = string.substring(beginIndex, firstIndex + 1);
String secondPart = STARTTAG;
String thirdPart = string.substring(firstIndex + 1,endIndex);
String thirdPart = string.substring(firstIndex + 1, endIndex);
String lastPart = ENDTAG;
stringWithTag = firstPart + secondPart + thirdPart + lastPart;
return stringWithTag;
@ -986,6 +998,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
this.layer = layer;
}
@Override
public void readXML(XMLableReader reader) {
String nodeName;
if (this.layer < 0) {

48
designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java

@ -1,6 +1,7 @@
package com.fr.design.extra;
import com.fr.base.passport.FinePassportManager;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.config.MarketConfig;
import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.exe.PluginLoginExecutor;
@ -8,47 +9,30 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.general.CloudCenter;
import com.fr.general.http.HttpClient;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils;
import javafx.concurrent.Task;
import javafx.scene.web.WebEngine;
import netscape.javascript.JSObject;
import javax.swing.JDialog;
import javax.swing.SwingUtilities;
import java.awt.Color;
import java.awt.Desktop;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URLEncoder;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* @author vito
*/
public class LoginWebBridge {
//默认查询消息时间, 30s
private static final long CHECK_MESSAGE_TIME = 30 * 1000L;
//数据查询正常的标志 ok
private static final String SUCCESS_MESSAGE_STATUS = "ok";
//数据通讯失败
private static final String FAILED_MESSAGE_STATUS = "error";
//最低消息的条数
private static final int MIN_MESSAGE_COUNT = 0;
//登录成功
private static final String LOGININ = "0";
//用户名不存在
private static final String USERNAME_NOT_EXSIT = "-1";
//密码错误
private static final String PASSWORD_ERROR = "-2";
//未知错误
private static final String UNKNOWN_ERROR = "-3";
//网络连接失败
private static final String NET_FAILED = "-4";
//用户名,密码为空
private static final String LOGIN_INFO_EMPTY = "-5";
private static final int TIME_OUT = 10000;
private static final String LOGIN_SUCCESS = "ok";
private static final String LOGIN_FAILED = "failed";
private static final Color LOGIN_BACKGROUND = new Color(184, 220, 242);
private static LoginWebBridge helper;
//消息条数
@ -131,22 +115,6 @@ public class LoginWebBridge {
return client.isServerAlive();
}
private String encode(String str) {
try {
return URLEncoder.encode(str, EncodeConstants.ENCODING_UTF_8);
} catch (UnsupportedEncodingException e) {
return str;
}
}
private void sleep(long millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
/**
* 注册页面
*/
@ -178,7 +146,9 @@ public class LoginWebBridge {
*/
public void defaultLogin(String username, String password, final JSObject callback) {
Task<Void> task = new PluginTask<>(webEngine, callback, new PluginLoginExecutor(username, password));
new Thread(task).start();
ExecutorService es = Executors.newSingleThreadExecutor(new NamedThreadFactory("bbsDefaultLogin"));
es.submit(task);
es.shutdown();
}
/**
@ -250,10 +220,6 @@ public class LoginWebBridge {
}
}
public void openUrlAtLocalWebBrowser(WebEngine eng, String url) {
if (url.indexOf("qqLogin.html") > 0) {
return;
}
}
}

2
designer-base/src/main/java/com/fr/design/extra/PluginControlPane.java

@ -15,6 +15,7 @@ import com.fr.plugin.manage.control.PluginTaskCallback;
import com.fr.plugin.manage.control.PluginTaskResult;
import com.fr.plugin.view.PluginView;
import com.fr.stable.StringUtils;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
@ -142,6 +143,7 @@ public class PluginControlPane extends BasicPane {
}
}
@Nullable
public PluginView getSelectedPlugin() {
return (PluginView) pluginList.getSelectedValue();
}

16
designer-base/src/main/java/com/fr/design/extra/PluginFromStorePane.java

@ -28,8 +28,6 @@ import java.util.List;
* @since 8.0
*/
public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<PluginView>, Void> {
private static final int LISTNUM1 = 1;
private static final int LISTNUM100 = 100;
private UILabel errorMsgLabel;
private UITabbedPane tabbedPane;
private PluginControlPane controlPane;
@ -45,6 +43,7 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<Plug
*
* @return 创建的页面对象
*/
@Override
public JPanel createSuccessPane() {
return new PluginStatusCheckCompletePane() {
@ -130,8 +129,8 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<Plug
*
* @return 插件
*/
@Override
public List<PluginView> loadData() throws Exception {
//Thread.sleep(3000);
return PluginsReaderFromStore.readPlugins();
}
@ -140,6 +139,7 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<Plug
*
* @param plugins 插件
*/
@Override
public void loadOnSuccess(List<PluginView> plugins) {
controlPane.loadPlugins(plugins);
tabbedPane.setTitleAt(2, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_All_Plugins") + "(" + plugins.size() + ")");
@ -150,10 +150,12 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<Plug
*
* @param e 异常消息
*/
@Override
public void loadOnFailed(Exception e) {
errorMsgLabel.setText(e.getCause().getMessage());
}
@Override
protected void installFromDiskFile() {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
@ -196,10 +198,11 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<Plug
}
if (StringUtils.isNotEmpty(MarketConfig.getInstance().getBbsUsername())) {
PluginView plugin = controlPane.getSelectedPlugin();
String id = null;
if (plugin != null) {
id = plugin.getID();
if (plugin == null) {
FineLoggerFactory.getLogger().error("selected plugin is null");
return;
}
String id = plugin.getID();
try {
PluginMarker pluginMarker = PluginMarker.create(id, plugin.getVersion());
@ -219,6 +222,7 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<Plug
*
* @return 标题字符串
*/
@Override
public String textForLoadingLabel() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Load_Plugins_From_Server");
}

Loading…
Cancel
Save