Destiny.Lin
1 year ago
5 changed files with 162 additions and 7 deletions
@ -0,0 +1,119 @@ |
|||||||
|
package com.fr.design.mainframe.vcs.ui; |
||||||
|
|
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.design.gui.frpane.UITabbedPane; |
||||||
|
import com.fr.design.gui.ibutton.UIButton; |
||||||
|
import com.fr.design.gui.icontainer.UIScrollPane; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
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.transaction.Configurations; |
||||||
|
import com.fr.transaction.WorkerAdaptor; |
||||||
|
import com.fr.workspace.WorkContext; |
||||||
|
import com.fr.workspace.server.vcs.VcsConfig; |
||||||
|
import com.fr.workspace.server.vcs.v2.scheduler.VcsAutoCleanOperator; |
||||||
|
import com.fr.workspace.server.vcs.v2.scheduler.VcsAutoCleanService; |
||||||
|
import com.fr.workspace.server.vcs.v2.scheduler.VcsAutoRecycleSchedule; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
import javax.swing.ScrollPaneConstants; |
||||||
|
import javax.swing.border.EmptyBorder; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 回收站配置面板 |
||||||
|
* |
||||||
|
* @author Destiny.Lin |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2023/7/21 |
||||||
|
*/ |
||||||
|
public class RecycleSettingPane extends BasicPane { |
||||||
|
|
||||||
|
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 = 30; |
||||||
|
|
||||||
|
private UISpinner spinner; |
||||||
|
|
||||||
|
private UIButton button; |
||||||
|
|
||||||
|
public RecycleSettingPane() { |
||||||
|
init(); |
||||||
|
} |
||||||
|
|
||||||
|
private void init() { |
||||||
|
|
||||||
|
this.setLayout(new BorderLayout()); |
||||||
|
UITabbedPane tabbedPane = new UITabbedPane(); |
||||||
|
//回收站内容
|
||||||
|
JPanel recyclePane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); |
||||||
|
UIScrollPane recycleScrollPane = patchScroll(recyclePane); |
||||||
|
tabbedPane.addTab(Toolkit.i18nText("Fine-Design_Vcs_Recycle_Content"), recycleScrollPane); |
||||||
|
recyclePane.add(new RecyclePane()); |
||||||
|
//通用设置
|
||||||
|
JPanel settingPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); |
||||||
|
UIScrollPane settingScrollPane = patchScroll(settingPane); |
||||||
|
tabbedPane.addTab(Toolkit.i18nText("Fine-Design_Basic_Carton_General_Settings"), settingScrollPane); |
||||||
|
settingPane.add(createSchedulePane()); |
||||||
|
this.add(tabbedPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createSchedulePane() { |
||||||
|
JPanel schedulePane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, VerticalFlowLayout.TOP, 0, 0); |
||||||
|
JPanel spinnerPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane_First0(); |
||||||
|
JPanel buttonPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane_First0(); |
||||||
|
spinnerPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Recycle_Schedule"))); |
||||||
|
spinner = new UISpinner(MIN_VALUE, MAX_VALUE, STEP, DEFAULT_VALUE); |
||||||
|
spinner.setValue(VcsConfig.getInstance().getV2CleanRecycleInterval()); |
||||||
|
spinnerPane.add(spinner); |
||||||
|
spinnerPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Recycle_Schedule_Day"))); |
||||||
|
schedulePane.add(spinnerPane); |
||||||
|
button = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Save")); |
||||||
|
initButtonListener(); |
||||||
|
buttonPane.add(button); |
||||||
|
schedulePane.add(buttonPane); |
||||||
|
return schedulePane; |
||||||
|
} |
||||||
|
|
||||||
|
private void initButtonListener() { |
||||||
|
button.addActionListener(new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
new Thread(() -> { |
||||||
|
Configurations.update(new WorkerAdaptor(VcsConfig.class) { |
||||||
|
@Override |
||||||
|
public void run() { |
||||||
|
VcsConfig.getInstance().setV2CleanRecycleInterval((int) spinner.getValue()); |
||||||
|
} |
||||||
|
}); |
||||||
|
WorkContext.getCurrent().get(VcsAutoCleanOperator.class).addOrUpdateVcsAutoCleanJob( |
||||||
|
VcsAutoCleanService.VCS_AUTO_CLEAN_RECYCLE_JOB_NAME, |
||||||
|
1, |
||||||
|
VcsAutoRecycleSchedule.class); |
||||||
|
}).start(); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private UIScrollPane patchScroll(JPanel generalPane) { |
||||||
|
UIScrollPane generalPanelWithScroll = new UIScrollPane(generalPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); |
||||||
|
generalPanelWithScroll.setBorder(new EmptyBorder(0, 0, 0, 0)); |
||||||
|
return generalPanelWithScroll; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return Toolkit.i18nText("Fine-Design_Vcs_Recycle"); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue