Browse Source

Merge remote-tracking branch 'origin/fbp/release' into fbp/release

fbp/merge
Destiny.Lin 3 months ago
parent
commit
3cebf78907
  1. 12
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 214
      designer-base/src/main/java/com/fr/design/EnvSwitcherSubmitTask.java
  3. 39
      designer-base/src/main/java/com/fr/design/metric/AbstractDesignerMetric.java
  4. 4
      designer-base/src/main/java/com/fr/design/roleAuthority/RoleTree.java
  5. 6
      designer-base/src/main/java/com/fr/design/style/color/ColorSelectDetailPane.java
  6. 8
      designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java
  7. 4
      designer-base/src/main/java/com/fr/design/style/color/CustomChooserPanel.java
  8. 11
      designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java
  9. 19
      designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvChooseComponent.java
  10. 11
      designer-realize/src/main/java/com/fanruan/boot/env/DesignPluginComponent.java
  11. 10
      designer-realize/src/main/java/com/fanruan/boot/env/function/app/PluginRemote.java
  12. 2
      designer-realize/src/main/java/com/fanruan/boot/init/DesignWorkContextComponent.java
  13. 12
      designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java
  14. 3
      designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java
  15. 4
      designer-realize/src/main/java/com/fr/design/report/ReportExportAttrPane.java
  16. 3
      designer-realize/src/main/java/com/fr/start/CarinaDesigner.java
  17. 94
      designer-realize/src/main/java/com/fr/start/DesignerStartupMetric.java

12
designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java

@ -2,8 +2,6 @@ package com.fr.design;
import com.fr.common.report.ReportState;
import com.fr.design.backup.EnvBackupHelper;
import com.fr.design.mainframe.manager.clip.TemplateTreeClipboard;
import com.fr.design.plugin.remind.PluginErrorDesignReminder;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
@ -52,7 +50,6 @@ import com.fr.workspace.engine.base.FineObjectPool;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import com.fr.workspace.engine.exception.WorkspaceConnectionException;
import com.fr.workspace.engine.rpc.WorkspaceProxyPool;
import static javax.swing.JOptionPane.QUESTION_MESSAGE;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
@ -68,9 +65,10 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
import static javax.swing.JOptionPane.QUESTION_MESSAGE;
public class EnvChangeEntrance {
private static final String BRANCH_TAG = "#";
private static final String BRANCH_BEGIN = "-";
@ -158,11 +156,11 @@ public class EnvChangeEntrance {
}
/**
* 由云端运维触发切换埋点
* 内部空实现
* <a href="https://kms.fineres.com/pages/viewpage.action?pageId=945327503">实现</a>
* 异步提交埋点
*
*/
private void triggerSwitchMetric() {
EnvSwitcherSubmitTask.asyncSubmit();
}
/**

214
designer-base/src/main/java/com/fr/design/EnvSwitcherSubmitTask.java

@ -0,0 +1,214 @@
package com.fr.design;
import com.fr.concurrent.FineExecutors;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.mainframe.SiteCenterToken;
import com.fr.design.metric.AbstractDesignerMetric;
import com.fr.general.CloudCenter;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceSwitchProcess;
import com.fr.workspace.WorkspaceSwitchStatics;
import com.fr.workspace.switcher.WorkspaceSwitchHistory;
import org.jetbrains.annotations.NotNull;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeSet;
import java.util.concurrent.ExecutorService;
/**
* 设计器环境切换埋点提交
*
* @author Bruce.Deng
* @since 11.0
* Created on 2024/9/5
*/
public class EnvSwitcherSubmitTask extends AbstractDesignerMetric {
private static final String TAG_MODULE = "module";
private static final String TAG_SELF_USED = "selfUsed";
private static final String TAG_SUB = "sub";
private static final String WORK_DIRECTORY_TYPE_BEFORE_SWITCHING = "workDirectoryTypeBeforeSwitching";
private static final String WORK_DIRECTORY_TYPE_AFTER_SWITCHING = "workDirectoryTypeAfterSwitching";
private static final String SWITCH_COMPLETED = "switchCompleted";
private static final String EXCHANGE_TIME = "exchangeTime";
private static final String START_SLOW_MODULE_NAME = "startSlowModuleName";
private static final String STOP_SLOW_MODULE_NAME = "stopSlowModuleName";
private static final int MIN_LIMIT = 100;
private static final String SWITCH_TABLE_SUFFIX = "record_of_fbp_remoteSwitch/single";
private final ExecutorService service;
private EnvSwitcherSubmitTask() {
service = FineExecutors.newSingleThreadExecutor(new NamedThreadFactory("DesignEnvSwitchMetricSubmit"));
}
/**
* 异步提交环境切换的埋点
*/
public static void asyncSubmit() {
new EnvSwitcherSubmitTask().run();
}
/**
* 执行任务
*/
private void run() {
WorkspaceSwitchHistory.consume(workspaceSwitchProcesses -> {
Iterator<WorkspaceSwitchProcess> workspaceSwitchProcessIterator = workspaceSwitchProcesses.descendingIterator();
while (workspaceSwitchProcessIterator.hasNext()) {
WorkspaceSwitchProcess next = workspaceSwitchProcessIterator.next();
// 过滤掉 source 为空的启动过程
if (next != null && next.getSource() != null) {
submitProcess(next);
}
// 提交之后要移除掉
workspaceSwitchProcessIterator.remove();
}
});
}
private void submitProcess(WorkspaceSwitchProcess process) {
service.submit(new Runnable() {
@Override
public void run() {
collectAndSubmit(process);
}
});
}
private void collectAndSubmit(WorkspaceSwitchProcess process) {
Map<String, Object> para = new HashMap<>();
para.put("token", SiteCenterToken.generateToken());
para.put("content", collect(process));
try {
HttpToolbox.post(getUrl(), para);
FineLoggerFactory.getLogger().debug("[EnvSwitcher] submit env switcher metric to cloud.");
} catch (Throwable t) {
FineLoggerFactory.getLogger().debug(t,"[EnvSwitcher] failed to submit env switcher metric to cloud.");
}
}
private JSONObject collect(WorkspaceSwitchProcess process) {
JSONObject info = new JSONObject();
addDefaultMetric(info);
addMeta(info, process);
addStatics(info, process.getStatics());
return info;
}
private static void addMeta(JSONObject info, WorkspaceSwitchProcess process) {
Workspace source = process.getSource();
info.put(WORK_DIRECTORY_TYPE_BEFORE_SWITCHING, workspaceType(source));
Workspace target = process.getTarget();
info.put(WORK_DIRECTORY_TYPE_AFTER_SWITCHING, workspaceType(target));
info.put(SWITCH_COMPLETED, switchCompleted(process));
}
@NotNull
private static String switchCompleted(WorkspaceSwitchProcess process) {
return process.isSwitchSuccess() ? "yes" : "no";
}
@NotNull
private static String workspaceType(Workspace workspace) {
return workspace.isLocal() ? "local" : "remote";
}
private void addStatics(JSONObject info, WorkspaceSwitchStatics statics) {
info.put(EXCHANGE_TIME, statics.getElapsed());
JSONObject startSlowModuleName = convert2CloudModel(statics.getStartModuleUsed());
info.put(START_SLOW_MODULE_NAME, startSlowModuleName);
JSONObject stopSlowModuleName = convert2CloudModel(statics.getStopModuleUsed());
info.put(STOP_SLOW_MODULE_NAME, stopSlowModuleName);
}
/* convert */
@NotNull
private JSONObject convert2CloudModel(JSONObject moduleUsedJO) {
TreeSet<Entry> entries = convert2SortSet(moduleUsedJO);
return convert2JO(entries);
}
@NotNull
private static JSONObject convert2JO(TreeSet<Entry> startEntries) {
JSONObject moduleNames = new JSONObject();
startEntries.stream()
.filter((e) -> e.getSelfUsed() > MIN_LIMIT)
.forEach((e) -> moduleNames.put(e.getModuleName(), e.getSelfUsed()));
return moduleNames;
}
@NotNull
private TreeSet<Entry> convert2SortSet(JSONObject moduleUsedJO) {
TreeSet<Entry> entries = new TreeSet<>(Comparator.comparingInt(Entry::getSelfUsed));
sortBySelfUsed(moduleUsedJO, entries);
return entries;
}
/**
* 循环处理 JSON, 并降序排序
*
* @param moduleUsed 模块用时 {@link com.fr.module.engine.FineModule}
* @param entries 降序排序的树集合
*/
private void sortBySelfUsed(JSONObject moduleUsed, TreeSet<Entry> entries) {
if (moduleUsed == null || moduleUsed.isEmpty()) {
return;
}
String moduleName = moduleUsed.optString(TAG_MODULE);
int selfUsed = moduleUsed.optInt(TAG_SELF_USED);
entries.add(new Entry(moduleName, selfUsed));
JSONArray subModules = moduleUsed.optJSONArray(TAG_SUB);
if (subModules != null) {
int length = subModules.length();
for (int i = 0; i < length; i++) {
JSONObject subModuleUsed = subModules.optJSONObject(i);
sortBySelfUsed(subModuleUsed, entries);
}
}
}
private String getUrl() {
String monitorEntry = CloudCenter.getInstance().acquireUrlByKind("cloud.monitor.api.entrypoint");
String url = (StringUtils.isNotEmpty(monitorEntry) ? monitorEntry : DEFAULT_MONITOR_URL)
+ SWITCH_TABLE_SUFFIX;
return url;
}
private static class Entry {
private final String moduleName;
private final Integer selfUsed;
public Entry(String moduleName, Integer selfUsed) {
this.moduleName = moduleName;
this.selfUsed = selfUsed;
}
public String getModuleName() {
return moduleName;
}
public Integer getSelfUsed() {
return selfUsed;
}
}
}

39
designer-base/src/main/java/com/fr/design/metric/AbstractDesignerMetric.java

@ -0,0 +1,39 @@
package com.fr.design.metric;
import com.fanruan.carina.Carina;
import com.fanruan.config.bbs.FineBBSConfigProvider;
import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.general.GeneralUtils;
import com.fr.json.JSONObject;
import org.jetbrains.annotations.NotNull;
/**
* 设计器埋点抽象
*
* @author Bruce.Deng
* @since 11.0
* Created on 2024/9/10
*/
public abstract class AbstractDesignerMetric {
public static final String TIME = "time";
public static final String DESIGNER_ID = "designerId";
public static final String DESIGNER_VERSION = "designerVersion";
public static final String USERID = "userId";
public static final String APPID = "appId";
public static final String DEFAULT_MONITOR_URL = "https://cloud.fanruan.com/api/monitor/";
protected void addDefaultMetric(@NotNull JSONObject info) {
info.put(TIME, System.currentTimeMillis());
info.put(DESIGNER_ID, DesignerEnvManager.getEnvManager().getUUID());
info.put(DESIGNER_VERSION, GeneralUtils.getVersion());
info.put(USERID, Carina.config(FineBBSConfigProvider.class).getBbsUid());
info.put(APPID, MarketConfig.getInstance().getCloudOperationMaintenanceId());
}
}

4
designer-base/src/main/java/com/fr/design/roleAuthority/RoleTree.java

@ -33,6 +33,8 @@ import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import static com.fine.theme.utils.FineUIScale.scale;
/**
* Author : daisy
* Time: 下午3:32
@ -48,7 +50,7 @@ public class RoleTree extends UserObjectRefreshJTree<RoleSourceOP> {
this.setCellRenderer(roleTreeRenderer);
this.setEnabled(true);
this.setEditable(true);
this.setRowHeight(20);
this.setRowHeight(scale(20));
this.setDigIn(true);
Handler handler = createHandlerForRoleTree();
this.replaceMouseListener(this, handler, 0);

6
designer-base/src/main/java/com/fr/design/style/color/ColorSelectDetailPane.java

@ -78,7 +78,6 @@ public class ColorSelectDetailPane extends BasicPane {
// 颜色选择器面板
selectedPanel = new JColorChooser(this.color);
selectedPanel.setPreferredSize(new Dimension(selectedPanel.getWidth(), FineUIScale.scale(SELECT_PANEL_HEIGHT)));
selectedPanel.setPreviewPanel(new JPanel());
swatchChooserPanel = new SwatchChooserPanel();
@ -130,12 +129,11 @@ public class ColorSelectDetailPane extends BasicPane {
column(
2,
cell(new UILabel(i18nText("Fine-Design_Basic_Preview"))),
cell(previewPanel).with(it -> {
cell(previewPanel).weight(1).with(it -> {
it.setBorder(new FineRoundBorder());
it.setPreferredSize(new Dimension(this.getPreferredSize().width, FineUIScale.scale(120)));
it.setBackground(FlatUIUtils.getUIColor("background.normal", Color.WHITE));
})
)).with(it -> it.setBorder(new ScaledEmptyBorder(0, 10, 0, 10)))
).weight(1)).weight(1).with(it -> it.setBorder(new ScaledEmptyBorder(0, 10, 0, 10)))
).getComponent();
}

8
designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java

@ -16,6 +16,8 @@ import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import static com.fine.swing.ui.layout.Layouts.cell;
import static com.fine.swing.ui.layout.Layouts.column;
import static com.fine.theme.utils.FineUIScale.scale;
@ -86,8 +88,7 @@ public class ColorSelectDialog extends MiddleChartDialog{
private void initComponent() {
this.setLayout(new BorderLayout());
this.add(pane,BorderLayout.NORTH);
this.setBasicDialogSize(scale(545),scale(500));
this.setBasicDialogSize(545,500);
this.setResizable(false);
this.applyClosingAction();
@ -95,8 +96,6 @@ public class ColorSelectDialog extends MiddleChartDialog{
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
this.add(buttonPane, BorderLayout.SOUTH);
ok = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Button_OK"));
cancel = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Button_Cancel"));
@ -121,6 +120,7 @@ public class ColorSelectDialog extends MiddleChartDialog{
}
});
this.add(column(10, cell(pane).weight(1), cell(buttonPane)).getComponent());
this.setTitle(pane.title4PopupWindow());
GUICoreUtils.setWindowCenter(getOwner(), this);
}

4
designer-base/src/main/java/com/fr/design/style/color/CustomChooserPanel.java

@ -599,7 +599,7 @@ class CustomChooserPanel extends AbstractColorChooserPanel implements ColorSelec
protected void buildChooser() {
setLayout(new BorderLayout(10, 0));
setPreferredSize(new Dimension((int) this.getPreferredSize().getWidth(), scale(180)));
add(buildRightPanel(), BorderLayout.CENTER);
Container rightPane = buildRightPanel();
JPanel container = new JPanel();
container.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 0));
@ -628,7 +628,7 @@ class CustomChooserPanel extends AbstractColorChooserPanel implements ColorSelec
slider.setSize(scale(new Dimension(12, 180)));
trackPanel.setSize(scale(new Dimension(12, 180)));
add(container, BorderLayout.WEST);
add(row(cell(container).weight(1), cell(rightPane).weight(1)).getComponent());
slider.addChangeListener(new SliderChangeListener());
updateTextFields();

11
designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java

@ -28,8 +28,6 @@ import com.fr.plugin.manage.control.PluginTaskCallback;
import com.fr.plugin.manage.control.PluginTaskResult;
import com.fr.plugin.manage.control.ProgressCallback;
import com.fr.report.ReportHelper;
import com.fr.rpc.ExceptionHandler;
import com.fr.rpc.RPCInvokerExceptionInfo;
import com.fr.rpc.Result;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
@ -39,7 +37,7 @@ import com.fr.workspace.engine.base.FineObjectPool;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import com.fr.workspace.engine.exception.WorkspaceConnectionException;
import com.fr.workspace.engine.rpc.WorkspaceProxyPool;
import com.fr.workspace.server.check.VersionInfoOperator;
import java.lang.reflect.Method;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
@ -53,7 +51,6 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import javax.swing.SwingWorker;
/**
* @author pengda
@ -285,16 +282,14 @@ public class VersionCheckUtils {
public static JSONArray checkLocalAndRemotePlugin() {
JSONArray differentPlugins = new JSONArray();
JSONArray remotePlugins = FRContext.getCommonOperator().getPluginStatus();
List<JSONObject> remotePlugins = FRContext.getCommonOperator().getPluginStatus();
Map<String, PluginContext> localPluginsMap = new HashMap<>();
List<PluginContext> localPlugins = PluginManager.getContexts();
for (PluginContext pluginContext : localPlugins) {
localPluginsMap.put(pluginContext.getID(), pluginContext);
}
JSONObject remotePlugin;
Map<String, String> pluginsNameMap = ReportHelper.getPluginNameMap();
for (int i = 0; i < remotePlugins.size(); i++) {
remotePlugin = remotePlugins.getJSONObject(i);
for (JSONObject remotePlugin : remotePlugins) {
if (isPluginNeedIgnore(remotePlugin)) {
continue;
}

19
designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvChooseComponent.java vendored

@ -1,8 +1,6 @@
package com.fanruan.boot.env;
import com.fr.design.ConfigHelper;
import com.fanruan.boot.key.StartupArgsShell;
import com.fr.design.mem.MemConfigRepositoryBuilder;
import com.fanruan.carina.Carina;
import com.fanruan.carina.annotions.FineComponent;
import com.fanruan.carina.annotions.Start;
@ -15,15 +13,18 @@ import com.fanruan.config.realm.local.LocalConfigRepositoryBuilder;
import com.fr.base.operator.org.OrganizationOperator;
import com.fr.base.rpc.encrypt.EncryptOperator;
import com.fr.decision.service.context.ServiceContext;
import com.fr.design.ConfigHelper;
import com.fr.design.DesignerEnvManager;
import com.fr.design.EnvChangeEntrance;
import com.fr.design.PluginClassRefreshManager;
import com.fr.design.backup.DesignContext;
import com.fr.design.constants.DesignerLaunchStatus;
import com.fr.design.editlock.ConnectionLockChangeChecker;
import com.fr.design.editlock.ServerTableDataLockChangeChecker;
import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mem.MemConfigRepositoryBuilder;
import com.fr.design.plugin.remind.PluginErrorDesignReminder;
import com.fr.env.utils.WorkspaceUtils;
import com.fr.event.Event;
@ -36,12 +37,12 @@ import com.fr.report.lock.DefaultLockInfoOperator;
import com.fr.report.lock.LocalLockInfoOperator;
import com.fr.report.lock.LockInfoOperator;
import com.fr.report.lock.ServerLockInfoOperator;
import com.fr.design.backup.DesignContext;
import com.fr.start.module.StartupArgs;
import com.fr.value.NotNullLazyValue;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent;
import com.fr.workspace.WorkspaceSwitchProcess;
import com.fr.workspace.base.WorkspaceKey;
import com.fr.workspace.pool.WorkRPCRegister;
import com.fr.workspace.pool.WorkRPCType;
@ -101,6 +102,8 @@ import com.fr.workspace.server.vcs.v2.scheduler.VcsAutoCleanOperator;
import com.fr.workspace.server.vcs.v2.scheduler.VcsAutoCleanService;
import org.jetbrains.annotations.NotNull;
import java.util.Optional;
/**
* 环境选择模块
*
@ -118,10 +121,20 @@ public class DesignEnvChooseComponent extends ResourceAffiliate {
BootstrapFactory.get().reboot("design_env_prepare");
// 环境切换后,等到模块重启更新一下当前的系统信息
WorkplaceConstants.updateBean();
recordModuleStartStop();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private void recordModuleStartStop() {
WorkspaceSwitchProcess process = WorkContext.getSwitcher().getProcess();
Optional.ofNullable(process)
.ifPresent((e) -> e.recordModuleStartUsed(() -> BootstrapFactory.get().profileStart("design_env_prepare")));
Optional.ofNullable(process)
.ifPresent((e) -> e.recordModuleStopUsed(() -> BootstrapFactory.get().profileStop("design_env_prepare")));
}
};
private Listener<Workspace> beforeSwitch4Max = new Listener<Workspace>(Integer.MAX_VALUE) {

11
designer-realize/src/main/java/com/fanruan/boot/env/DesignPluginComponent.java vendored

@ -9,9 +9,15 @@ import com.fanruan.carina.annotions.Stop;
import com.fanruan.carina.annotions.Supplemental;
import com.fanruan.plugin.autonomy.AutonomyClassManagerGroup;
import com.fanruan.plugin.autonomy.AutonomyClassManagerProvider;
import com.fr.json.JSONObject;
import com.fr.plugin.ExtraClassManager;
import com.fr.plugin.manage.PluginManager;
import com.fr.plugin.manage.PluginSyncModuleType;
import com.fr.workspace.server.repository.plugin.PluginRepository;
import javax.servlet.ServletContext;
import java.util.List;
import java.util.function.Supplier;
/**
* 设计器插件模块环境切换的中间模块
@ -38,6 +44,11 @@ public class DesignPluginComponent extends PluginComponent {
@Start
public void start() {
ExtraClassManager.getInstance().registerAutonomyClassManager(Carina.getApplicationContext().group(AutonomyClassManagerGroup.class).getAll().toArray(new AutonomyClassManagerProvider[0]));
Supplier<List<JSONObject>> supplier = () -> PluginRepository.getInstance().getPluginStatus();
PluginManager.registerRemotePluginSupplier(supplier);
PluginManager.setSyncModuleType(PluginSyncModuleType.DESIGN);
super.start();
}

10
designer-realize/src/main/java/com/fanruan/boot/env/function/app/PluginRemote.java vendored

@ -1,7 +1,6 @@
package com.fanruan.boot.env.function.app;
import com.fr.base.FRContext;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
@ -12,6 +11,7 @@ import com.fr.workspace.WorkContext;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@ -57,19 +57,17 @@ public class PluginRemote {
private Map<String, PluginStatus> getRemoteStatus() {
JSONArray statusArray = FRContext.getCommonOperator().getPluginStatus();
JSONObject status;
List<JSONObject> objectList = FRContext.getCommonOperator().getPluginStatus();
String id;
String version;
boolean running;
Map<String, PluginStatus> statusMap = new HashMap<>();
for (int i = 0; i < statusArray.length(); i++) {
for (JSONObject status : objectList) {
try {
status = statusArray.getJSONObject(i);
id = status.getString("id");
version = status.getString("version");
running = status.getBoolean("running");
if(StringUtils.isBlank(id)){
if (StringUtils.isBlank(id)) {
continue;
}
PluginStatus pluginStatus = PluginStatus.create(id, version, running);

2
designer-realize/src/main/java/com/fanruan/boot/init/DesignWorkContextComponent.java

@ -63,6 +63,7 @@ import com.fr.workspace.server.repository.compatible.register.CompatibleRegister
import com.fanruan.workplace.network.RemoteNetworkRepository;
import com.fr.workspace.server.repository.config.ConfigRepository;
import com.fr.workspace.server.repository.connection.ConnectionRepository;
import com.fr.workspace.server.repository.plugin.PluginRepository;
import com.fr.workspace.server.repository.resource.PublicResourceRepository;
import com.fr.workspace.server.repository.resource.WorkResourceRepository;
import com.fr.workspace.server.repository.system.SystemInfoRepository;
@ -112,6 +113,7 @@ public class DesignWorkContextComponent {
RepositoryManager.getInstance().pureRegisterRepo4Start(WorkResourceRepository.getInstance());
RepositoryManager.getInstance().pureRegisterRepo4Start(PublicResourceRepository.getInstance());
RepositoryManager.getInstance().pureRegisterRepo4Start(ConfigRepository.getInstance());
RepositoryManager.getInstance().pureRegisterRepo4Start(PluginRepository.getInstance());
RepositoryManager.getInstance().initLocalRepository();
CompatibleRegister.registerCompatibleEnv();
for (WorkRPCRegister<?> workRPCRegister : ServiceContext.group(WorkspaceKey.class).getAll()) {

12
designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe;
import com.fine.theme.utils.FineUIScale;
import com.formdev.flatlaf.util.ScaledEmptyBorder;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.file.HistoryTemplateListPane;
@ -37,7 +38,10 @@ import java.awt.event.MouseListener;
import java.util.List;
import static com.fine.swing.ui.layout.Layouts.cell;
import static com.fine.swing.ui.layout.Layouts.column;
import static com.fine.swing.ui.layout.Layouts.flex;
import static com.fine.swing.ui.layout.Layouts.row;
import static com.fine.theme.utils.FineUIScale.scale;
/**
* Author : daisy
@ -134,14 +138,14 @@ public class AuthorityToolBarPane<T extends WebContent> extends BasicBeanPane<Re
public AuthorityToolBarPane() {
this.setLayout(new BorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(0, PRE_GAP, 10, 0));
this.setBorder(new ScaledEmptyBorder(0, PRE_GAP, 10, 0));
title = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Toolbar_Choose_Role"));
title.setHorizontalAlignment(SwingConstants.LEFT);
title.setPreferredSize(new Dimension(FineUIScale.scale(120), title.getHeight()));
title.setPreferredSize(new Dimension(scale(120), title.getHeight()));
choseComboBox = new UIComboBox(CHOOSEITEM) {
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
dim.width = COMBOX_WIDTH;
dim.width = scale(COMBOX_WIDTH);
return dim;
}
};
@ -158,7 +162,7 @@ public class AuthorityToolBarPane<T extends WebContent> extends BasicBeanPane<Re
authorityEditToolBarPane.setAuthorityToolBarPane(this);
checkToolBarPaneEnable();
toolBarPane.setOpaque(false);
this.add(row(10, cell(title), cell(choseComboBox), cell(toolBarPane)).getComponent());
this.add(row(10, cell(title), cell(choseComboBox), column(flex(), cell(toolBarPane), flex())).getComponent());
}

3
designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java

@ -1,5 +1,6 @@
package com.fr.design.mainframe;
import com.fine.theme.utils.FineUIScale;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.editor.ValueEditorPane;
import com.fr.design.editor.ValueEditorPaneFactory;
@ -54,7 +55,7 @@ public class ElementCasePaneAuthorityEditPane extends AuthorityEditPane {
private static final int NEW_VALUE = 4;
//新值下面的编辑器的宽度
private static final int NEW_PANE_WIDTH = 120;
private static final Dimension VALUEPANE_NEW_DIMENSION = new Dimension(154,20);
private static final Dimension VALUEPANE_NEW_DIMENSION = FineUIScale.scale(new Dimension(154,20));
private static final Dimension VALUEPANE_OLD_DIMENSION = new Dimension(0,0);

4
designer-realize/src/main/java/com/fr/design/report/ReportExportAttrPane.java

@ -45,8 +45,8 @@ public class ReportExportAttrPane extends BasicPane {
}
private void initPane(BasicStorePane<?> exportPane) {
tabPaneBuilder.addTab(new ImageExportPane().getTitle(), new ImageExportPane());
paneList.add(new ImageExportPane());
tabPaneBuilder.addTab(exportPane.getTitle(), exportPane);
paneList.add(exportPane);
}
@Override

3
designer-realize/src/main/java/com/fr/start/CarinaDesigner.java

@ -10,11 +10,9 @@ import com.fanruan.gui.UiInspector;
import com.fr.base.StateHubContext;
import com.fr.design.backup.DesignContext;
import com.fr.design.carton.SwitchForSwingChecker;
import com.fr.design.carton.latency.DesignerLatencyMetric;
import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.log.FineLoggerFactory;
import com.fr.runtime.FineRuntime;
import com.fr.start.common.DesignerStartupContext;
import com.fr.start.module.StartupArgs;
@ -65,6 +63,7 @@ public class CarinaDesigner extends MainDesigner{
FineLoggerFactory.getLogger().info("Designer started.Time used {} ms", DesignerStartupContext.getRecorder().getTime(TimeUnit.MILLISECONDS));
DesignerStartupContext.getRecorder().stop();
DesignerStartupMetric.getInstance().asyncSubmit();
SwitchForSwingChecker.initThreadMonitoring();
DesignerLatencyMetric.getInstance().start();
}

94
designer-realize/src/main/java/com/fr/start/DesignerStartupMetric.java

@ -0,0 +1,94 @@
package com.fr.start;
import com.fr.concurrent.FineExecutors;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.mainframe.SiteCenterToken;
import com.fr.design.metric.AbstractDesignerMetric;
import com.fr.general.CloudCenter;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONObject;
import com.fr.json.revise.EmbedJson;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.start.common.DesignerStartupContext;
import com.fr.startup.metric.DesignerMetrics;
import com.fr.startup.metric.DesignerStartupModel;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* fbp设计器启动埋点提交
*
* @author Bruce.Deng
* @since 11.0
* Created on 2024/9/5
*/
public class DesignerStartupMetric extends AbstractDesignerMetric {
private static final String LANDING_TIME = "landingTime";
private static final String STARTING_TIME = "startingTime";
private static final String MODE = "mode";
private static final String INFO = "info";
private static volatile DesignerStartupMetric instance = new DesignerStartupMetric();
private static final String DESIGNER_START_TABLE_SUFFIX = "record_of_fbp_designerStartTime/single";
private DesignerStartupMetric() {
}
/**
* 获取单例
*/
public static DesignerStartupMetric getInstance() {
return instance;
}
/**
* 延迟5分钟提交埋点数据
*
*/
public void asyncSubmit() {
ScheduledExecutorService scheduledExecutorService = FineExecutors.newSingleThreadScheduledExecutor(new NamedThreadFactory("DesignerStartupMetricSubmit"));
scheduledExecutorService.schedule(new Runnable() {
@Override
public void run() {
collectAndSubmit();
}
}, 5, TimeUnit.MINUTES);
scheduledExecutorService.shutdown();
}
private void collectAndSubmit() {
Map<String, Object> para = new HashMap<>();
para.put("token", SiteCenterToken.generateToken());
para.put("content", collect());
try {
HttpToolbox.post(getUrl(), para);
FineLoggerFactory.getLogger().debug("[DesignerStartup] submit designer startup metric to cloud.");
} catch (Throwable t) {
FineLoggerFactory.getLogger().debug(t,"[DesignerStartup] failed to submit designer startup metric to cloud.");
}
}
private String getUrl() {
String monitorEntry = CloudCenter.getInstance().acquireUrlByKind("cloud.monitor.api.entrypoint");
String url = (StringUtils.isNotEmpty(monitorEntry) ? monitorEntry : DEFAULT_MONITOR_URL)
+ DESIGNER_START_TABLE_SUFFIX;
return url;
}
private JSONObject collect() {
JSONObject info = new JSONObject();
DesignerMetrics designerMetrics = DesignerStartupContext.getInstance().getDesignerMetrics();
DesignerStartupModel model = designerMetrics.getModel();
info.put(LANDING_TIME, model.getLandingTime());
info.put(STARTING_TIME, model.getStartingTime());
info.put(MODE, model.getMode());
info.put(INFO, EmbedJson.encode(model.getInfo()));
addDefaultMetric(info);
return info;
}
}
Loading…
Cancel
Save