Browse Source

调整代码格式

research/10.0
XiaXiang 5 years ago
parent
commit
99ba163c1f
  1. 36
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  2. 27
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java
  3. 10
      designer-base/src/main/java/com/fr/design/mainframe/vcs/proxy/VcsCacheFileNodeFile.java
  4. 4
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java
  5. 2
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellRender.java
  6. 4
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java
  7. 16
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionRowPanel.java
  8. 6
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java

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

@ -26,7 +26,6 @@ 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.vcs.ui.FileVersionTable;
import com.fr.design.mainframe.vcs.ui.FileVersionsPanel;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.ShortCut;
@ -50,7 +49,7 @@ import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import com.fr.workspace.WorkContext;
import com.fr.design.mainframe.vcs.common.Constants;
import com.fr.design.mainframe.vcs.common.VcsHelper;
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("Fine-Design_Vcs_Title"));
this.setSmallIcon(Constants.VCS_LIST_PNG);
this.setSmallIcon(VcsHelper.VCS_LIST_PNG);
}
@Override
@ -450,18 +449,45 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
newFolderAction.setEnabled(singleSelected);
renameAction.setEnabled(singleSelected);
showInExplorerAction.setEnabled(singleSelected);
vcsAction.setEnabled(singleSelected);
// 删除操作在至少选中一个时可用
boolean selected = selectedPathNum > 0;
delFileAction.setEnabled(selected);
// 刷新操作始终可用
refreshTreeAction.setEnabled(true);
handleVcsAction();
// 其他状态
otherStateChange();
}
private void handleVcsAction() {
if (VcsHelper.containsFolderCounts() + VcsHelper.selectedTemplateCounts() > 1) {
vcsAction.setEnabled(false);
return;
}
if (WorkContext.getCurrent() != null) {
if (!WorkContext.getCurrent().isLocal()) {
//当前环境为远程环境时
FileNode node = TemplateTreePane.getInstance().getTemplateFileTree().getSelectedFileNode();
if (selectedOperation.getFilePath() != null) {
if (node.getLock() != null && !ComparatorUtils.equals(node.getUserID(), node.getLock())) {
vcsAction.setEnabled(false);
} else {
vcsAction.setEnabled(true);
}
} else {
vcsAction.setEnabled(false);
}
} else {
//当前环境为本地环境时
vcsAction.setEnabled(selectedOperation.getFilePath() != null);
}
}
}
public FileOperations getSelectedOperation() {
return selectedOperation;
}

27
designer-base/src/main/java/com/fr/design/mainframe/vcs/common/Constants.java → designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java

@ -1,6 +1,8 @@
package com.fr.design.mainframe.vcs.common;
import com.fr.base.BaseUtils;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.i18n.Toolkit;
import com.fr.workspace.WorkContext;
@ -11,7 +13,7 @@ import java.awt.Color;
import static com.fr.stable.StableUtils.pathJoin;
public class Constants {
public class VcsHelper {
public final static String VCS_DIR = "vcs";
public final static String VCS_CACHE_DIR = pathJoin(VCS_DIR, "cache");
@ -35,5 +37,28 @@ public class Constants {
public final static Icon VCS_USER_PNG = BaseUtils.readIcon("/com/fr/design/mainframe/vcs/images/icon_user@1x.png");
public final static Icon VCS_REVERT = BaseUtils.readIcon("/com/fr/design/mainframe/vcs/images/icon_revert.png");
public static int containsFolderCounts() {
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) {
return 0;
}
//选择的包含文件和文件夹的数目
if (fileTree.getSelectionPaths().length == 0) {
return 0;
}
//所有的num减去模板的num,得到文件夹的num
return fileTree.getSelectionPaths().length - fileTree.getSelectedTemplatePaths().length;
}
public static int selectedTemplateCounts() {
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) {
return 0;
}
return fileTree.getSelectedTemplatePaths().length;
}
}

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

@ -1,7 +1,7 @@
package com.fr.design.mainframe.vcs.proxy;
import com.fr.base.io.XMLEncryptUtils;
import com.fr.design.mainframe.vcs.common.Constants;
import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
@ -37,12 +37,12 @@ public class VcsCacheFileNodeFile extends FileNodeFILE {
String envPath = node.getEnvPath();
// envPath必须以vcs开头
if (!envPath.startsWith(Constants.VCS_CACHE_DIR)) {
if (!envPath.startsWith(VcsHelper.VCS_CACHE_DIR)) {
return null;
}
InputStream in = WorkContext.getCurrent().get(WorkResource.class)
.openStream(StableUtils.pathJoin(Constants.VCS_CACHE_DIR, envPath.substring(Constants.VCS_CACHE_DIR.length() + 1)));
.openStream(StableUtils.pathJoin(VcsHelper.VCS_CACHE_DIR, envPath.substring(VcsHelper.VCS_CACHE_DIR.length() + 1)));
return envPath.endsWith(".cpt") || envPath.endsWith(".frm")
? XMLEncryptUtils.decodeInputStream(in) : in;
@ -63,10 +63,10 @@ public class VcsCacheFileNodeFile extends FileNodeFILE {
String envPath = node.getEnvPath();
// envPath必须以reportlets开头
if (!envPath.startsWith(Constants.VCS_CACHE_DIR)) {
if (!envPath.startsWith(VcsHelper.VCS_CACHE_DIR)) {
return null;
}
return new WorkResourceOutputStream(StableUtils.pathJoin(Constants.VCS_CACHE_DIR, envPath.substring(Constants.VCS_CACHE_DIR.length() + 1)));
return new WorkResourceOutputStream(StableUtils.pathJoin(VcsHelper.VCS_CACHE_DIR, envPath.substring(VcsHelper.VCS_CACHE_DIR.length() + 1)));
}
}

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

@ -5,7 +5,7 @@ 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.common.Constants;
import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.mainframe.vcs.proxy.VcsCacheFileNodeFile;
import com.fr.file.filetree.FileNode;
import com.fr.log.FineLoggerFactory;
@ -55,7 +55,7 @@ public class FileVersionCellEditor extends AbstractCellEditor implements TableCe
}
}
editor.setBackground(Constants.TABLE_SELECT_BACKGROUND);
editor.setBackground(VcsHelper.TABLE_SELECT_BACKGROUND);
if (StringUtils.isNotEmpty(fileOfVersion)) {
//先关闭当前打开的模板版本
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();

2
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.design.mainframe.vcs.common.Constants.TABLE_SELECT_BACKGROUND;
import static com.fr.design.mainframe.vcs.common.VcsHelper.TABLE_SELECT_BACKGROUND;
public class FileVersionCellRender implements TableCellRenderer {

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

@ -21,8 +21,8 @@ import java.awt.event.ActionListener;
import java.util.Date;
import java.util.List;
import static com.fr.design.mainframe.vcs.common.Constants.EMPTY_BORDER;
import static com.fr.design.mainframe.vcs.common.Constants.EMPTY_BORDER_BOTTOM;
import static com.fr.design.mainframe.vcs.common.VcsHelper.EMPTY_BORDER;
import static com.fr.design.mainframe.vcs.common.VcsHelper.EMPTY_BORDER_BOTTOM;
public class FileVersionDialog extends UIDialog {

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

@ -5,7 +5,7 @@ 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.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.vcs.common.Constants;
import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.log.FineLoggerFactory;
import com.fr.report.entity.VcsEntity;
import com.fr.stable.StringUtils;
@ -32,7 +32,7 @@ public class FileVersionRowPanel extends JPanel {
private VcsEntity vcsEntity;
private UILabel versionLabel = new UILabel();
private UILabel usernameLabel = new UILabel("", Constants.VCS_USER_PNG, SwingConstants.LEFT);
private UILabel usernameLabel = new UILabel("", VcsHelper.VCS_USER_PNG, SwingConstants.LEFT);
private UITextPane timeAndMsgLabel = new UITextPane();
private UILabel timeLabel = new UILabel();
private EditFileVersionDialog editDialog;
@ -43,19 +43,19 @@ public class FileVersionRowPanel extends JPanel {
// version + username
Box upPane = Box.createHorizontalBox();
upPane.setBorder(Constants.EMPTY_BORDER);
upPane.setBorder(VcsHelper.EMPTY_BORDER);
upPane.add(versionLabel);
upPane.add(Box.createHorizontalGlue());
// msg
timeAndMsgLabel.setBorder(Constants.EMPTY_BORDER);
timeAndMsgLabel.setBorder(VcsHelper.EMPTY_BORDER);
timeAndMsgLabel.setOpaque(false);
timeAndMsgLabel.setBackground(new Color(0, 0, 0, 0));
timeAndMsgLabel.setEditable(false);
// confirm + delete
UIButton confirmBtn = new UIButton(Constants.VCS_REVERT);
UIButton confirmBtn = new UIButton(VcsHelper.VCS_REVERT);
confirmBtn.set4ToolbarButton();
confirmBtn.setToolTipText(Toolkit.i18nText("Fine-Design_Vcs_Version_Revert"));
confirmBtn.addActionListener(new ActionListener() {
@ -72,7 +72,7 @@ public class FileVersionRowPanel extends JPanel {
}
}
});
UIButton deleteBtn = new UIButton(Constants.VCS_DELETE_PNG);
UIButton deleteBtn = new UIButton(VcsHelper.VCS_DELETE_PNG);
deleteBtn.set4ToolbarButton();
deleteBtn.setToolTipText(Toolkit.i18nText("Fine-Design_Vcs_Version_Delete"));
deleteBtn.addActionListener(new ActionListener() {
@ -95,7 +95,7 @@ public class FileVersionRowPanel extends JPanel {
}
}
});
UIButton editBtn = new UIButton(Constants.VCS_EDIT_PNG);
UIButton editBtn = new UIButton(VcsHelper.VCS_EDIT_PNG);
editBtn.set4ToolbarButton();
editBtn.addActionListener(new ActionListener() {
@Override
@ -109,7 +109,7 @@ public class FileVersionRowPanel extends JPanel {
upPane.add(deleteBtn);
Box downPane = Box.createHorizontalBox();
downPane.add(usernameLabel);
downPane.setBorder(Constants.EMPTY_BORDER_BOTTOM);
downPane.setBorder(VcsHelper.EMPTY_BORDER_BOTTOM);
downPane.add(Box.createHorizontalGlue());
downPane.add(timeLabel);
add(upPane, BorderLayout.NORTH);

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

@ -14,7 +14,7 @@ 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.mainframe.vcs.common.VcsHelper;
import com.fr.design.menu.ToolBarDef;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
@ -63,7 +63,7 @@ public class FileVersionsPanel extends BasicPane {
toolbar.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
toolbar.setBorderPainted(true);
Box upPane = Box.createHorizontalBox();
UIButton backBtn = new UIButton(Constants.VCS_BACK_PNG);
UIButton backBtn = new UIButton(VcsHelper.VCS_BACK_PNG);
backBtn.set4ToolbarButton();
backBtn.addActionListener(new ActionListener() {
@Override
@ -72,7 +72,7 @@ public class FileVersionsPanel extends BasicPane {
}
});
toolbar.add(backBtn);
filterBtn = new UIButton(Constants.VCS_FILTER_PNG);
filterBtn = new UIButton(VcsHelper.VCS_FILTER_PNG);
filterBtn.set4ToolbarButton();
filterBtn.setHorizontalAlignment(SwingConstants.RIGHT);
filterBtn.addActionListener(new ActionListener() {

Loading…
Cancel
Save