PT 163720674 - Style current mode with bold in Go To Symbol dialogue

This commit is contained in:
nsingh@pivotal.io
2019-02-06 12:18:05 -08:00
parent 7fe0d75412
commit 1106709183
2 changed files with 25 additions and 10 deletions

View File

@@ -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;

View File

@@ -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<String> status = new LiveVariable<>();
private final LiveVariable<HighlightedText> status = new LiveVariable<>();
private int currentSymbolsProviderIndex;
private final LiveVariable<SymbolsProvider> currentSymbolsProvider = new LiveVariable<>(null);
private final LiveVariable<String> searchBox = new LiveVariable<>("");
@@ -92,7 +93,7 @@ public class GotoSymbolDialogModel {
@Override
protected ImmutableSet<Either<SymbolInformation, DocumentSymbol>> 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<Either<SymbolInformation, DocumentSymbol>> 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<String> getStatus() {
public LiveExpression<HighlightedText> getStatus() {
return status;
}