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

Editor context menu #49

Merged
merged 14 commits into from
Jun 25, 2019
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 82 additions & 47 deletions lib/spl-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,48 +346,21 @@ export default {
label: 'IBM Streams',
shouldDisplay: self.shouldShowMenu,
beforeGroupContaining: ['tree-view:open-selected-entry-up'],
submenu: [
{
label: 'Build',
command: 'spl-build:build-download',
shouldDisplay: self.shouldShowMenuSpl
},
{
label: 'Build and submit job',
command: 'spl-build:build-submit',
shouldDisplay: self.shouldShowMenuSpl
},
{
label: 'Build',
command: 'spl-build:build-make-download',
shouldDisplay: self.shouldShowMenuMake
},
{
label: 'Build and submit job(s)',
command: 'spl-build:build-make-submit',
shouldDisplay: self.shouldShowMenuMake
},
{
label: 'Submit job',
command: 'spl-build:submit',
shouldDisplay: self.shouldShowMenuSubmit
},
{
label: 'Open IBM Cloud Private for Data dashboard',
command: 'spl-build:open-icp4d-dashboard',
shouldDisplay: self.shouldShowMenuV5.bind(self)
},
{
label: 'Open IBM Cloud dashboard',
command: 'spl-build:open-IBM-cloud-dashboard',
shouldDisplay: self.shouldShowMenuV4.bind(self)
},
{
label: 'Open IBM Streams Console',
command: 'spl-build:open-streams-console',
shouldDisplay: self.shouldShowMenu.bind(self)
}
]
submenu: self.menu(self)
Kyrellos-Salib marked this conversation as resolved.
Show resolved Hide resolved
},
{
type: 'separator'
}
],
'atom-text-editor': [
{
type: 'separator'
},
{
label: 'IBM Streams',
shouldDisplay: self.shouldShowMenu,
beforeGroupContaining: ['tree-view:open-selected-entry-up'],
Kyrellos-Salib marked this conversation as resolved.
Show resolved Hide resolved
submenu: self.menu(self)
Kyrellos-Salib marked this conversation as resolved.
Show resolved Hide resolved
},
{
type: 'separator'
Expand All @@ -397,6 +370,51 @@ export default {
);
},

menu(self) {
Kyrellos-Salib marked this conversation as resolved.
Show resolved Hide resolved
const m = [
{
label: 'Build',
command: 'spl-build:build-download',
shouldDisplay: self.shouldShowMenuSpl
},
{
label: 'Build and submit job',
command: 'spl-build:build-submit',
shouldDisplay: self.shouldShowMenuSpl
},
{
label: 'Build',
command: 'spl-build:build-make-download',
shouldDisplay: self.shouldShowMenuMake
},
{
label: 'Build and submit job(s)',
command: 'spl-build:build-make-submit',
shouldDisplay: self.shouldShowMenuMake
},
{
label: 'Submit job',
command: 'spl-build:submit',
shouldDisplay: self.shouldShowMenuSubmit
},
{
label: 'Open IBM Cloud Private for Data dashboard',
command: 'spl-build:open-icp4d-dashboard',
shouldDisplay: self.shouldShowMenuV5.bind(self)
},
{
label: 'Open IBM Cloud dashboard',
command: 'spl-build:open-IBM-cloud-dashboard',
shouldDisplay: self.shouldShowMenuV4.bind(self)
},
{
label: 'Open IBM Streams Console',
command: 'spl-build:open-streams-console',
shouldDisplay: self.shouldShowMenu.bind(self)
}
];
return m;
},
consumeLinter(registerIndie) {
this.linterService = registerIndie({
name: 'SPL Build'
Expand All @@ -423,33 +441,50 @@ export default {
},

shouldShowMenuSpl(event) {
if (atom.workspace.getActivePane().activeItem.constructor.name === 'TextEditor') {
Kyrellos-Salib marked this conversation as resolved.
Show resolved Hide resolved
return !!atom.workspace.getActiveTextEditor().getTitle().toLowerCase().endsWith('spl');
}
return !!event.target.innerText.toLowerCase().endsWith('.spl');
},

shouldShowMenuMake(event) {
if (atom.workspace.getActivePane().activeItem.constructor.name === 'TextEditor') {
return atom.workspace.getActiveTextEditor().getTitle().toLowerCase() === 'makefile';
}
return event.target.innerText.toLowerCase() === 'makefile';
},

shouldShowMenuSubmit(event) {
if (atom.workspace.getActivePane().activeItem.constructor.name === 'TextEditor') {
return !!atom.workspace.getActiveTextEditor().getTitle().toLowerCase().endsWith('.sab');
}
return !!event.target.innerText.toLowerCase().endsWith('.sab');
},

shouldShowMenu(event) {
if (atom.workspace.getActivePane().activeItem.constructor.name === 'TextEditor') {
return !!(atom.workspace.getActiveTextEditor().getTitle().toLowerCase() === 'makefile'
|| atom.workspace.getActiveTextEditor().getTitle().toLowerCase().endsWith('.spl')
|| atom.workspace.getActiveTextEditor().getTitle().toLowerCase().endsWith('.sab'));
}
return !!(event.target.innerText.toLowerCase() === 'makefile'
|| event.target.innerText.toLowerCase().endsWith('.spl')
|| event.target.innerText.toLowerCase().endsWith('.sab'));
},

shouldShowMenuV4(event) {
if (atom.workspace.getActivePane().activeItem.constructor.name === 'TextEditor') {
this.shouldShowMenu = this.shouldShowMenu.bind(this);
guychris marked this conversation as resolved.
Show resolved Hide resolved
return this.shouldShowMenu() && this.apiVersion === CONF_API_VERSION_V4;
}
this.shouldShowMenu = this.shouldShowMenu.bind(this);
return this.shouldShowMenu(event) && this.apiVersion === CONF_API_VERSION_V4;
},

shouldShowMenuV5(event) {
if (atom.workspace.getActivePane().activeItem.constructor.name === 'TextEditor') {
this.shouldShowMenu = this.shouldShowMenu.bind(this);
return this.shouldShowMenu() && this.apiVersion === CONF_API_VERSION_V5;
}
this.shouldShowMenu = this.shouldShowMenu.bind(this);
return this.shouldShowMenu(event) && this.apiVersion === CONF_API_VERSION_V5;
},

handleBuildCallback(e) {
const selectedComp = this.mainCompositePickerView.mainComposite;
if (selectedComp) {
Expand Down