plough 8 years ago
parent
commit
2795f32e41
  1. 27
      designer/src/com/fr/design/cell/clipboard/CellElementsClip.java
  2. 12
      designer/src/com/fr/design/report/freeze/RepeatAndFreezeSettingPane.java
  3. 2
      designer/src/com/fr/grid/GridUtils.java
  4. 12
      designer/src/com/fr/grid/selection/CellSelection.java
  5. 12
      designer_base/src/com/fr/design/actions/server/PluginManagerAction.java
  6. 53
      designer_base/src/com/fr/design/actions/server/ReuseManagerAction.java
  7. 43
      designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java
  8. 117
      designer_base/src/com/fr/design/extra/ShopManagerPane.java
  9. 165
      designer_base/src/com/fr/design/extra/WebDialog.java
  10. 99
      designer_base/src/com/fr/design/extra/WebManagerPaneFactory.java
  11. 12
      designer_base/src/com/fr/start/BaseDesigner.java
  12. 0
      sonar-dev-project.properties

27
designer/src/com/fr/design/cell/clipboard/CellElementsClip.java

@ -12,24 +12,29 @@ import com.fr.report.cell.CellElement;
import com.fr.report.cell.CellElementComparator; import com.fr.report.cell.CellElementComparator;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.unit.FU;
/** /**
* The clip of CellElement. * The clip of CellElement.
*/ */
public class CellElementsClip implements Cloneable, java.io.Serializable { public class CellElementsClip implements Cloneable, java.io.Serializable {
private int column;
private int row;
private int columnSpan = 0; private int columnSpan = 0;
private int rowSpan = 0; private int rowSpan = 0;
private FU[] columnWidth;
private FU[] rowHeight;
private TemplateCellElement[] clips; private TemplateCellElement[] clips;
public CellElementsClip(int column, int row, int columnSpan, int rowSpan, TemplateCellElement[] clips) { public CellElementsClip(int columnSpan, int rowSpan, FU[] columnWidth , FU[] rowHeight, TemplateCellElement[] clips) {
this.column = column;
this.row = row;
this.columnSpan = columnSpan; this.columnSpan = columnSpan;
this.rowSpan = rowSpan; this.rowSpan = rowSpan;
this.columnWidth = columnWidth ;
this.rowHeight = rowHeight;
this.clips = clips;
}
public CellElementsClip(int columnSpan, int rowSpan, TemplateCellElement[] clips) {
this.columnSpan = columnSpan;
this.rowSpan = rowSpan;
this.clips = clips; this.clips = clips;
} }
@ -86,16 +91,18 @@ public class CellElementsClip implements Cloneable, java.io.Serializable {
), false); ), false);
} }
//设置单元格的宽高 //设置单元格的宽高
if(this.columnWidth != null && this.rowHeight != null){
pasteWidthAndHeight(ec, column, row, columnSpan, rowSpan); pasteWidthAndHeight(ec, column, row, columnSpan, rowSpan);
}
return new CellSelection(column, row, columnSpan, rowSpan); return new CellSelection(column, row, columnSpan, rowSpan);
} }
public void pasteWidthAndHeight(TemplateElementCase ec, int column, int row, int columnSpan, int rowSpan){ public void pasteWidthAndHeight(TemplateElementCase ec, int column, int row, int columnSpan, int rowSpan){
for(int i = 0; i<columnSpan; i++){ for(int i = 0; i < columnSpan; i++){
for(int j = 0; j<rowSpan; j++){ ec.setColumnWidth(column + i, columnWidth[i]);
ec.setColumnWidth(column + i, ec.getColumnWidth(this.column + i));
ec.setRowHeight(row + j, ec.getRowHeight(this.row + j));
} }
for(int j = 0; j < rowSpan; j++){
ec.setRowHeight(row + j, rowHeight[j]);
} }
} }

12
designer/src/com/fr/design/report/freeze/RepeatAndFreezeSettingPane.java

@ -9,16 +9,11 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.UIDialog; import com.fr.design.extra.WebDialog;
import com.fr.design.extra.ShopManagerPane;
import com.fr.design.extra.ShopDialog;
import com.fr.design.extra.PluginWebBridge;
import com.fr.design.extra.WebManagerPaneFactory;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.page.ReportPageAttrProvider; import com.fr.page.ReportPageAttrProvider;
import com.fr.stable.ColumnRow; import com.fr.stable.ColumnRow;
@ -552,10 +547,7 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
try { try {
//Desktop.getDesktop().browse(new URI(url)); //Desktop.getDesktop().browse(new URI(url));
BasicPane managerPane = new WebManagerPaneFactory().createPluginPane(); WebDialog.createPluginDialog();
UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane);
PluginWebBridge.getHelper().setDialogHandle(dlg);
dlg.setVisible(true);
RepeatAndFreezeSettingPane.this.getTopLevelAncestor().setVisible(false); RepeatAndFreezeSettingPane.this.getTopLevelAncestor().setVisible(false);
} catch (Exception exp) { } catch (Exception exp) {

2
designer/src/com/fr/grid/GridUtils.java

@ -288,7 +288,7 @@ public class GridUtils {
} }
} }
elementsTransferable.addObject(new CellElementsClip(cs.getColumn(), cs.getRow(), elementsTransferable.addObject(new CellElementsClip(
cs.getColumnSpan(), cs.getRowSpan(), elList.toArray(new TemplateCellElement[elList.size()]) cs.getColumnSpan(), cs.getRowSpan(), elList.toArray(new TemplateCellElement[elList.size()])
)); ));
} }

12
designer/src/com/fr/grid/selection/CellSelection.java

@ -33,6 +33,7 @@ import com.fr.report.cell.cellattr.CellGUIAttr;
import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.ColumnRow; import com.fr.stable.ColumnRow;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.unit.FU;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -236,8 +237,15 @@ public class CellSelection extends Selection {
TemplateCellElement cellElement = (TemplateCellElement) cells.next(); TemplateCellElement cellElement = (TemplateCellElement) cells.next();
list.add((TemplateCellElement) cellElement.deriveCellElement(cellElement.getColumn() - column, cellElement.getRow() - row)); list.add((TemplateCellElement) cellElement.deriveCellElement(cellElement.getColumn() - column, cellElement.getRow() - row));
} }
FU [] columnWidth = new FU[columnSpan];
transferable.addObject(new CellElementsClip(this.column, this.row, this.columnSpan, this.rowSpan, list.toArray(new TemplateCellElement[list.size()]))); FU [] rowHeight = new FU[rowSpan];
for(int i = 0; i < columnSpan; i++){
columnWidth[i] = ec.getColumnWidth(this.column + i);
}
for(int j = 0; j < rowSpan; j++){
rowHeight[j] = ec.getRowHeight(this.row + j);
}
transferable.addObject(new CellElementsClip(this.columnSpan, this.rowSpan, columnWidth, rowHeight, list.toArray(new TemplateCellElement[list.size()])));
} }
/** /**

12
designer_base/src/com/fr/design/actions/server/PluginManagerAction.java

@ -2,12 +2,7 @@ package com.fr.design.actions.server;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicPane; import com.fr.design.extra.WebDialog;
import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.PluginWebBridge;
import com.fr.design.extra.ShopDialog;
import com.fr.design.extra.WebManagerPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter; import com.fr.general.Inter;
@ -30,10 +25,7 @@ public class PluginManagerAction extends UpdateAction {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
BasicPane managerPane = new WebManagerPaneFactory().createPluginPane(); WebDialog.createPluginDialog();
UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane);
PluginWebBridge.getHelper().setDialogHandle(dlg);
dlg.setVisible(true);
} }
public static final MenuKeySet PLUGIN_MANAGER = new MenuKeySet() { public static final MenuKeySet PLUGIN_MANAGER = new MenuKeySet() {

53
designer_base/src/com/fr/design/actions/server/ReuseManagerAction.java

@ -1,53 +0,0 @@
package com.fr.design.actions.server;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.ShopDialog;
import com.fr.design.extra.PluginWebBridge;
import com.fr.design.extra.WebManagerPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.event.ActionEvent;
/**
* Created by vito on 2016/9/27.
*/
public class ReuseManagerAction extends UpdateAction {
public ReuseManagerAction() {
this.setMenuKeySet(REUSE_MANAGER);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/server/plugin.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
BasicPane managerPane = new WebManagerPaneFactory().createReusePane();
UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane);
PluginWebBridge.getHelper().setDialogHandle(dlg);
dlg.setVisible(true);
}
public static final MenuKeySet REUSE_MANAGER = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'R';
}
@Override
public String getMenuName() {
return Inter.getLocText("FR-Designer-Reuse_Manager");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
}

43
designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java

@ -57,6 +57,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
private UICheckBox isShareCheckBox; private UICheckBox isShareCheckBox;
private MaxMemRowCountPanel maxPanel; private MaxMemRowCountPanel maxPanel;
private String pageQuery = null; private String pageQuery = null;
private String customCountQuery = null;
public DBTableDataPane() { public DBTableDataPane() {
@ -148,9 +149,10 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
} }
private void refresh() { private void refresh() {
String[] paramTexts = new String[2]; String[] paramTexts = new String[3];
paramTexts[0] = sqlTextPane.getText(); paramTexts[0] = sqlTextPane.getText();
paramTexts[1] = pageQuery; paramTexts[1] = pageQuery;
paramTexts[2] = customCountQuery;
List<ParameterProvider> existParameterList = editorPane.update(); List<ParameterProvider> existParameterList = editorPane.update();
Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[existParameterList.size()]); Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[existParameterList.size()]);
@ -164,6 +166,8 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
toolBarDef.addShortCut(new PreviewAction()); toolBarDef.addShortCut(new PreviewAction());
toolBarDef.addShortCut(SeparatorDef.DEFAULT); toolBarDef.addShortCut(SeparatorDef.DEFAULT);
toolBarDef.addShortCut(new EditPageQueryAction()); toolBarDef.addShortCut(new EditPageQueryAction());
toolBarDef.addShortCut(SeparatorDef.DEFAULT);
toolBarDef.addShortCut(new EditCustomCountQueryAction());
isShareCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Is_Share_DBTableData")); isShareCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Is_Share_DBTableData"));
maxPanel = new MaxMemRowCountPanel(); maxPanel = new MaxMemRowCountPanel();
maxPanel.setBorder(null); maxPanel.setBorder(null);
@ -175,9 +179,10 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
} }
private void checkParameter() { private void checkParameter() {
String[] paramTexts = new String[2]; String[] paramTexts = new String[3];
paramTexts[0] = sqlTextPane.getText(); paramTexts[0] = sqlTextPane.getText();
paramTexts[1] = pageQuery; paramTexts[1] = pageQuery;
paramTexts[2] = customCountQuery;
Parameter[] parameters = ParameterHelper.analyze4Parameters(paramTexts, false); Parameter[] parameters = ParameterHelper.analyze4Parameters(paramTexts, false);
@ -222,6 +227,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
isShare = dbtabledata.isShare(); isShare = dbtabledata.isShare();
maxMemeryRow = dbtabledata.getMaxMemRowCount(); maxMemeryRow = dbtabledata.getMaxMemRowCount();
this.pageQuery = dbtabledata.getPageQuerySql(); this.pageQuery = dbtabledata.getPageQuerySql();
this.customCountQuery = dbtabledata.getCustomCountQuery();
this.connectionTableProcedurePane.setSelectedDatabaseConnection(db); this.connectionTableProcedurePane.setSelectedDatabaseConnection(db);
this.sqlTextPane.setText(query); this.sqlTextPane.setText(query);
@ -258,6 +264,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
dbTableData.setShare(isShareCheckBox.isSelected()); dbTableData.setShare(isShareCheckBox.isSelected());
dbTableData.setMaxMemRowCount(maxPanel.getValue()); dbTableData.setMaxMemRowCount(maxPanel.getValue());
dbTableData.setPageQuerySql(this.pageQuery); dbTableData.setPageQuerySql(this.pageQuery);
dbTableData.setCustomCountQuery(this.customCountQuery);
return dbTableData; return dbTableData;
} }
@ -298,7 +305,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
} }
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
final PageQueryPane pane = new PageQueryPane(); final QueryPane pane = new QueryPane(Inter.getLocText("FR-Designer-LayerPageReport_Define_PageQuerySQL"));
pane.populate(pageQuery); pane.populate(pageQuery);
BasicDialog dialog = pane.showWindow(DesignerContext.getDesignerFrame()); BasicDialog dialog = pane.showWindow(DesignerContext.getDesignerFrame());
dialog.addDialogActionListener(new DialogActionAdapter() { dialog.addDialogActionListener(new DialogActionAdapter() {
@ -311,10 +318,34 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
} }
} }
private class PageQueryPane extends BasicPane { private class EditCustomCountQueryAction extends UpdateAction {
public EditCustomCountQueryAction() {
this.setName(Inter.getLocText("FR-Designer-LayerPageReport_CustomCountQuery"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/text.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
final QueryPane editPane = new QueryPane(Inter.getLocText("FR-Designer-LayerPageReport_Define_CustomCountQuery"));
editPane.populate(customCountQuery);
BasicDialog dialog = editPane.showWindow(DesignerContext.getDesignerFrame());
dialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() {
customCountQuery = editPane.update();
checkParameter();
}
});
dialog.setVisible(true);
}
}
private class QueryPane extends BasicPane {
private SQLEditPane pageQueryPane; private SQLEditPane pageQueryPane;
private String title;
public PageQueryPane() { public QueryPane(String title) {
this.title = title;
this.initComponents(); this.initComponents();
} }
@ -342,7 +373,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return Inter.getLocText("FR-Designer-LayerPageReport_Define_PageQuerySQL"); return title;
} }
} }
} }

117
designer_base/src/com/fr/design/extra/ShopManagerPane.java

@ -1,23 +1,10 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.design.RestartHelper;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient;
import com.fr.plugin.PluginVerifyException;
import com.fr.stable.StableUtils;
import javafx.embed.swing.JFXPanel; import javafx.embed.swing.JFXPanel;
import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.io.File;
import java.net.HttpURLConnection;
import java.util.concurrent.ExecutionException;
/** /**
* @author richie * @author richie
@ -32,113 +19,11 @@ import java.util.concurrent.ExecutionException;
*/ */
public class ShopManagerPane extends BasicPane { public class ShopManagerPane extends BasicPane {
private static final String LATEST = "latest"; public ShopManagerPane(JFXPanel webPane) {
private ShopPaneConfig shopPaneConfig;
public ShopManagerPane(ShopPaneConfig shopPaneConfig) {
this.shopPaneConfig = shopPaneConfig;
setLayout(new BorderLayout()); setLayout(new BorderLayout());
if (StableUtils.isDebug()) {
addPane();
} else {
File file = new File(shopPaneConfig.getMainJS());
if (!file.exists()) {
int rv = JOptionPane.showConfirmDialog(
this,
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"),
Inter.getLocText("FR-Designer-Plugin_Warning"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE
);
if (rv == JOptionPane.OK_OPTION) {
downloadShopScripts();
}
} else {
addPane();
updateShopScripts();
}
}
}
private void addPane() {
JFXPanel webPane = shopPaneConfig.getWebPane();
add(webPane, BorderLayout.CENTER); add(webPane, BorderLayout.CENTER);
} }
private void downloadShopScripts() {
new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() throws Exception {
String username = DesignerEnvManager.getEnvManager().getBBSName();
String password = DesignerEnvManager.getEnvManager().getBBSPassword();
try {
PluginHelper.downloadPluginFile(shopPaneConfig.getScriptsId(), username, password, new Process<Double>() {
@Override
public void process(Double integer) {
}
});
} catch (PluginVerifyException e) {
JOptionPane.showMessageDialog(ShopManagerPane.this, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
return false;
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
return false;
}
return true;
}
@Override
protected void done() {
try {
if (get()) {
IOUtils.unzip(new File(StableUtils.pathJoin(PluginHelper.DOWNLOAD_PATH, PluginHelper.TEMP_FILE)), StableUtils.getInstallHome());
int rv = JOptionPane.showOptionDialog(
ShopManagerPane.this,
Inter.getLocText("FR-Designer-Plugin_Shop_Installed"),
Inter.getLocText("FR-Designer-Plugin_Warning"),
JOptionPane.YES_NO_OPTION,
JOptionPane.INFORMATION_MESSAGE,
null,
new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later")},
null
);
if (rv == JOptionPane.OK_OPTION) {
RestartHelper.restart();
}
}
} catch (InterruptedException | ExecutionException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
}.execute();
}
private void updateShopScripts() {
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("store.version") + "&version=" + PluginStoreConstants.VERSION);
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) {
if (!ComparatorUtils.equals(httpClient.getResponseText(), LATEST)) {
int rv = JOptionPane.showConfirmDialog(
ShopManagerPane.this,
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Update"),
Inter.getLocText("FR-Designer-Plugin_Warning"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE
);
if (rv == JOptionPane.OK_OPTION) {
downloadShopScripts();
}
}
}
return null;
}
}.execute();
}
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return Inter.getLocText("FR-Designer-Plugin_Manager"); return Inter.getLocText("FR-Designer-Plugin_Manager");

165
designer_base/src/com/fr/design/extra/WebDialog.java

@ -0,0 +1,165 @@
package com.fr.design.extra;
import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.design.RestartHelper;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient;
import com.fr.plugin.PluginVerifyException;
import com.fr.stable.StableUtils;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.net.HttpURLConnection;
import java.util.concurrent.ExecutionException;
/**
* Created by vito on 2016/9/28.
*/
public class WebDialog {
private static final String LATEST = "latest";
private static final String SHOP_SCRIPTS = "shop_scripts";
private static final int VERSION_8 = 8;
private static String installHome = StableUtils.getInstallHome();
public static void createPluginDialog() {
UIDialog dlg;
if (StableUtils.getMajorJavaVersion() >= VERSION_8) {
String relativePath = "/scripts/store/web/index.html";
String mainJsPath = StableUtils.pathJoin(new File(installHome).getAbsolutePath(), relativePath);
File file = new File(mainJsPath);
if (!file.exists()) {
int rv = JOptionPane.showConfirmDialog(
null,
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"),
Inter.getLocText("FR-Designer-Plugin_Warning"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE
);
if (rv == JOptionPane.OK_OPTION) {
downloadShopScripts(SHOP_SCRIPTS);
}
} else {
updateShopScripts(SHOP_SCRIPTS);
BasicPane managerPane = new ShopManagerPane(new PluginWebPane(mainJsPath));
dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane);
PluginWebBridge.getHelper().setDialogHandle(dlg);
dlg.setVisible(true);
}
} else {
BasicPane traditionalStorePane = new BasicPane() {
@Override
protected String title4PopupWindow() {
return Inter.getLocText("FR-Designer-Plugin_Manager");
}
};
traditionalStorePane.setLayout(new BorderLayout());
traditionalStorePane.add(initTraditionalStore(), BorderLayout.CENTER);
dlg = new ShopDialog(DesignerContext.getDesignerFrame(), traditionalStorePane);
dlg.setVisible(true);
}
}
/**
* 以关键词打开设计器商店
* <p>
* // * @param keyword 关键词
*/
public void createPluginDialog(String keyword) {
PluginWebBridge.getHelper().openWithSearch(keyword);
createPluginDialog();
}
private static Component initTraditionalStore() {
UITabbedPane tabbedPane = new UITabbedPane();
PluginInstalledPane installedPane = new PluginInstalledPane();
tabbedPane.addTab(installedPane.tabTitle(), installedPane);
tabbedPane.addTab(Inter.getLocText("FR-Designer-Plugin_Update"), new PluginUpdatePane(tabbedPane));
tabbedPane.addTab(Inter.getLocText("FR-Designer-Plugin_All_Plugins"), new PluginFromStorePane(tabbedPane));
return tabbedPane;
}
private static void downloadShopScripts(final String scriptsId) {
new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() throws Exception {
String username = DesignerEnvManager.getEnvManager().getBBSName();
String password = DesignerEnvManager.getEnvManager().getBBSPassword();
try {
PluginHelper.downloadPluginFile(scriptsId, username, password, new Process<Double>() {
@Override
public void process(Double integer) {
}
});
} catch (PluginVerifyException e) {
JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
return false;
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
return false;
}
return true;
}
@Override
protected void done() {
try {
if (get()) {
IOUtils.unzip(new File(StableUtils.pathJoin(PluginHelper.DOWNLOAD_PATH, PluginHelper.TEMP_FILE)), StableUtils.getInstallHome());
int rv = JOptionPane.showOptionDialog(
null,
Inter.getLocText("FR-Designer-Plugin_Shop_Installed"),
Inter.getLocText("FR-Designer-Plugin_Warning"),
JOptionPane.YES_NO_OPTION,
JOptionPane.INFORMATION_MESSAGE,
null,
new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later")},
null
);
if (rv == JOptionPane.OK_OPTION) {
RestartHelper.restart();
}
}
} catch (InterruptedException | ExecutionException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
}.execute();
}
private static void updateShopScripts(final String scriptsId) {
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("store.version") + "&version=" + PluginStoreConstants.VERSION);
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) {
String text = httpClient.getResponseText();
if (!ComparatorUtils.equals(text, LATEST)) {
int rv = JOptionPane.showConfirmDialog(
null,
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Update"),
Inter.getLocText("FR-Designer-Plugin_Warning"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE
);
if (rv == JOptionPane.OK_OPTION) {
downloadShopScripts(scriptsId);
}
}
}
return null;
}
}.execute();
}
}

99
designer_base/src/com/fr/design/extra/WebManagerPaneFactory.java

@ -1,99 +0,0 @@
package com.fr.design.extra;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.general.Inter;
import com.fr.stable.StableUtils;
import javafx.embed.swing.JFXPanel;
import java.awt.*;
import java.io.File;
import java.net.URL;
/**
* Created by vito on 2016/9/28.
*/
public class WebManagerPaneFactory {
private String installHome;
public WebManagerPaneFactory() {
if (StableUtils.isDebug()) {
URL url = ClassLoader.getSystemResource("");
this.installHome = url.getPath();
} else {
this.installHome = StableUtils.getInstallHome();
}
}
public BasicPane createPluginPane() {
if (StableUtils.getMajorJavaVersion() == 8) {
return new ShopManagerPane(new ShopPaneConfig() {
@Override
String getMainJS() {
String relativePath = "/scripts/store/web/index.html";
return StableUtils.pathJoin(new File(installHome).getAbsolutePath(), relativePath);
}
@Override
String getScriptsId() {
return "shop_scripts";
}
@Override
JFXPanel getWebPane() {
return new PluginWebPane(getMainJS());
}
});
} else {
BasicPane traditionalStorePane = new BasicPane() {
@Override
protected String title4PopupWindow() {
return Inter.getLocText("FR-Designer-Plugin_Manager");
}
};
traditionalStorePane.setLayout(new BorderLayout());
traditionalStorePane.add(initTraditionalStore(), BorderLayout.CENTER);
return traditionalStorePane;
}
}
public BasicPane createReusePane() {
return new ShopManagerPane(new ShopPaneConfig() {
@Override
String getMainJS() {
String relativePath = "/scripts/store/reuse/index.html";
return StableUtils.pathJoin(new File(installHome).getAbsolutePath(), relativePath);
}
@Override
String getScriptsId() {
return "reuse_scripts";
}
@Override
JFXPanel getWebPane() {
return new ReuseWebPane(getMainJS());
}
});
}
/**
* 以关键词打开设计器商店
*
* @param keyword 关键词
*/
public BasicPane createPluginPane(String keyword) {
PluginWebBridge.getHelper().openWithSearch(keyword);
return createPluginPane();
}
private Component initTraditionalStore() {
UITabbedPane tabbedPane = new UITabbedPane();
PluginInstalledPane installedPane = new PluginInstalledPane();
tabbedPane.addTab(installedPane.tabTitle(), installedPane);
tabbedPane.addTab(Inter.getLocText("FR-Designer-Plugin_Update"), new PluginUpdatePane(tabbedPane));
tabbedPane.addTab(Inter.getLocText("FR-Designer-Plugin_All_Plugins"), new PluginFromStorePane(tabbedPane));
return tabbedPane;
}
}

12
designer_base/src/com/fr/start/BaseDesigner.java

@ -7,16 +7,11 @@ import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.RestartHelper; import com.fr.design.RestartHelper;
import com.fr.design.dialog.BasicPane; import com.fr.design.extra.WebDialog;
import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.ShopDialog;
import com.fr.design.extra.PluginWebBridge;
import com.fr.design.extra.WebManagerPaneFactory;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.file.TemplateTreePane; import com.fr.design.file.TemplateTreePane;
import com.fr.design.fun.GlobalListenerProvider; import com.fr.design.fun.GlobalListenerProvider;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame; import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.mainframe.TemplatePane; import com.fr.design.mainframe.TemplatePane;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
@ -131,10 +126,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
String text = StableUtils.join(plugins, ",") + Inter.getLocText("FR-Designer_Plugin_Should_Update"); String text = StableUtils.join(plugins, ",") + Inter.getLocText("FR-Designer_Plugin_Should_Update");
int r = JOptionPane.showConfirmDialog(null, text, Inter.getLocText("FR-Designer_Plugin_Should_Update_Title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); int r = JOptionPane.showConfirmDialog(null, text, Inter.getLocText("FR-Designer_Plugin_Should_Update_Title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
if (r == JOptionPane.OK_OPTION) { if (r == JOptionPane.OK_OPTION) {
BasicPane managerPane = new WebManagerPaneFactory().createPluginPane(); WebDialog.createPluginDialog();
UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane);
PluginWebBridge.getHelper().setDialogHandle(dlg);
dlg.setVisible(true);
} }
} }
timer.stop(); timer.stop();

0
sonar-project.properties → sonar-dev-project.properties

Loading…
Cancel
Save