Browse Source

格式化

bugfix/10.0
XiaXiang 6 years ago
parent
commit
4bf5c3b39e
  1. 132
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

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

@ -27,6 +27,7 @@ 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.common.VcsHelper;
import com.fr.design.mainframe.vcs.ui.FileVersionsPanel;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.ShortCut;
@ -50,7 +51,6 @@ 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.VcsHelper;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
@ -80,6 +80,9 @@ import static javax.swing.JOptionPane.WARNING_MESSAGE;
public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange {
private static final String FILE = "file";
private static volatile DesignerFrameFileDealerPane THIS;
static {
GeneralContext.listenPluginRunningChanged(new PluginEventListener() {
@ -96,10 +99,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
});
}
private static final String FILE = "file";
private static volatile DesignerFrameFileDealerPane THIS;
private List<FileToolbarStateChangeListener> otherToolbarStateChangeListeners = new ArrayList<>();
private FileOperations selectedOperation;
@ -119,25 +118,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private VcsAction vcsAction = new VcsAction();
/**
* 刷新
*/
public void refresh() {
selectedOperation.refresh();
}
public static DesignerFrameFileDealerPane getInstance() {
if (THIS == null) {
synchronized (DesignerFrameFileDealerPane.class) {
if (THIS == null) {
THIS = new DesignerFrameFileDealerPane();
}
}
}
return THIS;
}
private DesignerFrameFileDealerPane() {
setLayout(new BorderLayout());
@ -165,6 +145,24 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
stateChange();
}
public static DesignerFrameFileDealerPane getInstance() {
if (THIS == null) {
synchronized (DesignerFrameFileDealerPane.class) {
if (THIS == null) {
THIS = new DesignerFrameFileDealerPane();
}
}
}
return THIS;
}
/**
* 刷新
*/
public void refresh() {
selectedOperation.refresh();
}
public final void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
@ -256,6 +254,41 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
}
private boolean isCurrentEditing(String path) {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
String editing = jt.getEditingFILE().getPath();
return ComparatorUtils.equals(editing, path);
}
/**
* 按钮状态改变
*/
@Override
public void stateChange() {
int selectedPathNum = TemplateTreePane.getInstance().countSelectedPath();
// 新建文件夹,重命名操作,在explorer中打开三个操作在选中单个文件夹或者文件时可用,其他情况不可用
boolean singleSelected = selectedPathNum == 1;
newFolderAction.setEnabled(singleSelected);
renameAction.setEnabled(singleSelected);
showInExplorerAction.setEnabled(singleSelected);
// 删除操作在至少选中一个时可用
boolean selected = selectedPathNum > 0;
delFileAction.setEnabled(selected);
// 刷新操作始终可用
refreshTreeAction.setEnabled(true);
//触发vcsAction变化
vcsAction.fireVcsActionChange();
// 其他状态
otherStateChange();
}
public FileOperations getSelectedOperation() {
return selectedOperation;
}
/*
* 新建文件夹
*/
@ -288,6 +321,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(VcsHelper.VCS_LIST_PNG);
@ -313,26 +347,27 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
*/
private void fireVcsActionChange() {
if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() || VcsHelper.getInstance().isUnSelectedTemplate() || FineClusterConfig.getInstance().isCluster()) {
vcsAction.setEnabled(false);
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);
setEnabled(false);
} else {
vcsAction.setEnabled(true);
setEnabled(true);
}
} else {
vcsAction.setEnabled(false);
setEnabled(false);
}
} else {
//当前环境为本地环境时
vcsAction.setEnabled(selectedOperation.getFilePath() != null);
setEnabled(selectedOperation.getFilePath() != null);
}
}
}
@ -353,12 +388,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
private boolean isCurrentEditing(String path) {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
String editing = jt.getEditingFILE().getPath();
return ComparatorUtils.equals(editing, path);
}
/**
* 在系统资源管理器中打开
*/
@ -460,39 +489,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
}
/**
* 按钮状态改变
*/
@Override
public void stateChange() {
int selectedPathNum = TemplateTreePane.getInstance().countSelectedPath();
// 新建文件夹,重命名操作,在explorer中打开三个操作在选中单个文件夹或者文件时可用,其他情况不可用
boolean singleSelected = selectedPathNum == 1;
newFolderAction.setEnabled(singleSelected);
renameAction.setEnabled(singleSelected);
showInExplorerAction.setEnabled(singleSelected);
// 删除操作在至少选中一个时可用
boolean selected = selectedPathNum > 0;
delFileAction.setEnabled(selected);
// 刷新操作始终可用
refreshTreeAction.setEnabled(true);
//触发vcsAction变化
vcsAction.fireVcsActionChange();
// 其他状态
otherStateChange();
}
public FileOperations getSelectedOperation() {
return selectedOperation;
}
/**
* 重命名对话框
* 支持快捷键EnterESC

Loading…
Cancel
Save