Browse Source

REPORT-14835

模板版本管理优化及内置 代码逻辑调整
research/10.0
XiaXiang 6 years ago
parent
commit
c446292250
  1. 36
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 50
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  3. 10
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  4. 17
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/VcsContext.java
  5. 16
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/Constants.java
  6. 4
      designer-base/src/main/java/com/fr/design/mainframe/vcs/proxy/VcsCacheFileNodeFile.java
  7. 79
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/EditFileVersionDialog.java
  8. 23
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java
  9. 8
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellRender.java
  10. 20
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java
  11. 3
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionFirstRowPanel.java
  12. 49
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionRowPanel.java
  13. 48
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionTable.java
  14. 40
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java
  15. 28
      designer-realize/src/main/java/com/fr/start/Designer.java

36
designer-base/src/main/java/com/fr/design/DesignerEnvManager.java

@ -130,6 +130,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private int westRegionContainerWidth = 240;
private String encryptionKey;
private String jdkHome;
private boolean vcsEnable;
private boolean saveCommit;
private int saveInterval;
//上一次登录弹窗的时间, 为了控制一天只弹一次窗口
private String lastShowBBSTime;
@ -1341,6 +1346,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
}
}
private void readJettyPort(XMLableReader reader) {
String tmpVal;
if ((tmpVal = reader.getElementValue()) != null) {
@ -1601,6 +1607,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.setDragPermited(reader.getAttrAsBoolean("isDragPermited", false));
this.setUndoLimit(reader.getAttrAsInt("undoLimit", 5));
this.setDefaultStringToFormula(reader.getAttrAsBoolean("defaultStringToFormula", false));
this.setVcsEnable(reader.getAttrAsBoolean("supportVcs", false));
this.setSaveCommit(reader.getAttrAsBoolean("saveCommit", false));
this.setSaveInterval(reader.getAttrAsInt("saveInterval", 60));
if ((tmpVal = reader.getAttrAsString("gridLineColor", null)) != null) {
this.setGridLineColor(new Color(Integer.parseInt(tmpVal)));
}
@ -1936,6 +1945,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
.attr("verticalScrollBarVisible", this.isVerticalScrollBarVisible())
.attr("horizontalScrollBarVisible", this.isHorizontalScrollBarVisible())
.attr("supportCellEditorDef", this.isSupportCellEditorDef())
.attr("supportVcs", this.isVcsEnable())
.attr("saveInterval", this.getSaveInterval())
.attr("saveCommit", this.isSaveCommit())
.attr("isDragPermited", this.isDragPermited())
.attr("gridLineColor", this.getGridLineColor().getRGB())
.attr("paginationLineColor", this.getPaginationLineColor().getRGB())
@ -1946,4 +1958,28 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private void writeDesignerPushUpdateAttr(XMLPrintWriter writer) {
this.designerPushUpdateConfigManager.writeXML(writer);
}
public boolean isVcsEnable() {
return vcsEnable;
}
public void setVcsEnable(boolean vcsEnable) {
this.vcsEnable = vcsEnable;
}
public boolean isSaveCommit() {
return saveCommit;
}
public void setSaveCommit(boolean saveCommit) {
this.saveCommit = saveCommit;
}
public int getSaveInterval() {
return saveInterval;
}
public void setSaveInterval(int saveInterval) {
this.saveInterval = saveInterval;
}
}

50
designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java

@ -1,5 +1,6 @@
package com.fr.design.actions.file;
import com.apple.laf.AquaProgressBarUI;
import com.fr.base.BaseUtils;
import com.fr.config.Configuration;
import com.fr.design.DesignerEnvManager;
@ -41,6 +42,8 @@ import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
@ -135,6 +138,12 @@ public class PreferencePane extends BasicPane {
private UICheckBox joinProductImproveCheckBox;
private UICheckBox autoPushUpdateCheckBox;
private UICheckBox vcsEnableCheckBox;
private UICheckBox saveCommitCheckBox;
private IntegerEditor saveIntervalEditor;
public PreferencePane() {
this.initComponents();
}
@ -155,6 +164,7 @@ public class PreferencePane extends BasicPane {
createEditPane(generalPane);
createGuiOfGridPane(generalPane);
createColorSettingPane(generalPane);
createVcsSettingPane(generalPane);
// ConfPane
JPanel confLocationPane = FRGUIPaneFactory.createX_AXISBoxInnerContainer_S_Pane();
@ -193,6 +203,36 @@ public class PreferencePane extends BasicPane {
advancePane.add(spaceUpPane);
}
private void createVcsSettingPane(JPanel generalPane) {
JPanel vcsPane = FRGUIPaneFactory.createVerticalTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("版本控制"));
generalPane.add(vcsPane);
vcsEnableCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("保存自动生成版本"));
saveCommitCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("备注版本不会自动清理"));
saveIntervalEditor = new IntegerEditor(30);
JPanel memorySpace = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
UILabel label1 = new UILabel(" 每 ");
UILabel label2 = new UILabel(" 分钟每个用户同个模板最多保留一个模板");
memorySpace.add(label1);
memorySpace.add(saveIntervalEditor);
memorySpace.add(label2);
vcsEnableCheckBox.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
boolean selected = vcsEnableCheckBox.isSelected();
if (selected) {
saveCommitCheckBox.setEnabled(true);
saveIntervalEditor.setEnabled(true);
} else {
saveCommitCheckBox.setEnabled(false);
saveIntervalEditor.setEnabled(false);
}
}
});
vcsPane.add(vcsEnableCheckBox);
vcsPane.add(memorySpace);
vcsPane.add(saveCommitCheckBox);
}
private void createFunctionPane(JPanel generalPane) {
JPanel functionPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Function"));
generalPane.add(functionPane);
@ -542,6 +582,13 @@ public class PreferencePane extends BasicPane {
defaultStringToFormulaBox.setEnabled(false);
defaultStringToFormulaBox.setSelected(false);
}
vcsEnableCheckBox.setSelected(designerEnvManager.isVcsEnable());
if (!vcsEnableCheckBox.isSelected()) {
saveIntervalEditor.setEnabled(false);
saveCommitCheckBox.setEnabled(false);
}
saveIntervalEditor.setValue(designerEnvManager.getSaveInterval());
saveCommitCheckBox.setSelected(designerEnvManager.isSaveCommit());
supportCellEditorDefCheckBox.setSelected(designerEnvManager.isSupportCellEditorDef());
@ -631,6 +678,9 @@ public class PreferencePane extends BasicPane {
designerEnvManager.setOracleSystemSpace(this.oracleSpace.isSelected());
designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue());
designerEnvManager.setJoinProductImprove(this.joinProductImproveCheckBox.isSelected());
designerEnvManager.setSaveInterval(this.saveIntervalEditor.getValue());
designerEnvManager.setVcsEnable(this.vcsEnableCheckBox.isSelected());
designerEnvManager.setSaveCommit(this.saveCommitCheckBox.isSelected());
if (this.autoPushUpdateCheckBox != null) {
designerEnvManager.setAutoPushUpdateEnabled(this.autoPushUpdateCheckBox.isSelected());
}

10
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

@ -26,7 +26,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.toolbar.VcsConfig;
import com.fr.design.mainframe.vcs.ui.FileVersionTable;
import com.fr.design.mainframe.vcs.ui.FileVersionsPanel;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.ShortCut;
@ -49,9 +49,8 @@ import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import com.fr.third.springframework.context.annotation.AnnotationConfigApplicationContext;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.common.Constants;
import com.fr.design.mainframe.vcs.common.Constants;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
@ -287,7 +286,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
*/
private class VcsAction extends UpdateAction {
public VcsAction() {
this.setName(Toolkit.i18nText("Plugin-VCS_Title"));
this.setName(Toolkit.i18nText("Fine-Design_Vcs_Title"));
this.setSmallIcon(Constants.VCS_LIST_PNG);
}
@ -305,8 +304,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
// 如果模板已经打开了,关掉,避免出现2个同名tab(1个是模板,1个是版本)
closeOpendTemplate(path, isCurrentEditing);
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(VcsConfig.class);
FileVersionsPanel fileVersionTablePanel = context.getBean(FileVersionsPanel.class);
FileVersionsPanel fileVersionTablePanel = FileVersionsPanel.getInstance();
fileVersionTablePanel.showFileVersionsPane();
}

17
designer-base/src/main/java/com/fr/design/mainframe/toolbar/VcsContext.java

@ -1,17 +0,0 @@
package com.fr.design.mainframe.toolbar;
import com.fr.third.springframework.context.annotation.AnnotationConfigApplicationContext;
/**
* Created by XiaXiang on 2019/4/20.
*/
public class VcsContext extends AnnotationConfigApplicationContext {
public static final VcsContext INSTANCE = new VcsContext();
public static VcsContext get() {
return INSTANCE;
}
}

16
designer-base/src/main/java/com/fr/design/mainframe/vcs/common/Constants.java

@ -1,7 +1,7 @@
package com.fr.workspace.server.vcs.common;
package com.fr.design.mainframe.vcs.common;
import com.fr.base.BaseUtils;
import com.fr.locale.InterProviderFactory;
import com.fr.design.i18n.Toolkit;
import com.fr.workspace.WorkContext;
import javax.swing.Icon;
@ -14,21 +14,14 @@ import static com.fr.stable.StableUtils.pathJoin;
public class Constants {
public final static String VCS_DIR = "vcs";
// 如果用其他方式实现vcs,未必需要这个cache
//TODO 要不要放到其他地方
public final static String VCS_CACHE_DIR = pathJoin(VCS_DIR, "cache");
public final static String CURRENT_USERSNAME = WorkContext.getCurrent().isLocal()
? InterProviderFactory.getProvider().getLocText("本地用户")
public final static String CURRENT_USERNAME = WorkContext.getCurrent().isLocal()
? Toolkit.i18nText("Fine-Design_Vcs_Local_User")
: WorkContext.getCurrent().getConnection().getUserName();
public final static Color TABLE_SELECT_BACKGROUND = new Color(0xD8F2FD);
public final static Color COPY_VERSION_BTN_COLOR = new Color(0x419BF9);
public final static Color DELETE_VERSION_BTN_COLOR = new Color(0xEB1D1F);
public final static EmptyBorder EMPTY_BORDER = new EmptyBorder(5, 10, 0, 10);
public final static EmptyBorder EMPTY_BORDER_BOTTOM = new EmptyBorder(10, 10, 10, 10);
@ -36,7 +29,6 @@ public class Constants {
public final static Icon VCS_LIST_PNG = BaseUtils.readIcon("/com/fr/design/mainframe/vcs/images/vcs_list.png");
public final static Icon VCS_BACK_PNG = BaseUtils.readIcon("/com/fr/design/mainframe/vcs/images/vcs_back.png");
public final static Icon VCS_SAVE_PNG = BaseUtils.readIcon("/com/fr/design/mainframe/vcs/images/vcs_save.png");
public final static Icon VCS_FILTER_PNG = BaseUtils.readIcon("/com/fr/design/mainframe/vcs/images/icon_filter@1x.png");
public final static Icon VCS_EDIT_PNG = BaseUtils.readIcon("/com/fr/design/mainframe/vcs/images/icon_edit.png");
public final static Icon VCS_DELETE_PNG = BaseUtils.readIcon("/com/fr/design/mainframe/vcs/images/icon_delete.png");

4
designer-base/src/main/java/com/fr/design/mainframe/vcs/proxy/VcsCacheFileNodeFile.java

@ -14,11 +14,11 @@ import java.io.InputStream;
import java.io.OutputStream;
public class VcsCacheFileNodeFileProxy extends FileNodeFILE {
public class VcsCacheFileNodeFile extends FileNodeFILE {
private final FileNode node;
public VcsCacheFileNodeFileProxy(FileNode node) {
public VcsCacheFileNodeFile(FileNode node) {
super(node);
this.node = node;
}

79
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/EditFileVersionDialog.java

@ -1,24 +1,18 @@
package com.fr.plugin.vcs.ui;
package com.fr.design.mainframe.vcs.ui;
import com.fr.design.dialog.UIDialog;
import com.fr.design.file.HistoryTemplateListPane;
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.itextarea.UITextArea;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import com.fr.plugin.vcs.Vcs;
import com.fr.plugin.vcs.common.proxy.VcsCacheFileNodeFileProxy;
import com.fr.stable.StringUtils;
import com.fr.third.guava.base.Preconditions;
import com.google.inject.Inject;
import com.fr.locale.InterProviderFactory;
import com.fr.report.ReportContext;
import com.fr.report.entity.VcsEntity;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FlowLayout;
@ -26,33 +20,29 @@ import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import static com.fr.plugin.vcs.common.CommonUtils.editingFilename;
import static com.fr.plugin.vcs.common.Constants.CURRENT_USERSNAME;
/**
* 保存保本时候弹出的对话框输入commit msg点确定保存版本
* Created by hzzz on 2017/12/11.
* 编辑版本信息面板
*/
public class SaveFileVersionDialog extends UIDialog {
public class EditFileVersionDialog extends UIDialog {
private final UITextArea msgTestArea = new UITextArea();
private final UILabel versionLabel = new UILabel();
private Vcs vcs;
private FileVersionTablePanel fileVersionTablePanel;
private VcsEntity entity;
@Inject
public SaveFileVersionDialog(FileVersionTablePanel fileVersionTablePanel, Vcs vcs) {
public EditFileVersionDialog(VcsEntity entity) {
this(DesignerContext.getDesignerFrame());
this.vcs = Preconditions.checkNotNull(vcs, "vcs is null");
this.fileVersionTablePanel = Preconditions.checkNotNull(fileVersionTablePanel, "fileVersionTablePanel is null");
this.entity = entity;
msgTestArea.setText(entity.getCommitMsg());
versionLabel.setText(String.valueOf(entity.getVersion()));
}
private SaveFileVersionDialog(Frame parent) {
private EditFileVersionDialog(Frame parent) {
super(parent);
initComponents();
setModal(true);
setTitle(Inter.getLocText("Plugin-VCS_Save_Version"));
setTitle(InterProviderFactory.getProvider().getLocText("Fine-Design_Vcs_Save_Version"));
setSize(300, 220);
setResizable(false);
GUICoreUtils.centerWindow(this);
@ -62,14 +52,14 @@ public class SaveFileVersionDialog extends UIDialog {
private void initComponents() {
JPanel fontPane = new JPanel(new BorderLayout());
fontPane.add(new UILabel(" " + Inter.getLocText("Plugin-VCS_Version_Message") + ":"), BorderLayout.NORTH);
fontPane.add(new UILabel(" " + InterProviderFactory.getProvider().getLocText("Fine-Design_Vcs_Version_Message") + ":"), BorderLayout.NORTH);
msgTestArea.setBorder(null);
JScrollPane jScrollPane = new UIScrollPane(msgTestArea);
UIScrollPane scrollPane = new UIScrollPane(msgTestArea);
Component[][] components = new Component[][]{
new Component[]{new UILabel(" " + Inter.getLocText("Plugin-VCS_Version_Number") + ":"), versionLabel},
new Component[]{fontPane, jScrollPane}
new Component[]{new UILabel(" " + InterProviderFactory.getProvider().getLocText("Fine-Design_Vcs_Version_Number") + ":"), versionLabel},
new Component[]{fontPane, scrollPane}
};
double[] rowSizes = new double[]{25, 100};
double[] columnSizes = new double[]{70, 200};
@ -79,30 +69,18 @@ public class SaveFileVersionDialog extends UIDialog {
JPanel buttonPane = new JPanel(new FlowLayout(FlowLayout.RIGHT));
add(buttonPane, BorderLayout.SOUTH);
UIButton ok = new UIButton(Inter.getLocText("OK"));
UIButton cancel = new UIButton(Inter.getLocText("Cancel"));
UIButton ok = new UIButton(InterProviderFactory.getProvider().getLocText("OK"));
UIButton cancel = new UIButton(InterProviderFactory.getProvider().getLocText("Cancel"));
buttonPane.add(ok);
buttonPane.add(cancel);
ok.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
jt.stopEditing();
jt.saveTemplate();
String filename = editingFilename();
String versionLabelText = versionLabel.getText();
// V.3 -> 3
String version = versionLabelText.substring(2);
//TODO refactor
if (jt.getEditingFILE() instanceof VcsCacheFileNodeFileProxy) {
vcs.saveVersionFromCache(CURRENT_USERSNAME, filename, msgTestArea.getText(), Integer.parseInt(version));
fileVersionTablePanel.updateModel(1);
} else {
vcs.saveVersion(CURRENT_USERSNAME, filename, msgTestArea.getText(), Integer.parseInt(version));
}
jt.requestFocus();
doOK();
entity.setCommitMsg(msgTestArea.getText());
ReportContext.getInstance().getVcsController().saveOrUpdateFileVersion(entity);
setVisible(false);
}
});
@ -113,17 +91,6 @@ public class SaveFileVersionDialog extends UIDialog {
});
}
private void refresh() {
int latestFileVersion = vcs.getLatestFileVersion(editingFilename());
versionLabel.setText("V." + String.valueOf(latestFileVersion + 1));
msgTestArea.setText(StringUtils.EMPTY);
}
public void showMsgInputDialog() {
refresh();
setVisible(true);
}
@Override
public void checkValid() throws Exception {

23
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java

@ -5,13 +5,14 @@ import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.vcs.proxy.VcsCacheFileNodeFileProxy;
import com.fr.design.mainframe.vcs.common.Constants;
import com.fr.design.mainframe.vcs.proxy.VcsCacheFileNodeFile;
import com.fr.file.filetree.FileNode;
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 com.fr.workspace.server.vcs.common.Constants;
import javax.swing.AbstractCellEditor;
import javax.swing.JPanel;
@ -21,16 +22,15 @@ import java.awt.Component;
public class FileVersionCellEditor extends AbstractCellEditor implements TableCellEditor {
private final VcsOperator vcs;
private static final long serialVersionUID = -7299526575184810693L;
//第一行
private final JPanel firstRowPanel;
//其余行
private final FileVersionRowPanel renderAndEditor;
public FileVersionCellEditor(FileVersionFirstRowPanel firstRowPanel, FileVersionRowPanel renderAndEditor, VcsOperator vcs) {
this.vcs = vcs;
this.firstRowPanel = firstRowPanel;
this.renderAndEditor = renderAndEditor;
public FileVersionCellEditor() {
this.firstRowPanel = new FileVersionFirstRowPanel();
this.renderAndEditor = new FileVersionRowPanel();
}
@Override
@ -40,17 +40,16 @@ public class FileVersionCellEditor extends AbstractCellEditor implements TableCe
if (isSelected) {
return editor;
} else if (row == 0) {
//TODO path "/"
String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath();
try {
fileOfVersion = vcs.getFileOfCurrent(path.replaceFirst("/", ""));
fileOfVersion = WorkContext.getCurrent().get(VcsOperator.class).getFileOfCurrent(path.replaceFirst("/", ""));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
}
} else {
renderAndEditor.update((VcsEntity) value);
try {
fileOfVersion = vcs.getFileOfFileVersion(((VcsEntity) value).getFilename(), ((VcsEntity) value).getVersion());
fileOfVersion = WorkContext.getCurrent().get(VcsOperator.class).getFileOfFileVersion(((VcsEntity) value).getFilename(), ((VcsEntity) value).getVersion());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
}
@ -65,7 +64,7 @@ public class FileVersionCellEditor extends AbstractCellEditor implements TableCe
MutilTempalteTabPane.getInstance().closeFormat(jt);
MutilTempalteTabPane.getInstance().closeSpecifiedTemplate(jt);
//再打开cache中的模板
DesignerContext.getDesignerFrame().openTemplate(new VcsCacheFileNodeFileProxy(new FileNode(fileOfVersion, false)));
DesignerContext.getDesignerFrame().openTemplate(new VcsCacheFileNodeFile(new FileNode(fileOfVersion, false)));
}
@ -78,6 +77,6 @@ public class FileVersionCellEditor extends AbstractCellEditor implements TableCe
@Override
public Object getCellEditorValue() {
return renderAndEditor.getFileVersion();
return renderAndEditor.getVcsEntity();
}
}

8
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellRender.java

@ -8,7 +8,7 @@ import javax.swing.table.TableCellRenderer;
import java.awt.Component;
import static com.fr.design.constants.UIConstants.TREE_BACKGROUND;
import static com.fr.workspace.server.vcs.common.Constants.TABLE_SELECT_BACKGROUND;
import static com.fr.design.mainframe.vcs.common.Constants.TABLE_SELECT_BACKGROUND;
public class FileVersionCellRender implements TableCellRenderer {
@ -18,9 +18,9 @@ public class FileVersionCellRender implements TableCellRenderer {
//其余行
private final FileVersionRowPanel render;
public FileVersionCellRender(FileVersionFirstRowPanel firstRowPanel, FileVersionRowPanel render) {
this.render = render;
this.firstRowPanel = firstRowPanel;
public FileVersionCellRender() {
this.render = new FileVersionRowPanel();
this.firstRowPanel = new FileVersionFirstRowPanel();
}
@Override

20
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java

@ -6,6 +6,8 @@ import com.fr.design.gui.date.UIDatePicker;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.report.ReportContext;
import com.fr.report.entity.VcsEntity;
import javax.swing.AbstractAction;
import javax.swing.Box;
@ -17,14 +19,18 @@ import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;
import java.util.List;
import static com.fr.workspace.server.vcs.common.Constants.EMPTY_BORDER;
import static com.fr.workspace.server.vcs.common.Constants.EMPTY_BORDER_BOTTOM;
import static com.fr.design.mainframe.vcs.common.Constants.EMPTY_BORDER;
import static com.fr.design.mainframe.vcs.common.Constants.EMPTY_BORDER_BOTTOM;
public class FileVersionDialog extends UIDialog {
private UIButton okBtn = new UIButton("确定");
private UIButton cancelBtn = new UIButton("取消");
private DateEditor dateEditor;
private UITextField textField;
public static final long DELAY = 24 * 60 * 60 * 1000;
public FileVersionDialog(Frame frame) {
@ -35,11 +41,13 @@ public class FileVersionDialog extends UIDialog {
box0.setBorder(EMPTY_BORDER_BOTTOM);
box0.add(new UILabel("生成日期"));
box0.add(Box.createHorizontalGlue());
box0.add(new DateEditor(new Date(), true, "生成日期", UIDatePicker.STYLE_CN_DATE1));
dateEditor = new DateEditor(new Date(), true, "生成日期", UIDatePicker.STYLE_CN_DATE1);
box0.add(dateEditor);
Box box1 = Box.createHorizontalBox();
box1.setBorder(EMPTY_BORDER_BOTTOM);
box1.add(new UILabel("备注关键词 "));
box1.add(new UITextField());
textField = new UITextField();
box1.add(textField);
Box box2 = Box.createHorizontalBox();
box2.add(Box.createHorizontalGlue());
box2.setBorder(EMPTY_BORDER);
@ -49,6 +57,10 @@ public class FileVersionDialog extends UIDialog {
@Override
public void actionPerformed(ActionEvent e) {
FileVersionDialog.this.setVisible(false);
Date date = dateEditor.getValue();
List<VcsEntity> vcsEntities = ReportContext.getInstance().getVcsController().queryFilterFileVersions(date, new Date(date.getTime() + DELAY), textField.getText());
FileVersionTable.getInstance().updateModel(1, vcsEntities);
}
});
cancelBtn.addActionListener(new AbstractAction() {

3
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionFirstRowPanel.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe.vcs.ui;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import javax.swing.Box;
import javax.swing.JPanel;
@ -14,7 +15,7 @@ public class FileVersionFirstRowPanel extends JPanel {
super(new BorderLayout());
Box upPane = Box.createVerticalBox();
upPane.setBorder(new EmptyBorder(5, 10, 5, 10));
upPane.add(new UILabel("本地用户"));
upPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Local_User")));
add(upPane, BorderLayout.CENTER);
}
}

49
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionRowPanel.java

@ -4,13 +4,14 @@ import com.fr.design.gui.frpane.UITextPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.toolbar.VcsConfig;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.vcs.common.Constants;
import com.fr.log.FineLoggerFactory;
import com.fr.report.entity.VcsEntity;
import com.fr.stable.StringUtils;
import com.fr.third.springframework.context.annotation.AnnotationConfigApplicationContext;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator;
import com.fr.workspace.server.vcs.common.Constants;
import com.fr.workspace.server.vcs.git.FineGit;
import javax.swing.Box;
import javax.swing.JOptionPane;
@ -30,17 +31,15 @@ import java.util.Date;
public class FileVersionRowPanel extends JPanel {
private final VcsOperator<VcsEntity> vcs;
private VcsEntity fileVersion;
private VcsEntity vcsEntity;
private UILabel versionLabel = new UILabel();
private UILabel usernameLabel = new UILabel("", Constants.VCS_USER_PNG, SwingConstants.LEFT);
private UITextPane timeAndMsgLabel = new UITextPane();
private UILabel timeLabel = new UILabel();
private EditFileVersionDialog editDialog;
@SuppressWarnings("unchecked")
public FileVersionRowPanel(final VcsOperator vcsOperator) {
this.vcs = vcsOperator;
public FileVersionRowPanel() {
setLayout(new BorderLayout());
// version + username
@ -59,38 +58,41 @@ public class FileVersionRowPanel extends JPanel {
// confirm + delete
UIButton confirmBtn = new UIButton(Constants.VCS_REVERT);
confirmBtn.set4ToolbarButton();
confirmBtn.setToolTipText(Toolkit.i18nText("Plugin-VCS_Version_Revert"));
confirmBtn.setToolTipText(Toolkit.i18nText("Fine-Design_Vcs_Version_Revert"));
confirmBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
if (JOptionPane.showConfirmDialog(null, Toolkit.i18nText("Plugin-VCS_Version_Revert_Confirm"), Toolkit.i18nText("Plugin-VCS_Version_Revert_Title"),
if (JOptionPane.showConfirmDialog(null, Toolkit.i18nText("Fine-Design_Vcs_Version_Revert_Confirm"), Toolkit.i18nText("Fine-Design_Vcs_Version_Revert_Title"),
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
try {
vcs.rollbackTo(fileVersion);
WorkContext.getCurrent().get(VcsOperator.class).rollbackTo(vcsEntity);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
}
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(VcsConfig.class);
context.getBean(FileVersionsPanel.class).exitVcs(fileVersion.getFilename());
FileVersionsPanel.getInstance().exitVcs(vcsEntity.getFilename());
}
}
});
UIButton deleteBtn = new UIButton(Constants.VCS_DELETE_PNG);
deleteBtn.set4ToolbarButton();
deleteBtn.setToolTipText(Toolkit.i18nText("Plugin-VCS_Version_Delete"));
deleteBtn.setToolTipText(Toolkit.i18nText("Fine-Design_Vcs_Version_Delete"));
deleteBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
if (JOptionPane.showConfirmDialog(null, Toolkit.i18nText("Plugin-VCS_Version_Delete_Confirm"), Toolkit.i18nText("FR-Designer_Remove"),
if (JOptionPane.showConfirmDialog(null, Toolkit.i18nText("Fine-Design_Vcs_Version_Delete_Confirm"), Toolkit.i18nText("FR-Designer_Remove"),
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
//TODO refactor
try {
vcs.deleteVersion(fileVersion.getFilename(), fileVersion.getVersion());
WorkContext.getCurrent().get(VcsOperator.class).deleteVersion(vcsEntity.getFilename(), vcsEntity.getVersion());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
}
FileVersionTable table = (FileVersionTable) (FileVersionRowPanel.this.getParent());
String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath();
try {
table.updateModel(table.getSelectedRow() - 1, WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst("/", "")));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
}
FileVersionTablePanel table = (FileVersionTablePanel) (FileVersionRowPanel.this.getParent());
table.updateModel(table.getSelectedRow() - 1);
}
}
});
@ -117,12 +119,15 @@ public class FileVersionRowPanel extends JPanel {
}
private void showEditDialog() {
this.editDialog = new EditFileVersionDialog(vcsEntity);
editDialog.setVisible(true);
update(vcsEntity);
}
public void update(final VcsEntity fileVersion) {
this.fileVersion = fileVersion;
this.vcsEntity = fileVersion;
versionLabel.setText(String.format("V.%s", fileVersion.getVersion()));
usernameLabel.setText(fileVersion.getUsername());
timeAndMsgLabel.setText(StringUtils.EMPTY);
@ -142,7 +147,7 @@ public class FileVersionRowPanel extends JPanel {
return simpleDateFormat.format(time);
}
public VcsEntity getFileVersion() {
return fileVersion;
public VcsEntity getVcsEntity() {
return vcsEntity;
}
}

48
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionTable.java

@ -3,52 +3,53 @@ package com.fr.design.mainframe.vcs.ui;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.log.FineLoggerFactory;
import com.fr.report.entity.VcsEntity;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.util.ArrayList;
import java.util.List;
public class FileVersionTablePanel extends JTable {
public class FileVersionTable extends JTable {
private static volatile FileVersionTable instance;
private final VcsOperator vcs;
private FileVersionTable() {
super(new CellModel(new ArrayList<VcsEntity>()));
public FileVersionTablePanel(VcsOperator vcs, TableCellEditor tableCellEditor, TableCellRenderer tableCellRenderer) {
super(new Model(new ArrayList<VcsEntity>()));
this.vcs = vcs;
setDefaultRenderer(VcsEntity.class, tableCellRenderer);
setDefaultEditor(VcsEntity.class, tableCellEditor);
setDefaultRenderer(VcsEntity.class, new FileVersionCellRender());
setDefaultEditor(VcsEntity.class, new FileVersionCellEditor());
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
setTableHeader(null);
setRowHeight(30);
}
public void updateModel(int selectedRow) {
String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath();
List<VcsEntity> vcsEntities = null;
try {
vcsEntities = vcs.getVersions(path.replaceFirst("/", ""));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
public static FileVersionTable getInstance() {
if (instance == null) {
synchronized (FileVersionTable.class) {
instance = new FileVersionTable();
}
}
if (selectedRow > vcsEntities.size()) {
selectedRow = vcsEntities.size();
return instance;
}
public void updateModel(int selectedRow, List<VcsEntity> entities) {
if (selectedRow > entities.size()) {
selectedRow = entities.size();
}
setModel(new Model(vcsEntities));
setModel(new CellModel(entities));
editCellAt(selectedRow, 0);
setRowSelectionInterval(selectedRow, selectedRow);
}
private static class Model extends AbstractTableModel {
private static class CellModel extends AbstractTableModel {
private static final long serialVersionUID = -6078568799037607690L;
private List<VcsEntity> vcsEntities;
Model(List<VcsEntity> vcsEntities) {
CellModel(List<VcsEntity> vcsEntities) {
this.vcsEntities = vcsEntities;
}
@ -76,10 +77,5 @@ public class FileVersionTablePanel extends JTable {
}
public List<VcsEntity> getVcsEntities() {
return vcsEntities;
}
}
}

40
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java

@ -4,7 +4,6 @@ import com.fr.base.GraphHelper;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.dialog.BasicPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIScrollPane;
@ -15,12 +14,15 @@ import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.ToolBarNewTemplatePane;
import com.fr.design.mainframe.WestRegionContainerPane;
import com.fr.design.mainframe.vcs.common.Constants;
import com.fr.design.menu.ToolBarDef;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.server.vcs.common.Constants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator;
import javax.swing.BorderFactory;
import javax.swing.Box;
@ -33,19 +35,28 @@ import java.awt.event.ActionListener;
public class FileVersionsPanel extends BasicPane {
private static final String ELLIPSIS = "...";
private static volatile FileVersionsPanel instance;
private final FileVersionTablePanel fileVersionsTablePane;
private UILabel titleLabel;
private String templatePath;
private UIButton filterBtn;
private FileVersionDialog versionDialog;
public FileVersionsPanel(FileVersionTablePanel fileVersionTablePanel) {
this.fileVersionsTablePane = fileVersionTablePanel;
private FileVersionsPanel() {
initComponents();
}
public static FileVersionsPanel getInstance() {
if (instance == null) {
synchronized (FileVersionsPanel.class) {
instance = new FileVersionsPanel();
}
}
return instance;
}
private void initComponents() {
setLayout(new BorderLayout());
UIToolbar toolbar = ToolBarDef.createJToolBar();
@ -83,7 +94,7 @@ public class FileVersionsPanel extends BasicPane {
toolbar.add(upPane);
add(toolbar, BorderLayout.NORTH);
UIScrollPane jScrollPane = new UIScrollPane(fileVersionsTablePane);
UIScrollPane jScrollPane = new UIScrollPane(FileVersionTable.getInstance());
add(jScrollPane, BorderLayout.CENTER);
}
@ -106,7 +117,7 @@ public class FileVersionsPanel extends BasicPane {
MutilTempalteTabPane.getInstance().closeFormat(jt);
MutilTempalteTabPane.getInstance().closeSpecifiedTemplate(jt);
udpateDesignerFrame(true);
updateDesignerFrame(true);
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, path);
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false)));
@ -116,16 +127,21 @@ public class FileVersionsPanel extends BasicPane {
templatePath = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath();
String[] paths = StableUtils.pathSplit(templatePath);
String filename = paths[paths.length - 1];
int width = fileVersionsTablePane.getWidth() - 40;
int width = FileVersionTable.getInstance().getWidth() - 40;
if (getStringWidth(filename) > width) {
filename = getEllipsisName(filename, width);
}
titleLabel.setText(filename);
fileVersionsTablePane.updateModel(1);
String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath();
try {
FileVersionTable.getInstance().updateModel(1, WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst("/", "")));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
}
}
public void showFileVersionsPane() {
udpateDesignerFrame(false);
updateDesignerFrame(false);
refreshVersionTablePane();
}
@ -135,7 +151,7 @@ public class FileVersionsPanel extends BasicPane {
}
private void udpateDesignerFrame(boolean isExit) {
private void updateDesignerFrame(boolean isExit) {
// 左上侧面板
WestRegionContainerPane.getInstance().replaceUpPane(
isExit ? DesignerFrameFileDealerPane.getInstance() : this);
@ -144,7 +160,7 @@ public class FileVersionsPanel extends BasicPane {
// MutilTempalteTabPane & NewTemplatePane 是否可点
ToolBarNewTemplatePane.getInstance().setButtonGray(!isExit);
JTemplate<?, ?> currentEditingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
JTemplate<?, ?> currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (currentEditingTemplate.isJWorkBook()) {
DesignerContext.getDesignerFrame().resetToolkitByPlus(currentEditingTemplate);
}

28
designer-realize/src/main/java/com/fr/start/Designer.java

@ -23,6 +23,7 @@ import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.gui.itoolbar.UILargeToolbar;
import com.fr.design.mainframe.ActiveKeyGenerator;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.InformationCollector;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JWorkBook;
@ -31,9 +32,8 @@ import com.fr.design.mainframe.bbs.UserInfoLabel;
import com.fr.design.mainframe.bbs.UserInfoPane;
import com.fr.design.mainframe.template.info.TemplateInfoCollector;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.mainframe.toolbar.VcsConfig;
import com.fr.design.mainframe.vcs.proxy.VcsCacheFileNodeFileProxy;
import com.fr.design.mainframe.vcs.ui.FileVersionTablePanel;
import com.fr.design.mainframe.vcs.proxy.VcsCacheFileNodeFile;
import com.fr.design.mainframe.vcs.ui.FileVersionTable;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.SeparatorDef;
@ -60,10 +60,9 @@ import com.fr.start.jni.SplashMac;
import com.fr.start.module.StartupArgs;
import com.fr.start.preload.ImagePreLoader;
import com.fr.start.server.ServerTray;
import com.fr.third.springframework.context.annotation.AnnotationConfigApplicationContext;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator;
import com.fr.workspace.server.vcs.common.Constants;
import com.fr.design.mainframe.vcs.common.Constants;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
@ -277,35 +276,32 @@ public class Designer extends BaseDesigner {
saveButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
jt.stopEditing();
jt.saveTemplate();
jt.requestFocus();
String fileName = getEditingFilename();
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(VcsConfig.class);
VcsOperator vcsOperator = context.getBean(VcsOperator.class);
int latestFileVersion = 0;
try {
latestFileVersion = vcsOperator.getLatestFileVersion(fileName);
latestFileVersion = WorkContext.getCurrent().get(VcsOperator.class).getLatestFileVersion(fileName);
} catch (Exception e1) {
FineLoggerFactory.getLogger().error(e1.getMessage());
}
try {
if (jt.getEditingFILE() instanceof VcsCacheFileNodeFileProxy) {
vcsOperator.saveVersionFromCache(Constants.CURRENT_USERSNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1);
context.getBean(FileVersionTablePanel.class).updateModel(1);
if (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) {
WorkContext.getCurrent().get(VcsOperator.class).saveVersionFromCache(Constants.CURRENT_USERNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1);
String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath();
FileVersionTable.getInstance().updateModel(1, WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst("/", "")));
} else {
vcsOperator.saveVersion(Constants.CURRENT_USERSNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1);
WorkContext.getCurrent().get(VcsOperator.class).saveVersion(Constants.CURRENT_USERNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1);
}
} catch (Exception e1) {
FineLoggerFactory.getLogger().error(e1.getMessage());
}
}
});
return saveButton;

Loading…
Cancel
Save