Browse Source

Merge pull request #854 in DESIGN/design from ~XIAOXIA/design:feature/10.0 to feature/10.0

* commit 'babcaf299d55e82495fb1f3947d41fe463b1d5f5':
  REPORT-16559
  rt
  REPORT-16559
  REPORT-16559
  REPORT-16547
  REPORT-16547 bug fix
research/10.0
xiaoxia 6 years ago
parent
commit
e835baccd1
  1. 3
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  2. 39
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java
  3. 7
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/EditFileVersionDialog.java
  4. 4
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionRowPanel.java
  5. 7
      designer-realize/src/main/java/com/fr/start/Designer.java

3
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -543,9 +543,6 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return false;
}
collectInfo();
if (DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable()) {
VcsHelper.dealWithVcs(this);
}
return this.saveFile();
}

39
designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java

@ -30,25 +30,11 @@ import static com.fr.stable.StableUtils.pathJoin;
*/
public class VcsHelper {
private final static String VCS_DIR = "vcs";
public final static String VCS_CACHE_DIR = pathJoin(VCS_DIR, "cache");
private static final int MINUTE = 60 * 1000;
private final static String VCS_PLUGIN_ID = "com.fr.plugin.vcs.v10";
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 EmptyBorder EMPTY_BORDER = new EmptyBorder(10, 10, 0, 10);
public final static EmptyBorder EMPTY_BORDER_MEDIUM = new EmptyBorder(5, 10, 0, 10);
public final static EmptyBorder EMPTY_BORDER_BOTTOM = new EmptyBorder(10, 10, 10, 10);
public final static Icon VCS_LIST_PNG = IOUtils.readIcon("/com/fr/design/images/vcs/vcs_list.png");
public final static Icon VCS_BACK_PNG = IOUtils.readIcon("/com/fr/design/images/vcs/vcs_back.png");
public final static Icon VCS_FILTER_PNG = IOUtils.readIcon("/com/fr/design/images/vcs/icon_filter@1x.png");
@ -56,6 +42,10 @@ public class VcsHelper {
public final static Icon VCS_DELETE_PNG = IOUtils.readIcon("/com/fr/design/images/vcs/icon_delete.png");
public final static Icon VCS_USER_PNG = IOUtils.readIcon("/com/fr/design/images/vcs/icon_user@1x.png");
public final static Icon VCS_REVERT = IOUtils.readIcon("/com/fr/design/images/vcs/icon_revert.png");
private final static String VCS_DIR = "vcs";
public final static String VCS_CACHE_DIR = pathJoin(VCS_DIR, "cache");
private static final int MINUTE = 60 * 1000;
private final static String VCS_PLUGIN_ID = "com.fr.plugin.vcs.v10";
private static int containsFolderCounts() {
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
@ -71,6 +61,12 @@ public class VcsHelper {
return fileTree.getSelectionPaths().length - fileTree.getSelectedTemplatePaths().length;
}
public static String getCurrentUsername() {
return WorkContext.getCurrent().isLocal()
? Toolkit.i18nText("Fine-Design_Vcs_Local_User")
: WorkContext.getCurrent().getConnection().getUserName();
}
private static int selectedTemplateCounts() {
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) {
@ -99,10 +95,14 @@ public class VcsHelper {
}
public static boolean needDeleteVersion(VcsEntity entity) {
if (entity == null || !DesignerEnvManager.getEnvManager().getVcsConfigManager().isUseInterval()) {
VcsConfigManager configManager = DesignerEnvManager.getEnvManager().getVcsConfigManager();
if (entity == null || !configManager.isUseInterval()) {
return false;
}
if (configManager.isSaveCommit() && StringUtils.isNotBlank(entity.getCommitMsg())) {
return false;
}
return new Date().getTime() - entity.getTime().getTime() < DesignerEnvManager.getEnvManager().getVcsConfigManager().getSaveInterval() * MINUTE && StringUtils.isBlank(entity.getCommitMsg());
return new Date().getTime() - entity.getTime().getTime() < DesignerEnvManager.getEnvManager().getVcsConfigManager().getSaveInterval() * MINUTE;
}
public static boolean needInit() {
@ -112,6 +112,7 @@ public class VcsHelper {
/**
* 版本控制
*
* @param jt
*/
public static void dealWithVcs(final JTemplate jt) {
@ -127,11 +128,11 @@ public class VcsHelper {
latestFileVersion = entity.getVersion();
}
if (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) {
operator.saveVersionFromCache(VcsHelper.CURRENT_USERNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1);
operator.saveVersionFromCache(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1);
String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath();
FileVersionTable.getInstance().updateModel(1, WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst("/", "")));
} else {
operator.saveVersion(VcsHelper.CURRENT_USERNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1);
operator.saveVersion(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1);
}
VcsEntity oldEntity = WorkContext.getCurrent().get(VcsOperator.class).getFileVersionByIndex(fileName, 1);
if (VcsHelper.needDeleteVersion(oldEntity)) {

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

@ -8,16 +8,15 @@ import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.locale.InterProviderFactory;
import com.fr.report.ReportContext;
import com.fr.report.entity.VcsEntity;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@ -80,7 +79,7 @@ public class EditFileVersionDialog extends UIDialog {
@Override
public void actionPerformed(ActionEvent e) {
entity.setCommitMsg(msgTestArea.getText());
ReportContext.getInstance().getVcsController().saveOrUpdateFileVersion(entity);
WorkContext.getCurrent().get(VcsOperator.class).updateVersion(entity);
setVisible(false);
}
});

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

@ -43,13 +43,13 @@ public class FileVersionRowPanel extends JPanel {
// version + username
Box upPane = Box.createHorizontalBox();
upPane.setBorder(VcsHelper.EMPTY_BORDER);
upPane.setBorder(VcsHelper.EMPTY_BORDER_MEDIUM);
upPane.add(versionLabel);
upPane.add(Box.createHorizontalGlue());
// msg
msgLabel.setBorder(VcsHelper.EMPTY_BORDER);
msgLabel.setBorder(VcsHelper.EMPTY_BORDER_MEDIUM);
msgLabel.setOpaque(false);
msgLabel.setBackground(new Color(0, 0, 0, 0));
msgLabel.setEditable(false);

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

@ -32,6 +32,7 @@ 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.vcs.common.VcsHelper;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.SeparatorDef;
@ -274,6 +275,9 @@ public class Designer extends BaseDesigner {
jt.stopEditing();
jt.saveTemplate();
jt.requestFocus();
if (DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable()) {
VcsHelper.dealWithVcs(jt);
}
}
});
return saveButton;
@ -332,6 +336,9 @@ public class Designer extends BaseDesigner {
return;
}
WebPreviewUtils.preview(jt);
if (DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable()) {
VcsHelper.dealWithVcs(jt);
}
}
@Override

Loading…
Cancel
Save