Auto open last project, repair recent projects opening, some translations improvments

This commit is contained in:
Vitaly Livshic 2017-08-06 15:19:23 +03:00
parent d0bcf70269
commit 1e71bdd63e
8 changed files with 184 additions and 37 deletions

View File

@ -132,8 +132,8 @@ const Action ACTION_HELP_VIEW_HELP = new Action(IDEActions.HelpViewHelp, "MENU_H
const Action ACTION_WINDOW_CLOSE_DOCUMENT = new Action(IDEActions.WindowCloseDocument, "MENU_WINDOW_CLOSE_DOCUMENT"c, null, KeyCode.KEY_W, KeyFlag.Control);
const Action ACTION_WINDOW_CLOSE_ALL_DOCUMENTS = new Action(IDEActions.WindowCloseAllDocuments, "MENU_WINDOW_CLOSE_ALL_DOCUMENTS"c);
const Action ACTION_CREATE_NEW_WORKSPACE = new Action(IDEActions.CreateNewWorkspace, "Create new workspace"d);
const Action ACTION_ADD_TO_CURRENT_WORKSPACE = new Action(IDEActions.AddToCurrentWorkspace, "Add to current workspace"d);
const Action ACTION_CREATE_NEW_WORKSPACE = new Action(IDEActions.CreateNewWorkspace, "OPTION_CREATE_NEW_WORKSPACE"c);
const Action ACTION_ADD_TO_CURRENT_WORKSPACE = new Action(IDEActions.AddToCurrentWorkspace, "OPTION_ADD_TO_CURRENT_WORKSPACE"c);
const Action ACTION_GET_DOC_COMMENTS = (new Action(IDEActions.GetDocComments, "SHOW_DOC_COMMENTS"c, ""c, KeyCode.KEY_D, KeyFlag.Control|KeyFlag.Shift)).addAccelerator(KeyCode.F12, KeyFlag.Control).disableByDefault();
const Action ACTION_GO_TO_DEFINITION = (new Action(IDEActions.GoToDefinition, "GO_TO_DEFINITION"c, ""c, KeyCode.KEY_G, KeyFlag.Control)).addAccelerator(KeyCode.F12, 0).disableByDefault();

View File

@ -284,10 +284,11 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
}
}
if (!program.isDebugger)
_logPanel.logLine("Starting " ~ executableFileName);
_logPanel.logLine("MSG_STARTING"c ~ " " ~ executableFileName);
else
_logPanel.logLine("Starting debugger for " ~ executableFileName);
_statusLine.setBackgroundOperationStatus("debug-run", program.isDebugger ? "debugging..."d : "running..."d);
_logPanel.logLine("MSG_STARTING_DEBUGGER"c ~ " " ~ executableFileName);
const auto status = program.isDebugger ? UIString("DEBUGGING"c).value : UIString("RUNNING"c).value;
_statusLine.setBackgroundOperationStatus("debug-run", status);
string[string] env;
program.setExecutableParams(executableFileName, args, workingDirectory, env);
if (!tty.empty) {
@ -456,8 +457,17 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
_tabs.selectTab(index, true);
} else {
HomeScreen home = new HomeScreen(HOME_SCREEN_ID, this);
_tabs.addTab(home, "DlangIDE Home"d, null, true);
_tabs.addTab(home, UIString("HOME"c), null, true);
_tabs.selectTab(HOME_SCREEN_ID, true);
auto _settings = new IDESettings(buildNormalizedPath(settingsDir, "settings.json"));
// Auto open last project
const auto recentWorkspaces = settings.recentWorkspaces;
if (recentWorkspaces.length > 0 && _settings.autoOpenLastProject())
{
Action a = ACTION_FILE_OPEN_WORKSPACE.clone();
a.stringParam = recentWorkspaces[0];
handleAction(a);
}
}
}
@ -879,7 +889,7 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
Platform.instance.openURL(HELP_PAGE_URL);
return true;
case IDEActions.HelpAbout:
window.showMessageBox(UIString("About DlangIDE "d ~ DLANGIDE_VERSION),
window.showMessageBox(UIString("ABOUT"c) ~ " " ~ DLANGIDE_VERSION,
UIString("DLangIDE\n(C) Vadim Lopatin, 2014-2016\nhttp://github.com/buggins/dlangide\nIDE for D programming language written in D\nUses DlangUI library for GUI"d));
return true;
case StandardAction.OpenUrl:
@ -887,10 +897,10 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
return true;
case IDEActions.FileOpen:
UIString caption;
caption = "Open Text File"d;
caption = UIString("HEADER_OPEN_TEXT_FILE"c);
FileDialog dlg = createFileDialog(caption);
dlg.addFilter(FileFilterEntry(UIString("Source files"d), "*.d;*.dd;*.ddoc;*.di;*.dh;*.json;*.sdl;*.xml;*.ini"));
dlg.addFilter(FileFilterEntry(UIString("All files"d), "*.*"));
dlg.addFilter(FileFilterEntry(UIString("SOURCE_FILES"c), "*.d;*.dd;*.ddoc;*.di;*.dh;*.json;*.sdl;*.xml;*.ini"));
dlg.addFilter(FileFilterEntry(UIString("ALL_FILES"c), "*.*"));
dlg.path = _settings.getRecentPath("FILE_OPEN_PATH");
dlg.dialogResult = delegate(Dialog d, const Action result) {
if (result.id == ACTION_OPEN.id) {
@ -960,14 +970,15 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
});
return true;
case IDEActions.FileOpenWorkspace:
// Already specified workspace
if (!a.stringParam.empty) {
openFileOrWorkspace(a.stringParam);
return true;
}
UIString caption;
caption = "Open Workspace or Project"d;
// Ask user for workspace to open
UIString caption = "HEADER_OPEN_WORKSPACE_OR_PROJECT"c;
FileDialog dlg = createFileDialog(caption);
dlg.addFilter(FileFilterEntry(UIString("Workspace and project files"d), "*.dlangidews;dub.json;dub.sdl;package.json"));
dlg.addFilter(FileFilterEntry(UIString("WORKSPACE_AND_PROJECT_FILES"c), "*.dlangidews;dub.json;dub.sdl;package.json"));
dlg.path = _settings.getRecentPath("FILE_OPEN_WORKSPACE_PATH");
dlg.dialogResult = delegate(Dialog d, const Action result) {
if (result.id == ACTION_OPEN.id) {
@ -1227,7 +1238,7 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
//Log.d("settings before copy:\n", _settings.setting.toJSON(true));
Setting s = _settings.copySettings();
//Log.d("settings after copy:\n", s.toJSON(true));
SettingsDialog dlg = new SettingsDialog(UIString("DlangIDE settings"d), window, s, createSettingsPages());
SettingsDialog dlg = new SettingsDialog(UIString("HEADER_SETTINGS"c), window, s, createSettingsPages());
dlg.dialogResult = delegate(Dialog dlg, const Action result) {
if (result.id == ACTION_APPLY.id) {
//Log.d("settings after edit:\n", s.toJSON(true));
@ -1290,14 +1301,16 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
private bool loadProject(Project project) {
if (!project.load()) {
_logPanel.logLine("Cannot read project " ~ project.filename);
window.showMessageBox(UIString("Cannot open project"d), UIString("Error occured while opening project "d ~ toUTF32(project.filename)));
window.showMessageBox(UIString("ERROR_OPEN_PROJECT"c).value, UIString("ERROR_OPENING_PROJECT"c).value ~ toUTF32(project.filename));
return false;
}
const auto msg = UIString("MSG_OPENED_PROJECT"c);
_logPanel.logLine(toUTF32("Project file " ~ project.filename ~ " is opened ok"));
return true;
}
void openFileOrWorkspace(string filename) {
// Open DlangIDE workspace file
if (filename.isWorkspaceFile) {
Workspace ws = new Workspace(this);
if (ws.load(filename)) {
@ -1307,22 +1320,23 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
_settings.updateRecentWorkspace(filename);
});
} else {
window.showMessageBox(UIString("Cannot open workspace"d), UIString("Error occured while opening workspace"d));
window.showMessageBox(UIString("ERROR_OPEN_WORKSPACE"c).value, UIString("ERROR_OPENING_WORKSPACE"c).value);
return;
}
} else if (filename.isProjectFile) {
} else if (filename.isProjectFile) { // Open non-DlangIDE project file or DlangIDE project
_logPanel.clear();
_logPanel.logLine("Trying to open project from " ~ filename);
const auto msg = "MSG_TRY_OPEN_PROJECT"c;
_logPanel.logLine(msg ~ " " ~ filename);
Project project = new Project(currentWorkspace, filename);
string defWsFile = project.defWorkspaceFile;
if (currentWorkspace) {
Project existing = currentWorkspace.findProject(project.filename);
if (existing) {
_logPanel.logLine("This project already exists in current workspace");
window.showMessageBox(UIString("Open project"d), UIString("Project is already in workspace"d));
_logPanel.logLine("MSG_PROJECT_ALREADY_OPENED"c);
window.showMessageBox(UIString("MSG_OPEN_PROJECT"c), UIString("MSG_PROJECT_ALREADY_OPENED"c));
return;
}
window.showMessageBox(UIString("Open project"d), UIString("Do you want to create new workspace or use current one?"d),
window.showMessageBox(UIString("MSG_OPEN_PROJECT"c), UIString("QUESTION_NEW_WORKSPACE"c),
[ACTION_ADD_TO_CURRENT_WORKSPACE, ACTION_CREATE_NEW_WORKSPACE, ACTION_CANCEL], 0, delegate(const Action result) {
if (result.id == IDEActions.CreateNewWorkspace) {
// new ws
@ -1344,7 +1358,7 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
}
} else {
_logPanel.logLine("File is not recognized as DlangIDE project or workspace file");
window.showMessageBox(UIString("Invalid workspace file"d), UIString("This file is not a valid workspace or project file"d));
window.showMessageBox(UIString("ERROR_INVALID_WORKSPACE_FILE"c), UIString("ERROR_INVALID_WS_OR_PROJECT_FILE"c));
}
}
@ -1361,7 +1375,10 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
Workspace ws = new Workspace(this);
ws.name = project.name;
ws.description = project.description;
Log.d("workspace name: ", project.name);
Log.d("workspace description: ", project.description);
ws.addProject(project);
// Load project data
loadProject(project);
ws.save(defWsFile);
setWorkspace(ws);

View File

@ -6,6 +6,7 @@ import dlangui.widgets.scroll;
import dlangui.widgets.controls;
import dlangide.ui.frame;
import dlangide.ui.commands;
import dlangui.core.i18n;
import std.path;
import std.utf : toUTF32;
@ -30,11 +31,11 @@ class HomeScreen : ScrollWidget {
_column2.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT).padding(Rect(pad, pad, pad, pad));
_content.addChild(_column1);
_content.addChild(_column2);
_column1.addChild((new TextWidget(null, "Dlang IDE"d ~ " " ~ DLANGIDE_VERSION)).fontSize(32).textColor(linkColor));
_column1.addChild((new TextWidget(null, "D language IDE written in D"d)).fontSize(20));
_column1.addChild((new TextWidget(null, "(c) Vadim Lopatin 2015"d)).fontSize(22).textColor(linkColor));
_column1.addChild((new TextWidget(null, "Dlang IDE "d ~ DLANGIDE_VERSION)).fontSize(32).textColor(linkColor));
_column1.addChild((new TextWidget(null, UIString("DESCRIPTION"c))).fontSize(20));
_column1.addChild((new TextWidget(null, UIString("COPYRIGHT"c))).fontSize(22).textColor(linkColor));
_column1.addChild(new VSpacer());
_column1.addChild((new TextWidget(null, "Start with:"d)).fontSize(20).textColor(linkColor));
_column1.addChild((new TextWidget(null, UIString("START_WITH"c))).fontSize(20).textColor(linkColor));
_startItems = new VerticalLayout();
_recentItems = new VerticalLayout();
_startItems.addChild(new ImageTextButton(ACTION_FILE_OPEN_WORKSPACE));
@ -42,7 +43,9 @@ class HomeScreen : ScrollWidget {
_startItems.addChild(new ImageTextButton(ACTION_FILE_NEW_PROJECT));
_column1.addChild(_startItems);
_column1.addChild(new VSpacer());
_column1.addChild((new TextWidget(null, "Recent:"d)).fontSize(20).textColor(linkColor));
// Recent workspaces
_column1.addChild((new TextWidget(null, UIString("RECENT"c))).fontSize(20).textColor(linkColor));
string[] recentWorkspaces = _frame.settings.recentWorkspaces;
if (recentWorkspaces.length) {
foreach(fn; recentWorkspaces) {
@ -52,15 +55,17 @@ class HomeScreen : ScrollWidget {
_column1.addChild(new LinkButton(a));
}
} else {
_recentItems.addChild((new TextWidget(null, "No recent items"d)));
_recentItems.addChild((new TextWidget(null, UIString("NO_RECENT"c))));
}
_column1.addChild(_recentItems);
// Useful links
_column1.addChild(new VSpacer());
_column2.addChild((new TextWidget(null, "Useful Links:"d)).fontSize(20).textColor(linkColor));
_column2.addChild(new UrlImageTextButton(null, "D Programming Language"d, "http://dlang.org/"));
_column2.addChild(new UrlImageTextButton(null, "DUB repository"d, "http://code.dlang.org/"));
_column2.addChild(new UrlImageTextButton(null, "DLangUI on GitHub"d, "https://github.com/buggins/dlangui"));
_column2.addChild(new UrlImageTextButton(null, "DLangIDE on GitHub"d, "https://github.com/buggins/dlangide"));
_column2.addChild((new TextWidget(null, UIString("USEFUL_LINKS"c))).fontSize(20).textColor(linkColor));
_column2.addChild(new UrlImageTextButton(null, UIString("D_LANG"c).value, "http://dlang.org/"));
_column2.addChild(new UrlImageTextButton(null, UIString("DUB_REP"c).value, "http://code.dlang.org/"));
_column2.addChild(new UrlImageTextButton(null, UIString("DLANG_UI"c).value, "https://github.com/buggins/dlangui"));
_column2.addChild(new UrlImageTextButton(null, UIString("DLANG_IDE"c).value, "https://github.com/buggins/dlangide"));
_column2.addChild(new VSpacer());
contentWidget = _content;
}

View File

@ -12,8 +12,14 @@ public import dlangide.workspace.workspacesettings;
/// create DlangIDE settings pages tree
SettingsPage createSettingsPages() {
// Root page
SettingsPage res = new SettingsPage("", UIString(""d));
// Common page
SettingsPage common = res.addChild("common", UIString("OPTION_COMMON"c));
common.addCheckbox("common/autoOpenLastProject", UIString("OPTION_AUTO_OPEN_LAST_PROJECT"c));
// UI settings page
SettingsPage ui = res.addChild("interface", UIString("OPTION_INTERFACE"c));
ui.addStringComboBox("interface/theme", UIString("OPTION_THEME"c), [
StringListValue("ide_theme_default", "OPTION_DEFAULT"c),

View File

@ -280,5 +280,9 @@ class IDESettings : SettingsFile {
save();
}
@property bool autoOpenLastProject() {
Setting obj =_setting.objectByPath("common/autoOpenLastProject");
return _setting.objectByPath("common/autoOpenLastProject").boolean;
}
}

View File

@ -244,8 +244,31 @@ class Workspace : WorkspaceItem {
if (_filename.empty) // no file name specified
return false;
_settings.save(_filename ~ WORKSPACE_SETTINGS_EXTENSION);
// If name is null, then compose it from projects
// If description is null, then compose it from project's descriptions
immutable auto nf = _name.empty;
immutable auto df = _description.empty;
if (nf || df)
{
_name = nf ? "" : _name;
_description = df ? "" : _description;
foreach (Project p; _projects) {
if (p.isDependency)
continue; // don't add dependency
if (nf)
_name ~= p.name ~ ",";
if (df)
_description ~= p.description ~ " / ";
}
if (!_name.empty) // cut off last comma
_name = _name[ 0 .. $ - 1 ];
if (!_description.empty) // cut off last delimiter
_description = _description[ 0 .. $ - 3 ];
}
_workspaceFile.setString("name", toUTF8(_name));
_workspaceFile.setString("description", toUTF8(_description));
Log.d("workspace name: ", _name);
Log.d("workspace description: ", _description);
Setting projects = _workspaceFile.objectByPath("projects", true);
projects.clear(SettingType.OBJECT);
foreach (Project p; _projects) {

View File

@ -1,4 +1,21 @@
EXIT=Exit
ABOUT=About DlangIDE
HOME=DlangIDE Home
DESCRIPTION=D language IDE written in D
COPYRIGHT=(c) Vadim Lopatin 2015
START_WITH=Start with:
RECENT=Recent:
NO_RECENT=No recent items
USEFUL_LINKS=Useful Links:
D_LANG=D Programming Language
DUB_REP=DUB repository
DLANG_UI=DLangUI on GitHub
DLANG_IDE=DLangIDE on GitHub
EXIT=Exit
ALL_FILES=All files
SOURCE_FILES=Source files
WORKSPACE_AND_PROJECT_FILES=Workspace and project files
MENU_FILE=&File
MENU_FILE_NEW=&Create
MENU_FILE_NEW_SOURCE_FILE=New file
@ -97,6 +114,14 @@ MENU_PROJECT_FOLDER_RENAME_ITEM=Rename...
MENU_PROJECT_FOLDER_REFRESH=Refresh
MENU_PROJECT_REVEAL_IN_EXPLORER=Reveal in Explorer
HEADER_SETTINGS=DlangIDE settings
HEADER_OPEN_WORKSPACE_OR_PROJECT=Open Workspace or Project
HEADER_OPEN_TEXT_FILE=Open Text File
OPTION_ADD_TO_CURRENT_WORKSPACE=Add to current workspace
OPTION_AUTO_OPEN_LAST_PROJECT=Auto open last project
OPTION_COMMON=Common
OPTION_CREATE_NEW_WORKSPACE=Create new workspace
OPTION_DARK=Dark
OPTION_DEBUGGER=Debugger
OPTION_DEBUGGER_EXECUTABLE=Debugger executable
@ -133,3 +158,20 @@ OPTION_TERMINAL_EXECUTABLE=Terminal executable
OPTION_THEME=Theme
OPTION_TOOLCHANS=Toolchains
OPTION_USE_SPACES=Use spaces for tabs
ERROR_INVALID_WORKSPACE_FILE=Invalid workspace file
ERROR_INVALID_WS_OR_PROJECT_FILE=This file is not a valid workspace or project file
ERROR_OPEN_PROJECT=Cannot open project
ERROR_OPEN_WORKSPACE=Cannot open workspace
ERROR_OPENING_PROJECT=Error occured while opening project
ERROR_OPENING_WORKSPACE=Error occured while opening workspace
MSG_OPEN_PROJECT=Open project
MSG_PROJECT_ALREADY_OPENED=Project is already in workspace
MSG_STARTING=Starting
MSG_STARTING_DEBUGGER=Starting debugger for
MSG_TRY_OPEN_PROJECT=Trying to open project from
DEBUGGING=debugging...
RUNNING=running...
QUESTION_NEW_WORKSPACE=Do you want to create new workspace or use current one?

View File

@ -1,4 +1,21 @@
EXIT=Выход
ABOUT=О DlangIDE
HOME=Домашняя страница DlangIDE
DESCRIPTION=IDE для языка D написанная на D
COPYRIGHT=(c) Вадим Лопатин 2015
START_WITH=Начать с:
RECENT=Недавнее:
NO_RECENT=Нет недавно открытых файлов/проектов
USEFUL_LINKS=Полезные ссылки:
D_LANG=Язык программирования D
DUB_REP=Хранилище DUB
DLANG_UI=DLangUI на GitHub
DLANG_IDE=DLangIDE на GitHub
EXIT=Выход
ALL_FILES=Все файлы
SOURCE_FILES=Исходники
WORKSPACE_AND_PROJECT_FILES=Файлы проектов и раб. прост.
MENU_FILE=&Файл
MENU_FILE_NEW=&Создать
MENU_FILE_NEW_SOURCE_FILE=Новый файл
@ -41,6 +58,7 @@ SHOW_PAREN_COMPLETION=Показать параметры вызова
FIND_IN_FILES=Найти в файлах...
MENU_BUILD_CONFIGURATIONS=Собрать конфигурации
MENU_BUILD=&Сборка
MENU_BUILD_WORKSPACE_BUILD=Собрать рабочее пространство
MENU_BUILD_WORKSPACE_REBUILD=Пересобрать рабочее пространство
@ -89,6 +107,21 @@ TAB_ANIMATION=Анимация
TAB_TABLE_LAYOUT=Табличный layout
TAB_EDITORS=Редакторы
MENU_PROJECT_FOLDER_ADD_ITEM=Добавить...
MENU_PROJECT_FOLDER_OPEN_ITEM=Открыть
MENU_PROJECT_FOLDER_REMOVE_ITEM=Удалить
MENU_PROJECT_FOLDER_RENAME_ITEM=Переименовать...
MENU_PROJECT_FOLDER_REFRESH=Обновить
MENU_PROJECT_REVEAL_IN_EXPLORER=Открыть в проводнике
HEADER_SETTINGS=DlangIDE настройки
HEADER_OPEN_WORKSPACE_OR_PROJECT=Открыть рабочее пространство или проект
HEADER_OPEN_TEXT_FILE=Открыть текстовый файл
OPTION_ADD_TO_CURRENT_WORKSPACE=Добавить в текущее пр-во
OPTION_AUTO_OPEN_LAST_PROJECT=Авт.открывать последний проект
OPTION_COMMON=Общие
OPTION_CREATE_NEW_WORKSPACE=Создать новое пр-во
OPTION_DARK=Темная
OPTION_DEBUGGER=Отладчик
OPTION_DEBUGGER_EXECUTABLE=Исполняемый файл отладчика
@ -125,3 +158,20 @@ OPTION_TERMINAL_EXECUTABLE=Исполняемый файл терминала
OPTION_THEME=Тема оформления
OPTION_TOOLCHANS=Наборы инструментов
OPTION_USE_SPACES=Использовать пробелы вместо табуляции
ERROR_INVALID_WORKSPACE_FILE=Неверный файл раб.пространства
ERROR_INVALID_WS_OR_PROJECT_FILE=Файл не является ни файлом раб.пространства, ни проектным
ERROR_OPEN_PROJECT=Невозможно открыть проект
ERROR_OPEN_WORKSPACE=Невозможно открыть рабочее пространство
ERROR_OPENING_PROJECT=Ошибка в ходе открытия проекта
ERROR_OPENING_WORKSPACE=Ошибка в ходе открытия рабочего пространства
MSG_OPEN_PROJECT=Открыть проект
MSG_PROJECT_ALREADY_OPENED=Проект уже в рабочем пространстве
MSG_STARTING=Выполняем
MSG_STARTING_DEBUGGER=Стартуем отладчик для
MSG_TRY_OPEN_PROJECT=Попытка открыть проект из
DEBUGGING=отладка...
RUNNING=выполнение...
QUESTION_NEW_WORKSPACE=Открыть новое рабочее пространство или использовать текущее?