Skip to content

Commit

Permalink
Merge pull request #50 from zowe/staging
Browse files Browse the repository at this point in the history
Zowe Suite 1.3.0
  • Loading branch information
1000TurquoisePogs authored May 24, 2019
2 parents fcca350 + 64fc3f4 commit 7d95aec
Show file tree
Hide file tree
Showing 25 changed files with 493 additions and 12,194 deletions.
2 changes: 1 addition & 1 deletion pluginDefinition.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"identifier": "org.zowe.editor",
"apiVersion": "1.0.0",
"pluginVersion": "2.0.0",
"pluginVersion": "2.1.0",
"pluginType": "application",
"webContent": {
"framework": "angular",
Expand Down
28 changes: 22 additions & 6 deletions webClient/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion webClient/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "org.zowe.editor.webclient",
"version": "2.0.0",
"version": "2.1.0",
"license": "EPL-2.0",
"scripts": {
"start": "webpack --config ./webpack.build.config.js --watch --progress",
Expand Down
4 changes: 4 additions & 0 deletions webClient/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export class AppComponent {

handleLaunchOrMessageObject(data: any) {
switch (data.type) {
case 'test-language':
this.log.info(`Setting language test mode`);
this.editorControl._isTestLangMode = true;
break;
case 'openFile':
//TODO should this or must this also load the directory at the time that the file is
let lastSlash = data.name.lastIndexOf("/");
Expand Down
2 changes: 1 addition & 1 deletion webClient/src/app/core/core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { MenuBarComponent } from './menu-bar/menu-bar.component';
imports: [
CommonModule,
MatIconModule,
MatDialogModule,
MatDialogModule
],
exports: [
NavComponent,
Expand Down
6 changes: 3 additions & 3 deletions webClient/src/app/core/menu-bar/menu-bar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
<ul class="gz-menu-list">
<li class="gz-menu-section" [ngClass]="{'active': menuActive}" *ngFor="let menu of menuList" (click)="menuActive = !menuActive">
{{menu.name}}
<div class="gz-menu-function">
<div class="gz-menu-function" *ngIf="menuActive">
<ul>
<li class="gz-menu-function-item" [ngClass]="{'group-line': function.name === 'group-end'}" *ngFor="let function of menu.children"
(click)="menuAction(function.action.name, function.action.params)">
<mat-icon *ngIf="function.type === 'checkbox' && menuAction(function.active.name, function.active.params)" class="gz-menu-function-check">
(click)="menuAction(function.action)">
<mat-icon *ngIf="function.type === 'checkbox' && menuAction(function.active)" class="gz-menu-function-check">
fiber_manual_record
</mat-icon>
<span>{{ function.name !== 'group-end' ? menuLabel(function) : '' }}</span>
Expand Down
205 changes: 164 additions & 41 deletions webClient/src/app/core/menu-bar/menu-bar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
import { Component, OnInit, Inject } from '@angular/core';
import { MatDialog } from '@angular/material';
import { MENU } from './menu-bar.config';
import { MENU, TEST_LANGUAGE_MENU } from './menu-bar.config';
import { EditorControlService } from '../../shared/editor-control/editor-control.service';
import { OpenProjectComponent } from '../../shared/dialog/open-project/open-project.component';
import { OpenFolderComponent } from '../../shared/dialog/open-folder/open-folder.component';
Expand All @@ -33,9 +33,16 @@ import { Angular2InjectionTokens } from 'pluginlib/inject-resources';
styleUrls: ['./menu-bar.component.scss', '../../../styles.scss']
})
export class MenuBarComponent implements OnInit {
private menuList: any = MENU;
private menuActive: any = false;
private menuList: any = MENU.slice(0);//clone to prevent language from persisting
private currentLang: string | undefined;
private fileCount: number = 0;
private languageSelectionMenu: any = {
name: 'Language',
children: []
};

private languagesMenu: any = {};

constructor(
private http: HttpService,
private editorControl: EditorControlService,
Expand All @@ -44,43 +51,56 @@ export class MenuBarComponent implements OnInit {
private utils: UtilsService,
private dialog: MatDialog,
private snackBar: SnackBarService,
@Inject(Angular2InjectionTokens.LOGGER) private log: ZLUX.ComponentLogger
@Inject(Angular2InjectionTokens.LOGGER) private log: ZLUX.ComponentLogger,
@Inject(Angular2InjectionTokens.PLUGIN_DEFINITION) private pluginDefinition: ZLUX.ContainerPluginDefinition
) {
// add monaco languages support to menu
let languageSelectionMenu = {
name: 'Language',
children: []
};

/*
//Ideas: load languages at this time, if response occurs after file open, append results to monaco and try to reset it to the language
this.httpClient.get(ZoweZLUX.uriBroker.pluginConfigUri(this.pluginDefinition, 'languages/definitions')).subscribe(data=> {
monaco.languages.register(language);
if (language) {
setLanguage()
monaco.languages.setMonarchTokensProvider('hlasm', <any>HLASM_HILITE);
}
});
this.httpClient.get(ZoweZLUX.uriBroker.pluginConfigUri(this.pluginDefinition, 'languages/menus')).subscribe(data=> {
});
*/

this.editorControl.languageRegistered.subscribe((languageDefinition)=> {
this.resetLanguageSelectionMenu();
});

this.editorControl.selectFile.subscribe((fileContext)=> {
if (this.fileCount != 0){this.showLanguageMenu(fileContext.model.language);}
});

this.editorControl.initializedFile.subscribe((fileContext)=> {
this.showLanguageMenu(fileContext.model.language);
this.fileCount++;
this.log.debug(`fileCount now=`,this.fileCount);
});

this.editorControl.closeFile.subscribe(()=> {
if (this.fileCount != 0) {
this.fileCount--;
this.log.debug(`fileCount now=`,this.fileCount);
} else {
this.log.warn(`Open file count cannot be made negative`);
}
this.removeLanguageMenu();
});

this.editorControl.changeLanguage.subscribe((obj:{context: any, language: string})=> {
this.showLanguageMenu(obj.language);
});

this.editorControl.editorCore.subscribe((monaco) => {
if (monaco != null) {
//This is triggered after monaco initializes & is loaded with configuration items
languageSelectionMenu.children = monaco.languages.getLanguages().sort(function(lang1, lang2) {
let name1 = lang1.aliases[0].toLowerCase();
let name2 = lang2.aliases[0].toLowerCase();
if (name1 < name2) {
return -1;
} else if (name1 > name2) {
return 1;
} else {
return 0;
}
}).map(language => {
return {
name: language.aliases[0],
type: 'checkbox',
action: {
name: 'setEditorLanguage',
params: [language.id],
},
active: {
name: 'languageActiveCheck',
params: [language.id],
}
}});
let existItem = this.menuList.filter(m => m.name === 'Language');
existItem.length > 0 ? existItem.children = languageSelectionMenu.children
: this.menuList.splice(-1, 0, languageSelectionMenu);
this.resetLanguageSelectionMenu();
}
});

Expand All @@ -89,14 +109,110 @@ export class MenuBarComponent implements OnInit {
// });
}

private resetLanguageSelectionMenu() {
const monaco = this.editorControl.editorCore.getValue();
if (!monaco) {
this.log.warn(`Language registered without monaco present`);
return;
}
this.languageSelectionMenu.children = monaco.languages.getLanguages().sort(function(lang1, lang2) {
let name1 = lang1.aliases[0].toLowerCase();
let name2 = lang2.aliases[0].toLowerCase();
if (name1 < name2) {
return -1;
} else if (name1 > name2) {
return 1;
} else {
return 0;
}
}).map(language => {
return {
name: language.aliases[0],
type: 'checkbox',
action: {
internalName: 'setEditorLanguage',
params: [language.id]
},
active: {
internalName: 'languageActiveCheck',
params: [language.id]
}
}
});
}

removeLanguageMenu() {
const removeSelectionMenu = this.fileCount===0;
for (let i = 0; i < this.menuList.length; i++) {
if (this.currentLang && this.menuList[i].name === this.currentLang) {
this.menuList.splice(i,1);
if (!removeSelectionMenu) {
break;
}
i = -1;
} else if (removeSelectionMenu && this.menuList[i].name === 'Language') {
this.menuList.splice(i,1);
i = -1;
}
}
}

showLanguageMenu(language) {
let menus = [];
if (this.fileCount===0) {//will become 1 after
//add language selection menu, too
menus.push(this.languageSelectionMenu);
}

if (language) {
this.removeLanguageMenu();

let menuChildren = this.languagesMenu[language];
if (menuChildren) {
menus.push({
name: language,
children: menuChildren
});
this.currentLang = language;
}
}
if (menus.length>0) {
this.menuList.splice(this.fileCount===0 ? 1 : 2 ,0,...menus);
}
}

ngOnInit() {
if (this.editorControl._isTestLangMode) {
this.log.info(`Adding test language menu`);
this.languagesMenu['TEST_LANGUAGE'] = TEST_LANGUAGE_MENU;
}
}

//this is dumb because everything is local to this file.
//It needs to be anonymous functions given editorControl, monaco, and fileNode
menuAction(actionName: string, actionParams: any[]): any {
if (actionName != null) {
return this[actionName].apply(this, actionParams != null ? actionParams : []);
menuAction(menuItem: any): any {
if (!menuItem) {
return;
}
if (menuItem.internalName != null) {
return this[menuItem.internalName].apply(this, menuItem.params ? menuItem.params : []);
} else {
if (!menuItem.func) {
if (menuItem.functionString) {
menuItem.func = new Function('context', menuItem.functionString);
} else {
this.log.warn(`Cant do menu action, no function to execute.`);
return;
}
}
const editor = this.editorControl.editor.getValue();
if (editor) {
//TODO do we also need fileNode?
menuItem.func({
editor: editor,
controller: this.editorControl,
log: this.log
}, ...menuItem.params);
}
return;
}
}

Expand Down Expand Up @@ -165,7 +281,13 @@ export class MenuBarComponent implements OnInit {

saveFile() {
let fileContext = this.editorControl.fetchActiveFile();
let sub = this.monacoService.saveFile(fileContext).subscribe(() => { sub.unsubscribe(); });
if (!fileContext) {
this.snackBar.open('Warning: Cannot save, no file found', 'Dismiss', {duration: MessageDuration.Medium, panelClass: 'center'});
} else if (fileContext.model.isDataset) {
this.snackBar.open('Dataset saving not yet supported', 'Dismiss', {duration: MessageDuration.Short, panelClass: 'center'});
} else {
let sub = this.monacoService.saveFile(fileContext).subscribe(() => { sub.unsubscribe(); });
}
}

//saveAll() {
Expand Down Expand Up @@ -225,6 +347,7 @@ export class MenuBarComponent implements OnInit {
setEditorLanguage(language: string) {
let fileContext = this.editorControl.fetchActiveFile();
this.editorControl.setHighlightingModeForBuffer(fileContext, language);
this.editorControl.setThemeForLanguage(language);
}

languageActiveCheck(language: string): boolean {
Expand Down
Loading

0 comments on commit 7d95aec

Please sign in to comment.