Browse Source

Merge branch 'release/10.0' of http://cloud.finedevelop.com:2015/scm/~plough/10-design into release/10.0

master
plough 6 years ago
parent
commit
3befb0d8ea
  1. 16
      designer-base/src/com/fr/design/DesignerEnvManager.java
  2. 14
      designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java
  3. 3
      designer-base/src/com/fr/design/env/DesignerWorkspaceGenerator.java
  4. 21
      designer-base/src/com/fr/design/mainframe/DesignerFrame.java
  5. 30
      designer-realize/src/com/fr/design/mainframe/CellWidgetPropertyPane.java
  6. 88
      designer-realize/src/com/fr/design/mainframe/socketio/DesignerSocketIO.java
  7. 5
      designer-realize/src/com/fr/design/webattr/WriteToolBarPane.java
  8. 5
      designer-realize/src/com/fr/design/webattr/WriteWebSettingPane.java
  9. 6
      designer-realize/src/com/fr/design/widget/WidgetEventPane.java
  10. 3
      designer-realize/src/com/fr/start/module/DesignerActivator.java

16
designer-base/src/com/fr/design/DesignerEnvManager.java

@ -35,10 +35,12 @@ import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.workspace.WorkContext;
import com.fr.workspace.connect.AuthException;
import javax.swing.*;
import javax.swing.SwingWorker;
import javax.swing.SwingWorker.StateValue;
import java.awt.*;
import java.awt.Color;
import java.awt.Rectangle;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
@ -476,7 +478,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* @return 是默认则返回true
*/
public boolean isCurrentEnvDefault() {
DesignerWorkspaceInfo current = this.getWorkspaceInfo(curEnvName);
String defaultEnvPath = StableUtils.pathJoin(new String[]{StableUtils.getInstallHome(), ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME});
return ComparatorUtils.equals(new File(defaultEnvPath).getPath(), current.getPath());
@ -530,7 +532,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (isCurrentEnvDefault()) {
return;
}
WorkContext.switchTo(DesignerWorkspaceGenerator.generate(getDefaultConfig()));
try {
WorkContext.switchTo(DesignerWorkspaceGenerator.generate(getDefaultConfig()));
} catch (AuthException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
/**
@ -708,7 +714,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* @param info 对应的环境信息
*/
public void putEnv(String name, DesignerWorkspaceInfo info) {
this.nameEnvMap.put(name, info);
}

14
designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java

@ -10,7 +10,6 @@ import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.TemplatePane;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.SeparatorDef;
@ -20,6 +19,8 @@ import com.fr.general.Inter;
import com.fr.stable.EnvChangedListener;
import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.AuthException;
import javax.swing.JOptionPane;
import java.awt.event.ActionEvent;
@ -103,7 +104,16 @@ public class SwitchExistEnv extends MenuDef {
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
final String envName = getName();
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName);
WorkContext.switchTo(DesignerWorkspaceGenerator.generate(selectedEnv), new WorkContextCallback() {
Workspace workspace;
try {
workspace = DesignerWorkspaceGenerator.generate(selectedEnv);
} catch (AuthException exception) {
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Inter.getLocText(new String[]{"Fine-Designer_Basic_Remote_Connect_Auth_Failed"}));
return;
}
WorkContext.switchTo(workspace, new WorkContextCallback() {
@Override
public void success() {
DesignerEnvManager.getEnvManager().setCurEnvName(envName);

3
designer-base/src/com/fr/design/env/DesignerWorkspaceGenerator.java vendored

@ -2,6 +2,7 @@ package com.fr.design.env;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.AuthException;
import com.fr.workspace.connect.WorkspaceClient;
/**
@ -9,7 +10,7 @@ import com.fr.workspace.connect.WorkspaceClient;
*/
public class DesignerWorkspaceGenerator {
public static Workspace generate(DesignerWorkspaceInfo config) {
public static Workspace generate(DesignerWorkspaceInfo config) throws AuthException {
if (config == null || config.getType() == null) {
return null;

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

@ -375,18 +375,18 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
final JPanel northEastPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
//优先级为-1,保证最后全面刷新一次
GeneralContext.listenPluginRunningChanged(new PluginEventListener(-1) {
@Override
public void on(PluginEvent event) {
refreshNorthEastPane(northEastPane, ad);
DesignUtils.refreshDesignerFrame();
}
}, new PluginFilter() {
@Override
public boolean accept(PluginContext context) {
return context.contain(PluginModule.ExtraDesign);
}
});
@ -469,16 +469,16 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
// 下面的虚线
downDottedLine = new DottedLine(UIScrollBar.HORIZONTAL, centerWidth);
downDottedLine.setBounds(WestRegionContainerPane.getInstance().getContainerWidth(), contentHeight - 3,
centerWidth, 3);
centerWidth, 3);
// 左边的虚线
leftDottedLine = new DottedLine(UIScrollBar.VERTICAL, contentHeight - MENU_HEIGHT);
leftDottedLine.setBounds(WestRegionContainerPane.getInstance().getContainerWidth(), MENU_HEIGHT, 3,
contentHeight - MENU_HEIGHT);
contentHeight - MENU_HEIGHT);
rightDottedLine = new DottedLine(UIScrollBar.VERTICAL, contentHeight - MENU_HEIGHT);
rightDottedLine.setBounds(contentWidth - EastRegionContainerPane.getInstance().getContainerWidth() - 3,
MENU_HEIGHT, 3, contentHeight - MENU_HEIGHT);
MENU_HEIGHT, 3, contentHeight - MENU_HEIGHT);
}
@ -719,7 +719,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
String envName = DesignerEnvManager.getEnvManager().getCurEnvName();
Workspace workspace = WorkContext.getCurrent();
DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(envName);
defaultTitleSB.append(info.getName()).append("@").append(envName).append("[").append(workspace.getDescription()).append("]");
String username = null;
if (info != null){
username = info.getName();
}
defaultTitleSB.append(username).append("@").append(envName).append("[").append(workspace.getDescription()).append("]");
if (editingTemplate != null) {
String path = editingTemplate.getEditingFILE().getPath();
if (!editingTemplate.getEditingFILE().exists()) {

30
designer-realize/src/com/fr/design/mainframe/CellWidgetPropertyPane.java

@ -108,6 +108,36 @@ public class CellWidgetPropertyPane extends BasicPane {
final CellSelection finalCS = (CellSelection) ePane.getSelection();
final TemplateElementCase tplEC = ePane.getEditingElementCase();
final Widget cellWidget = cellEditorDefPane.update();
if (finalCS.isSelectedOneCell(ePane)) {
if (tplEC.getTemplateCellElement(cellElement.getColumn(), cellElement.getRow()) == null) {//cellElement未加入到report中时要添加进去
tplEC.addCellElement(cellElement);
}
setCellWidget(cellWidget, cellElement);
} else {
ReportActionUtils.actionIterateWithCellSelection(finalCS, tplEC, new ReportActionUtils.IterAction() {
public void dealWith(CellElement editCellElement) {
// p:最后把这个cellEditorDef设置到CellGUIAttr.
TemplateCellElement templateCellElement = (TemplateCellElement) editCellElement;
try {
setCellWidget((Widget) cellWidget.clone(), templateCellElement);
} catch (CloneNotSupportedException e) {
FRContext.getLogger().error("InternalError: " + e.getMessage());
}
}
});
}
if (DesignerContext.getDesignerFrame().getSelectedJTemplate() != null) {
DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified();
}
}
public void update(Selection selection) {
if (cellElement == null || !cellEditorDefPane.isShouldFireSelectedEvent()) {
return;
}
final CellSelection finalCS = (CellSelection) selection;
final TemplateElementCase tplEC = ePane.getEditingElementCase();
final Widget cellWidget = cellEditorDefPane.update();
if(finalCS.isSelectedOneCell(ePane)){
if(tplEC.getTemplateCellElement(cellElement.getColumn(), cellElement.getRow())== null){//cellElement未加入到report中时要添加进去
tplEC.addCellElement(cellElement);

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

@ -0,0 +1,88 @@
package com.fr.design.mainframe.socketio;
import com.fr.decision.webservice.utils.DecisionServiceConstants;
import com.fr.design.mainframe.loghandler.DesignerLogHandler;
import com.fr.general.LogRecordTime;
import com.fr.general.LogUtils;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.third.guava.base.Optional;
import com.fr.third.guava.primitives.Ints;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.base.WorkspaceConstants;
import com.fr.workspace.engine.server.rpc.netty.RemoteCallClient;
import io.socket.client.IO;
import io.socket.client.Socket;
import io.socket.emitter.Emitter;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
public class DesignerSocketIO {
private static Optional<Socket> socketIO = Optional.absent();
private static final Emitter.Listener printLog = new Emitter.Listener() {
@Override
public void call(Object... objects) {
try {
LogRecordTime[] logRecordTimes = LogUtils.readXMLLogRecords(new ByteArrayInputStream((byte[]) objects[0]));
for (LogRecordTime logRecordTime : logRecordTimes) {
DesignerLogHandler.getInstance().printRemoteLog(logRecordTime);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
};
public static void close() {
if (socketIO.isPresent()) {
socketIO.get().close();
socketIO = Optional.absent();
}
}
public static void update() {
Workspace current = WorkContext.getCurrent();
if (current.isLocal()) {
return;
}
try {
String uri = getSocketUri(current);
socketIO = Optional.of(IO.socket(new URI(uri)));
socketIO.get().on(WorkspaceConstants.WS_LOGRECORD, printLog);
socketIO.get().connect();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
private static String getSocketUri(Workspace current) throws IOException {
URL url = new URL(current.getPath());
int port = getPort(current);
return String.format("http://%s:%s%s?%s=%s",
url.getHost(),
port,
WorkspaceConstants.WS_NAMESPACE,
DecisionServiceConstants.WEB_SOCKET_TOKEN_NAME,
RemoteCallClient.getInstance().getToken());
}
private static int getPort(Workspace current) throws IOException {
String url = current.getPath() + WorkspaceConstants.CONTROLLER_PREFIX + WorkspaceConstants.CONTROLLER_SOCKETIO_PORT;
try {
String portStr = HttpToolbox.get(url);
JSONObject jsonObject = new JSONObject(portStr);
return Ints.tryParse(jsonObject.optString("data"));
} catch (JSONException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
throw new RuntimeException(e);
}
}
}

5
designer-realize/src/com/fr/design/webattr/WriteToolBarPane.java

@ -155,7 +155,7 @@ public class WriteToolBarPane extends AbstractEditToolBarPane {
webContent = new WebWrite();
}
WebWrite webWrite = (WebWrite) webContent;
if (webWrite.getSelectedColor() != null) {
if (webWrite.isEditRowColor()) {
colorBox.setSelected(true);
colorButton.setColor(webWrite.getSelectedColor());
} else {
@ -205,9 +205,10 @@ public class WriteToolBarPane extends AbstractEditToolBarPane {
}
if (colorBox.isSelected()) {
webWrite.setEditRowColor(true);
webWrite.setSelectedColor(colorButton.getColor());
} else {
webWrite.setSelectedColor(null);
webWrite.setEditRowColor(false);
}
webWrite.setUnloadCheck(unloadCheck.isSelected());

5
designer-realize/src/com/fr/design/webattr/WriteWebSettingPane.java

@ -120,7 +120,7 @@ public class WriteWebSettingPane extends WebSettingPane<WebWrite> {
if (webWrite == null) {
webWrite = new WebWrite();
}
if (webWrite.getSelectedColor() != null) {
if (webWrite.isEditRowColor()) {
colorBox.setSelected(true);
colorButton.setColor(webWrite.getSelectedColor());
} else {
@ -148,9 +148,10 @@ public class WriteWebSettingPane extends WebSettingPane<WebWrite> {
protected WebWrite updateSubWebSettingBean() {
WebWrite webWrite = new WebWrite();
if (colorBox.isSelected()) {
webWrite.setEditRowColor(true);
webWrite.setSelectedColor(colorButton.getColor());
} else {
webWrite.setSelectedColor(null);
webWrite.setEditRowColor(false);
}
if (topRadioButton.isSelected()) {
webWrite.setSheetPosition(Constants.TOP);

6
designer-realize/src/com/fr/design/widget/WidgetEventPane.java

@ -18,6 +18,7 @@ import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.JTemplate;
import com.fr.form.event.Listener;
import com.fr.form.ui.Widget;
import com.fr.grid.selection.Selection;
import com.fr.log.FineLoggerFactory;
import com.fr.general.Inter;
import com.fr.general.NameObject;
@ -34,9 +35,12 @@ import javax.swing.*;
public class WidgetEventPane extends ObjectUIControlPane {
private Selection selection;
public WidgetEventPane(ElementCasePane pane) {
super(pane);
this.setNameListEditable(false);
selection = pane.getSelection();
setBorder(BorderFactory.createEmptyBorder(10, 0, 15, 0));
}
@ -57,7 +61,7 @@ public class WidgetEventPane extends ObjectUIControlPane {
@Override
public void saveSettings() {
CellWidgetPropertyPane.getInstance().update();
CellWidgetPropertyPane.getInstance().update(selection);
}
@Override

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

@ -50,6 +50,7 @@ import com.fr.design.mainframe.form.FormReportComponentComposite;
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.socketio.DesignerSocketIO;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.parameter.FormParameterReader;
import com.fr.design.parameter.ParameterPropertyPane;
@ -123,6 +124,7 @@ public class DesignerActivator extends Activator implements Prepare {
designerModuleStart();
preLoadPane();
loadLogAppender();
DesignerSocketIO.update();
}
private void loadLogAppender() {
@ -400,6 +402,7 @@ public class DesignerActivator extends Activator implements Prepare {
@Override
public void stop() {
unloadLogAppender();
DesignerSocketIO.close();
}
@Override

Loading…
Cancel
Save