Destiny.Lin
1 year ago
9 changed files with 560 additions and 172 deletions
@ -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<VcsEntity> vcsEntities) { |
||||
List<String> 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<VcsEntity> vcsEntities, boolean all) { |
||||
List<String> 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<VcsEntity> vcsEntities, List<String> 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<Boolean, Void>() { |
||||
@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<VcsEntity> vcsEntities, List<String> failedList, VcsWorkerOperator workerOperator) { |
||||
new SwingWorker<Boolean, Integer>() { |
||||
@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<Integer> 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<String> 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; |
||||
} |
||||
} |
@ -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; |
||||
|
||||
/** |
||||
* 版本管理常用操作 |
||||
* <p>便于版本管理面板快捷实现版本管理相关操作 |
||||
* |
||||
* @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<VcsEntity> 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<VcsEntity> 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); |
||||
} |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
Loading…
Reference in new issue