|
|
@ -2,6 +2,7 @@ package com.fr.design.mainframe; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.base.vcs.DesignerMode; |
|
|
|
import com.fr.base.vcs.DesignerMode; |
|
|
|
|
|
|
|
import com.fr.cluster.engine.base.FineClusterConfig; |
|
|
|
import com.fr.design.DesignModelAdapter; |
|
|
|
import com.fr.design.DesignModelAdapter; |
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
import com.fr.design.ExtraDesignClassManager; |
|
|
|
import com.fr.design.ExtraDesignClassManager; |
|
|
@ -26,6 +27,7 @@ import com.fr.design.i18n.Toolkit; |
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
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.mainframe.vcs.ui.FileVersionsPanel; |
|
|
|
import com.fr.design.menu.KeySetUtils; |
|
|
|
import com.fr.design.menu.KeySetUtils; |
|
|
|
import com.fr.design.menu.ShortCut; |
|
|
|
import com.fr.design.menu.ShortCut; |
|
|
@ -49,7 +51,6 @@ import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.project.ProjectConstants; |
|
|
|
import com.fr.stable.project.ProjectConstants; |
|
|
|
import com.fr.third.org.apache.commons.io.FilenameUtils; |
|
|
|
import com.fr.third.org.apache.commons.io.FilenameUtils; |
|
|
|
import com.fr.workspace.WorkContext; |
|
|
|
import com.fr.workspace.WorkContext; |
|
|
|
import com.fr.design.mainframe.vcs.common.VcsHelper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
import javax.swing.BorderFactory; |
|
|
|
import javax.swing.JDialog; |
|
|
|
import javax.swing.JDialog; |
|
|
@ -79,6 +80,9 @@ import static javax.swing.JOptionPane.WARNING_MESSAGE; |
|
|
|
|
|
|
|
|
|
|
|
public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange { |
|
|
|
public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String FILE = "file"; |
|
|
|
|
|
|
|
private static volatile DesignerFrameFileDealerPane THIS; |
|
|
|
|
|
|
|
|
|
|
|
static { |
|
|
|
static { |
|
|
|
GeneralContext.listenPluginRunningChanged(new PluginEventListener() { |
|
|
|
GeneralContext.listenPluginRunningChanged(new PluginEventListener() { |
|
|
|
|
|
|
|
|
|
|
@ -95,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 List<FileToolbarStateChangeListener> otherToolbarStateChangeListeners = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
private FileOperations selectedOperation; |
|
|
|
private FileOperations selectedOperation; |
|
|
@ -118,25 +118,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt |
|
|
|
private VcsAction vcsAction = new VcsAction(); |
|
|
|
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() { |
|
|
|
private DesignerFrameFileDealerPane() { |
|
|
|
|
|
|
|
|
|
|
|
setLayout(new BorderLayout()); |
|
|
|
setLayout(new BorderLayout()); |
|
|
@ -164,6 +145,24 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt |
|
|
|
stateChange(); |
|
|
|
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) { |
|
|
|
public final void setCurrentEditingTemplate(JTemplate<?, ?> jt) { |
|
|
|
|
|
|
|
|
|
|
@ -202,15 +201,31 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt |
|
|
|
for (ShortCut shortCut : extraShortCuts) { |
|
|
|
for (ShortCut shortCut : extraShortCuts) { |
|
|
|
toolbarDef.addShortCut(shortCut); |
|
|
|
toolbarDef.addShortCut(shortCut); |
|
|
|
} |
|
|
|
} |
|
|
|
if (VcsHelper.needInit()) { |
|
|
|
addVcsAction(toolbarDef); |
|
|
|
toolbarDef.addShortCut(vcsAction); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
toolbarDef.updateToolBar(toolBar); |
|
|
|
toolbarDef.updateToolBar(toolBar); |
|
|
|
resetActionStatus(); |
|
|
|
resetActionStatus(); |
|
|
|
refresh(); |
|
|
|
refresh(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 添加VcsAction |
|
|
|
|
|
|
|
* @param toolbarDef |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void addVcsAction(ToolBarDef toolbarDef) { |
|
|
|
|
|
|
|
if (VcsHelper.getInstance().needInit()) { |
|
|
|
|
|
|
|
vcsAction = new VcsAction(); |
|
|
|
|
|
|
|
if (FineClusterConfig.getInstance().isCluster()) { |
|
|
|
|
|
|
|
vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_NotSupportRemote")); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_Title")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
toolbarDef.addShortCut(vcsAction); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void resetActionStatus() { |
|
|
|
private void resetActionStatus() { |
|
|
|
|
|
|
|
|
|
|
|
newFolderAction.setEnabled(false); |
|
|
|
newFolderAction.setEnabled(false); |
|
|
@ -255,6 +270,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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
|
* 新建文件夹 |
|
|
|
* 新建文件夹 |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -287,8 +337,8 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt |
|
|
|
* 版本管理 |
|
|
|
* 版本管理 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private class VcsAction extends UpdateAction { |
|
|
|
private class VcsAction extends UpdateAction { |
|
|
|
|
|
|
|
|
|
|
|
public VcsAction() { |
|
|
|
public VcsAction() { |
|
|
|
this.setName(Toolkit.i18nText("Fine-Design_Vcs_Title")); |
|
|
|
|
|
|
|
this.setSmallIcon(VcsHelper.VCS_LIST_PNG); |
|
|
|
this.setSmallIcon(VcsHelper.VCS_LIST_PNG); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -303,6 +353,40 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt |
|
|
|
closeOpenedTemplate(path, isCurrentEditing); |
|
|
|
closeOpenedTemplate(path, isCurrentEditing); |
|
|
|
FileVersionsPanel fileVersionTablePanel = FileVersionsPanel.getInstance(); |
|
|
|
FileVersionsPanel fileVersionTablePanel = FileVersionsPanel.getInstance(); |
|
|
|
fileVersionTablePanel.showFileVersionsPane(); |
|
|
|
fileVersionTablePanel.showFileVersionsPane(); |
|
|
|
|
|
|
|
stateChange(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 版本管理可用状态的监控 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void fireVcsActionChange() { |
|
|
|
|
|
|
|
if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() || VcsHelper.getInstance().isUnSelectedTemplate() || FineClusterConfig.getInstance().isCluster()) { |
|
|
|
|
|
|
|
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())) { |
|
|
|
|
|
|
|
setEnabled(false); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
setEnabled(true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
setEnabled(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
//当前环境为本地环境时
|
|
|
|
|
|
|
|
setEnabled(selectedOperation.getFilePath() != null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void closeOpenedTemplate(String path, boolean isCurrentEditing) { |
|
|
|
private void closeOpenedTemplate(String path, boolean isCurrentEditing) { |
|
|
@ -321,12 +405,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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 在系统资源管理器中打开 |
|
|
|
* 在系统资源管理器中打开 |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -428,62 +506,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); |
|
|
|
|
|
|
|
handleVcsAction(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 其他状态
|
|
|
|
|
|
|
|
otherStateChange(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void handleVcsAction() { |
|
|
|
|
|
|
|
if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() || VcsHelper.isUnSelectedTemplate()) { |
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 重命名对话框 |
|
|
|
* 重命名对话框 |
|
|
|
* 支持快捷键Enter,ESC |
|
|
|
* 支持快捷键Enter,ESC |
|
|
|