From 11067091831327c30814796ff16b7bfaf4b8ce63 Mon Sep 17 00:00:00 2001 From: "nsingh@pivotal.io" Date: Wed, 6 Feb 2019 12:18:05 -0800 Subject: [PATCH] PT 163720674 - Style current mode with bold in Go To Symbol dialogue --- .../gotosymbol/dialogs/GotoSymbolDialog.java | 14 ++++++++++--- .../dialogs/GotoSymbolDialogModel.java | 21 ++++++++++++------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.gotosymbol/src/org/springframework/tooling/ls/eclipse/gotosymbol/dialogs/GotoSymbolDialog.java b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.gotosymbol/src/org/springframework/tooling/ls/eclipse/gotosymbol/dialogs/GotoSymbolDialog.java index 2df084475..8a329d96d 100644 --- a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.gotosymbol/src/org/springframework/tooling/ls/eclipse/gotosymbol/dialogs/GotoSymbolDialog.java +++ b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.gotosymbol/src/org/springframework/tooling/ls/eclipse/gotosymbol/dialogs/GotoSymbolDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016. 2017 Rogue Wave Software Inc. and others. + * Copyright (c) 2016, 2019 Rogue Wave Software Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -43,6 +43,7 @@ import org.eclipse.lsp4j.Range; import org.eclipse.lsp4j.SymbolInformation; import org.eclipse.lsp4j.jsonrpc.messages.Either; import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.graphics.Color; @@ -423,9 +424,16 @@ public class GotoSymbolDialog extends PopupDialog { // }); installWidgetListeners(pattern, viewer); - Label statusLabel = new Label(dialogArea, SWT.NONE); + StyledText statusLabel = new StyledText(dialogArea, SWT.NONE); + // Allow for some extra space for highlight fonts + statusLabel.setLeftMargin(3); + statusLabel.setBottomMargin(2); statusLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - SwtConnect.connect(statusLabel, model.getStatus(), Duration.ofMillis(500)); + + Stylers stylers = new Stylers(dialogArea.getFont()); + disposables.add(stylers); + + SwtConnect.connectHighlighted(stylers.bold(), statusLabel, model.getStatus(), Duration.ofMillis(500)); viewer.setInput(model); return dialogArea; diff --git a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.gotosymbol/src/org/springframework/tooling/ls/eclipse/gotosymbol/dialogs/GotoSymbolDialogModel.java b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.gotosymbol/src/org/springframework/tooling/ls/eclipse/gotosymbol/dialogs/GotoSymbolDialogModel.java index dac4627ba..0970a957c 100644 --- a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.gotosymbol/src/org/springframework/tooling/ls/eclipse/gotosymbol/dialogs/GotoSymbolDialogModel.java +++ b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.gotosymbol/src/org/springframework/tooling/ls/eclipse/gotosymbol/dialogs/GotoSymbolDialogModel.java @@ -28,6 +28,7 @@ import org.springsource.ide.eclipse.commons.livexp.core.AsyncLiveExpression.Asyn import org.springsource.ide.eclipse.commons.livexp.core.LiveExpression; import org.springsource.ide.eclipse.commons.livexp.core.LiveVariable; import org.springsource.ide.eclipse.commons.livexp.core.ObservableSet; +import org.springsource.ide.eclipse.commons.livexp.core.HighlightedText; import org.springsource.ide.eclipse.commons.livexp.util.ExceptionUtil; import com.google.common.collect.ImmutableList; @@ -78,7 +79,7 @@ public class GotoSymbolDialogModel { private static final OKHandler DEFAULT_OK_HANDLER = (selection) -> true; private SymbolsProvider[] symbolsProviders; - private final LiveVariable status = new LiveVariable<>(); + private final LiveVariable status = new LiveVariable<>(); private int currentSymbolsProviderIndex; private final LiveVariable currentSymbolsProvider = new LiveVariable<>(null); private final LiveVariable searchBox = new LiveVariable<>(""); @@ -92,7 +93,7 @@ public class GotoSymbolDialogModel { @Override protected ImmutableSet> compute() { - status.setValue("Fetching symbols..."); + status.setValue(HighlightedText.plain("Fetching symbols...")); try { SymbolsProvider sp = currentSymbolsProvider.getValue(); if (sp!=null) { @@ -102,17 +103,23 @@ public class GotoSymbolDialogModel { debug("Fetching symbols... from symbol provider, for '"+query+"'"); Collection> fetched = sp.fetchFor(query); if (keyBindings==null) { - status.setValue(currentProviderName); + status.setValue(HighlightedText.plain(currentProviderName)); } else { - status.setValue("Showing "+ currentProviderName + ". Press [" + keyBindings + "] for " + nextSymbolsProvider().getName()); + status.setValue(HighlightedText + .create() + .appendHighlight("Showing ") + .appendHighlight(currentProviderName) + .appendPlain(". Press [" + keyBindings + "] for ") + .appendPlain(nextSymbolsProvider().getName()) + ); } return ImmutableSet.copyOf(fetched); } else { - status.setValue("No symbol provider"); + status.setValue(HighlightedText.plain("No symbol provider")); } } catch (Exception e) { GotoSymbolPlugin.getInstance().getLog().log(ExceptionUtil.status(e)); - status.setValue(ExceptionUtil.getMessage(e)); + status.setValue(HighlightedText.plain(ExceptionUtil.getMessage(e))); } return ImmutableSet.of(); } @@ -191,7 +198,7 @@ public class GotoSymbolDialogModel { return SEARCH_BOX_HINT_MESSAGE; } - public LiveExpression getStatus() { + public LiveExpression getStatus() { return status; }