From b9b1b0e10b7df57a017fd30ca392d01cff90128c Mon Sep 17 00:00:00 2001
From: Anton Gushcha <ncrashed@gmail.com>
Date: Thu, 26 Feb 2015 17:54:34 +0300
Subject: [PATCH] Combobox to select project configuration

---
 src/dlangide/ui/commands.d         |  2 ++
 src/dlangide/ui/frame.d            | 11 +++++++++++
 src/dlangide/workspace/workspace.d |  7 ++++++-
 views/res/i18n/en.ini              |  1 +
 views/res/i18n/ru.ini              |  1 +
 5 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/dlangide/ui/commands.d b/src/dlangide/ui/commands.d
index d7fd6b6..f1b68ba 100644
--- a/src/dlangide/ui/commands.d
+++ b/src/dlangide/ui/commands.d
@@ -16,6 +16,7 @@ enum IDEActions : int {
     FileClose,
     FileExit,
     EditPreferences,
+    ProjectConfigurations,
     BuildConfigurations,
     BuildWorkspace,
     RebuildWorkspace,
@@ -68,6 +69,7 @@ const Action ACTION_FILE_EXIT = new Action(IDEActions.FileExit, "MENU_FILE_EXIT"
 const Action ACTION_WORKSPACE_BUILD = new Action(IDEActions.BuildWorkspace, "MENU_BUILD_WORKSPACE_BUILD"c);
 const Action ACTION_WORKSPACE_REBUILD = new Action(IDEActions.RebuildWorkspace, "MENU_BUILD_WORKSPACE_REBUILD"c);
 const Action ACTION_WORKSPACE_CLEAN = new Action(IDEActions.CleanWorkspace, "MENU_BUILD_WORKSPACE_CLEAN"c);
+const Action ACTION_PROJECT_CONFIGURATIONS = new Action(IDEActions.ProjectConfigurations, "MENU_PROJECT_CONFIGURATIONS"c);
 const Action ACTION_BUILD_CONFIGURATIONS = new Action(IDEActions.BuildConfigurations, "MENU_BUILD_CONFIGURATIONS"c);
 const Action ACTION_PROJECT_BUILD = new Action(IDEActions.BuildProject, "MENU_BUILD_PROJECT_BUILD"c, "run-build", KeyCode.F7, 0);
 const Action ACTION_PROJECT_REBUILD = new Action(IDEActions.RebuildProject, "MENU_BUILD_PROJECT_REBUILD"c, "run-build-clean", KeyCode.F7, KeyFlag.Control);
diff --git a/src/dlangide/ui/frame.d b/src/dlangide/ui/frame.d
index 67ea836..357ef3b 100644
--- a/src/dlangide/ui/frame.d
+++ b/src/dlangide/ui/frame.d
@@ -434,6 +434,17 @@ class IDEFrame : AppFrame {
         tb.addButtons(ACTION_FILE_OPEN, ACTION_FILE_SAVE, ACTION_SEPARATOR);
 
         tb.addButtons(ACTION_DEBUG_START);
+        
+        ToolBarComboBox cbProjectConfiguration = new ToolBarComboBox("projectConfig", [DEFAULT_PROJECT_CONFIGURATION]);
+        cbProjectConfiguration.onItemClickListener = delegate(Widget source, int index) {
+            if (currentWorkspace) {
+                currentWorkspace.projectConfiguration = cbProjectConfiguration.text; 
+            }
+            return true;
+        };
+        cbProjectConfiguration.action = ACTION_PROJECT_CONFIGURATIONS;
+        tb.addControl(cbProjectConfiguration);
+        
         ToolBarComboBox cbBuildConfiguration = new ToolBarComboBox("buildConfig", ["Debug"d, "Release"d, "Unittest"d]);
         cbBuildConfiguration.onItemClickListener = delegate(Widget source, int index) {
             if (currentWorkspace && index < 3) {
diff --git a/src/dlangide/workspace/workspace.d b/src/dlangide/workspace/workspace.d
index 02244f2..7181047 100644
--- a/src/dlangide/workspace/workspace.d
+++ b/src/dlangide/workspace/workspace.d
@@ -35,6 +35,7 @@ class WorkspaceException : Exception
 }
 
 immutable string WORKSPACE_EXTENSION = ".dlangidews";
+immutable dstring DEFAULT_PROJECT_CONFIGURATION = "default"d;
 
 /// return true if filename matches rules for workspace file names
 bool isWorkspaceFile(string filename) {
@@ -46,7 +47,8 @@ class Workspace : WorkspaceItem {
     protected Project[] _projects;
 
     protected BuildConfiguration _buildConfiguration;
-
+    protected dstring _projectConfiguration = DEFAULT_PROJECT_CONFIGURATION;
+    
     this(string fname = null) {
         super(fname);
     }
@@ -58,6 +60,9 @@ class Workspace : WorkspaceItem {
     @property BuildConfiguration buildConfiguration() { return _buildConfiguration; }
     @property void buildConfiguration(BuildConfiguration config) { _buildConfiguration = config; }
 
+    @property dstring projectConfiguration() { return _projectConfiguration; }
+    @property void projectConfiguration(dstring config) { _projectConfiguration = config; }
+     
     protected Project _startupProject;
 
     @property Project startupProject() { return _startupProject; }
diff --git a/views/res/i18n/en.ini b/views/res/i18n/en.ini
index 1939fe4..68922e4 100644
--- a/views/res/i18n/en.ini
+++ b/views/res/i18n/en.ini
@@ -32,6 +32,7 @@ MENU_BUILD_PROJECT_BUILD=Build Project
 MENU_BUILD_PROJECT_REBUILD=Rebuild Project
 MENU_BUILD_PROJECT_CLEAN=Clean Project
 MENU_PROJECT=&PROJECT
+MENU_PROJECT_CONFIGURATIONS=Project configurations
 MENU_PROJECT_SET_AS_STARTUP=Set as Startup Project
 MENU_PROJECT_SETTINGS=Project Settings
 MENU_PROJECT_REFRESH=Refresh Workspace Items
diff --git a/views/res/i18n/ru.ini b/views/res/i18n/ru.ini
index 82f24a2..4598b3b 100644
--- a/views/res/i18n/ru.ini
+++ b/views/res/i18n/ru.ini
@@ -11,6 +11,7 @@ MENU_EDIT_CUT=Вырезать
 MENU_EDIT_UNDO=&Отмена
 MENU_EDIT_REDO=&Повторить
 MENU_EDIT_PREFERENCES=&Настройки
+MENU_PROJECT_CONFIGURATIONS=Конфигурации проекта
 MENU_VIEW=&Вид
 MENU_VIEW_LANGUAGE=&Язык интерфейса
 MENU_VIEW_LANGUAGE_EN=English