use of io.flutter.inspector.InspectorService in project flutter-intellij by flutter.
the class LabelInput method addBrowserInspectorViewContent.
private void addBrowserInspectorViewContent(FlutterApp app, @Nullable InspectorService inspectorService, ToolWindow toolWindow, boolean isEmbedded, DevToolsInstance devToolsInstance) {
assert (SwingUtilities.isEventDispatchThread());
final ContentManager contentManager = toolWindow.getContentManager();
final FlutterDevice device = app.device();
final List<FlutterDevice> existingDevices = new ArrayList<>();
for (FlutterApp otherApp : perAppViewState.keySet()) {
existingDevices.add(otherApp.device());
}
final String tabName = device.getUniqueName(existingDevices);
if (emptyContent != null) {
contentManager.removeContent(emptyContent, true);
emptyContent = null;
}
final String browserUrl = app.getConnector().getBrowserUrl();
if (isEmbedded) {
final String color = ColorUtil.toHex(UIUtil.getEditorPaneBackground());
final DevToolsUrl devToolsUrl = new DevToolsUrl(devToolsInstance.host, devToolsInstance.port, browserUrl, "inspector", true, color, UIUtil.getFontSize(UIUtil.FontSize.NORMAL));
// noinspection CodeBlock2Expr
ApplicationManager.getApplication().invokeLater(() -> {
embeddedBrowserOptional().ifPresent(embeddedBrowser -> embeddedBrowser.openPanel(contentManager, tabName, devToolsUrl, () -> {
// If the embedded browser doesn't work, offer a link to open in the regular browser.
final List<LabelInput> inputs = Arrays.asList(new LabelInput("The embedded browser failed to load."), openDevToolsLabel(app, inspectorService, toolWindow));
presentClickableLabel(toolWindow, inputs);
}));
});
if (!busSubscribed) {
busConnection.subscribe(EditorColorsManager.TOPIC, scheme -> embeddedBrowserOptional().ifPresent(embeddedBrowser -> embeddedBrowser.updateColor(ColorUtil.toHex(UIUtil.getEditorPaneBackground()))));
busConnection.subscribe(UISettingsListener.TOPIC, scheme -> embeddedBrowserOptional().ifPresent(embeddedBrowser -> embeddedBrowser.updateFontSize(UIUtil.getFontSize(UIUtil.FontSize.NORMAL))));
busSubscribed = true;
}
} else {
BrowserLauncher.getInstance().browse((new DevToolsUrl(devToolsInstance.host, devToolsInstance.port, browserUrl, "inspector", false, null, null).getUrlString()), null);
presentLabel(toolWindow, "DevTools inspector has been opened in the browser.");
}
}
use of io.flutter.inspector.InspectorService in project flutter-intellij by flutter.
the class VmServiceWidgetPerfProvider method setupConnection.
private void setupConnection(@NotNull VmService vmService) {
if (isDisposed || connected) {
return;
}
final VMServiceManager vmServiceManager = app.getVMServiceManager();
assert vmServiceManager != null;
connected = true;
isolateRefStreamSubscription = vmServiceManager.getCurrentFlutterIsolate((isolateRef) -> requestRepaint(When.soon), false);
vmService.addVmServiceListener(new VmServiceListenerAdapter() {
@Override
public void received(String streamId, Event event) {
onVmServiceReceived(streamId, event);
}
@Override
public void connectionClosed() {
}
});
inspectorService = InspectorService.create(app, app.getFlutterDebugProcess(), app.getVmService());
inspectorService.whenCompleteAsync((service, throwable) -> Disposer.register(this, service));
requestRepaint(When.soon);
}
use of io.flutter.inspector.InspectorService in project flutter-intellij by flutter.
the class WidgetEditToolbar method applyChangeAndShowException.
private void applyChangeAndShowException(SourceChange change) {
ApplicationManager.getApplication().runWriteAction(() -> {
try {
AssistUtils.applySourceChange(project, change, false);
if (hotReloadOnAction) {
final InspectorService inspectorService = InspectorGroupManagerService.getInstance(project).getInspectorService();
if (inspectorService != null) {
final ArrayList<FlutterApp> apps = new ArrayList<>();
apps.add(inspectorService.getApp());
FlutterReloadManager.getInstance(project).saveAllAndReloadAll(apps, "Refactor widget");
}
}
} catch (DartSourceEditException exception) {
FlutterMessages.showError("Error applying change", exception.getMessage(), project);
}
});
}
Aggregations