Browse Source

Merge branch 'release/10.0' of ssh://cloud.finedevelop.com:7999/~hzzz/design61 into release/10.0

master
hzzz 6 years ago
parent
commit
ee9ebf43b2
  1. 1
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogAppender.java
  2. 82
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
  3. 46
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogImpl.java
  4. 17
      designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java
  5. 5
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java
  6. 18
      designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java
  7. 19
      designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java

1
designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogAppender.java

@ -1,7 +1,6 @@
package com.fr.design.mainframe.loghandler; package com.fr.design.mainframe.loghandler;
import com.fr.general.FRLogLevel;
import com.fr.third.apache.log4j.AppenderSkeleton; import com.fr.third.apache.log4j.AppenderSkeleton;
import com.fr.third.apache.log4j.Level; import com.fr.third.apache.log4j.Level;
import com.fr.third.apache.log4j.spi.LoggingEvent; import com.fr.third.apache.log4j.spi.LoggingEvent;

82
designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java

@ -1,17 +1,16 @@
package com.fr.design.mainframe.loghandler; package com.fr.design.mainframe.loghandler;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogLevel;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.LogRecordTime;
import com.fr.general.log.Log4jConfig; import com.fr.general.log.Log4jConfig;
import com.fr.stable.xml.LogRecordTimeProvider; import com.fr.log.FineLoggerFactory;
import com.fr.third.apache.log4j.Level; import com.fr.third.apache.log4j.Level;
import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.third.apache.log4j.spi.ThrowableInformation;
import javax.swing.*; import javax.swing.*;
import javax.swing.text.BadLocationException; import javax.swing.text.BadLocationException;
@ -29,11 +28,13 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.logging.LogRecord;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
public class DesignerLogHandler { public class DesignerLogHandler {
private static final SimpleDateFormat LOG_SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
protected static final int INFO_INT = Level.INFO.toInt(); protected static final int INFO_INT = Level.INFO.toInt();
protected static final int ERROR_INT = Level.ERROR.toInt(); protected static final int ERROR_INT = Level.ERROR.toInt();
protected static final int WARN_INT = Level.WARN.toInt(); protected static final int WARN_INT = Level.WARN.toInt();
@ -67,7 +68,6 @@ public class DesignerLogHandler {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
logHandlerArea.jTextArea.setText(""); logHandlerArea.jTextArea.setText("");
caption.clearMessage(); caption.clearMessage();
DesignerLogImpl.getInstance().clear();
} }
}); });
caption.addSelectedListener(new ActionListener() { caption.addSelectedListener(new ActionListener() {
@ -84,10 +84,6 @@ public class DesignerLogHandler {
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
logHandlerArea.jTextArea.setText(""); logHandlerArea.jTextArea.setText("");
caption.clearMessage(); caption.clearMessage();
LogRecordTimeProvider[] recorders = DesignerLogImpl.getInstance().getRecorders();
for (LogRecordTimeProvider logRecordTime : recorders) {
logHandlerArea.printStackTrace(logRecordTime);
}
} }
}; };
showInfo = new JCheckBoxMenuItem(Inter.getLocText(new String[]{"Display", "Normal", "Info"}), true); showInfo = new JCheckBoxMenuItem(Inter.getLocText(new String[]{"Display", "Normal", "Info"}), true);
@ -193,55 +189,52 @@ public class DesignerLogHandler {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
resultPane.setText(""); resultPane.setText("");
caption.clearMessage(); caption.clearMessage();
DesignerLogImpl.getInstance().clear();
} }
}); });
return resultPane; return resultPane;
} }
public void printStackTrace(LogRecordTimeProvider logRecordTime) { public void printStackTrace(LoggingEvent event) {
LogRecord logRecord = logRecordTime.getLogRecord(); int intLevel = event.getLevel().toInt();
Date date = logRecordTime.getDate(); Date date = new Date(event.getTimeStamp());
int logLevelvalue = logRecord.getLevel().intValue(); ThrowableInformation information = event.getThrowableInformation();
if (logLevelvalue == INFO_INT && showInfo.isSelected()) { if (intLevel == INFO_INT && showInfo.isSelected()) {
printMessage(logRecord.getMessage(), logLevelvalue, date, logRecord.getThrown()); printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable());
} else if (logLevelvalue == ERROR_INT && showError.isSelected()) { } else if (intLevel == ERROR_INT && showError.isSelected()) {
printMessage(logRecord.getMessage(), logLevelvalue, date, logRecord.getThrown()); printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable());
} else if (logLevelvalue == WARN_INT && showServer.isSelected()) { } else if (intLevel == WARN_INT && showServer.isSelected()) {
printMessage(logRecord.getMessage(), logLevelvalue, date, logRecord.getThrown()); printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable());
} }
} }
public void printStackTrace(String message, Level level, Date date) { public void printStackTrace(String message, Level level, Date date) {
int logLevelvalue = level.toInt(); int intLevel = level.toInt();
if (logLevelvalue == INFO_INT && showInfo.isSelected()) { if (intLevel == INFO_INT && showInfo.isSelected()) {
printMessage(message, logLevelvalue, date); printMessage(message, intLevel, date);
} else if (logLevelvalue == ERROR_INT && showError.isSelected()) { } else if (intLevel == ERROR_INT && showError.isSelected()) {
printMessage(message, logLevelvalue, date); printMessage(message, intLevel, date);
} else if (logLevelvalue == WARN_INT && showServer.isSelected()) { } else if (intLevel == WARN_INT && showServer.isSelected()) {
printMessage(message, logLevelvalue, date); printMessage(message, intLevel, date);
} }
} }
private void printMessage(String message, int logLevelvalue, Date date) { private void printMessage(String message, int intLevel, Date date) {
printMessage(message, logLevelvalue, date, null); printMessage(message, intLevel, date, null);
} }
private void printMessage(String messange, int logLevelvalue, Date date, Throwable e) { private void printMessage(String msg, int intLevel, Date date, Throwable e) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.log(LOG_SIMPLE_DATE_FORMAT.format(date) + "\n", 0);
this.log(simpleDateFormat.format(date) + "\n", 0); String message = appendLocaleMark(msg, intLevel);
String message = swithInter(messange, logLevelvalue); this.log(message, intLevel);
this.log(message, logLevelvalue); setMessage(message, intLevel);
setMessage(message, logLevelvalue);
if (e == null) { if (e == null) {
return; return;
} }
StackTraceElement[] stacktraceelement = e.getStackTrace(); StackTraceElement[] traceElements = e.getStackTrace();
for (int i = 0; i < stacktraceelement.length; i++) { for (int i = 0; i < traceElements.length; i++) {
this.log("\t" + "at " + stacktraceelement[i].toString() + "\n", 0); this.log("\t" + "at " + traceElements[i].toString() + "\n", 0);
} }
} }
@ -264,11 +257,11 @@ public class DesignerLogHandler {
try { try {
doc.insertString(doc.getLength(), str, attrSet); doc.insertString(doc.getLength(), str, attrSet);
} catch (BadLocationException e) { } catch (BadLocationException e) {
FRContext.getLogger().error(e.getMessage()); FineLoggerFactory.getLogger().error(e.getMessage());
} }
} }
private String swithInter(String str, int style) { private String appendLocaleMark(String str, int style) {
if (style == ERROR_INT) { if (style == ERROR_INT) {
str = Inter.getLocText("FR-Designer_Alert") + ":" + str + "\n"; str = Inter.getLocText("FR-Designer_Alert") + ":" + str + "\n";
} else if (style == WARN_INT) { } else if (style == WARN_INT) {
@ -318,14 +311,13 @@ public class DesignerLogHandler {
} else if (ComparatorUtils.equals(evt.getActionCommand(), LogHandlerArea.this.clear.getText())) { } else if (ComparatorUtils.equals(evt.getActionCommand(), LogHandlerArea.this.clear.getText())) {
LogHandlerArea.this.jTextArea.setText(""); LogHandlerArea.this.jTextArea.setText("");
caption.clearMessage(); caption.clearMessage();
DesignerLogImpl.getInstance().clear();
} }
} }
}; };
} }
public void printRemoteLog(LogRecordTime logRecordTime) { public void printLoggingEvent(LoggingEvent event) {
logHandlerArea.printStackTrace(logRecordTime); logHandlerArea.printStackTrace(event);
} }
} }

46
designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogImpl.java

@ -1,46 +0,0 @@
package com.fr.design.mainframe.loghandler;
import com.fr.stable.fun.impl.AbstractLogProvider;
import com.fr.stable.xml.LogRecordTimeProvider;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Administrator on 2016/1/11 0011.
*/
public class DesignerLogImpl extends AbstractLogProvider{
private static DesignerLogImpl instance = new DesignerLogImpl();
public static DesignerLogImpl getInstance(){
return instance;
}
private DesignerLogImpl(){
}
private List<LogRecordTimeProvider> records = new ArrayList<LogRecordTimeProvider>();
/**
* 清除内存中的日志记录
*/
public void clear(){
records.clear();
}
/**
* 获取所有日志信息
*
* @return 日志信息
*/
public LogRecordTimeProvider[] getRecorders(){
return records.toArray(new LogRecordTimeProvider[records.size()]);
}
@Override
public void record(LogRecordTimeProvider logRecordTime) {
records.add(logRecordTime);
}
}

17
designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java

@ -6,9 +6,10 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.loghandler.DesignerLogHandler; import com.fr.design.mainframe.loghandler.DesignerLogHandler;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.LogRecordTime;
import com.fr.general.LogUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.serialization.SerializerHelper;
import com.fr.stable.ArrayUtils;
import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.third.guava.base.Optional; import com.fr.third.guava.base.Optional;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
@ -19,9 +20,7 @@ import io.socket.client.IO;
import io.socket.client.Socket; import io.socket.client.Socket;
import io.socket.emitter.Emitter; import io.socket.emitter.Emitter;
import javax.swing.JOptionPane; import javax.swing.*;
import javax.swing.UIManager;
import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.net.URL; import java.net.URL;
@ -40,15 +39,15 @@ public class DesignerSocketIO {
private static final Emitter.Listener printLog = new Emitter.Listener() { private static final Emitter.Listener printLog = new Emitter.Listener() {
@Override @Override
public void call(Object... objects) { public void call(Object... objects) {
if (ArrayUtils.isNotEmpty(objects)) {
try { try {
LogRecordTime[] logRecordTimes = LogUtils.readXMLLogRecords(new ByteArrayInputStream((byte[]) objects[0])); LoggingEvent event = SerializerHelper.deserialize((byte[]) objects[0]);
for (LogRecordTime logRecordTime : logRecordTimes) { DesignerLogHandler.getInstance().printLoggingEvent(event);
DesignerLogHandler.getInstance().printRemoteLog(logRecordTime);
}
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }
}
}; };
public static void close() { public static void close() {

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

@ -48,7 +48,6 @@ import com.fr.design.mainframe.form.FormECDesignerProvider;
import com.fr.design.mainframe.form.FormElementCaseDesigner; import com.fr.design.mainframe.form.FormElementCaseDesigner;
import com.fr.design.mainframe.form.FormReportComponentComposite; import com.fr.design.mainframe.form.FormReportComponentComposite;
import com.fr.design.mainframe.loghandler.DesignerLogAppender; import com.fr.design.mainframe.loghandler.DesignerLogAppender;
import com.fr.design.mainframe.loghandler.DesignerLogImpl;
import com.fr.design.mainframe.loghandler.LogMessageBar; import com.fr.design.mainframe.loghandler.LogMessageBar;
import com.fr.design.mainframe.socketio.DesignerSocketIO; import com.fr.design.mainframe.socketio.DesignerSocketIO;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
@ -91,7 +90,6 @@ import com.fr.report.cell.painter.CellImagePainter;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.stable.bridge.StableFactory; import com.fr.stable.bridge.StableFactory;
import com.fr.stable.fun.LogProvider;
import com.fr.stable.plugin.ExtraDesignClassManagerProvider; import com.fr.stable.plugin.ExtraDesignClassManagerProvider;
import com.fr.stable.script.CalculatorProviderContext; import com.fr.stable.script.CalculatorProviderContext;
import com.fr.stable.script.ValueConverter; import com.fr.stable.script.ValueConverter;
@ -100,7 +98,7 @@ import com.fr.stable.xml.ObjectXMLWriterFinder;
import com.fr.start.BBSGuestPaneProvider; import com.fr.start.BBSGuestPaneProvider;
import com.fr.xml.ReportXMLUtils; import com.fr.xml.ReportXMLUtils;
import java.awt.Image; import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -165,7 +163,6 @@ public class DesignerActivator extends Activator implements Prepare {
InformationCollector.getInstance().collectStartTime(); InformationCollector.getInstance().collectStartTime();
ExtraDesignClassManager.getInstance().getFeedback().didFeedback(); ExtraDesignClassManager.getInstance().getFeedback().didFeedback();
StableFactory.registerMarkedObject(LogProvider.MARK_STRING, DesignerLogImpl.getInstance());
} }
private static void preLoadPane() { private static void preLoadPane() {

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

@ -1,14 +1,16 @@
package com.fr.start.module; package com.fr.start.module;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.Listener; import com.fr.event.Listener;
import com.fr.general.ComparatorUtils;
import com.fr.module.Activator; import com.fr.module.Activator;
import com.fr.record.analyzer.EnableMetrics; import com.fr.record.analyzer.EnableMetrics;
import com.fr.record.analyzer.Metrics; import com.fr.record.analyzer.Metrics;
import com.fr.start.Designer; import com.fr.start.Designer;
import com.fr.start.EnvSwitcher; import com.fr.start.ServerStarter;
import com.fr.start.SplashContext; import com.fr.start.SplashContext;
import com.fr.startup.activators.BasicActivator; import com.fr.startup.activators.BasicActivator;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
@ -31,10 +33,20 @@ public class DesignerStartup extends Activator {
startSub(BasicActivator.class); startSub(BasicActivator.class);
final String[] args = getModule().upFindSingleton(StartupArgs.class).get(); final String[] args = getModule().upFindSingleton(StartupArgs.class).get();
final Designer designer = new Designer(args); final Designer designer = new Designer(args);
//启动env
startSub(DesignerWorkspaceProvider.class); startSub(DesignerWorkspaceProvider.class);
//启动env
startSub(EnvBasedModule.class); startSub(EnvBasedModule.class);
getRoot().getSingleton(EnvSwitcher.class).switch2LastEnv();
if (args != null) {
for (String arg : args) {
if (ComparatorUtils.equals(arg, "demo")) {
DesignerEnvManager.getEnvManager().setCurrentEnv2Default();
ServerStarter.browserDemoURL();
break;
}
}
}
ExecutorService service = Executors.newSingleThreadExecutor(); ExecutorService service = Executors.newSingleThreadExecutor();
registerEnvListener(); registerEnvListener();
service.submit(new Runnable() { service.submit(new Runnable() {

19
designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java

@ -1,10 +1,9 @@
package com.fr.start.module; package com.fr.start.module;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.general.ComparatorUtils;
import com.fr.module.Activator; import com.fr.module.Activator;
import com.fr.start.EnvSwitcher; import com.fr.start.EnvSwitcher;
import com.fr.start.ServerStarter;
/** /**
* Created by juhaoyu on 2018/1/8. * Created by juhaoyu on 2018/1/8.
@ -17,20 +16,10 @@ public class DesignerWorkspaceProvider extends Activator {
//检查环境 //检查环境
DesignerEnvManager.checkNameEnvMap(); DesignerEnvManager.checkNameEnvMap();
String[] args = getModule().upFindSingleton(StartupArgs.class).get(); EnvSwitcher switcher = new EnvSwitcher();
if (args != null) {
for (String arg : args) {
if (ComparatorUtils.equals(arg, "demo")) {
DesignerEnvManager.getEnvManager().setCurrentEnv2Default();
ServerStarter.browserDemoURL();
break;
}
}
}
getRoot().setSingleton(EnvSwitcher.class, new EnvSwitcher());
//设置好环境即可,具体跟环境有关的模块会自动调用 //设置好环境即可,具体跟环境有关的模块会自动调用
getRoot().getSingleton(EnvSwitcher.class).switch2LastEnv(); switcher.switch2LastEnv();
getRoot().setSingleton(EnvSwitcher.class, switcher);
} }

Loading…
Cancel
Save