Browse Source
* commit '5619bf3f828fe962a37b7f00a277524380fcc2a3': REPORT-91839 模板版本管理二期 修复bug REPORT-91839 模板版本管理二期 多删了一部分 REPORT-91839 模板版本管理二期 补充按钮交互,消除冗余代码 REPORT-91839 模板版本管理二期 优化判断新老模式的逻辑,事件响应改为Config准备后进行 REPORT-91839 模板版本管理二期 完善一下判断逻辑,增加自动保存标签设置 REPORT-91839 模板版本管理二期 修复规范问题 REPORT-91839 模板版本管理二期 REPORT-86153 误传 REPORT-86153【信创】达梦数据库适配存储过程 REPORT-80651 模板版本管理重构一期补交 REPORT-89867 【降本增效】插件管理优化 优化代码 REPORT-89867 【降本增效】插件管理优化 去除两次for循环 REPORT-89867 【降本增效】插件管理优化 REPORT-89867 【降本增效】插件管理优化 REPORT-89867 【降本增效】插件管理优化 无jira任务,提交遗漏代码 REPORT-89867 【降本增效】插件管理优化 REPORT-89867 【降本增效】插件管理优化 REPORT-89867 【降本增效】插件管理优化 KERNEL-9267 feat: 平台提供的CBB组件目前过于冗杂,没法精简使用bugfix/11.0
superman
1 year ago
15 changed files with 1331 additions and 53 deletions
@ -0,0 +1,184 @@
|
||||
package com.fr.design.extra; |
||||
|
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.i18n.Toolkit; |
||||
|
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.BoxLayout; |
||||
import javax.swing.JDialog; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JScrollPane; |
||||
import javax.swing.JTextArea; |
||||
import javax.swing.SwingUtilities; |
||||
import javax.swing.UIManager; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Color; |
||||
import java.awt.Cursor; |
||||
import java.awt.Dialog; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
|
||||
/** |
||||
* 插件批量处理弹窗面板 |
||||
* |
||||
* @author Destiny.Lin |
||||
* @since 11.0 |
||||
* Created on 2023/5/19 |
||||
*/ |
||||
public class PluginBatchModifyDetailPane { |
||||
private UILabel message = new UILabel(); |
||||
private UIButton cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Report_OK")); |
||||
private UILabel uiLabel = new UILabel(); |
||||
private UILabel directUiLabel = new UILabel(); |
||||
private UILabel detailLabel = new UILabel(); |
||||
|
||||
private JPanel upPane; |
||||
private JPanel midPane; |
||||
private JPanel downPane; |
||||
private JPanel hiddenPanel; |
||||
private JTextArea jta; |
||||
private JDialog dialog; |
||||
|
||||
/** |
||||
* 弹窗面板默认大小 |
||||
*/ |
||||
public static final Dimension DEFAULT = new Dimension(380, 150); |
||||
|
||||
/** |
||||
* 弹窗面板展开大小 |
||||
*/ |
||||
public static final Dimension DEFAULT_PRO = new Dimension(380, 270); |
||||
|
||||
public PluginBatchModifyDetailPane(Dialog parent) { |
||||
init(parent); |
||||
} |
||||
|
||||
private void init(Dialog parent) { |
||||
message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0)); |
||||
dialog = new JDialog(parent, Toolkit.i18nText("Fine-Design_Basic_Plugin_Manager"), true); |
||||
dialog.setSize(DEFAULT); |
||||
JPanel jp = new JPanel(); |
||||
initUpPane(); |
||||
initDownPane(); |
||||
initMidPane(); |
||||
initHiddenPanel(); |
||||
initListener(); |
||||
jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS)); |
||||
jp.add(upPane); |
||||
jp.add(midPane); |
||||
jp.add(hiddenPanel); |
||||
jp.add(downPane); |
||||
hiddenPanel.setVisible(false); |
||||
dialog.add(jp); |
||||
dialog.setResizable(false); |
||||
dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(parent)); |
||||
} |
||||
|
||||
private void initDownPane() { |
||||
downPane = new JPanel(); |
||||
downPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 15, 9)); |
||||
downPane.add(cancelButton); |
||||
} |
||||
|
||||
private void initUpPane() { |
||||
upPane = new JPanel(); |
||||
uiLabel = new UILabel(UIManager.getIcon("OptionPane.errorIcon")); |
||||
upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); |
||||
upPane.add(uiLabel); |
||||
upPane.add(message); |
||||
} |
||||
|
||||
private void initMidPane() { |
||||
midPane = new JPanel(); |
||||
midPane.add(directUiLabel); |
||||
midPane.add(detailLabel); |
||||
midPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 0)); |
||||
detailLabel.setText(Toolkit.i18nText("Fine_Designer_Look_Detail")); |
||||
detailLabel.setForeground(Color.BLUE); |
||||
detailLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
||||
directUiLabel.setIcon(UIManager.getIcon("OptionPane.narrow.right")); |
||||
} |
||||
|
||||
private void initHiddenPanel() { |
||||
hiddenPanel = new JPanel(); |
||||
hiddenPanel.setLayout(new BorderLayout(2, 0)); |
||||
hiddenPanel.add(new JPanel(), BorderLayout.WEST); |
||||
hiddenPanel.add(new JPanel(), BorderLayout.EAST); |
||||
JPanel borderPanel = new JPanel(); |
||||
borderPanel.setLayout(new BorderLayout()); |
||||
jta = new JTextArea(); |
||||
JScrollPane jsp = new JScrollPane(jta); |
||||
jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); |
||||
jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
||||
jta.setEditable(false); |
||||
borderPanel.add(jsp, BorderLayout.CENTER); |
||||
hiddenPanel.add(borderPanel); |
||||
} |
||||
|
||||
/** |
||||
* 补充更详细的报错信息 |
||||
* |
||||
* @param message 信息 |
||||
*/ |
||||
public void updateDetailArea(String message) { |
||||
jta.append(message + "\n"); |
||||
} |
||||
|
||||
private void initListener() { |
||||
detailLabel.addMouseListener(new MouseAdapter() { |
||||
@Override |
||||
public void mouseClicked(MouseEvent e) { |
||||
if (hiddenPanel.isVisible()) { |
||||
hiddenPanel.setVisible(false); |
||||
dialog.setSize(DEFAULT); |
||||
detailLabel.setText(Toolkit.i18nText("Fine_Designer_Look_Detail")); |
||||
directUiLabel.setIcon(UIManager.getIcon("OptionPane.narrow.right")); |
||||
} else { |
||||
dialog.setSize(DEFAULT_PRO); |
||||
hiddenPanel.setVisible(true); |
||||
detailLabel.setText(Toolkit.i18nText("Fine_Designer_Hide_Detail")); |
||||
directUiLabel.setIcon(UIManager.getIcon("OptionPane.narrow.down")); |
||||
} |
||||
} |
||||
|
||||
}); |
||||
cancelButton.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
hiddenPanel.removeAll(); |
||||
dialog.dispose(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 更新标题 |
||||
* @param title 标题 |
||||
*/ |
||||
public void updateTitle(String title) { |
||||
dialog.setTitle(title); |
||||
} |
||||
|
||||
/** |
||||
* 更新展示信息 |
||||
* |
||||
* @param failedCount 处理失败个数 |
||||
* @param successCount 处理成功个数 |
||||
*/ |
||||
public void updateMessage(int failedCount, int successCount) { |
||||
message.setText(Toolkit.i18nText("Fine-Design_Basic_Plugin_Batch_Modify_Info", failedCount, successCount)); |
||||
} |
||||
|
||||
/** |
||||
* 显示面板 |
||||
*/ |
||||
public void show() { |
||||
dialog.setVisible(true); |
||||
} |
||||
} |
@ -0,0 +1,127 @@
|
||||
package com.fr.design.extra.exe.callback; |
||||
|
||||
import com.fr.design.bridge.exec.JSCallback; |
||||
import com.fr.design.dialog.FineJOptionPane; |
||||
import com.fr.design.extra.PluginBatchModifyDetailPane; |
||||
import com.fr.design.extra.PluginOperateUtils; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.plugin.DesignerPluginContext; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.context.PluginMarker; |
||||
import com.fr.plugin.manage.control.PluginTask; |
||||
import com.fr.plugin.manage.control.PluginTaskResult; |
||||
import com.fr.plugin.manage.control.ProgressCallback; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.JOptionPane; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 带进度条的批量处理的callback |
||||
* <li> content与title是处理完成后弹出的面板的内容与标题,子类需要在done之前设定好对应的信息 |
||||
* <li> 进度条是以 当前完成任务数/总任务数 来计算的 |
||||
* |
||||
* @author Destiny.Lin |
||||
* @since 11.0 |
||||
* Created on 2023/6/6 |
||||
*/ |
||||
public abstract class AbstractBatchModifyStatusCallback implements ProgressCallback { |
||||
protected JSCallback jsCallback; |
||||
protected Map<String, String> resultMap = new HashMap<>(); |
||||
protected String content = StringUtils.EMPTY; |
||||
protected String title = StringUtils.EMPTY; |
||||
public int pluginCount = 0; |
||||
public int allPluginCount = 0; |
||||
public int successCount = 0; |
||||
public int failedCount = 0; |
||||
public static final int HUNDRED_PERCENT = 100; |
||||
public static final String PERCENT = "%"; |
||||
public static final String DEFAULT = "default"; |
||||
|
||||
public AbstractBatchModifyStatusCallback() { |
||||
} |
||||
|
||||
public AbstractBatchModifyStatusCallback(JSCallback jsCallback, int size) { |
||||
this.jsCallback = jsCallback; |
||||
this.allPluginCount = size; |
||||
} |
||||
|
||||
@Override |
||||
public void done(PluginTaskResult result) { |
||||
String pluginInfo = PluginOperateUtils.getSuccessInfo(result); |
||||
if (result.isSuccess()) { |
||||
successCount++; |
||||
String modifyMessage = updateMessage(pluginInfo); |
||||
FineLoggerFactory.getLogger().info(modifyMessage); |
||||
} else { |
||||
failedCount++; |
||||
resultMap.put(getPluginName(result), pluginInfo); |
||||
} |
||||
updateProgressAndCheckCompletion(); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 获取插件名 |
||||
* |
||||
* @param result 任务结果 |
||||
* @return 插件名 |
||||
*/ |
||||
public String getPluginName(PluginTaskResult result) { |
||||
PluginTask pluginTask = result.getCurrentTask(); |
||||
if (pluginTask != null) { |
||||
PluginMarker pluginMarker = pluginTask.getToMarker(); |
||||
if (pluginMarker != null) { |
||||
return pluginMarker.getPluginID(); |
||||
} |
||||
} |
||||
return DEFAULT; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 更新当前Map状态,进度条,如果全部都更新完了就回调 |
||||
*/ |
||||
public void updateProgressAndCheckCompletion() { |
||||
pluginCount++; |
||||
updateProgress(StringUtils.EMPTY, (double) pluginCount / allPluginCount); |
||||
if (pluginCount == allPluginCount) { |
||||
jsCallback.execute("success"); |
||||
showMessageDialog(); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 展示信息面板 |
||||
*/ |
||||
public void showMessageDialog() { |
||||
if (failedCount == 0) { |
||||
FineJOptionPane.showMessageDialog(DesignerPluginContext.getPluginDialog(), |
||||
content, |
||||
title, |
||||
JOptionPane.INFORMATION_MESSAGE); |
||||
} else { |
||||
PluginBatchModifyDetailPane detailPane = new PluginBatchModifyDetailPane(DesignerPluginContext.getPluginDialog()); |
||||
for (String key : resultMap.keySet()) { |
||||
detailPane.updateDetailArea(resultMap.get(key)); |
||||
} |
||||
detailPane.updateMessage(failedCount, successCount); |
||||
detailPane.updateTitle(title); |
||||
detailPane.show(); |
||||
} |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void updateProgress(String description, double progress) { |
||||
jsCallback.execute(progress * HUNDRED_PERCENT + PERCENT); |
||||
} |
||||
|
||||
/** |
||||
* 更新处理成功返回的日志信息 |
||||
* |
||||
* @return 返回的日志信息 |
||||
*/ |
||||
abstract public String updateMessage(String pluginInfo); |
||||
} |
@ -0,0 +1,43 @@
|
||||
package com.fr.design.extra.exe.callback; |
||||
|
||||
|
||||
import com.fr.design.bridge.exec.JSCallback; |
||||
|
||||
import com.fr.design.i18n.Toolkit; |
||||
|
||||
|
||||
/** |
||||
* 批量启用/禁用插件的Callback |
||||
* |
||||
* @author Destiny.Lin |
||||
* @since 11.0 |
||||
* Created on 2023/5/18 |
||||
*/ |
||||
public class BatchModifyStatusCallback extends AbstractBatchModifyStatusCallback { |
||||
private boolean active; |
||||
private boolean operatorFlag = false; |
||||
|
||||
public BatchModifyStatusCallback(JSCallback jsCallback, int size) { |
||||
super(jsCallback, size); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public String updateMessage(String pluginInfo) { |
||||
return active ? pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Disabled_Duplicate") : pluginInfo + Toolkit.i18nText("Fine-Design_Plugin_Has_Been_Actived_Duplicate"); |
||||
} |
||||
|
||||
/** |
||||
* 更新启用/禁用信息 |
||||
* |
||||
* @param active |
||||
*/ |
||||
public void updateActiveStatus(boolean active) { |
||||
if (!operatorFlag) { |
||||
this.active = active; |
||||
this.operatorFlag = true; |
||||
this.title = active ? Toolkit.i18nText("Fine-Design_Basic_Plugin_Stop") : Toolkit.i18nText("Fine-Design_Basic_Plugin_Start"); |
||||
this.content = active ? Toolkit.i18nText("Fine-Design_Basic_Plugin_Batch_Modify_Stop_Success") : Toolkit.i18nText("Fine-Design_Basic_Plugin_Batch_Modify_Start_Success"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,77 @@
|
||||
package com.fr.design.extra.exe.callback; |
||||
|
||||
|
||||
import com.fr.design.bridge.exec.JSCallback; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.manage.control.PluginTask; |
||||
import com.fr.plugin.manage.control.PluginTaskResult; |
||||
|
||||
|
||||
/** |
||||
* 批量更新的callback |
||||
* |
||||
* @author Destiny.Lin |
||||
* @since 11.0 |
||||
* Created on 2023/6/6 |
||||
*/ |
||||
public class BatchUpdateOnlineCallback extends AbstractBatchModifyStatusCallback{ |
||||
public static final BatchUpdateOnlineCallback NONE = new BatchUpdateOnlineCallback(); |
||||
|
||||
/** |
||||
* 可自动处理前置任务的callback,用来处理实际更新逻辑 |
||||
*/ |
||||
private InnerUpdateCallback innerPreTaskCallback; |
||||
|
||||
public BatchUpdateOnlineCallback() { |
||||
} |
||||
|
||||
public BatchUpdateOnlineCallback(JSCallback jsCallback, int size) { |
||||
super(jsCallback, size); |
||||
this.title = Toolkit.i18nText("Fine-Design_Basic_Plugin_Update"); |
||||
this.content = Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success"); |
||||
} |
||||
|
||||
/** |
||||
* 更新任务 |
||||
* |
||||
* @param pluginTask 任务 |
||||
* @param jsCallback callback |
||||
*/ |
||||
public void createInnerPreTaskCallback(PluginTask pluginTask, JSCallback jsCallback) { |
||||
innerPreTaskCallback = new InnerUpdateCallback(pluginTask, jsCallback); |
||||
} |
||||
|
||||
|
||||
|
||||
public InnerUpdateCallback getInnerPreTaskCallback() { |
||||
return innerPreTaskCallback; |
||||
} |
||||
|
||||
@Override |
||||
public String updateMessage(String pluginInfo) { |
||||
return pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success"); |
||||
} |
||||
|
||||
/** |
||||
* 可自动处理前置任务的callback,用来处理实际更新逻辑 |
||||
*/ |
||||
public class InnerUpdateCallback extends UpdateOnlineCallback { |
||||
|
||||
|
||||
public InnerUpdateCallback(PluginTask pluginTask, JSCallback jsCallback) { |
||||
super(pluginTask, jsCallback); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void updateProgress(String description, double aProgress) { |
||||
//不进行处理
|
||||
} |
||||
|
||||
@Override |
||||
public void allDone(PluginTaskResult result) { |
||||
BatchUpdateOnlineCallback.this.done(result); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,406 @@
|
||||
package com.fr.design.mainframe.vcs.ui; |
||||
|
||||
|
||||
import com.fr.base.svg.IconUtils; |
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.ibutton.UIRadioButton; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.iprogressbar.ModernUIProgressBarUI; |
||||
import com.fr.design.gui.ispinner.UISpinner; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.VerticalFlowLayout; |
||||
import com.fr.design.mainframe.vcs.common.VcsHelper; |
||||
import com.fr.design.utils.DesignUtils; |
||||
import com.fr.design.widget.FRWidgetFactory; |
||||
import com.fr.general.FRFont; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.workspace.server.vcs.v2.move.VcsMoveService; |
||||
import com.fr.workspace.server.vcs.v2.move.VcsMoveStrategy; |
||||
|
||||
import javax.swing.ButtonGroup; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JProgressBar; |
||||
import javax.swing.SwingUtilities; |
||||
import javax.swing.SwingWorker; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import java.util.List; |
||||
import java.util.concurrent.ExecutionException; |
||||
|
||||
|
||||
/** |
||||
* 迁移面板 |
||||
* |
||||
* @author Destiny.Lin |
||||
* @since 11.0 |
||||
* Created on 2023/6/13 |
||||
*/ |
||||
public class VcsMovePanel extends BasicPane { |
||||
private static final FRFont FONT = DesignUtils |
||||
.getDefaultGUIFont() |
||||
.applySize(14) |
||||
.applyStyle(FRFont.BOLD); |
||||
|
||||
private static final Color BACK_GROUND_COLOR = new Color(202,232,255); |
||||
|
||||
//提示字体的颜色,直接模仿其他面板的写法
|
||||
private static final Color TIP_COLOR = new Color(51, 51, 52, (int)Math.round(0.5 * 255)); |
||||
|
||||
private static final Color LABEL_COLOR = new Color(34,149,233); |
||||
|
||||
private static final int MIN_VALUE = 1; |
||||
|
||||
private static final int MAX_VALUE = 999; |
||||
|
||||
private static final int STEP = 1; |
||||
|
||||
private static final int DEFAULT_VALUE = 5; |
||||
|
||||
public static final String SETTING = "SETTING"; |
||||
|
||||
public static final String PROCESS = "PROCESS"; |
||||
|
||||
public static final String SUCCESS = "SUCCESS"; |
||||
|
||||
public static final String FAILED = "FAILED"; |
||||
|
||||
public static boolean moving = false; |
||||
private UILabel vcsUpdateExistLabel; |
||||
private UILabel vcsUpdateFireLabel; |
||||
private BasicPane choosePane; |
||||
private CardLayout parentCard; |
||||
private JPanel parentPane; |
||||
private static final JProgressBar PROGRESS_BAR = new JProgressBar(); |
||||
|
||||
private JPanel progressPanel; |
||||
private UILabel tipLabel; |
||||
private UIButton successButton; |
||||
private UILabel iconLabel; |
||||
private UILabel successLabel; |
||||
private UILabel successTipLabel; |
||||
private UIButton failedButton; |
||||
private UILabel failedIconLabel; |
||||
private UILabel failedLabel; |
||||
private UILabel failedTipLabel; |
||||
|
||||
//保留全部
|
||||
private UIRadioButton moveAllButton; |
||||
//默认选项,保留部分
|
||||
private UIRadioButton moveDefaultButton; |
||||
//全部放弃
|
||||
private UIRadioButton moveNothingButton; |
||||
|
||||
private UISpinner spinner; |
||||
|
||||
private MoveCallBack callBack; |
||||
|
||||
private JPanel updatePane; |
||||
|
||||
private boolean visible = false; |
||||
|
||||
|
||||
public VcsMovePanel(CardLayout cardLayout, JPanel parentPane, MoveCallBack callBack) { |
||||
this.parentCard = cardLayout; |
||||
this.parentPane = parentPane; |
||||
this.callBack = callBack; |
||||
this.setLayout(new BorderLayout()); |
||||
updatePane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(); |
||||
updatePane.setBackground(BACK_GROUND_COLOR); |
||||
//初始化迁移的面板
|
||||
initVcsLabel(updatePane); |
||||
//initVcsChoosePane
|
||||
initVcsChoosePane(); |
||||
//初始化listener
|
||||
initListener(); |
||||
this.add(updatePane); |
||||
checkVisible(); |
||||
//如果已经在迁移
|
||||
if (VcsMoveService.getInstance().isMoving()) { |
||||
initProcessPane(); |
||||
VcsMovePanel.this.getParentCard().show(getParentPane(), PROCESS); |
||||
} |
||||
} |
||||
|
||||
private void checkVisible() { |
||||
new SwingWorker<Boolean, Void>() { |
||||
@Override |
||||
protected Boolean doInBackground() throws Exception { |
||||
return VcsHelper.getInstance().checkMoveFunctionSupport(); |
||||
} |
||||
@Override |
||||
protected void done() { |
||||
try { |
||||
boolean useMove = get(); |
||||
VcsMovePanel.this.setVisible(useMove); |
||||
} catch (InterruptedException | ExecutionException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
}.execute(); |
||||
} |
||||
|
||||
private void initProcessPane() { |
||||
JPanel processPane = new JPanel(); |
||||
JPanel body = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); |
||||
PROGRESS_BAR.setStringPainted(true); |
||||
PROGRESS_BAR.setUI(new ModernUIProgressBarUI()); |
||||
PROGRESS_BAR.setBorderPainted(false); |
||||
PROGRESS_BAR.setOpaque(false); |
||||
PROGRESS_BAR.setBorder(null); |
||||
PROGRESS_BAR.setSize(BasicDialog.MEDIUM); |
||||
body.add(PROGRESS_BAR); |
||||
body.add(new UILabel(StringUtils.BLANK)); |
||||
tipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_While_Moving")); |
||||
tipLabel.setAlignmentX(CENTER_ALIGNMENT); |
||||
body.add(tipLabel); |
||||
processPane.add(body); |
||||
processPane.setLayout(FRGUIPaneFactory.createCenterLayout(body, 0.5f, 0.5f)); |
||||
parentPane.add(processPane, PROCESS); |
||||
} |
||||
|
||||
private void initVcsChoosePane() { |
||||
choosePane = new BasicPane() { |
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return Toolkit.i18nText("Fine-Design_Vcs_Deal_With_Entry"); |
||||
} |
||||
}; |
||||
VerticalFlowLayout layout = new VerticalFlowLayout(VerticalFlowLayout.TOP); |
||||
layout.setAlignLeft(true); |
||||
choosePane.setLayout(layout); |
||||
|
||||
//初始化上方的文字板块
|
||||
initTopDesc(); |
||||
//初始化中间区域的单选框
|
||||
initRadioButton(); |
||||
//初始化下方的Tip描述
|
||||
initTipDesc(); |
||||
} |
||||
|
||||
private void initTopDesc() { |
||||
UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_How_To_Deal_With_Entry")); |
||||
choosePane.add(label); |
||||
} |
||||
|
||||
private void initTipDesc() { |
||||
UILabel descLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Desc")); |
||||
descLabel.setForeground(TIP_COLOR); |
||||
choosePane.add(descLabel); |
||||
} |
||||
|
||||
private void initRadioButton() { |
||||
//保留全部
|
||||
moveAllButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Vcs_Move_All")); |
||||
//默认选项,保留部分
|
||||
moveDefaultButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Vcs_Move_Default")); |
||||
//全部放弃
|
||||
moveNothingButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Vcs_Move_Nothing")); |
||||
// 将按钮"保留部分"设置为选中状态
|
||||
moveDefaultButton.setSelected(true); |
||||
// 创建一个按钮组,添加三个按钮
|
||||
ButtonGroup buttonGroup = new ButtonGroup(); |
||||
buttonGroup.add(moveAllButton); |
||||
buttonGroup.add(moveDefaultButton); |
||||
buttonGroup.add(moveNothingButton); |
||||
|
||||
JPanel moveDefaultPanel = new JPanel(); |
||||
JPanel moveAllPane = new JPanel(); |
||||
JPanel moveNothingPane = new JPanel(); |
||||
moveAllPane.add(moveAllButton); |
||||
moveDefaultPanel.add(moveDefaultButton); |
||||
moveDefaultPanel.add(new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Default_Text_Left"))); |
||||
spinner = new UISpinner(MIN_VALUE, MAX_VALUE, STEP, DEFAULT_VALUE); |
||||
moveDefaultPanel.add(spinner); |
||||
moveDefaultPanel.add(new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Default_Text_Right"))); |
||||
moveNothingPane.add(moveNothingButton); |
||||
choosePane.add(moveAllPane); |
||||
choosePane.add(moveDefaultPanel); |
||||
choosePane.add(moveNothingPane); |
||||
} |
||||
|
||||
private void initVcsLabel(JPanel parent) { |
||||
vcsUpdateExistLabel = new UILabel(IconUtils.readIcon("/com/fr/design/vcs/vcs_move_icon.svg")); |
||||
vcsUpdateExistLabel.setText(Toolkit.i18nText("Fine-Design_Vcs_Can_Update")); |
||||
vcsUpdateFireLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Update")); |
||||
vcsUpdateFireLabel.setForeground(LABEL_COLOR); |
||||
vcsUpdateFireLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
||||
parent.add(vcsUpdateExistLabel); |
||||
parent.add(vcsUpdateFireLabel); |
||||
} |
||||
|
||||
private void initListener() { |
||||
vcsUpdateFireLabel.addMouseListener(new MouseAdapter() { |
||||
@Override |
||||
public void mouseClicked(MouseEvent e) { |
||||
BasicDialog dlg = choosePane.showMediumWindow(SwingUtilities.getWindowAncestor(VcsMovePanel.this), new DialogActionAdapter() { |
||||
@Override |
||||
public void doOk() { |
||||
//进度条面板
|
||||
initProcessPane(); |
||||
VcsMovePanel.this.getParentCard().next(getParentPane()); |
||||
VcsMoveStrategy strategy; |
||||
if (moveDefaultButton.isSelected()) { |
||||
strategy = VcsMoveStrategy.createNumStrategy((int) spinner.getValue()); |
||||
} else if (moveNothingButton.isSelected()) { |
||||
strategy = VcsMoveStrategy.ALL_GIVE_UP; |
||||
} else { |
||||
strategy = VcsMoveStrategy.ALL_RETAIN; |
||||
} |
||||
new MoveWorker(strategy).execute(); |
||||
} |
||||
}); |
||||
dlg.setVisible(true); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void initSuccessPane() { |
||||
JPanel successPane = new JPanel(); |
||||
JPanel body = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); |
||||
successButton = new UIButton(Toolkit.i18nText("Fine-Design_Vcs_Move_Success_Go")); |
||||
initSuccessButtonListener(); |
||||
iconLabel = new UILabel(IconUtils.readIcon("/com/fr/design/vcs/move_success.svg")); |
||||
successLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Success")); |
||||
successLabel.setFont(FONT); |
||||
successTipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Success_Tip")); |
||||
initStatusPane(successTipLabel, iconLabel, successLabel, successButton, body, SUCCESS, successPane); |
||||
} |
||||
|
||||
private void initSuccessButtonListener() { |
||||
successButton.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
doAfterMove(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void initFailedButtonListener() { |
||||
failedButton.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
doAfterMove(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void doAfterMove() { |
||||
visible = !VcsHelper.getInstance().isLegacyMode(); |
||||
updatePane.setVisible(!visible); |
||||
callBack.doCallBack(visible); |
||||
parentCard.show(parentPane, SETTING); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
|
||||
public CardLayout getParentCard() { |
||||
return parentCard; |
||||
} |
||||
|
||||
public JPanel getParentPane() { |
||||
return parentPane; |
||||
} |
||||
|
||||
private void initFailedPane() { |
||||
JPanel failedPane = new JPanel(); |
||||
JPanel body = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); |
||||
failedButton = new UIButton(Toolkit.i18nText("Fine-Design_Vcs_Move_Failed_Go")); |
||||
initFailedButtonListener(); |
||||
failedIconLabel = new UILabel(IconUtils.readIcon("/com/fr/design/vcs/move_failed.svg")); |
||||
failedLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Failed")); |
||||
failedLabel.setFont(FONT); |
||||
failedTipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Failed_Tip")); |
||||
initStatusPane(failedTipLabel, failedIconLabel, failedLabel, failedButton, body, FAILED, failedPane); |
||||
} |
||||
|
||||
private void initStatusPane(UILabel tipLabel, UILabel iconLabel, UILabel label, UIButton button, JPanel body, String tag,JPanel statusPane) { |
||||
tipLabel.setForeground(TIP_COLOR); |
||||
body.add(iconLabel); |
||||
body.add(new UILabel(StringUtils.BLANK)); |
||||
body.add(label); |
||||
body.add(new UILabel(StringUtils.BLANK)); |
||||
body.add(tipLabel); |
||||
body.add(new UILabel(StringUtils.BLANK)); |
||||
body.add(button); |
||||
statusPane.add(body); |
||||
statusPane.setLayout(FRGUIPaneFactory.createCenterLayout(body, 0.5f, 0.5f)); |
||||
parentPane.add(statusPane, tag); |
||||
iconLabel.setAlignmentX(CENTER_ALIGNMENT); |
||||
label.setAlignmentX(CENTER_ALIGNMENT); |
||||
button.setAlignmentX(CENTER_ALIGNMENT); |
||||
tipLabel.setAlignmentX(CENTER_ALIGNMENT); |
||||
} |
||||
|
||||
|
||||
private class MoveWorker extends SwingWorker<Void, Integer> { |
||||
|
||||
private VcsMoveStrategy strategy; |
||||
|
||||
public MoveWorker(VcsMoveStrategy strategy) { |
||||
this.strategy = strategy; |
||||
} |
||||
|
||||
@Override |
||||
protected Void doInBackground() throws Exception { |
||||
try { |
||||
//开始迁移
|
||||
VcsMoveService.getInstance().startMove(new VcsMoveService.BaseMoveServiceWhileMoving() { |
||||
@Override |
||||
public void publishProgress() { |
||||
int num = VcsMoveService.getInstance().getCurrentMove(); |
||||
publish(num); |
||||
} |
||||
@Override |
||||
public void prepare4Move() { |
||||
PROGRESS_BAR.setMaximum(VcsMoveService.getInstance().getTotal()); |
||||
} |
||||
}, strategy); |
||||
} catch (Exception e) { |
||||
this.cancel(true); |
||||
VcsMoveService.getInstance().stopMoving(); |
||||
initFailedPane(); |
||||
VcsMovePanel.this.getParentCard().show(getParentPane(), FAILED); |
||||
FineLoggerFactory.getLogger().error("[VcsV2] Vcs move failed!"); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
protected void process(List<Integer> chunks) { |
||||
PROGRESS_BAR.setValue(chunks.get(chunks.size() - 1)); |
||||
} |
||||
|
||||
@Override |
||||
protected void done() { |
||||
VcsMoveService.getInstance().stopMoving(); |
||||
initSuccessPane(); |
||||
VcsMovePanel.this.getParentCard().show(getParentPane(), SUCCESS); |
||||
VcsHelper.getInstance().updateLegacyMode(); |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 迁移回调事件 |
||||
* |
||||
*/ |
||||
public static class MoveCallBack { |
||||
/** |
||||
* 处理回调 |
||||
*/ |
||||
public void doCallBack(boolean visible){} |
||||
} |
||||
|
||||
} |
After Width: | Height: | Size: 549 B |
After Width: | Height: | Size: 533 B |
Loading…
Reference in new issue