Skip to content

Commit

Permalink
Merge staging (v1.4.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
zowe-robot authored Jul 18, 2019
2 parents 7d95aec + 4420d1c commit 690d527
Show file tree
Hide file tree
Showing 23 changed files with 371 additions and 87 deletions.
4 changes: 2 additions & 2 deletions pluginDefinition.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"descriptionDefault": "Zowe Editor",
"isSingleWindowApp": true,
"defaultWindowStyle": {
"width": 1600,
"height": 800
"width": 1200,
"height": 600
}
}
}
2 changes: 1 addition & 1 deletion webClient/package-lock.json

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

4 changes: 4 additions & 0 deletions webClient/src/app/app.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1984,11 +1984,15 @@ input.mat-input-element {
padding-top: 32px;
.header {
margin-top: -32px;
position: absolute;
width: 100%;
height: 100%;
app-nav {
display: block;
}
app-menu-bar {
display: block;
height: 100%;
}
}
main.main-frame {
Expand Down
2 changes: 1 addition & 1 deletion webClient/src/app/core/menu-bar/menu-bar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{{menu.name}}
<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"
<li class="gz-menu-function-item" [ngClass]="getMenuItemStyle(function)" *ngFor="let function of menu.children"
(click)="menuAction(function.action)">
<mat-icon *ngIf="function.type === 'checkbox' && menuAction(function.active)" class="gz-menu-function-check">
fiber_manual_record
Expand Down
12 changes: 10 additions & 2 deletions webClient/src/app/core/menu-bar/menu-bar.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
:host {
.gz-menu-bar {
background-color: #303030;
height: 100%;
.gz-menu-list {
font-family: Arial, sans-serif;
list-style-type: none;
color: #e0e0e0;
display: flex;
flex-direction: row;
padding: 0px;
height: 32px;
height: 100%;
margin-bottom: 0;
.gz-menu-section {
position: relative;
Expand Down Expand Up @@ -46,6 +47,13 @@
margin: 5px 0;
}
}
.gz-menu-function-item.disabled {
color: #9d9d9d;
pointer-events: none;
}
.gz-menu-function-item.disabled:hover {
background-color: #586198;
}
.gz-menu-function-item:hover {
background-color: #e0e0e0;
}
Expand All @@ -57,7 +65,7 @@
display: initial;
position: absolute;
left: 0;
max-height: 588px;
max-height: calc(90% - 45px);
overflow-y: auto;
}
}
Expand Down
116 changes: 82 additions & 34 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, TEST_LANGUAGE_MENU } from './menu-bar.config';
import { MENU, TEST_LANGUAGE_MENU, LANGUAGE_MENUS } 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 @@ -27,6 +27,29 @@ import { MessageDuration } from "../../shared/message-duration";
import { DeleteFileComponent } from '../../shared/dialog/delete-file/delete-file.component';
import { Angular2InjectionTokens } from 'pluginlib/inject-resources';

function initMenu(menuItems) {
menuItems.forEach(function(menuItem) {
if (menuItem.action && !menuItem.action.func && menuItem.action.functionString) {
menuItem.action.func = new Function('context', menuItem.action.functionString);
}
if (!menuItem.isDisabled && menuItem.isDisabledString) {
menuItem.isDisabled = new Function('context', menuItem.isDisabledString);
}
});
return menuItems;
}
function initMenus(menus) {
if (menus.isArray) {
return initMenu(menus);
} else {
const keys = (Object as any).keys(menus);
for (let i = 0; i < keys.length; i++){
menus[keys[i]] = initMenu(menus[keys[i]]);
}
return menus;
}
}

@Component({
selector: 'app-menu-bar',
templateUrl: './menu-bar.component.html',
Expand All @@ -36,12 +59,13 @@ export class MenuBarComponent implements OnInit {
private menuList: any = MENU.slice(0);//clone to prevent language from persisting
private currentLang: string | undefined;
private fileCount: number = 0;
private monaco: any;
private languageSelectionMenu: any = {
name: 'Language',
children: []
};

private languagesMenu: any = {};
public languagesMenu: any = (Object as any).assign({}, LANGUAGE_MENUS);//clone for sanitization

constructor(
private http: HttpService,
Expand All @@ -68,6 +92,7 @@ export class MenuBarComponent implements OnInit {
});
*/
this.languagesMenu = initMenus(this.languagesMenu);

this.editorControl.languageRegistered.subscribe((languageDefinition)=> {
this.resetLanguageSelectionMenu();
Expand Down Expand Up @@ -99,6 +124,7 @@ export class MenuBarComponent implements OnInit {

this.editorControl.editorCore.subscribe((monaco) => {
if (monaco != null) {
this.monaco = monaco;
//This is triggered after monaco initializes & is loaded with configuration items
this.resetLanguageSelectionMenu();
}
Expand All @@ -107,15 +133,30 @@ export class MenuBarComponent implements OnInit {
// this.editorControl.saveAllFile.subscribe(x => {
// this.saveAll();
// });

}

private resetLanguageSelectionMenu() {
const monaco = this.editorControl.editorCore.getValue();
if (!monaco) {
this.log.warn(`Language registered without monaco present`);
return;
public getMenuItemStyle(menuItem) {
let style = [];
if (menuItem.name === 'group-end') {
style.push('group-line');
}
const editor = this.editorControl.editor.getValue();
if (editor) {
if (menuItem.isDisabled
&& menuItem.isDisabled({
editor: editor,
controller: this.editorControl,
log: this.log
})) {
style.push('disabled');
}
}
this.languageSelectionMenu.children = monaco.languages.getLanguages().sort(function(lang1, lang2) {
return style;
}

private resetLanguageSelectionMenu() {
this.languageSelectionMenu.children = this.monaco.languages.getLanguages().sort(function(lang1, lang2) {
let name1 = lang1.aliases[0].toLowerCase();
let name2 = lang2.aliases[0].toLowerCase();
if (name1 < name2) {
Expand All @@ -141,6 +182,16 @@ export class MenuBarComponent implements OnInit {
});
}

private getReadableLangName(languageId) {
const languages = this.monaco.languages.getLanguages();
for (let language of languages) {
if (language.id === languageId) {
return language.aliases ? language.aliases[0] : languageId;
}
}
return languageId;
}

removeLanguageMenu() {
const removeSelectionMenu = this.fileCount===0;
for (let i = 0; i < this.menuList.length; i++) {
Expand All @@ -163,17 +214,17 @@ export class MenuBarComponent implements OnInit {
//add language selection menu, too
menus.push(this.languageSelectionMenu);
}


this.removeLanguageMenu();
if (language) {
this.removeLanguageMenu();

let menuChildren = this.languagesMenu[language];
if (menuChildren) {
let readableLanguage = this.getReadableLangName(language)
menus.push({
name: language,
name: readableLanguage,
children: menuChildren
});
this.currentLang = language;
this.currentLang = readableLanguage;
}
}
if (menus.length>0) {
Expand All @@ -192,27 +243,21 @@ export class MenuBarComponent implements OnInit {
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);
const editor = this.editorControl.editor.getValue();
if (editor) {
const context = { editor: editor,
controller: this.editorControl,
log: this.log };

if (menuItem.internalName != null) {
return this[menuItem.internalName].apply(this, menuItem.params ? menuItem.params : []);
} else if (menuItem.func) {
menuItem.func(context, ...menuItem.params);
return;
} else {
this.log.warn(`Cant do menu action, no function to execute.`);
return;
}
return;
}
}

Expand Down Expand Up @@ -362,6 +407,8 @@ export class MenuBarComponent implements OnInit {

createFile() {
this.editorControl.createFile("(new)");
let fileContext = this.editorControl.fetchActiveFile();
this.editorControl.initializedFile.next(fileContext);
/*
let newFileRef = this.dialog.open(NewFileComponent, {
width: '500px'
Expand Down Expand Up @@ -395,7 +442,7 @@ export class MenuBarComponent implements OnInit {

newFileRef.afterClosed().subscribe(result => {
if (result) {
this.languageServer.updateSettings(JSON.parse(result.config));
this.languageServer.updateSettings(result);
if (result.enable) {
this.editorControl.connToLS.next();
} else {
Expand All @@ -406,6 +453,7 @@ export class MenuBarComponent implements OnInit {
}
}


/*
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
Expand Down
Loading

0 comments on commit 690d527

Please sign in to comment.