Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
fixes #73
Browse files Browse the repository at this point in the history
  • Loading branch information
jcaillon committed Feb 15, 2017
1 parent e8803fc commit 7da840a
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 83 deletions.
20 changes: 13 additions & 7 deletions 3PA/MainFeatures/AppliMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,13 @@ public static void ShowEditCodeMenuAtCursor() {
/// <returns></returns>
private static List<MenuItem> DisableItemIfNeeded(List<MenuItem> list) {
var isCurrentFileProgressFile = Abl.IsCurrentProgressFile;
list.ForEach(item => item.IsDisabled = !isCurrentFileProgressFile && (!item.Generic));
foreach (var menu in list) {
menu.IsDisabled = !isCurrentFileProgressFile && !menu.Generic;
if (menu.Children != null)
foreach (var subMenu in menu.Children.Cast<MenuItem>()) {
subMenu.IsDisabled = !isCurrentFileProgressFile && (!menu.Generic || !subMenu.Generic);
}
}
return list;
}

Expand Down Expand Up @@ -227,7 +233,7 @@ private AppliMenu() {
_databaseTools = new List<MenuItem> {
new MenuItem(this, "Open data administration", ImageResources.DataAdmin, item => ProMisc.OpenDbAdmin(), "Data_admin", "") { Generic = true },
new MenuItem(this, "Open progress dictionary", ImageResources.Dictionary, item => ProMisc.OpenDictionary(), "Data_dictionary", "") { Generic = true },
new MenuItem(true), // --------------------------
new MenuItem(true) { Generic = true }, // --------------------------
new MenuItem(this, "Explore and modify your data", ImageResources.DataDigger, item => ProMisc.OpenDataDigger(), "Data_digger", "") { Generic = true },
new MenuItem(this, "Explore (read-only) your data", ImageResources.DataReader, item => ProMisc.OpenDataReader(), "Data_reader", "") { Generic = true },

Expand All @@ -248,24 +254,24 @@ private AppliMenu() {
MainMenuList = new List<MenuItem> {
new MenuItem(this, "Show main window", ImageResources.MainWindow, item => Appli.Appli.ToggleView(), "Open_main_window", "Alt+Space") { Generic = true },
new MenuItem(this, "Show auto-completion at caret", ImageResources.Autocompletion, item => AutoCompletion.OnShowCompleteSuggestionList(), "Show_Suggestion_List", "Ctrl+Space"),
new MenuItem(true), // --------------------------
new MenuItem(true) { Generic = true }, // --------------------------
new MenuItem(this, "Open 4GL help", ImageResources.ProgressHelp, item => ProMisc.Open4GlHelp(), "Open_4GL_help", "F1") { Generic = true },
new MenuItem(this, "Check syntax", ImageResources.CheckCode, item => ProMisc.StartProgressExec(ExecutionType.CheckSyntax), "Check_syntax", "Shift+F1"),
new MenuItem(this, "Compile", ImageResources.CompileCode, item => ProMisc.StartProgressExec(ExecutionType.Compile), "Compile", "Alt+F1"),
new MenuItem(this, "Run program", ImageResources.RunCode, item => ProMisc.StartProgressExec(ExecutionType.Run), "Run_program", "Ctrl+F1"),
new MenuItem(this, "Prolint code", ImageResources.ProlintCode, item => ProMisc.StartProgressExec(ExecutionType.Prolint), "Prolint", "F12"),
new MenuItem(this, "Deploy current file", ImageResources.Deploy, item => ProMisc.DeployCurrentFile(), "Deploy", "Ctrl+Alt+Prior") { Generic = true },
new MenuItem(true), // --------------------------
new MenuItem(true) { Generic = true }, // --------------------------
new MenuItem(this, "Progress desktop", ImageResources.ProDesktop, item => ProMisc.OpenProDesktop(), "Pro_desktop", "") { Generic = true },
new MenuItem(this, "Open in the AppBuilder", ImageResources.SendToAppbuilder, item => ProMisc.OpenCurrentInAppbuilder(), "Send_appbuilder", "Alt+O"),
new MenuItem(true), // --------------------------
new MenuItem(true) { Generic = true }, // --------------------------
new MenuItem(this, "Start searching files", ImageResources.Search, item => FileExplorer.FileExplorer.Instance.StartSearch(), "Search_file", "Alt+Q") { Generic = true },
goToDefItem,
goToPreviousJump,
//new MenuItem(this, "New 4GL file", ImageResources.GenerateCode, ShowNewFileAtCursor, "New_file", "Ctrl+Shift+N") {
// Children = GenerateCodeMenuList.Select(item => (YamuiMenuItem)item).ToList(),
//},
new MenuItem(true), // --------------------------
new MenuItem(true) { Generic = true }, // --------------------------
new MenuItem(this, "Switch environment", ImageResources.Env, item => ShowEnvMenuAtCursor(), "Switch_env", "Ctrl+E") {
Generic = true
},
Expand All @@ -282,7 +288,7 @@ private AppliMenu() {
new MenuItem(this, "Miscellaneous", ImageResources.Miscellaneous, item => ShowMiscMenuAtCursor(), "Miscellaneous", "Alt+M") {
Children = _miscMenuList.Cast<FilteredTypeTreeListItem>().ToList()
},
new MenuItem(true), // --------------------------
new MenuItem(true) { Generic = true }, // --------------------------
new MenuItem(this, "Options", ImageResources.ShowOptions, item => Appli.Appli.GoToPage(PageNames.OptionsGeneral), "Go_to_options", null) {Generic = true}
};

Expand Down
9 changes: 4 additions & 5 deletions 3PA/MainFeatures/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ internal class ConfigObject {
[Range(1000, 30000)]
public int FileExplorerListFilesTimeOutInMs = 3000;

// Current folder mode for the file explorer : local/compilation/propath/everywhere
public int FileExplorerDirectoriesToExplore = 0;

#endregion

#region CODE EXPLORER
Expand Down Expand Up @@ -376,11 +379,7 @@ internal class ConfigObject {
public NppEncodingFormat AutoSwitchEncodingTo = NppEncodingFormat._Automatic_default;

#endregion


// Current folder mode for the file explorer : local/compilation/propath/everywhere
public int FileExplorerViewMode = 3;


// Shared configuration last folder selected
public string SharedConfFolder = "";
// a list of Label corresponding to confLine(s) that are auto-updated
Expand Down
14 changes: 8 additions & 6 deletions 3PA/MainFeatures/FileExplorer/FileExplorer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using YamuiFramework.Controls.YamuiList;
using YamuiFramework.Helper;
Expand Down Expand Up @@ -159,18 +160,19 @@ public List<FileListItem> ListFileOjectsInDirectory(string dirPath, bool recursi
try {
foreach (var directoryInfo in dirInfo.GetDirectories()) {
if (!Config.Instance.FileExplorerIgnoreUnixHiddenFolders || !regex.IsMatch(directoryInfo.FullName)) {
// recursive
if (recursive && DateTime.Now.Subtract(_startTime).TotalMilliseconds <= Config.Instance.FileExplorerListFilesTimeOutInMs) {
output.AddRange(ListFileOjectsInDirectory(directoryInfo.FullName, true, true, false));
}
output.Add(new FileListItem {
var folderItem = new FileListItem {
DisplayText = directoryInfo.Name,
BasePath = Path.GetDirectoryName(directoryInfo.FullName),
FullPath = directoryInfo.FullName,
CreateDateTime = directoryInfo.CreationTime,
ModifieDateTime = directoryInfo.LastWriteTime,
Type = FileType.Folder
});
};
output.Add(folderItem);
// recursive
if (recursive && DateTime.Now.Subtract(_startTime).TotalMilliseconds <= Config.Instance.FileExplorerListFilesTimeOutInMs) {
folderItem.Children = ListFileOjectsInDirectory(directoryInfo.FullName, true, true, false).Cast<FilteredTypeTreeListItem>().ToList();
}
}
}
} catch (Exception e) {
Expand Down
20 changes: 8 additions & 12 deletions 3PA/MainFeatures/FileExplorer/FileExplorerForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,6 @@ protected override void OnVisibleChanged(EventArgs e) {

#endregion

#region File list

#region Refresh file list and selector mechanic

/// <summary>
Expand Down Expand Up @@ -228,7 +226,7 @@ private void RefreshFileListAction() {

// get the list of FileObjects
_initialObjectsList = new List<FileListItem>();
switch (Config.Instance.FileExplorerViewMode) {
switch (Config.Instance.FileExplorerDirectoriesToExplore) {
case 0:
_initialObjectsList = FileExplorer.Instance.ListFileOjectsInDirectory(ProEnvironment.Current.BaseLocalPath);
break;
Expand Down Expand Up @@ -284,8 +282,6 @@ private void RefreshFileListAction() {

#endregion

#endregion

#region File list events

private void YamuiListOnEnterPressed(YamuiScrollList yamuiScrollList, KeyEventArgs keyEventArgs) {
Expand Down Expand Up @@ -322,25 +318,25 @@ private void RefreshGotoDirButton() {
// refresh a button depending on the mode...
if (IsHandleCreated) {
BeginInvoke((Action) delegate {
btGotoDir.Visible = Config.Instance.FileExplorerViewMode <= 1;
Image tryImg = (Image)ImageResources.ResourceManager.GetObject("ExplorerDir" + Config.Instance.FileExplorerViewMode);
btGotoDir.Visible = Config.Instance.FileExplorerDirectoriesToExplore <= 1;
Image tryImg = (Image)ImageResources.ResourceManager.GetObject("ExplorerDir" + Config.Instance.FileExplorerDirectoriesToExplore);
btDirectory.BackGrndImage = tryImg ?? ImageResources.Error;
btDirectory.Invalidate();
lbDirectory.Text = _explorerDirStr[Config.Instance.FileExplorerViewMode];
lbDirectory.Text = _explorerDirStr[Config.Instance.FileExplorerDirectoriesToExplore];
});
}
}

private void BtGotoDirOnButtonPressed(object sender, EventArgs buttonPressedEventArgs) {
if (Config.Instance.FileExplorerViewMode == 0)
if (Config.Instance.FileExplorerDirectoriesToExplore == 0)
Utils.OpenFolder(ProEnvironment.Current.BaseLocalPath);
else if (Config.Instance.FileExplorerViewMode == 1)
else if (Config.Instance.FileExplorerDirectoriesToExplore == 1)
Utils.OpenFolder(ProEnvironment.Current.BaseCompilationPath);
}

private void BtDirectoryOnButtonPressed(object sender, EventArgs buttonPressedEventArgs) {
Config.Instance.FileExplorerViewMode++;
if (Config.Instance.FileExplorerViewMode > 3) Config.Instance.FileExplorerViewMode = 0;
Config.Instance.FileExplorerDirectoriesToExplore++;
if (Config.Instance.FileExplorerDirectoriesToExplore > 3) Config.Instance.FileExplorerDirectoriesToExplore = 0;
RefreshGotoDirButton();

RefreshFileList();
Expand Down
4 changes: 4 additions & 0 deletions 3PA/MainFeatures/FileExplorer/FileListItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ public override List<Image> TagImages {
/// </summary>
public override List<FilteredTypeTreeListItem> Children { get; set; }

// make all items expanded by default
public FileListItem() {
IsExpanded = true;
}
}

/// <summary>
Expand Down
17 changes: 2 additions & 15 deletions YamuiFramework/Controls/YamuiList/ListItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ public class ListItem {

#region private

private bool _isSeparator;
private bool _isDisabled;

#endregion

#region Virtual properties
Expand All @@ -46,22 +43,12 @@ public class ListItem {
/// <summary>
/// The item is disabled or not (a separator is necesseraly disabled)
/// </summary>
public virtual bool IsDisabled {
get { return _isDisabled; }
set { _isDisabled = _isSeparator || value; }
}
public virtual bool IsDisabled { get; set; }

/// <summary>
/// true if the item is a separator
/// </summary>
public virtual bool IsSeparator {
get { return _isSeparator; }
set {
_isSeparator = value;
if (_isSeparator)
IsDisabled = true;
}
}
public virtual bool IsSeparator { get; set; }

#endregion

Expand Down
8 changes: 5 additions & 3 deletions YamuiFramework/Controls/YamuiList/YamuiFilteredList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ protected virtual List<ListItem> GetFilteredAndSortedList(List<FilteredListItem>
/// Called by default to paint the row if no OnRowPaint is defined
/// </summary>
protected override void RowPaint(ListItem item, YamuiListRow row, PaintEventArgs e) {
var backColor = YamuiThemeManager.Current.MenuBg(row.IsSelected, row.IsHovered, !item.IsDisabled);
var backColor = item.IsSeparator ?
YamuiThemeManager.Current.MenuBg(false, false, !item.IsDisabled) :
YamuiThemeManager.Current.MenuBg(row.IsSelected, row.IsHovered, !item.IsDisabled);
var foreColor = YamuiThemeManager.Current.MenuFg(row.IsSelected, row.IsHovered, !item.IsDisabled);

// background
Expand All @@ -241,7 +243,7 @@ protected override void RowPaint(ListItem item, YamuiListRow row, PaintEventArgs

// foreground
// left line
if (row.IsSelected && !item.IsDisabled) {
if (row.IsSelected) {
using (SolidBrush b = new SolidBrush(YamuiThemeManager.Current.AccentColor)) {
e.Graphics.FillRectangle(b, new Rectangle(0, 0, 3, row.ClientRectangle.Height));
}
Expand All @@ -250,7 +252,7 @@ protected override void RowPaint(ListItem item, YamuiListRow row, PaintEventArgs
var textRectangle = new Rectangle(5, 0, row.ClientRectangle.Width - 5, RowHeight);

// letter highlight
if (!item.IsDisabled)
if (!(item.IsDisabled || item.IsSeparator))
DrawTextHighlighting(e.Graphics, ((FilteredListItem) item).InternalFilterMatchedRanges, textRectangle, item.DisplayText, TextFlags);

// text
Expand Down
8 changes: 5 additions & 3 deletions YamuiFramework/Controls/YamuiList/YamuiFilteredTypeList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,11 @@ protected override void DrawButtons() {
/// Called by default to paint the row if no OnRowPaint is defined
/// </summary>
protected override void RowPaint(ListItem item, YamuiListRow row, PaintEventArgs e) {

// background
var backColor = YamuiThemeManager.Current.MenuBg(row.IsSelected, row.IsHovered, !item.IsDisabled);
var backColor = item.IsSeparator ?
YamuiThemeManager.Current.MenuBg(false, false, !item.IsDisabled) :
YamuiThemeManager.Current.MenuBg(row.IsSelected, row.IsHovered, !item.IsDisabled);
e.Graphics.Clear(backColor);

var curItem = item as FilteredTypeListItem;
Expand Down Expand Up @@ -436,7 +438,7 @@ protected virtual void DrawFilteredTypeRow(Graphics g, FilteredTypeListItem item
var textRectangle = new Rectangle(drawRect.X + 3 + (img != null ? img.Width : 0), 0, drawRect.Width - 3 - (img != null ? img.Width : 0), drawRect.Height);

// letter highlight
if (!item.IsDisabled)
if (!(item.IsDisabled || item.IsSeparator))
DrawTextHighlighting(g, item.InternalFilterMatchedRanges, textRectangle, item.DisplayText, TextFlags);

// text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ private bool ExpandCollapse(int itemIndex, ForceExpansion forceExpansion) {
protected override void RowPaint(ListItem item, YamuiListRow row, PaintEventArgs e) {

// background
var backColor = YamuiThemeManager.Current.MenuBg(row.IsSelected, row.IsHovered, !item.IsDisabled);
var backColor = item.IsSeparator ?
YamuiThemeManager.Current.MenuBg(false, false, !item.IsDisabled) :
YamuiThemeManager.Current.MenuBg(row.IsSelected, row.IsHovered, !item.IsDisabled);
e.Graphics.Clear(backColor);

var curItem = item as FilteredTypeTreeListItem;
Expand Down Expand Up @@ -328,7 +330,7 @@ protected virtual Rectangle RowPaintTree(Graphics g, FilteredTypeTreeListItem cu

// draw the branches of the tree
if (ShowTreeBranches) {
using (var linePen = new Pen(!curItem.IsDisabled || curItem.IsSeparator ? YamuiThemeManager.Current.SubTextFore : foreColor, 1.5f) { DashStyle = DashStyle.Solid }) {
using (var linePen = new Pen(!(curItem.IsDisabled || curItem.IsSeparator) ? YamuiThemeManager.Current.SubTextFore : foreColor, 1.5f) { DashStyle = DashStyle.Solid }) {

var pos = drawRect.X + TreeWidth / 2;
if (curItem.Level >= 1)
Expand Down
Loading

0 comments on commit 7da840a

Please sign in to comment.