-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from anzwdev/master
Update
- Loading branch information
Showing
51 changed files
with
1,436 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<html> | ||
<header> | ||
<script src="##EXTENSIONPATH##/htmlresources/lib/jquery/jquery.min.js"></script> | ||
<script src="##EXTENSIONPATH##/htmlresources/lib/jquery-ui-position/jquery.ui.position.min.js"></script> | ||
<script src="##EXTENSIONPATH##/htmlresources/lib/jquery-context-menu/js/jquery.contextmenu.min.js"></script> | ||
<script src="##EXTENSIONPATH##/htmlresources/lib/filtercompiler/filterCompiler.js"></script> | ||
<script src="##EXTENSIONPATH##/htmlresources/lib/azgridview/azgridview.js"></script> | ||
<script src="##EXTENSIONPATH##/htmlresources/carulesviewer/js/carulesviewer.js"></script> | ||
<script src="##EXTENSIONPATH##/htmlresources/carulesviewer/js/startup.js"></script> | ||
<link rel="stylesheet" type="text/css" href="##EXTENSIONPATH##/htmlresources/lib/jquery-context-menu/css/jquery.contextMenu.css"> | ||
<link rel="stylesheet" type="text/css" href="##EXTENSIONPATH##/htmlresources/lib/azgridview/azgridview.css"> | ||
<link rel="stylesheet" type="text/css" href="##EXTENSIONPATH##/htmlresources/carulesviewer/css/carulesviewer.css"> | ||
</header> | ||
|
||
<div id="search"> | ||
<div class="searchcaption">Code Analyzer:</div> | ||
<select id="analyzers" class="searchinput" tabindex="1"></select> | ||
</div> | ||
<div id="rules" tabindex="2"></div> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
body { | ||
position: absolute; | ||
left: 0; | ||
right: 0; | ||
top: 0; | ||
bottom: 0; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: stretch; | ||
justify-content: stretch; | ||
padding: 0 !important; | ||
} | ||
input:focus, select:focus, div:focus, button:focus { | ||
outline-color: var(--vscode-focusBorder) !important; | ||
} | ||
input, select { | ||
background: var(--vscode-input-background); | ||
border: 1px solid var(--vscode-panel-border); | ||
color: var(--vscode-input-foreground); | ||
} | ||
input:focus, select:focus, div:focus { | ||
outline-color: var(--vscode-focusBorder) !important; | ||
} | ||
|
||
#search .searchinput, #search .ms-options-wrap { | ||
margin: 5px 0px 5px 5px; | ||
} | ||
|
||
#search { | ||
flex: 0 0 30px; | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: stretch; | ||
padding: 0 5px; | ||
} | ||
#search .searchinput, #search .ms-options-wrap { | ||
flex: 1 1 auto; | ||
display: flex; | ||
flex-direction: row; | ||
margin: 5px 0px 5px 5px; | ||
} | ||
#search .searchcaption { | ||
flex: 0 0 auto; | ||
} | ||
|
||
#rules { | ||
flex: 1 1 auto; | ||
border: 1px solid var(--vscode-panel-border); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
class CARulesViewer { | ||
|
||
constructor() { | ||
this._vscode = acquireVsCodeApi(); | ||
this._rulesTab = new AZGridView('rules', [ | ||
{name:'id', caption:'Id', style: 'width:100px;'}, | ||
{name:'title', caption:'Title' }, | ||
{name:'defaultSeverity', caption:'Severity', style: 'width:100px' } | ||
]); | ||
this._rulesTab.clipboardEnabled = true; | ||
this._rulesTab.onClipboardCopy = (() => { | ||
this.execRuleCommand('copytable', undefined); | ||
}); | ||
|
||
this._analyzersSel = document.getElementById('analyzers'); | ||
|
||
// Handle messages sent from the extension to the webview | ||
window.addEventListener('message', event => { | ||
this.onMessage(event.data); | ||
}); | ||
|
||
document.getElementById('analyzers').addEventListener('change', event => { | ||
this.onAnalyzerChanged(); | ||
}); | ||
|
||
this.initContextMenu(); | ||
|
||
this.sendMessage({ | ||
command: 'documentLoaded' | ||
}); | ||
} | ||
|
||
onMessage(message) { | ||
switch (message.command) { | ||
case 'setAnalyzers': | ||
this.setAnalyzers(message.data); | ||
break; | ||
case 'setRules': | ||
this.setRules(message.data); | ||
break; | ||
} | ||
} | ||
|
||
sendMessage(data) { | ||
this._vscode.postMessage(data); | ||
} | ||
|
||
setAnalyzers(data) { | ||
while (this._analyzersSel.firstChild) { | ||
this._analyzersSel.removeChild(this._analyzersSel.firstChild); | ||
} | ||
|
||
if (data) { | ||
for (let i=0; i<data.length; i++) { | ||
let option = document.createElement('option'); | ||
option.label = data[i].label; | ||
option.value = data[i].value; | ||
this._analyzersSel.appendChild(option); | ||
} | ||
|
||
if (data.length > 0) { | ||
this._analyzersSel.value = data[0].value; | ||
this.onAnalyzerChanged(); | ||
} | ||
} | ||
} | ||
|
||
setRules(rules) { | ||
if (!rules) | ||
rules = []; | ||
for (let i=0; i<rules.length; i++) { | ||
rules[i].idx = i; | ||
} | ||
this._rulesTab.setData(rules); | ||
} | ||
|
||
onAnalyzerChanged() { | ||
this.sendMessage({ | ||
command: 'analyzerselected', | ||
name: this._analyzersSel.value | ||
}); | ||
} | ||
|
||
initContextMenu() { | ||
let me = this; | ||
$('#rules').contextMenu({ | ||
selector: 'tr', | ||
callback: (key, options) => { | ||
this.execRuleCommand(key, $(this)[0]); | ||
}, | ||
items: { | ||
"newruleset": {name: "New Ruleset File"}, | ||
"copyrules": {name: "Copy as Rules"}, | ||
"copytable": {name: "Copy as Table"} | ||
} | ||
}); | ||
} | ||
|
||
execRuleCommand(cmdname, selectedrow) { | ||
//merge path with selectedpaths | ||
let selFound = false; | ||
let mainItem = undefined; | ||
|
||
let items = this._rulesTab.getSelected(); | ||
let selRules = []; | ||
if (selectedrow) | ||
mainItem = selectedrow.tabData; | ||
|
||
if ((items) && (items.length > 0)) { | ||
if (!mainItem) | ||
mainItem = items[0]; | ||
|
||
for (let i=0; i<items.length; i++) { | ||
if (items[i].idx == mainItem.idx) | ||
selFound = true; | ||
selRules.push(items[i].idx); | ||
} | ||
} | ||
|
||
if (mainItem) { | ||
if (!selFound) | ||
selRules.push(mainItem.idx); | ||
|
||
this.sendMessage({ | ||
command : cmdname, | ||
mainrule : mainItem.idx, | ||
selrules: selRules}); | ||
} | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var caRulesViewer; | ||
|
||
$(function() { | ||
caRulesViewer = new CARulesViewer(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.