Browse Source

Merge branch 'release/10.0' of https://code.fineres.com/scm/~qinghui.liu/design into release/10.0

feature/big-screen
Qinghui.Liu 5 years ago
parent
commit
bf6b9e89b0
  1. 59
      designer-base/src/main/java/com/fr/common/detect/CommonPortDetector.java
  2. 2
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java
  3. 11
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java
  4. 9
      designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java
  5. 7
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  6. 16
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  7. 41
      designer-base/src/main/java/com/fr/design/os/impl/MacOsAddListenerAction.java
  8. 10
      designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java
  9. 9
      designer-base/src/main/java/com/fr/design/parameter/ParameterInputPane.java
  10. 2
      designer-base/src/main/java/com/fr/start/BaseDesigner.java
  11. 45
      designer-base/src/test/java/com/fr/common/detect/CommonPortDetectorTest.java
  12. 3
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  13. 30
      designer-realize/src/main/java/com/fr/design/actions/cell/NewPresentAction.java
  14. 77
      designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java
  15. 2
      designer-realize/src/main/java/com/fr/grid/CellElementPainter.java
  16. 8
      designer-realize/src/main/java/com/fr/grid/GridUI.java
  17. 5
      designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java

59
designer-base/src/main/java/com/fr/common/detect/CommonPortDetector.java

@ -0,0 +1,59 @@
package com.fr.common.detect;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.DesignerEnvManager;
import com.fr.log.FineLoggerFactory;
import com.fr.module.ModuleContext;
import com.fr.web.WebSocketConfig;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/3/10
*/
public class CommonPortDetector {
private static final CommonPortDetector INSTANCE = new CommonPortDetector();
private ExecutorService service = ModuleContext.getExecutor().newSingleThreadExecutor(new NamedThreadFactory("CommonPortDetector"));
public static CommonPortDetector getInstance() {
return INSTANCE;
}
public void execute() {
service.submit(new Runnable() {
@Override
public void run() {
detectTomcatPort();
detectWebSocketPort();
}
});
}
private void detectTomcatPort() {
int port = DesignerEnvManager.getEnvManager().getEmbedServerPort();
if (checkPort(port)) {
FineLoggerFactory.getLogger().error("EmbedTomcat Port: {} is not available, maybe occupied by other programs, please check it!", port);
}
}
private void detectWebSocketPort() {
Integer[] ports = WebSocketConfig.getInstance().getPort();
for (int port : ports) {
if (checkPort(port)) {
FineLoggerFactory.getLogger().error("WebSocKet Port: {} is not available, maybe occupied by other programs, please check it!", port);
}
}
}
private boolean checkPort(int port) {
try (Socket socket = new Socket("localhost", port)) {
return true;
} catch (Exception e) {
return false;
}
}
}

2
designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java

@ -69,7 +69,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
}
if (nameableList.getSelectedValue() instanceof ListModelElement) {
Nameable selected = ((ListModelElement) nameableList.getSelectedValue()).wrapper;
if (!ComparatorUtils.equals(tempName, selected.getName())) {
if (!ComparatorUtils.equals(tempName, selected.getName()) && !isNameRepeated(new List[]{Arrays.asList(allDSNames), Arrays.asList(allListNames)}, tempName)) {
rename(selected.getName(), tempName);
}

11
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java

@ -33,9 +33,16 @@ public class TableDataManagerPane extends LoadingBasicPane {
);
}
tableDataPane = pane == null ? new TableDataPaneListPane() {
public void rename(String oldName, String newName) {
@Override
public void rename(final String oldName, final String newName) {
super.rename(oldName, newName);
renameConnection(oldName, newName);
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() {
renameConnection(oldName, newName);
return null;
}
}.execute();
}
} : pane;
container.add(tableDataPane.getPanel(), BorderLayout.CENTER);

9
designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java vendored

@ -1,6 +1,6 @@
package com.fr.design.env;
import com.fr.cluster.engine.base.FineClusterConfig;
import com.fr.cluster.engine.remote.ClusterOperator;
import com.fr.design.i18n.Toolkit;
import com.fr.base.operator.common.CommonOperator;
import com.fr.rpc.ExceptionHandler;
@ -79,7 +79,12 @@ public class RemoteWorkspace implements Workspace {
@Override
public boolean isCluster() {
return FineClusterConfig.getInstance().isCluster();
return WorkContext.getCurrent().get(ClusterOperator.class, new ExceptionHandler<Boolean>() {
@Override
public Boolean callHandler(RPCInvokerExceptionInfo rpcInvokerExceptionInfo) {
return false;
}
}).isCluster();
}
@Override

7
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -40,6 +40,7 @@ import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.menu.MenuManager;
import com.fr.design.menu.ShortCut;
import com.fr.design.os.impl.MacOsAddListenerAction;
import com.fr.design.os.impl.SupportOSImpl;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.event.EventDispatcher;
@ -316,6 +317,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
// window close listener.
this.addWindowListeners(getFrameListeners());
addMacOsListener();
this.addComponentListener(new ComponentAdapter() {
@Override
@ -523,6 +526,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
}
private void addMacOsListener() {
OSSupportCenter.buildAction(new MacOsAddListenerAction(), SupportOSImpl.DOCK_QUIT);
}
protected ArrayList<WindowListener> getFrameListeners() {
ArrayList<WindowListener> arrayList = new ArrayList<>();

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

@ -684,21 +684,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
this.dispose();
//模版重命名
boolean success = false;
// 提醒保存文件
SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true);
// 只有一个文件未保存时
if (HistoryTemplateListCache.getInstance().getHistoryCount() == 1) {
int choose = saveSomeTempaltePane.saveLastOneTemplate();
if (choose != JOptionPane.CANCEL_OPTION) {
success = selectedOperation.rename(fnf, path, newPath);
}
} else {
if (saveSomeTempaltePane.showSavePane()) {
success = selectedOperation.rename(fnf, path, newPath);
}
}
boolean success = selectedOperation.rename(fnf, path, newPath);
if (success) {
HistoryTemplateListCache.getInstance().rename(fnf, path, newPath);

41
designer-base/src/main/java/com/fr/design/os/impl/MacOsAddListenerAction.java

@ -0,0 +1,41 @@
package com.fr.design.os.impl;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.invoke.Reflect;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.os.support.OSBasedAction;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/3/13
*/
public class MacOsAddListenerAction implements OSBasedAction {
@Override
public void execute(final Object... objects) {
try {
Class app = Class.forName("com.apple.eawt.Application");
Class handler = Class.forName("com.apple.eawt.QuitHandler");
Object instance = Proxy.newProxyInstance(handler.getClassLoader(), new Class[]{handler},
new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method,
Object[] args) throws Throwable {
if ("handleQuitRequestWith".equals(method.getName())) {
DesignerFrame designerFrame = (DesignerFrame) objects[0];
designerFrame.exit();
}
return null;
}
});
Reflect.on(Reflect.on(app).call("getApplication").get()).call("setQuitHandler", instance);
} catch (ClassNotFoundException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}

10
designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java

@ -73,6 +73,16 @@ public enum SupportOSImpl implements SupportOS {
public boolean support() {
return FRContext.isChineseEnv() && !OperatingSystem.isMacos() && Arch.getArch() != Arch.ARM;
}
},
/**
* mac下dock栏右键退出
*/
DOCK_QUIT {
@Override
public boolean support() {
return OperatingSystem.isMacos();
}
}
}

9
designer-base/src/main/java/com/fr/design/parameter/ParameterInputPane.java

@ -17,6 +17,7 @@ import com.fr.design.editor.editor.Editor;
import com.fr.design.editor.editor.FloatEditor;
import com.fr.design.editor.editor.IntegerEditor;
import com.fr.design.editor.editor.TextEditor;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
@ -24,6 +25,8 @@ import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.util.ArrayList;
import java.util.Date;
@ -103,6 +106,12 @@ public class ParameterInputPane extends BasicPane {
contentPane.add(flowTableLayoutHelper.createLabelFlowPane(parameterDisplayName + ":", editPane));
//add editor to parameter hashtable.
textF.getCurrentEditor().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified();
}
});
this.editorNameMap.put(textF, parameter.getName());
nameAddedList.add(parameter.getName());
}

2
designer-base/src/main/java/com/fr/start/BaseDesigner.java

@ -3,6 +3,7 @@
*/
package com.fr.start;
import com.fr.common.detect.CommonPortDetector;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.constants.DesignerLaunchStatus;
@ -76,6 +77,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
public void on(Event event, Null param) {
EventDispatcher.stopListen(this);
collectUserInformation();
CommonPortDetector.getInstance().execute();
}
});
}

45
designer-base/src/test/java/com/fr/common/detect/CommonPortDetectorTest.java

@ -0,0 +1,45 @@
package com.fr.common.detect;
import com.fr.invoke.Reflect;
import com.fr.log.FineLoggerFactory;
import junit.framework.TestCase;
import org.junit.Assert;
import java.io.IOException;
import java.net.ServerSocket;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/3/10
*/
public class CommonPortDetectorTest extends TestCase {
private ServerSocket serverSocket;
@Override
public void setUp() throws Exception {
serverSocket = new ServerSocket(55555);
new Thread(new Runnable() {
@Override
public void run() {
try {
serverSocket.accept();
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}).start();
}
public void testCheckPort() {
CommonPortDetector detector = CommonPortDetector.getInstance();
boolean access = Reflect.on(detector).call("checkPort", 55555).get();
Assert.assertTrue(access);
}
@Override
public void tearDown() throws Exception {
serverSocket.close();
}
}

3
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -5,6 +5,7 @@ import com.fr.base.PaperSize;
import com.fr.base.Parameter;
import com.fr.base.extension.FileExtension;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState;
import com.fr.design.actions.FormMobileAttrAction;
import com.fr.design.actions.TemplateParameterAction;
@ -12,6 +13,7 @@ import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.actions.file.export.EmbeddedFormExportExportAction;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.cell.FloatElementsProvider;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.designer.TargetComponent;
import com.fr.design.designer.beans.actions.CopyAction;
import com.fr.design.designer.beans.actions.CutAction;
@ -587,6 +589,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
//下面这句话是防止撤销之后直接退出编辑再编辑撤销的东西会回来,因为撤销不会保存EC
formDesign.setElementCase(dataTable);
}
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).refreshDockingView();
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}

30
designer-realize/src/main/java/com/fr/design/actions/cell/NewPresentAction.java

@ -9,9 +9,13 @@ import com.fr.general.GeneralUtils;
import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.Selection;
import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.StableUtils;
import java.awt.*;
public class NewPresentAction extends PresentCheckBoxAction {
private String itemName = null;
@ -28,10 +32,28 @@ public class NewPresentAction extends PresentCheckBoxAction {
if (!ComparatorUtils.equals(this.itemName, "NOPRESENT")) {
CellElementPropertyPane.getInstance().GoToPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Present"), this.itemName);
} else {
TemplateCellElement ce = getSelectedCellElement();
// 只有原来ce设置了形态的情况下才有undo操作
if (ce != null && ce.getPresent() != null) {
ce.setPresent(null);
ElementCasePane ePane = this.getEditingComponent();
TemplateElementCase elementCase = ePane.getEditingElementCase();
Selection sel = ePane.getSelection();
if (sel instanceof CellSelection) {
CellSelection cs = (CellSelection) sel;
int cellRectangleCount = cs.getCellRectangleCount();
for (int rect = 0; rect < cellRectangleCount; rect++) {
Rectangle cellRectangle = cs.getCellRectangle(rect);
for (int j = 0; j < cellRectangle.height; j++) {
for (int i = 0; i < cellRectangle.width; i++) {
int column = i + cellRectangle.x;
int row = j + cellRectangle.y;
TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row);
if (cellElement == null) {
cellElement = new DefaultTemplateCellElement(column, row);
elementCase.addCellElement(cellElement);
} else if (cellElement.getPresent() != null) {
cellElement.setPresent(null);
}
}
}
}
return true;
} else {
return false;

77
designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java

@ -1,22 +1,18 @@
package com.fr.design.mainframe.messagecollect.solid;
import com.fr.analysis.cloud.solid.SolidRecordExecutor;
import com.fr.general.CloudCenter;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSON;
import com.fr.json.JSONFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.security.JwtUtils;
import com.fr.rpc.ExceptionHandler;
import com.fr.rpc.RPCInvokerExceptionInfo;
import com.fr.stable.CommonUtils;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static com.fr.design.mainframe.messagecollect.solid.SolidCollectConstants.REQUEST_SUBJECT;
import static com.fr.design.mainframe.messagecollect.solid.SolidCollectConstants.TIME_OUT;
/**
* 设计器固化信息回传类
* Created by alex sung on 2019/8/22.
@ -24,9 +20,6 @@ import static com.fr.design.mainframe.messagecollect.solid.SolidCollectConstants
public class SolidCollector {
private static final String CONTENT_URL = "/v10/collect/solid";
private static final String DELETE_URL = "/v10/collect/solid/delete";
private static final String UNLOCK_URL = "/v10/collect/solid/unlock";
private static final String ATTR_CIPHER_TEXT = "cipherText";
private static final String ATTR_SIGNATURE = "signature";
private static final String SOLID_UPLOAD_URL = CloudCenter.getInstance().acquireUrlByKind("design.solid");
@ -53,27 +46,22 @@ public class SolidCollector {
}
FineLoggerFactory.getLogger().info("start to get solid content from server...");
try {
String content = requestContent();
if (StringUtils.isNotEmpty(content)) {
String cipherText = JSONFactory.createJSON(JSON.OBJECT, content).optString("data");
if(StringUtils.isNotEmpty(cipherText)){
Map<String, Object> params = new HashMap<>();
params.put(ATTR_CIPHER_TEXT, cipherText);
params.put(ATTR_SIGNATURE, String.valueOf(CommonUtils.signature()));
HttpToolbox.post(SOLID_UPLOAD_URL, params);
String cipherText = requestContent();
if (StringUtils.isNotEmpty(cipherText)) {
Map<String, Object> params = new HashMap<>();
params.put(ATTR_CIPHER_TEXT, cipherText);
params.put(ATTR_SIGNATURE, String.valueOf(CommonUtils.signature()));
HttpToolbox.post(SOLID_UPLOAD_URL, params);
String deleteUrl = WorkContext.getCurrent().getPath() + DELETE_URL;
HttpToolbox.post(deleteUrl, getParams());
}
deleteSolidFile();
}
FineLoggerFactory.getLogger().info("send solid content to cloud center success.");
} catch (Exception e) {
FineLoggerFactory.getLogger().info(e.getMessage(), e);
} finally {
String unlockUrl = WorkContext.getCurrent().getPath() + UNLOCK_URL;
try {
HttpToolbox.post(unlockUrl, getParams());
} catch (IOException e) {
unlockSolidFile();
} catch (Exception e) {
FineLoggerFactory.getLogger().warn(e.getMessage(), e);
}
}
@ -81,17 +69,42 @@ public class SolidCollector {
/**
* 获取服务端固化文件内容
*
* @return 回传内容
*/
public String requestContent() throws Exception {
Map<String, String> params = new HashMap<String, String>();
params.put("token", JwtUtils.createDefaultJWT(REQUEST_SUBJECT, TIME_OUT));
return HttpToolbox.get(WorkContext.getCurrent().getPath() + CONTENT_URL, params);
private String requestContent() throws Exception {
return WorkContext.getCurrent().get(SolidRecordExecutor.class, new ExceptionHandler<String>() {
@Override
public String callHandler(RPCInvokerExceptionInfo info) {
FineLoggerFactory.getLogger().error(info.getException().getMessage(), info.getException());
return StringUtils.EMPTY;
}
}).feedBackTask(StringUtils.EMPTY);
}
private Map<String, Object> getParams() {
Map<String, Object> params = new HashMap<String, Object>();
params.put("token", JwtUtils.createDefaultJWT(REQUEST_SUBJECT, TIME_OUT));
return params;
/**
* 删除服务端固化文件
*/
private void deleteSolidFile() throws Exception {
WorkContext.getCurrent().get(SolidRecordExecutor.class, new ExceptionHandler<Void>() {
@Override
public Void callHandler(RPCInvokerExceptionInfo info) {
FineLoggerFactory.getLogger().error(info.getException().getMessage(), info.getException());
return null;
}
}).deleteSolidFile();
}
/**
* unlock
*/
private void unlockSolidFile() throws Exception {
WorkContext.getCurrent().get(SolidRecordExecutor.class, new ExceptionHandler<Void>() {
@Override
public Void callHandler(RPCInvokerExceptionInfo info) {
FineLoggerFactory.getLogger().error(info.getException().getMessage(), info.getException());
return null;
}
}).unlockSolidFile();
}
}

2
designer-realize/src/main/java/com/fr/grid/CellElementPainter.java

@ -9,7 +9,7 @@ import com.fr.report.core.PaintUtils;
import com.fr.report.elementcase.ElementCase;
public class CellElementPainter {
public void paintBackground(Graphics2D g2d, ElementCase report, CellElement ce, int width, int height) {
public void paintBackground(Graphics2D g2d, ElementCase report, CellElement ce, double width, double height) {
Style.paintBackground(g2d, ce.getStyle(), width, height);
}

8
designer-realize/src/main/java/com/fr/grid/GridUI.java

@ -497,12 +497,12 @@ public class GridUI extends ComponentUI {
paintCellElementRectangleList.add(this.tmpRectangle.clone());
int cellWidth = (int) this.tmpRectangle.getWidth();
int cellHeight = (int) this.tmpRectangle.getHeight();
double cellWidth = this.tmpRectangle.getWidth();
double cellHeight = this.tmpRectangle.getHeight();
// denny_Grid: 画Grid中单元格的内容(包括单元格的背景Content + Background), 不包括边框
painter.paintBackground(g2d, report, tmpCellElement, cellWidth, cellHeight);
painter.paintContent(g2d, report, tmpCellElement, cellWidth, cellHeight, resolution);
painter.paintBackground(g2d, report, tmpCellElement, cellWidth - 1, cellHeight - 1);
painter.paintContent(g2d, report, tmpCellElement, (int) cellWidth, (int) cellHeight, resolution);
// denny_Grid: 注意下面还要减一, 因为上面translate时加一
g2d.translate(-this.tmpRectangle.getX() - 1, -this.tmpRectangle.getY() - 1);
paintAuthorityCell(g2d, tmpCellElement);

5
designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java

@ -24,6 +24,7 @@ import com.fr.record.analyzer.Metrics;
import com.fr.stable.BuildContext;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.start.DesignerProcessType;
import com.fr.start.OemHandler;
import com.fr.start.ServerStarter;
@ -91,6 +92,10 @@ public class DesignerStartup extends Activator {
}
};
dialog.setVisible(true);
StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.DESIGNER_PROCESS_OCCUPIED.getId(),
DesignerErrorMessage.DESIGNER_PROCESS_OCCUPIED.getMessage(),
StringUtils.EMPTY);
FineLoggerFactory.getLogger().error(DesignerErrorMessage.DESIGNER_PROCESS_OCCUPIED.getId() + ": " + DesignerErrorMessage.DESIGNER_PROCESS_OCCUPIED.getMessage());
}
DesignerExiter.getInstance().execute();
return;

Loading…
Cancel
Save