Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open Files, Command Output, and Notifications Updates #3672

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ this.updateFilters = (function NWC_updateFilters() {
}
}).bind(this);

/**
* Clear all notifications
*/
this.clearMessages = (function NWC_clearMessages() {
while (this.container.firstChild)
this.container.removeChild(this.container.firstChild);
this._map = {};
}).bind(this);

/**
* Determine whether a given item should be shown
* @param aElem {richlistitem} The item to check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
<toolbarbutton type="checkbox" id="filter-progress"
tooltiptext="&filterProgressTooltip;"
oncommand="NotificationsWidgetController.updateFilters()"/>
<toolbarbutton id="notifications-clear"
tooltiptext="&notificationsClearTooltip;"
oncommand="NotificationsWidgetController.clearMessages()"/>
</toolbargroup>
</toolbar>
</box>
Expand Down
4 changes: 4 additions & 0 deletions src/chrome/komodo/content/run/runOutputPane.xul
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
tooltiptext="&terminateProcess.tooltiptext;"
oncommand="ko.run.output.kill(-1);"
disabled="true"/>
<toolbarbutton id="runoutput-clear-button"
class="icon-close"
tooltiptext="&clearOutput.tooltiptext;"
oncommand="ko.run.output.clearOutput();" />
</toolbar>
</box>

Expand Down
15 changes: 15 additions & 0 deletions src/chrome/komodo/content/run/runOutputWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,21 @@ this.kill = function RunOutput_Kill(retval)
}
}

/** Clear */
this.clearOutput = function RunOutput_ClearOutput()
{
var descWidget = document.getElementById("runoutput-desc");
var cmdWidget = document.getElementById("runoutput-command");
descWidget.setAttribute("value", "");
cmdWidget.setAttribute("value", "");

// Clear session
if (_gTerminalView && !_gTerminalHandler.active)
{
_gTerminalView.startSession(true);
_gTerminalView.endSession();
}
}

function _SetView(editor, showParsedOutputList)
{
Expand Down
1 change: 1 addition & 0 deletions src/chrome/komodo/locale/en-US/komodo.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<!ENTITY checkForUpdates.label "Check for Updates...">
<!ENTITY checkSyntaxNow.label "Check syntax now">
<!ENTITY cleanLineEndings.label "Clean Line Endings">
<!ENTITY clearOutput.tooltiptext "Clear Output">
<!ENTITY clearSearchHighlighting.label "Clear Highlighting">
<!ENTITY clearWarningErrorSquigglies.label "Clear warning/error squigglies">
<!ENTITY close.label "Close">
Expand Down
1 change: 1 addition & 0 deletions src/chrome/komodo/locale/en-US/notifications.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<!ENTITY filterWarningTooltip "Toggle whether warnings are shown">
<!ENTITY filterInfoTooltip "Toggle whether informational messages are shown">
<!ENTITY filterProgressTooltip "Toggle whether to limit to in-progress tasks">
<!ENTITY notificationsClearTooltip "Clear all messages">
<!ENTITY filterSearchEmpty "Filter messages">
1 change: 1 addition & 0 deletions src/chrome/komodo/skin/global/icons.less
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ richlistitem.file-item[view-type="browser"]
#filter-warning { .icon(); .icon-exclamation-circle(); }
#filter-info { .icon(); .icon-info-circle(); }
#filter-progress { .icon(); .icon-clock-o(); }
#notifications-clear { .icon(); .icon-close(); }
}

.scrollbutton-up
Expand Down
3 changes: 3 additions & 0 deletions src/chrome/komodo/skin/notifications.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#filter-progress {
list-style-image: url("chrome://fugue/skin/icons/clock-history.png");
}
#notifications-clear {
list-style-image: url("chrome://global/skin/icons/close.png");
}

#filter-search {
-moz-box-flex: 1;
Expand Down
5 changes: 5 additions & 0 deletions src/chrome/komodo/skin/plat/shared/icons_rules.less
Original file line number Diff line number Diff line change
Expand Up @@ -1616,6 +1616,11 @@ ko-pane[type="icons"]
{
list-style-image: @icon-filter-progress !important;
}

#notifications-clear
{
list-style-image: @icon-close !important;
}
}

/* Syntax checking widget */
Expand Down
89 changes: 83 additions & 6 deletions src/modules/openfiles/content/openfiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ if (typeof ko.openfiles == 'undefined')
var groupOptions = {};
var sortOptions = {};

/** Filters. Array of arrays. First dimension is an AND. Second is an OR. */
var filters = [];

/** File separator */
const system = require("sdk/system");
const sep = system.platform == "winnt" ? "\\" : "/";

/* Keep track of listeners so we can remove them if needed */
var listeners = {};

Expand Down Expand Up @@ -91,6 +98,9 @@ if (typeof ko.openfiles == 'undefined')
template.groupItem.removeAttribute('id')
tpl.parentNode.removeChild(tpl);

// Disables select handler
this._disableSelectHandler = false;

// Register built in sorting options
this.registerSortOption(
'byName',
Expand Down Expand Up @@ -449,7 +459,7 @@ if (typeof ko.openfiles == 'undefined')

/**** OpenFiles Events ******/
listbox.addEventListener('select', function(e) {
if (e.target == listbox && e.target.selectedItem)
if (e.target == listbox && e.target.selectedItem && !this._disableSelectHandler)
{
this.selectItem(e.target.selectedItem, true /*sendEditorTabClick*/ );
ko.commands.doCommandAsync('cmd_focusEditor')
Expand Down Expand Up @@ -658,6 +668,8 @@ if (typeof ko.openfiles == 'undefined')
*/
drawList: function openfiles_drawList(noDelay = false)
{
var hasRemovedItems = false;

// Prevent multiple calls in a short amount of time (10ms)
if ( ! noDelay) {
clearTimeout(timers.drawList || {});
Expand All @@ -671,14 +683,58 @@ if (typeof ko.openfiles == 'undefined')
// Iterate through open views and append them to the list
for (let uid of Object.keys(openViews))
{
// Get view
var editorView = openViews[uid];

// Check filters
var foundInFilter = true;
if (filters.length > 0)
{
var dirName = editorView.koDoc.file ? editorView.koDoc.file.dirName : '';
var file = dirName + sep + editorView.title;
file = file.toLowerCase();

// Check AND filters
for (var filterIdx = 0; filterIdx < filters.length; filterIdx++)
{
// Check OR filters
var orFilters = filters[filterIdx];
var foundInOr = false;
for (var orFiltersIdx = 0; orFiltersIdx < orFilters.length; orFiltersIdx++)
{
if (file.indexOf(orFilters[orFiltersIdx]) !== -1)
{
foundInOr = true;
break;
}
}
if (!foundInOr)
{
foundInFilter = false;
break;
}
}
}

// Skip items that are already in the list
if (listbox.querySelector('richlistitem[id="'+uid+'"]'))
var existingItem = listbox.querySelector('richlistitem[id="'+uid+'"]');
if (existingItem !== null)
{
// Remove if shouldn't be in list
if (!foundInFilter)
{
hasRemovedItems = true;
existingItem.parentNode.removeChild(existingItem);
}

continue;
}


// Skip if not found in filters
if (!foundInFilter)
continue;

// Append the item
var editorView = openViews[uid];
var listItem = listbox.appendChild(
this.createListItem(editorView));

Expand All @@ -691,7 +747,11 @@ if (typeof ko.openfiles == 'undefined')
this.selectItem(editorView);
}
}


// Remove empty groups caused by removed items
if (hasRemovedItems)
this.removeEmptyGroups();

// Render the groups and splits
this.drawGroups();
this.updateLabelCounter();
Expand Down Expand Up @@ -1906,8 +1966,25 @@ if (typeof ko.openfiles == 'undefined')
{
var groupOption = ko.prefs.getString(PREF_GROUPING_TYPE, 'byLanguage');
return groupOptions[groupOption];
},

/** Update filters */
updateFilters: function openfiles_updateFilters()
{
filters = [];
var textSearch = document.getElementById("filter-search").value.toLowerCase().trim();
if (textSearch.length > 0)
{
for (var word of textSearch.split(/\s+/))
filters.push(word.split("|"));
}

// Redraw list
var orig_disableSelectHandler = this._disableSelectHandler;
this._disableSelectHandler = true;
this.drawList(true);
this._disableSelectHandler = orig_disableSelectHandler;
}

};

ko.openfiles = new ko.openfiles();
Expand Down
7 changes: 7 additions & 0 deletions src/modules/openfiles/content/panel.xul
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@
tooltiptext="&closeFiles.tooltip;"/>

</richlistitem>
<box class="widgetToolbarWrap centered">
<textbox id="filter-search" flex="1"
emptytext="&openFiles.filterSearch;" type="search"
oninput="ko.openfiles.updateFilters();"
oncommand="ko.openfiles.updateFilters();" />
<separator flex="1"/>
</box>
</vbox>
</vbox>

Expand Down
1 change: 1 addition & 0 deletions src/modules/openfiles/locale/en-US/openfiles.dtd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!ENTITY openFiles.label "Open Files">
<!ENTITY openFiles.filterSearch "Filter Files">
<!ENTITY viewEditorTabs.label "Show Editor Tabs">
<!ENTITY viewEditorTabs.tooltip "Toggle Editor Tabs">
<!ENTITY closeFile.tooltip "Close File">
Expand Down