Browse Source

REPORT-14835 调整代码

research/10.0
XiaXiang 6 years ago
parent
commit
0574c315ad
  1. 18
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java
  2. 25
      designer-realize/src/main/java/com/fr/start/Designer.java

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

@ -1,9 +1,13 @@
package com.fr.design.mainframe.vcs.common; package com.fr.design.mainframe.vcs.common;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.TemplateTreePane; import com.fr.design.file.TemplateTreePane;
import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import javax.swing.Icon; import javax.swing.Icon;
@ -64,5 +68,19 @@ public class VcsHelper {
return VcsHelper.containsFolderCounts() + VcsHelper.selectedTemplateCounts() > 1; return VcsHelper.containsFolderCounts() + VcsHelper.selectedTemplateCounts() > 1;
} }
public static String getEdittingFilename() {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
String editingFilePath = jt.getEditingFILE().getPath();
if (editingFilePath.startsWith(ProjectConstants.REPORTLETS_NAME)) {
editingFilePath = editingFilePath.replaceFirst(ProjectConstants.REPORTLETS_NAME, StringUtils.EMPTY);
} else if (editingFilePath.startsWith(VcsHelper.VCS_CACHE_DIR)) {
editingFilePath = editingFilePath.replaceFirst(VcsHelper.VCS_CACHE_DIR, StringUtils.EMPTY);
}
if (editingFilePath.startsWith("/")) {
editingFilePath = editingFilePath.substring(1);
}
return editingFilePath;
}
} }

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

@ -62,7 +62,7 @@ import com.fr.start.preload.ImagePreLoader;
import com.fr.start.server.ServerTray; import com.fr.start.server.ServerTray;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.VcsOperator;
import com.fr.design.mainframe.vcs.common.Constants; import com.fr.design.mainframe.vcs.common.VcsHelper;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
@ -280,7 +280,7 @@ public class Designer extends BaseDesigner {
jt.stopEditing(); jt.stopEditing();
jt.saveTemplate(); jt.saveTemplate();
jt.requestFocus(); jt.requestFocus();
String fileName = getEditingFilename(); String fileName = VcsHelper.getEdittingFilename();
int latestFileVersion = 0; int latestFileVersion = 0;
try { try {
latestFileVersion = WorkContext.getCurrent().get(VcsOperator.class).getLatestFileVersion(fileName); latestFileVersion = WorkContext.getCurrent().get(VcsOperator.class).getLatestFileVersion(fileName);
@ -288,15 +288,14 @@ public class Designer extends BaseDesigner {
} catch (Exception e1) { } catch (Exception e1) {
FineLoggerFactory.getLogger().error(e1.getMessage()); FineLoggerFactory.getLogger().error(e1.getMessage());
} }
try { try {
if (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) { if (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) {
WorkContext.getCurrent().get(VcsOperator.class).saveVersionFromCache(Constants.CURRENT_USERNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1); WorkContext.getCurrent().get(VcsOperator.class).saveVersionFromCache(VcsHelper.CURRENT_USERNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1);
String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath();
FileVersionTable.getInstance().updateModel(1, WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst("/", ""))); FileVersionTable.getInstance().updateModel(1, WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst("/", "")));
} else { } else {
WorkContext.getCurrent().get(VcsOperator.class).saveVersion(Constants.CURRENT_USERNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1); WorkContext.getCurrent().get(VcsOperator.class).saveVersion(VcsHelper.CURRENT_USERNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1);
} }
} catch (Exception e1) { } catch (Exception e1) {
FineLoggerFactory.getLogger().error(e1.getMessage()); FineLoggerFactory.getLogger().error(e1.getMessage());
@ -307,22 +306,6 @@ public class Designer extends BaseDesigner {
return saveButton; return saveButton;
} }
public static String getEditingFilename() {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
String editingFilePath = jt.getEditingFILE().getPath();
//TODO 如果是cache里的文件,也会走到这里,这里是找到reportlets去掉的。万一刚好cache/reportlets会出问题
if (editingFilePath.startsWith(ProjectConstants.REPORTLETS_NAME)) {
editingFilePath = editingFilePath.replaceFirst(ProjectConstants.REPORTLETS_NAME, StringUtils.EMPTY);
} else if (editingFilePath.startsWith(Constants.VCS_CACHE_DIR)) {
editingFilePath = editingFilePath.replaceFirst(Constants.VCS_CACHE_DIR, StringUtils.EMPTY);
}
//TODO refactor 考虑直接用reportlets/xxx/x/x/x/x/x// or /xx/x/x/x/x/x
if (editingFilePath.startsWith("/")) {
editingFilePath = editingFilePath.substring(1);
}
return editingFilePath;
}
private UIButton createUndoButton() { private UIButton createUndoButton() {
undo = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/undo.png")); undo = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/undo.png"));
undo.setToolTipText(KeySetUtils.UNDO.getMenuKeySetName()); undo.setToolTipText(KeySetUtils.UNDO.getMenuKeySetName());

Loading…
Cancel
Save