Skip to content

Commit 3e92567

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
GH-421: Cleaned up the _Output_ channel UI.
- Merged the Arduino channels into one, - Removed the channel selector dropdown from the UI. Closes arduino/arduino-pro-ide#421. Signed-off-by: Akos Kitta <[email protected]>
1 parent 19613de commit 3e92567

10 files changed

+45
-31
lines changed

Diff for: arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts

+6
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ import { bindArduinoPreferences } from './arduino-preferences'
140140
import { SettingsService, SettingsDialog, SettingsWidget, SettingsDialogProps } from './settings';
141141
import { AddFile } from './contributions/add-file';
142142
import { ArchiveSketch } from './contributions/archive-sketch';
143+
import { OutputToolbarContribution as TheiaOutputToolbarContribution } from '@theia/output/lib/browser/output-toolbar-contribution';
144+
import { OutputToolbarContribution } from './theia/output/output-toolbar-contribution';
143145

144146
const ElementQueries = require('css-element-queries/src/ElementQueries');
145147

@@ -313,6 +315,10 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
313315
bind(ShellLayoutRestorer).toSelf().inSingletonScope();
314316
rebind(TheiaShellLayoutRestorer).toService(ShellLayoutRestorer);
315317

318+
// No dropdown for the _Output_ view.
319+
bind(OutputToolbarContribution).toSelf().inSingletonScope();
320+
rebind(TheiaOutputToolbarContribution).toService(OutputToolbarContribution);
321+
316322
bind(ArduinoDaemon).toDynamicValue(context => WebSocketConnectionProvider.createProxy(context.container, ArduinoDaemonPath)).inSingletonScope();
317323

318324
// File-system extension

Diff for: arduino-ide-extension/src/browser/contributions/burn-bootloader.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class BurnBootloader extends SketchContribution {
5353
this.preferences.get('arduino.upload.verify'),
5454
this.preferences.get('arduino.upload.verbose')
5555
]);
56-
this.outputChannelManager.getChannel('Arduino: bootloader').clear();
56+
this.outputChannelManager.getChannel('Arduino').clear();
5757
await this.coreService.burnBootloader({
5858
fqbn,
5959
programmer,

Diff for: arduino-ide-extension/src/browser/contributions/upload-sketch.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class UploadSketch extends SketchContribution {
122122
verify
123123
};
124124
}
125-
this.outputChannelManager.getChannel('Arduino: upload').clear();
125+
this.outputChannelManager.getChannel('Arduino').clear();
126126
if (usingProgrammer) {
127127
await this.coreService.uploadUsingProgrammer(options);
128128
} else {

Diff for: arduino-ide-extension/src/browser/contributions/verify-sketch.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export class VerifySketch extends SketchContribution {
7777
const { boardsConfig } = this.boardsServiceClientImpl;
7878
const fqbn = await this.boardsDataStore.appendConfigToFqbn(boardsConfig.selectedBoard?.fqbn);
7979
const verbose = this.preferences.get('arduino.compile.verbose');
80-
this.outputChannelManager.getChannel('Arduino: compile').clear();
80+
this.outputChannelManager.getChannel('Arduino').clear();
8181
await this.coreService.compile({
8282
sketchUri: uri,
8383
fqbn,

Diff for: arduino-ide-extension/src/browser/output-service-impl.ts

+4-10
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,10 @@ export class OutputServiceImpl implements OutputService {
1313
protected outputChannelManager: OutputChannelManager;
1414

1515
append(message: OutputMessage): void {
16-
const { name, chunk } = message;
17-
const channel = this.outputChannelManager.getChannel(`Arduino: ${name}`);
18-
// Zen-mode: we do not reveal the output for daemon messages.
19-
const show: Promise<any> = name === 'daemon'
20-
// This will open and reveal the view but won't show it. You will see the toggle bottom panel on the status bar.
21-
? this.outputContribution.openView({ activate: false, reveal: false })
22-
// This will open, reveal but do not activate the Output view.
23-
: Promise.resolve(channel.show({ preserveFocus: true }));
24-
25-
show.then(() => channel.append(chunk));
16+
const { chunk } = message;
17+
const channel = this.outputChannelManager.getChannel(`Arduino`);
18+
channel.show({ preserveFocus: true });
19+
channel.append(chunk);
2620
}
2721

2822
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { injectable } from 'inversify';
2+
import { ReactTabBarToolbarItem, TabBarToolbarItem, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
3+
import { OutputToolbarContribution as TheiaOutputToolbarContribution } from '@theia/output/lib/browser/output-toolbar-contribution';
4+
5+
@injectable()
6+
export class OutputToolbarContribution extends TheiaOutputToolbarContribution {
7+
8+
async registerToolbarItems(registry: TabBarToolbarRegistry): Promise<void> {
9+
await super.registerToolbarItems(registry); // Why is it async?
10+
// It's a hack. Currently, it's not possible to unregister a toolbar contribution via API.
11+
((registry as any).items as Map<string, TabBarToolbarItem | ReactTabBarToolbarItem>).delete('channels');
12+
(registry as any).fireOnDidChange();
13+
}
14+
15+
}

Diff for: arduino-ide-extension/src/common/protocol/output-service.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export interface OutputMessage {
2-
readonly name: string;
32
readonly chunk: string;
43
readonly severity?: 'error' | 'warning' | 'info'; // Currently not used!
54
}

Diff for: arduino-ide-extension/src/node/boards-service-impl.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ export class BoardsServiceImpl implements BoardsService {
271271
resp.on('data', (r: PlatformInstallResp) => {
272272
const prog = r.getProgress();
273273
if (prog && prog.getFile()) {
274-
this.outputService.append({ name: 'board download', chunk: `downloading ${prog.getFile()}\n` });
274+
this.outputService.append({ chunk: `downloading ${prog.getFile()}\n` });
275275
}
276276
});
277277
await new Promise<void>((resolve, reject) => {
@@ -302,7 +302,7 @@ export class BoardsServiceImpl implements BoardsService {
302302
const resp = client.platformUninstall(req);
303303
resp.on('data', (_: PlatformUninstallResp) => {
304304
if (!logged) {
305-
this.outputService.append({ name: 'board uninstall', chunk: `uninstalling ${item.id}\n` });
305+
this.outputService.append({ chunk: `uninstalling ${item.id}\n` });
306306
logged = true;
307307
}
308308
})

Diff for: arduino-ide-extension/src/node/core-service-impl.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class CoreServiceImpl implements CoreService {
2424
protected readonly notificationService: NotificationServiceServer;
2525

2626
async compile(options: CoreService.Compile.Options & { exportBinaries: boolean }): Promise<void> {
27-
this.outputService.append({ name: 'compile', chunk: 'Compile...\n' + JSON.stringify(options, null, 2) + '\n--------------------------\n' });
27+
this.outputService.append({ chunk: 'Compile...\n' + JSON.stringify(options, null, 2) + '\n--------------------------\n' });
2828
const { sketchUri, fqbn } = options;
2929
const sketchFilePath = FileUri.fsPath(sketchUri);
3030
const sketchpath = dirname(sketchFilePath);
@@ -48,15 +48,15 @@ export class CoreServiceImpl implements CoreService {
4848
try {
4949
await new Promise<void>((resolve, reject) => {
5050
result.on('data', (cr: CompileResp) => {
51-
this.outputService.append({ name: 'compile', chunk: Buffer.from(cr.getOutStream_asU8()).toString() });
52-
this.outputService.append({ name: 'compile', chunk: Buffer.from(cr.getErrStream_asU8()).toString() });
51+
this.outputService.append({ chunk: Buffer.from(cr.getOutStream_asU8()).toString() });
52+
this.outputService.append({ chunk: Buffer.from(cr.getErrStream_asU8()).toString() });
5353
});
5454
result.on('error', error => reject(error));
5555
result.on('end', () => resolve());
5656
});
57-
this.outputService.append({ name: 'compile', chunk: '\n--------------------------\nCompilation complete.\n' });
57+
this.outputService.append({ chunk: '\n--------------------------\nCompilation complete.\n' });
5858
} catch (e) {
59-
this.outputService.append({ name: 'compile', chunk: `Compilation error: ${e}\n`, severity: 'error' });
59+
this.outputService.append({ chunk: `Compilation error: ${e}\n`, severity: 'error' });
6060
throw e;
6161
}
6262
}
@@ -77,7 +77,7 @@ export class CoreServiceImpl implements CoreService {
7777

7878
await this.compile(Object.assign(options, { exportBinaries: false }));
7979
const chunk = firstToUpperCase(task) + '...\n';
80-
this.outputService.append({ name: 'upload', chunk: chunk + JSON.stringify(options, null, 2) + '\n--------------------------\n' });
80+
this.outputService.append({ chunk: chunk + JSON.stringify(options, null, 2) + '\n--------------------------\n' });
8181
const { sketchUri, fqbn, port, programmer } = options;
8282
const sketchFilePath = FileUri.fsPath(sketchUri);
8383
const sketchpath = dirname(sketchFilePath);
@@ -104,15 +104,15 @@ export class CoreServiceImpl implements CoreService {
104104
try {
105105
await new Promise<void>((resolve, reject) => {
106106
result.on('data', (resp: UploadResp) => {
107-
this.outputService.append({ name: task, chunk: Buffer.from(resp.getOutStream_asU8()).toString() });
108-
this.outputService.append({ name: task, chunk: Buffer.from(resp.getErrStream_asU8()).toString() });
107+
this.outputService.append({ chunk: Buffer.from(resp.getOutStream_asU8()).toString() });
108+
this.outputService.append({ chunk: Buffer.from(resp.getErrStream_asU8()).toString() });
109109
});
110110
result.on('error', error => reject(error));
111111
result.on('end', () => resolve());
112112
});
113-
this.outputService.append({ name: 'upload', chunk: '\n--------------------------\n' + firstToLowerCase(task) + ' complete.\n' });
113+
this.outputService.append({ chunk: '\n--------------------------\n' + firstToLowerCase(task) + ' complete.\n' });
114114
} catch (e) {
115-
this.outputService.append({ name: 'upload', chunk: `${firstToUpperCase(task)} error: ${e}\n`, severity: 'error' });
115+
this.outputService.append({ chunk: `${firstToUpperCase(task)} error: ${e}\n`, severity: 'error' });
116116
throw e;
117117
}
118118
}
@@ -138,14 +138,14 @@ export class CoreServiceImpl implements CoreService {
138138
try {
139139
await new Promise<void>((resolve, reject) => {
140140
result.on('data', (resp: BurnBootloaderResp) => {
141-
this.outputService.append({ name: 'bootloader', chunk: Buffer.from(resp.getOutStream_asU8()).toString() });
142-
this.outputService.append({ name: 'bootloader', chunk: Buffer.from(resp.getErrStream_asU8()).toString() });
141+
this.outputService.append({ chunk: Buffer.from(resp.getOutStream_asU8()).toString() });
142+
this.outputService.append({ chunk: Buffer.from(resp.getErrStream_asU8()).toString() });
143143
});
144144
result.on('error', error => reject(error));
145145
result.on('end', () => resolve());
146146
});
147147
} catch (e) {
148-
this.outputService.append({ name: 'bootloader', chunk: `Error while burning the bootloader: ${e}\n`, severity: 'error' });
148+
this.outputService.append({ chunk: `Error while burning the bootloader: ${e}\n`, severity: 'error' });
149149
throw e;
150150
}
151151
}

Diff for: arduino-ide-extension/src/node/library-service-server-impl.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export class LibraryServiceImpl implements LibraryService {
177177
resp.on('data', (r: LibraryInstallResp) => {
178178
const prog = r.getProgress();
179179
if (prog) {
180-
this.outputService.append({ name: 'library', chunk: `downloading ${prog.getFile()}: ${prog.getCompleted()}%\n` });
180+
this.outputService.append({ chunk: `downloading ${prog.getFile()}: ${prog.getCompleted()}%\n` });
181181
}
182182
});
183183
await new Promise<void>((resolve, reject) => {
@@ -209,7 +209,7 @@ export class LibraryServiceImpl implements LibraryService {
209209
const resp = client.libraryUninstall(req);
210210
resp.on('data', (_: LibraryUninstallResp) => {
211211
if (!logged) {
212-
this.outputService.append({ name: 'library', chunk: `uninstalling ${item.name}:${item.installedVersion}%\n` });
212+
this.outputService.append({ chunk: `uninstalling ${item.name}:${item.installedVersion}%\n` });
213213
logged = true;
214214
}
215215
});

0 commit comments

Comments
 (0)