diff --git a/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java b/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java index 75626441bf..5b77b9571a 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java +++ b/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java @@ -75,6 +75,26 @@ public abstract class BasicPane extends JPanel { return dg; } + /** + * 显示小窗口并允许自定义需不需要按钮 + * + * @param window 窗口 + * @param isNeedButtonsPane 是否需要确定删除按钮 + * @return 对话框 + */ + public BasicDialog showSmallWindow(Window window, boolean isNeedButtonsPane) { + BasicDialog dg; + if (window instanceof Frame) { + dg = new DIALOG((Frame) window, isNeedButtonsPane); + } else { + dg = new DIALOG((Dialog) window, isNeedButtonsPane); + } + dg.setBasicDialogSize(BasicDialog.SMALL); + GUICoreUtils.centerWindow(dg); + dg.setResizable(false); + return dg; + } + /** * 图表类型选择时 弹出的按钮大小, 不适合用最大最小, 因为图表大小 默认是规定好的, 那么界面大小也是必须配合. diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java index a3af0ea8fa..d730c69d35 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java @@ -18,7 +18,6 @@ import com.fr.design.lock.LockInfoDialog; import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager; import com.fr.design.mainframe.manager.search.searcher.control.pane.TemplateSearchRemindPane; -import com.fr.design.mainframe.vcs.VcsService; import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.file.FILE; import com.fr.file.FileNodeFILE; @@ -65,6 +64,7 @@ import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; +import com.fr.workspace.server.vcs.VcsOperator; import org.jetbrains.annotations.Nullable; @@ -407,7 +407,9 @@ public class TemplateTreePane extends JPanel implements FileOperations { if (node instanceof FileNode) { FileNodeFILE nodeFILE = new FileNodeFILE((FileNode) node); if (nodeFILE.exists()) { - VcsService.getInstance().doRecycle(VcsHelper.getInstance().dealWithFilePath(((FileNode) node).getEnvPath())); + WorkContext.getCurrent().get(VcsOperator.class).recycleVersion( + VcsHelper.getInstance().getCurrentUsername(), + VcsHelper.getInstance().dealWithFilePath(((FileNode) node).getEnvPath())); if (TemplateResourceManager.getResource().delete(nodeFILE)) { HistoryTemplateListCache.getInstance().deleteFile(nodeFILE); } else { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsOperatorWorker.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsOperatorWorker.java new file mode 100644 index 0000000000..b59ac3c128 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsOperatorWorker.java @@ -0,0 +1,291 @@ +package com.fr.design.mainframe.vcs; + +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.vcs.ui.VcsBatchProcessDetailPane; +import com.fr.design.mainframe.vcs.ui.VcsProgressDialog; +import com.fr.log.FineLoggerFactory; +import com.fr.report.entity.VcsEntity; +import com.fr.stable.StringUtils; +import com.fr.workspace.WorkContext; +import com.fr.workspace.server.vcs.VcsOperator; + +import javax.swing.SwingWorker; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +/** + * 为版本中心、回收站、版本详情提供带进度条与结算面板的操作的worker + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2023/7/18 + */ +public class VcsOperatorWorker { + private int count = 0; + + private static final int FREQ = 5; + + private String successStr; + + private String title; + + private String failedStr; + + private String everyFailedStr; + + private VcsProgressDialog dialog; + + + private static final String PREFIX = "(v."; + private static final String TAIL = ")"; + + public VcsOperatorWorker(String title, String dealingStr, String successStr, String failedStr, String everyFailedStr) { + this.title = title; + this.successStr = successStr; + this.failedStr = failedStr; + this.everyFailedStr = everyFailedStr; + dialog = new VcsProgressDialog(title, dealingStr); + } + + public VcsOperatorWorker(String everyFailedStr) { + this.title = StringUtils.EMPTY; + this.successStr = StringUtils.EMPTY; + this.failedStr = StringUtils.EMPTY; + this.everyFailedStr = everyFailedStr; + } + + /** + * 快速创建用于删除的worker + * + * @return + */ + public static VcsOperatorWorker createDeleteWorker() { + return new VcsOperatorWorker( + Toolkit.i18nText("Fine-Design_Vcs_Delete_Progress_Title"), + Toolkit.i18nText("Fine-Design_Vcs_Delete_Progress_Tips"), + Toolkit.i18nText("Fine-Design_Vcs_Delete_Progress_Success"), + "Fine-Design_Vcs_Delete_Progress_Failed", + Toolkit.i18nText("Fine-Design_Vcs_Delete_Every_Failed")); + } + + + /** + * 快速创建用于还原的worker + * + * @return + */ + public static VcsOperatorWorker createRestoreWorker() { + return new VcsOperatorWorker( + Toolkit.i18nText("Fine-Design_Vcs_Restore_Progress_Title"), + Toolkit.i18nText("Fine-Design_Vcs_Restore_Progress_Tips"), + Toolkit.i18nText("Fine-Design_Vcs_Restore_Progress_Success"), + "Fine-Design_Vcs_Restore_Progress_Failed", + Toolkit.i18nText("Fine-Design_Vcs_Restore_Every_Failed")); + } + + + /** + * 快速创建用于还原的worker + * + * @return + */ + public static VcsOperatorWorker createUpdateWorker() { + return new VcsOperatorWorker(Toolkit.i18nText("Fine-Design_Vcs_Update_Every_Failed")); + } + + + /** + * 批量还原 + * + * @param vcsEntities 需要还原的版本 + */ + public void batchRestore(List vcsEntities) { + List failedList = new ArrayList<>(); + startProcess(vcsEntities, failedList, (vcsEntity, operator) -> { + String fileName = vcsEntity.getFilename(); + boolean result = true; + try { + operator.restoreVersion(fileName); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + result = false; + } + if (!result) { + failedList.add(fileName+PREFIX+vcsEntity.getVersion()+TAIL); + } + }); + } + + + /** + * 批量删除 + * + * @param vcsEntities 需要删除的版本 + * @param all 是否需要删除所有版本 + */ + public void batchDelete(List vcsEntities, boolean all) { + List failedList = new ArrayList<>(); + startProcess(vcsEntities, failedList, (vcsEntity, operator) -> { + String fileName = vcsEntity.getFilename(); + boolean result = true; + try { + if (all) { + operator.deleteVersionForRecycle(fileName); + } else { + operator.deleteVersion(fileName, vcsEntity.getVersion()); + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + result = false; + } + if (!result) { + failedList.add(fileName+PREFIX+vcsEntity.getVersion()+TAIL); + } + }); + } + + + /** + * 删除指定模板的全部历史版本 + * + * @param entity VcsEntity + */ + public void doDelete(VcsEntity entity) { + String fileName = entity.getFilename(); + start4Single(entity, (vcsEntity, operator) -> operator.deleteVersionForRecycle(fileName), fileName + everyFailedStr); + } + + /** + * 删除指定模板的指定版本 + * + * @param entity 版本 + */ + public void deleteTargetVersion(VcsEntity entity) { + String fileName = entity.getFilename(); + int version = entity.getVersion(); + start4Single(entity, (vcsEntity, operator) -> { + operator.deleteVersion(fileName, version); + }, fileName + everyFailedStr); + } + + + /** + * 更新版本 + * + * @param entity 版本 + */ + public void updateEntityAnnotation(VcsEntity entity) { + start4Single(entity, (vcsEntity, operator) -> { + operator.updateVersion(entity); + }, everyFailedStr); + } + + private void startProcess(List vcsEntities, List failedList, VcsWorkerOperator workerOperator) { + try { + dialog.getProgressBar().setMaximum(vcsEntities.size()); + start4Batch(vcsEntities, failedList, workerOperator); + dialog.showDialog(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + + /** + * 控制更新频率 + * + * @return 是否需要更新进度 + */ + private boolean needPublish() { + return (count > FREQ && count % FREQ == 0) || count < FREQ; + } + + private void start4Single(VcsEntity entity, VcsWorkerOperator vcsWorkerOperator, String failedTip) { + new SwingWorker() { + @Override + protected void done() { + try { + if (!get()) { + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), failedTip); + } + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + } + @Override + protected Boolean doInBackground() throws Exception { + try { + VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class); + vcsWorkerOperator.process(entity, operator); + } catch (Exception e) { + return false; + } + return true; + } + }.execute(); + } + + private void start4Batch(List vcsEntities, List failedList, VcsWorkerOperator workerOperator) { + new SwingWorker() { + @Override + protected Boolean doInBackground() throws Exception { + VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class); + for (VcsEntity vcsEntity : vcsEntities) { + workerOperator.process(vcsEntity, operator); + count++; + if (needPublish()) { + publish(count); + } + } + return failedList.isEmpty(); + } + @Override + protected void process(List chunks) { + dialog.getProgressBar().setValue(chunks.get(chunks.size() - 1)); + } + @Override + protected void done() { + dialog.closeDialog(); + try { + showErrorDetailPane(get(), failedList, failedList.size(), vcsEntities.size() - failedList.size()); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + } + }.execute(); + } + + + private void showErrorDetailPane(boolean result, List failedList, int failed, int success) { + if (result) { + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), successStr); + } else { + VcsBatchProcessDetailPane pane = new VcsBatchProcessDetailPane( + DesignerContext.getDesignerFrame(), + title, + Toolkit.i18nText(failedStr, failed, success) + ); + for (String msg : failedList) { + pane.updateDetailArea(msg + everyFailedStr); + } + pane.show(); + } + } + + /** + * Vcs面板操作处理接口 + * + */ + private interface VcsWorkerOperator { + + /** + * 处理 + * + * @param vcsEntity 版本 + * @param operator 操作类 + */ + void process(VcsEntity vcsEntity, VcsOperator operator) throws Exception; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsService.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsService.java deleted file mode 100644 index e83b0212e9..0000000000 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsService.java +++ /dev/null @@ -1,162 +0,0 @@ -package com.fr.design.mainframe.vcs; - -import com.fr.concurrent.NamedThreadFactory; -import com.fr.design.mainframe.vcs.common.VcsHelper; -import com.fr.log.FineLoggerFactory; -import com.fr.report.entity.VcsEntity; -import com.fr.workspace.WorkContext; -import com.fr.workspace.server.vcs.VcsOperator; - -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -/** - * 版本管理常用操作 - *

便于版本管理面板快捷实现版本管理相关操作 - * - * @author Destiny.Lin - * @since 11.0 - * Created on 2023/7/10 - */ -public class VcsService { - - private static final String SERVICE = "VcsService"; - private static final VcsService INSTANCE = new VcsService(); - - private static final ExecutorService executorService = Executors.newFixedThreadPool(5, new NamedThreadFactory(SERVICE)); - - /** - * 获取单例 - * - * @return - */ - public static VcsService getInstance() { - return INSTANCE; - } - - private VcsService() { - } - - /** - * 回收模板 - * - * @param filename - */ - public void doRecycle(String filename) { - try { - WorkContext.getCurrent().get(VcsOperator.class).recycleVersion(VcsHelper.getInstance().getCurrentUsername(), filename); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - - - /** - * 从回收站还原版本 - * - * @param vcsEntities - */ - public void doRestore(List vcsEntities) { - try { - executorService.execute(new Runnable() { - @Override - public void run() { - VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class); - for (VcsEntity vcsEntity : vcsEntities) { - String fileName = vcsEntity.getFilename(); - operator.restoreVersion(fileName); - } - } - }); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - - - /** - * 删除对应列表中所有模板的指定的历史版本 - * - * @param vcsEntities - */ - public void doDelete(List vcsEntities, boolean all) { - try { - executorService.execute(new Runnable() { - @Override - public void run() { - VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class); - for (VcsEntity vcsEntity : vcsEntities) { - String fileName = vcsEntity.getFilename(); - if (all) { - operator.deleteVersionForRecycle(fileName); - } else { - operator.deleteVersion(fileName, vcsEntity.getVersion()); - } - } - } - }); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - - /** - * 删除指定模板的全部历史版本 - * - * @param entity VcsEntity - */ - public void deleteEntity(VcsEntity entity) { - try { - executorService.execute(new Runnable() { - @Override - public void run() { - VcsOperator vcsOperator = WorkContext.getCurrent().get(VcsOperator.class); - String fileName = entity.getFilename(); - vcsOperator.deleteVersionForRecycle(fileName); - } - }); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - - /** - * 删除指定模板的指定版本 - * - * @param fileName 文件名 - * @param version 版本号 - */ - public void deleteEntity(String fileName, int version) { - try { - executorService.execute(new Runnable() { - @Override - public void run() { - VcsOperator vcsOperator = WorkContext.getCurrent().get(VcsOperator.class); - vcsOperator.deleteVersion(fileName, version); - } - }); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - - /** - * 更新版本 - * - * @param entity 版本 - */ - public void updateEntityAnnotation(VcsEntity entity) { - try { - executorService.execute(new Runnable() { - @Override - public void run() { - VcsOperator vcsOperator = WorkContext.getCurrent().get(VcsOperator.class); - vcsOperator.updateVersion(entity); - } - }); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } -} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/RecyclePane.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/RecyclePane.java index e829318174..594e0c1722 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/RecyclePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/RecyclePane.java @@ -5,7 +5,7 @@ import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; -import com.fr.design.mainframe.vcs.VcsService; +import com.fr.design.mainframe.vcs.VcsOperatorWorker; import com.fr.design.mainframe.vcs.TableEntity; import com.fr.design.mainframe.vcs.TableValueOperator; import com.fr.design.mainframe.vcs.VcsTableEntity; @@ -134,7 +134,7 @@ public class RecyclePane extends AbstractSupportSelectTablePane fireListener(new VcsResponseListener() { @Override public void doAfterChooseYes(List selectList) { - VcsService.getInstance().doDelete(selectList, isNeedDeleteAllVersion()); + VcsOperatorWorker.createDeleteWorker().batchDelete(selectList, isNeedDeleteAllVersion()); } }, true); } @@ -150,7 +150,7 @@ public class RecyclePane extends AbstractSupportSelectTablePane fireListener(new VcsResponseListener() { @Override public void doAfterChooseYes(List selectList) { - VcsService.getInstance().doRestore(selectList); + VcsOperatorWorker.createRestoreWorker().batchRestore(selectList); } }, false); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsBatchProcessDetailPane.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsBatchProcessDetailPane.java new file mode 100644 index 0000000000..4421b7f301 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsBatchProcessDetailPane.java @@ -0,0 +1,156 @@ +package com.fr.design.mainframe.vcs.ui; + +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.*; +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/7/19 + */ +public class VcsBatchProcessDetailPane { + + 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 VcsBatchProcessDetailPane(Frame parent, String title, String msg) { + init(parent, title, msg); + } + + private void init(Frame parent, String title, String msg) { + message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0)); + message.setText(msg); + dialog = new JDialog(parent, title, 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(); + } + }); + } + + + /** + * 显示面板 + */ + public void show() { + dialog.setVisible(true); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCenterPane.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCenterPane.java index 0da23fa3dd..d559b26191 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCenterPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCenterPane.java @@ -6,7 +6,7 @@ import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.vcs.VcsService; +import com.fr.design.mainframe.vcs.VcsOperatorWorker; import com.fr.design.mainframe.vcs.VcsTableEntity; import com.fr.file.FileNodeFILE; @@ -111,7 +111,7 @@ public class VcsCenterPane extends VcsNewPane { JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (selVal == JOptionPane.YES_OPTION) { - VcsService.getInstance().deleteEntity(entity); + VcsOperatorWorker.createDeleteWorker().doDelete(entity); } DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(getTemplateTruePath(fileName), false))); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java index 0916062ccb..e7d7af7e0e 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java @@ -9,7 +9,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.vcs.TableValueOperator; -import com.fr.design.mainframe.vcs.VcsService; +import com.fr.design.mainframe.vcs.VcsOperatorWorker; import com.fr.design.mainframe.vcs.VcsTableEntity; import com.fr.design.mainframe.vcs.common.VcsCacheFileNodeFile; import com.fr.design.mainframe.vcs.common.VcsHelper; @@ -209,7 +209,7 @@ public class VcsNewPane extends RecyclePane { if (selVal == JOptionPane.YES_OPTION) { model.getList().remove(o); model.fireTableDataChanged(); - VcsService.getInstance().deleteEntity(entity.getFilename(), entity.getVersion()); + VcsOperatorWorker.createDeleteWorker().deleteTargetVersion(entity); } } } @@ -329,7 +329,7 @@ public class VcsNewPane extends RecyclePane { @Override public void doOK() { entity.setCommitMsg(getMsgTestArea().getText()); - VcsService.getInstance().updateEntityAnnotation(entity); + VcsOperatorWorker.createUpdateWorker().updateEntityAnnotation(entity); setVisible(false); model.fireTableDataChanged(); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsProgressDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsProgressDialog.java new file mode 100644 index 0000000000..33b57e1f3e --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsProgressDialog.java @@ -0,0 +1,81 @@ +package com.fr.design.mainframe.vcs.ui; + +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.iprogressbar.ModernUIProgressBarUI; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DesignerContext; +import com.fr.stable.StringUtils; + +import javax.swing.JPanel; +import javax.swing.JProgressBar; + +import static java.awt.Component.CENTER_ALIGNMENT; + +/** + * Vcs操作进度条面板 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2023/7/18 + */ +public class VcsProgressDialog{ + private JProgressBar progressBar = new JProgressBar(); + private UILabel tipLabel; + private BasicPane processPane; + + private BasicDialog dialog; + + public VcsProgressDialog(String title, String dealingStr) { + + processPane = new BasicPane() { + @Override + protected String title4PopupWindow() { + return title; + } + }; + JPanel body = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); + progressBar.setStringPainted(true); + progressBar.setUI(new ModernUIProgressBarUI()); + progressBar.setBorderPainted(false); + progressBar.setOpaque(false); + progressBar.setBorder(null); + progressBar.setSize(BasicDialog.MEDIUM); + progressBar.setValue(0); + body.add(progressBar); + body.add(new UILabel(StringUtils.BLANK)); + tipLabel = new UILabel(dealingStr); + tipLabel.setAlignmentX(CENTER_ALIGNMENT); + body.add(tipLabel); + processPane.add(body); + processPane.setLayout(FRGUIPaneFactory.createCenterLayout(body, 0.5f, 0.5f)); + } + + + /** + * 展示面板 + * + */ + public void showDialog() { + dialog = processPane.showSmallWindow(DesignerContext.getDesignerFrame(), false); + dialog.setVisible(true); + } + + /** + * 关闭面板 + * + */ + public void closeDialog() { + dialog.setVisible(false); + } + + public JProgressBar getProgressBar() { + return progressBar; + } + + public void setProgressBar(JProgressBar progressBar) { + this.progressBar = progressBar; + } +}