Browse Source

REPORT-14835 版本管理代码调整 屏蔽集群

bugfix/10.0
XiaXiang 6 years ago
parent
commit
104a3018fb
  1. 4
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  2. 2
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  3. 5
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  4. 6
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  5. 50
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java
  6. 2
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionRowPanel.java

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

@ -217,7 +217,7 @@ public class PreferencePane extends BasicPane {
JPanel vcsPane = FRGUIPaneFactory.createVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Vcs_Title"));
generalPane.add(vcsPane);
remindVcsLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Remind"));
remindVcsLabel.setVisible(!VcsHelper.needInit());
remindVcsLabel.setVisible(!VcsHelper.getInstance().needInit());
vcsEnableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Vcs_SaveAuto"));
saveCommitCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Vcs_No_Delete"));
saveIntervalEditor = new IntegerEditor(60);
@ -602,7 +602,7 @@ public class PreferencePane extends BasicPane {
defaultStringToFormulaBox.setSelected(false);
}
VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager();
if (VcsHelper.needInit()) {
if (VcsHelper.getInstance().needInit()) {
vcsEnableCheckBox.setSelected(vcsConfigManager.isVcsEnable());
} else {
vcsEnableCheckBox.setEnabled(false);

2
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -37,6 +37,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.loghandler.LogMessageBar;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.menu.MenuManager;
import com.fr.design.menu.ShortCut;
import com.fr.design.utils.gui.GUICoreUtils;
@ -924,6 +925,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
jt.addJTemplateActionListener(this);
jt.addTargetModifiedListener(this);
jt.addJTemplateActionListener(new VcsHelper());
centerTemplateCardPane.showJTemplate(jt);
setTitle();
layeredPane.repaint();

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

@ -2,6 +2,7 @@ package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.vcs.DesignerMode;
import com.fr.cluster.engine.base.FineClusterConfig;
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
@ -202,7 +203,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
for (ShortCut shortCut : extraShortCuts) {
toolbarDef.addShortCut(shortCut);
}
if (VcsHelper.needInit()) {
if (VcsHelper.getInstance().needInit()) {
toolbarDef.addShortCut(vcsAction);
}
toolbarDef.updateToolBar(toolBar);
@ -453,7 +454,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
private void handleVcsAction() {
if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() || VcsHelper.isUnSelectedTemplate()) {
if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() || VcsHelper.getInstance().isUnSelectedTemplate()) {
vcsAction.setEnabled(false);
return;
}

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

@ -687,10 +687,6 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
this.saved = true;
this.authoritySaved = true;
DesignerContext.getDesignerFrame().setTitle();
if (DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable()) {
VcsHelper.dealWithVcs(this);
}
this.fireJTemplateSaved();
return true;
}
@ -831,7 +827,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
// Process the listeners last to first, notifying
// those that are interested in this event
for (int i = listeners.length - 2; i >= 0; i -= 2) {
for (int i = listeners.length - 1; i >= 0; i -= 1) {
if (listeners[i] == JTemplateActionListener.class) {
((JTemplateActionListener) listeners[i + 1]).templateSaved(this);
}

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

@ -1,5 +1,6 @@
package com.fr.design.mainframe.vcs.common;
import com.fr.cluster.engine.base.FineClusterConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.TemplateTreePane;
@ -7,6 +8,7 @@ import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JTemplateActionListener;
import com.fr.design.mainframe.vcs.VcsConfigManager;
import com.fr.design.mainframe.vcs.ui.FileVersionTable;
import com.fr.general.IOUtils;
@ -28,7 +30,7 @@ import static com.fr.stable.StableUtils.pathJoin;
/**
* Created by XiaXiang on 2019/4/17.
*/
public class VcsHelper {
public class VcsHelper implements JTemplateActionListener {
public final static Color TABLE_SELECT_BACKGROUND = new Color(0xD8F2FD);
public final static Color COPY_VERSION_BTN_COLOR = new Color(0x419BF9);
@ -46,8 +48,13 @@ public class VcsHelper {
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 final VcsHelper instance = new VcsHelper();
private static int containsFolderCounts() {
public static VcsHelper getInstance() {
return instance;
}
private int containsFolderCounts() {
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) {
return 0;
@ -61,13 +68,13 @@ public class VcsHelper {
return fileTree.getSelectionPaths().length - fileTree.getSelectedTemplatePaths().length;
}
public static String getCurrentUsername() {
public String getCurrentUsername() {
return WorkContext.getCurrent().isLocal()
? Toolkit.i18nText("Fine-Design_Vcs_Local_User")
: WorkContext.getCurrent().getConnection().getUserName();
}
private static int selectedTemplateCounts() {
private int selectedTemplateCounts() {
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) {
return 0;
@ -76,11 +83,11 @@ public class VcsHelper {
return fileTree.getSelectedTemplatePaths().length;
}
public static boolean isUnSelectedTemplate() {
return VcsHelper.containsFolderCounts() + VcsHelper.selectedTemplateCounts() != 1;
public boolean isUnSelectedTemplate() {
return containsFolderCounts() + selectedTemplateCounts() != 1;
}
public static String getEditingFilename() {
private String getEditingFilename() {
JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
String editingFilePath = jt.getEditingFILE().getPath();
if (editingFilePath.startsWith(ProjectConstants.REPORTLETS_NAME)) {
@ -94,7 +101,7 @@ public class VcsHelper {
return editingFilePath;
}
public static boolean needDeleteVersion(VcsEntity entity) {
private boolean needDeleteVersion(VcsEntity entity) {
VcsConfigManager configManager = DesignerEnvManager.getEnvManager().getVcsConfigManager();
if (entity == null || !configManager.isUseInterval()) {
return false;
@ -105,7 +112,7 @@ public class VcsHelper {
return new Date().getTime() - entity.getTime().getTime() < DesignerEnvManager.getEnvManager().getVcsConfigManager().getSaveInterval() * MINUTE;
}
public static boolean needInit() {
public boolean needInit() {
PluginContext context = PluginManager.getContext(VCS_PLUGIN_ID);
return context == null || !context.isActive();
}
@ -115,7 +122,7 @@ public class VcsHelper {
*
* @param jt
*/
public static void dealWithVcs(final JTemplate jt) {
public void dealWithVcs(final JTemplate jt) {
new Thread(new Runnable() {
@Override
public void run() {
@ -135,7 +142,7 @@ public class VcsHelper {
operator.saveVersion(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1);
}
VcsEntity oldEntity = WorkContext.getCurrent().get(VcsOperator.class).getFileVersionByIndex(fileName, 1);
if (VcsHelper.needDeleteVersion(oldEntity)) {
if (needDeleteVersion(oldEntity)) {
operator.deleteVersion(oldEntity.getFilename(), oldEntity.getVersion());
}
@ -145,4 +152,25 @@ public class VcsHelper {
}
@Override
public void templateOpened(JTemplate<?, ?> jt) {
}
/**
* 模板保存时 处理.
*
* @param jt 模板
*/
@Override
public void templateSaved(JTemplate<?, ?> jt) {
if (DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() && !FineClusterConfig.getInstance().isCluster()) {
dealWithVcs(jt);
}
}
@Override
public void templateClosed(JTemplate<?, ?> jt) {
}
}

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

@ -63,7 +63,7 @@ public class FileVersionRowPanel extends JPanel {
public void actionPerformed(ActionEvent evt) {
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) {
vcsEntity.setUsername(VcsHelper.getCurrentUsername());
vcsEntity.setUsername(VcsHelper.getInstance().getCurrentUsername());
WorkContext.getCurrent().get(VcsOperator.class).rollbackTo(vcsEntity);
FileVersionsPanel.getInstance().exitVcs(vcsEntity.getFilename());
}

Loading…
Cancel
Save