Browse Source

REPORT-16527

@xiaoxia 通过直接预览触发的模版保存,该模版不会保存新版本
research/10.0
XiaXiang 6 years ago
parent
commit
1e8eebe86d
  1. 4
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  2. 35
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java
  3. 51
      designer-realize/src/main/java/com/fr/start/Designer.java

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

@ -39,6 +39,7 @@ import com.fr.design.mainframe.template.info.TemplateProcessInfo;
import com.fr.design.mainframe.template.info.TimeConsumeTimer;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.mainframe.toolbar.VcsScene;
import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.NameSeparator;
import com.fr.design.menu.ShortCut;
@ -542,6 +543,9 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return false;
}
collectInfo();
if (DesignerEnvManager.getEnvManager().isVcsEnable()) {
VcsHelper.dealWithVcs(this);
}
return this.saveFile();
}

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

@ -5,7 +5,9 @@ import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.TemplateTreePane;
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.vcs.ui.FileVersionTable;
import com.fr.general.IOUtils;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.manage.PluginManager;
@ -13,6 +15,7 @@ import com.fr.report.entity.VcsEntity;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator;
import javax.swing.Icon;
import javax.swing.border.EmptyBorder;
@ -106,5 +109,37 @@ public class VcsHelper {
return context == null || !context.isActive();
}
/**
* 版本控制
* @param jt
*/
public static void dealWithVcs(final JTemplate jt) {
new Thread(new Runnable() {
@Override
public void run() {
String fileName = VcsHelper.getEditingFilename();
VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class);
VcsEntity entity = operator.getFileVersionByIndex(fileName, 0);
int latestFileVersion = 0;
if (entity != null) {
latestFileVersion = entity.getVersion();
}
if (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) {
operator.saveVersionFromCache(VcsHelper.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 {
operator.saveVersion(VcsHelper.CURRENT_USERNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1);
}
VcsEntity oldEntity = WorkContext.getCurrent().get(VcsOperator.class).getFileVersionByIndex(fileName, 1);
if (VcsHelper.needDeleteVersion(oldEntity)) {
operator.deleteVersion(oldEntity.getFilename(), oldEntity.getVersion());
}
}
}).start();
}
}

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

@ -23,7 +23,6 @@ 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;
@ -32,8 +31,6 @@ 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.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;
@ -46,7 +43,6 @@ import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.module.Module;
import com.fr.module.ModuleContext;
import com.fr.report.entity.VcsEntity;
import com.fr.runtime.FineRuntime;
import com.fr.stable.BuildContext;
import com.fr.stable.OperatingSystem;
@ -61,8 +57,6 @@ import com.fr.start.module.StartupArgs;
import com.fr.start.preload.ImagePreLoader;
import com.fr.start.server.ServerTray;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator;
import com.fr.design.mainframe.vcs.common.VcsHelper;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
@ -97,13 +91,17 @@ public class Designer extends BaseDesigner {
private UIButton redo;
private UIPreviewButton run;
public Designer(String[] args) {
super(args);
}
/**
* 设计器启动的Main方法
*
* @param args 参数
*/
public static void main(String[] args) {
//启动运行时
FineRuntime.start();
BuildContext.setBuildFilePath("/com/fr/stable/build.properties");
@ -169,11 +167,6 @@ public class Designer extends BaseDesigner {
return new SplashFx();
}
public Designer(String[] args) {
super(args);
}
/**
* 创建新建文件的快捷方式数组
*
@ -280,45 +273,11 @@ public class Designer extends BaseDesigner {
jt.stopEditing();
jt.saveTemplate();
jt.requestFocus();
if (DesignerEnvManager.getEnvManager().isVcsEnable()) {
dealWithVcs(jt);
}
}
});
return saveButton;
}
/**
* 版本控制
* @param jt
*/
private void dealWithVcs(final JTemplate jt) {
new Thread(new Runnable() {
@Override
public void run() {
String fileName = VcsHelper.getEditingFilename();
VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class);
VcsEntity entity = operator.getFileVersionByIndex(fileName, 0);
int latestFileVersion = 0;
if (entity != null) {
latestFileVersion = entity.getVersion();
}
if (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) {
operator.saveVersionFromCache(VcsHelper.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 {
operator.saveVersion(VcsHelper.CURRENT_USERNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1);
}
VcsEntity oldEntity = WorkContext.getCurrent().get(VcsOperator.class).getFileVersionByIndex(fileName, 1);
if (VcsHelper.needDeleteVersion(oldEntity)) {
operator.deleteVersion(oldEntity.getFilename(), oldEntity.getVersion());
}
}
}).start();
}
private UIButton createUndoButton() {
undo = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/undo.png"));

Loading…
Cancel
Save