mirror of https://github.com/buggins/dlangide.git
popup menu support for workspace tree
This commit is contained in:
parent
da35064cd8
commit
0fee21f99c
|
@ -36,8 +36,17 @@ enum IDEActions : int {
|
|||
WindowCloseAllDocuments,
|
||||
CreateNewWorkspace,
|
||||
AddToCurrentWorkspace,
|
||||
ProjectFolderAddItem,
|
||||
ProjectFolderRemoveItem,
|
||||
ProjectFolderOpenItem,
|
||||
ProjectFolderRenameItem,
|
||||
}
|
||||
|
||||
const Action ACTION_PROJECT_FOLDER_ADD_ITEM = new Action(IDEActions.ProjectFolderAddItem, "MENU_PROJECT_FOLDER_ADD_ITEM"c);
|
||||
const Action ACTION_PROJECT_FOLDER_OPEN_ITEM = new Action(IDEActions.ProjectFolderOpenItem, "MENU_PROJECT_FOLDER_OPEN_ITEM"c);
|
||||
const Action ACTION_PROJECT_FOLDER_REMOVE_ITEM = new Action(IDEActions.ProjectFolderRemoveItem, "MENU_PROJECT_FOLDER_REMOVE_ITEM"c);
|
||||
const Action ACTION_PROJECT_FOLDER_RENAME_ITEM = new Action(IDEActions.ProjectFolderRenameItem, "MENU_PROJECT_FOLDER_RENAME_ITEM"c);
|
||||
|
||||
const Action ACTION_FILE_NEW_SOURCE_FILE = new Action(IDEActions.FileNew, "MENU_FILE_NEW_SOURCE_FILE"c, "document-new", KeyCode.KEY_N, KeyFlag.Control);
|
||||
const Action ACTION_FILE_NEW_PROJECT = new Action(IDEActions.FileNewProject, "MENU_FILE_NEW_PROJECT"c);
|
||||
const Action ACTION_FILE_NEW_WORKSPACE = new Action(IDEActions.FileNewWorkspace, "MENU_FILE_NEW_WORKSPACE"c);
|
||||
|
|
|
@ -3,6 +3,7 @@ module dlangide.ui.wspanel;
|
|||
import dlangui.all;
|
||||
import dlangide.workspace.workspace;
|
||||
import dlangide.workspace.project;
|
||||
import dlangide.ui.commands;
|
||||
|
||||
enum ProjectItemType : int {
|
||||
None,
|
||||
|
@ -66,9 +67,54 @@ class WorkspacePanel : DockWindow {
|
|||
_tree.selectionListener = &onTreeItemSelected;
|
||||
_tree.fontSize = 16;
|
||||
_tree.noCollapseForSingleTopLevelItem = true;
|
||||
_tree.popupMenuListener = &onTreeItemPopupMenu;
|
||||
|
||||
_workspacePopupMenu = new MenuItem();
|
||||
_workspacePopupMenu.add(ACTION_PROJECT_FOLDER_ADD_ITEM);
|
||||
|
||||
_projectPopupMenu = new MenuItem();
|
||||
_projectPopupMenu.add(ACTION_PROJECT_FOLDER_ADD_ITEM, ACTION_PROJECT_FOLDER_OPEN_ITEM,
|
||||
ACTION_PROJECT_FOLDER_REMOVE_ITEM);
|
||||
|
||||
_folderPopupMenu = new MenuItem();
|
||||
_folderPopupMenu.add(ACTION_PROJECT_FOLDER_ADD_ITEM, ACTION_PROJECT_FOLDER_OPEN_ITEM,
|
||||
ACTION_PROJECT_FOLDER_REMOVE_ITEM, ACTION_PROJECT_FOLDER_RENAME_ITEM);
|
||||
_filePopupMenu = new MenuItem();
|
||||
_filePopupMenu.add(ACTION_PROJECT_FOLDER_ADD_ITEM, ACTION_PROJECT_FOLDER_OPEN_ITEM,
|
||||
ACTION_PROJECT_FOLDER_REMOVE_ITEM, ACTION_PROJECT_FOLDER_RENAME_ITEM);
|
||||
return _tree;
|
||||
}
|
||||
|
||||
protected MenuItem _workspacePopupMenu;
|
||||
protected MenuItem _projectPopupMenu;
|
||||
protected MenuItem _folderPopupMenu;
|
||||
protected MenuItem _filePopupMenu;
|
||||
protected string _popupMenuSelectedItemId;
|
||||
protected void onPopupMenuItem(MenuItem item) {
|
||||
if (item.action)
|
||||
handleAction(item.action);
|
||||
}
|
||||
|
||||
protected MenuItem onTreeItemPopupMenu(TreeItems source, TreeItem selectedItem) {
|
||||
MenuItem menu = null;
|
||||
_popupMenuSelectedItemId = selectedItem.id;
|
||||
if (selectedItem.intParam == ProjectItemType.SourceFolder) {
|
||||
menu = _folderPopupMenu;
|
||||
} else if (selectedItem.intParam == ProjectItemType.SourceFile) {
|
||||
menu = _filePopupMenu;
|
||||
} else if (selectedItem.intParam == ProjectItemType.Project) {
|
||||
menu = _projectPopupMenu;
|
||||
} else if (selectedItem.intParam == ProjectItemType.Workspace) {
|
||||
menu = _workspacePopupMenu;
|
||||
}
|
||||
if (menu && menu.subitemCount) {
|
||||
menu.onMenuItem = &onPopupMenuItem;
|
||||
menu.updateActionState(this);
|
||||
return menu;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@property Workspace workspace() {
|
||||
return _workspace;
|
||||
}
|
||||
|
|
|
@ -61,3 +61,8 @@ TAB_ANIMATION=Animation
|
|||
TAB_TABLE_LAYOUT=Table layout
|
||||
TAB_EDITORS=Editors
|
||||
|
||||
|
||||
MENU_PROJECT_FOLDER_ADD_ITEM=Add...
|
||||
MENU_PROJECT_FOLDER_OPEN_ITEM=Open
|
||||
MENU_PROJECT_FOLDER_REMOVE_ITEM=Remove
|
||||
MENU_PROJECT_FOLDER_RENAME_ITEM=Rename...
|
||||
|
|
Loading…
Reference in New Issue