Skip to content

Commit 45295a0

Browse files
authored
refactor: ui improves (#845)
* refactor: remove root source package config * refactor: LiveViewSubscription -> LiveView fixes: sourceplusplus/sourceplusplus#606 * refactor: LiveViewSubscription -> LiveView fixes: sourceplusplus/sourceplusplus#606 * chore(deps): bump * refactor: LiveView.liveViewConfig -> LiveView.viewConfig * chore(deps): bump * refactor: sourceplusplus/live-platform -> sourceplusplus/sourceplusplus * refactor: updateClientAccess -> refreshClientAccess fixes: sourceplusplus/sourceplusplus#558 * chore(deps): bump * refactor: move PortalConfiguration from protocol to probe * feat: command info trailer ui * chore(version): 0.7.0 * fix: Access is allowed from write thread only * fix: tab auto complete and some ui improvements
1 parent c1e7e36 commit 45295a0

File tree

16 files changed

+53
-31
lines changed

16 files changed

+53
-31
lines changed

detekt.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# https://github.com/detekt/detekt/blob/master/detekt-core/src/main/resources/default-detekt-config.yml
33

44
build:
5-
maxIssues: 27 #todo: zero out
5+
maxIssues: 26 #todo: zero out
66

77
formatting:
88
Indentation:

marker/src/main/kotlin/spp/jetbrains/marker/source/mark/api/SourceMark.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,10 @@ interface SourceMark : JBPopupListener, MouseMotionListener, VisibleAreaListener
239239

240240
fun dispose(removeFromMarker: Boolean = true, assertRemoval: Boolean = true) {
241241
if (this is InlayMark) {
242-
configuration.inlayRef?.get()?.dispose()
243-
configuration.inlayRef = null
242+
ApplicationManager.getApplication().invokeAndWait {
243+
configuration.inlayRef?.get()?.dispose()
244+
configuration.inlayRef = null
245+
}
244246
}
245247
closePopup()
246248

plugin/src/main/java/spp/jetbrains/sourcemarker/ControlBar.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ private void initComponents() {
225225
textField1 = new AutocompleteField(
226226
inlayMark.getProject(),
227227
message("location") + ": " + location + "#" + inlayMark.getLineNumber(),
228-
availableCommands, lookup, inlayMark.getArtifactQualifiedName(), true, true, SELECT_COLOR_RED, true);
228+
availableCommands, lookup, inlayMark.getArtifactQualifiedName(), true);
229+
textField1.setReplaceCommandOnTab(true);
230+
textField1.setAutocompleteAndFinishOnEnter(true);
229231
textField1.setMaxSuggestSize(3);
230232
textField1.setCellRenderer(new ControlBarCellRenderer(inlayMark, textField1));
231233
label2 = new JLabel();

plugin/src/main/java/spp/jetbrains/sourcemarker/element/LiveControlBarRow.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.jgoodies.forms.factories.FormFactory;
2121
import com.jgoodies.forms.layout.*;
2222
import org.jetbrains.annotations.NotNull;
23+
import spp.jetbrains.PluginUI;
2324

2425
import javax.swing.*;
2526
import java.awt.*;
@@ -36,7 +37,7 @@ public LiveControlBarRow() {
3637
}
3738

3839
public void setCommandName(String commandName, String input) {
39-
String selectHex = "#" + Integer.toHexString(SELECT_COLOR_RED.getRGB()).substring(2);
40+
String selectHex = "#" + Integer.toHexString(PluginUI.getCommandHighlightForeground().getRGB()).substring(2);
4041
String defaultHex = getCommandTypeColor();
4142

4243
int minIndex = 0;

plugin/src/main/java/spp/jetbrains/sourcemarker/status/BreakpointStatusBar.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ public Icon getUnselectedIcon() {
151151

152152
@Override
153153
public void onInstrumentRemovedEvent(@NotNull LiveInstrumentRemoved event) {
154+
LiveStatusManager.getInstance(inlayMark.getProject()).removeActiveLiveInstrument(event.getLiveInstrument());
154155
this.liveBreakpoint = null;
155156
}
156157

@@ -531,7 +532,7 @@ private void initComponents() {
531532
configLabel = new JLabel();
532533
configDropdownLabel = new JLabel();
533534
mainPanel = new JPanel();
534-
breakpointConditionField = new AutocompleteField(inlayMark.getProject(), placeHolderText, scopeVars, lookup, inlayMark.getArtifactQualifiedName(), false, false, COMPLETE_COLOR_PURPLE, false);
535+
breakpointConditionField = new AutocompleteField(inlayMark.getProject(), placeHolderText, scopeVars, lookup, inlayMark.getArtifactQualifiedName(), false);
535536
label1 = new JLabel();
536537
hitLimitSpinner = new JBIntSpinner(1, 1, 10_000);
537538
timeLabel = new JLabel();

plugin/src/main/java/spp/jetbrains/sourcemarker/status/LogStatusBar.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ public Icon getUnselectedIcon() {
133133
}
134134
}).collect(Collectors.toList());
135135
lookup = text -> scopeVars.stream()
136+
.filter(v -> {
137+
//ignore exact matches
138+
String var = substringAfterLast(" ", text.toLowerCase());
139+
var = substringAfterLast("$", var);
140+
return !var.equalsIgnoreCase(v);
141+
})
136142
.filter(v -> VariableParser.isVariable(text, v))
137143
.map(it -> new AutocompleteFieldRow() {
138144
public String getText() {
@@ -697,6 +703,12 @@ private void dispose() {
697703
inlayMark.dispose(true);
698704
}
699705

706+
public static String substringAfterLast(String delimiter, String value) {
707+
int index = value.lastIndexOf(delimiter);
708+
if (index == -1) return value;
709+
else return value.substring(index + delimiter.length());
710+
}
711+
700712
private void initComponents() {
701713
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
702714
setBackground(getBackgroundColor());
@@ -705,7 +717,7 @@ private void initComponents() {
705717
configDropdownLabel = new JLabel();
706718
timeLabel = new JLabel();
707719
separator1 = new JSeparator();
708-
liveLogTextField = new AutocompleteField(inlayMark.getProject(), placeHolderText, scopeVars, lookup, inlayMark.getArtifactQualifiedName(), false, false, COMPLETE_COLOR_PURPLE, false);
720+
liveLogTextField = new AutocompleteField(inlayMark.getProject(), placeHolderText, scopeVars, lookup, inlayMark.getArtifactQualifiedName(), false);
709721
liveLogTextField.setVarPattern(varPattern);
710722
closeLabel = new JLabel();
711723

plugin/src/main/java/spp/jetbrains/sourcemarker/status/MeterStatusBar.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,8 @@ private void initComponents() {
518518
configLabel = new JLabel();
519519
configDropdownLabel = new JLabel();
520520
mainPanel = new JPanel();
521-
meterIdField = new AutocompleteField(inlayMark.getProject(), meterName, Collections.emptyList(), null, inlayMark.getArtifactQualifiedName(), false, false, COMPLETE_COLOR_PURPLE, false);
522-
meterConditionField = new AutocompleteField(inlayMark.getProject(), placeHolderText, scopeVars, lookup, inlayMark.getArtifactQualifiedName(), false, false, COMPLETE_COLOR_PURPLE, false);
521+
meterIdField = new AutocompleteField(inlayMark.getProject(), meterName, Collections.emptyList(), null, inlayMark.getArtifactQualifiedName(), false);
522+
meterConditionField = new AutocompleteField(inlayMark.getProject(), placeHolderText, scopeVars, lookup, inlayMark.getArtifactQualifiedName(), false);
523523
label1 = new JLabel();
524524
meterTypeComboBox = new JComboBox<>();
525525
timeLabel = new JLabel();

plugin/src/main/java/spp/jetbrains/sourcemarker/status/SpanStatusBar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ private void initComponents() {
421421
configLabel = new JLabel();
422422
configDropdownLabel = new JLabel();
423423
mainPanel = new JPanel();
424-
spanOperationNameField = new AutocompleteField(inlayMark.getProject(), placeHolderText, Collections.emptyList(), null, inlayMark.getArtifactQualifiedName(), false, false, COMPLETE_COLOR_PURPLE, false);
424+
spanOperationNameField = new AutocompleteField(inlayMark.getProject(), placeHolderText, Collections.emptyList(), null, inlayMark.getArtifactQualifiedName(), false);
425425
timeLabel = new JLabel();
426426
separator1 = new JSeparator();
427427
closeLabel = new JLabel();

plugin/src/main/kotlin/spp/jetbrains/sourcemarker/portal/PortalController.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import spp.jetbrains.marker.source.mark.api.component.jcef.config.BrowserLoading
3434
import spp.jetbrains.marker.source.mark.api.component.jcef.config.SourceMarkJcefComponentConfiguration
3535
import spp.jetbrains.marker.source.mark.api.event.SourceMarkEventCode
3636
import spp.jetbrains.marker.source.mark.guide.GuideMark
37-
import spp.jetbrains.sourcemarker.mark.SourceMarkKeys
3837
import spp.jetbrains.sourcemarker.settings.SourceMarkerConfig
3938
import spp.jetbrains.sourcemarker.settings.getServicePortNormalized
4039
import spp.jetbrains.sourcemarker.settings.isSsl

plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/LiveInstrumentManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class LiveInstrumentManager(
6767

6868
//register listener
6969
FrameHelper.sendFrame(
70-
BridgeEventType.REGISTER.name.toLowerCase(),
70+
BridgeEventType.REGISTER.name.lowercase(),
7171
toLiveInstrumentSubscriberAddress(developer), null,
7272
JsonObject().apply { pluginConfig.serviceToken?.let { put("auth-token", it) } },
7373
null, null, TCPServiceDiscoveryBackend.getSocket(project)

plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/LiveViewManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class LiveViewManager(
6262
}
6363

6464
FrameHelper.sendFrame(
65-
BridgeEventType.REGISTER.name.toLowerCase(),
65+
BridgeEventType.REGISTER.name.lowercase(),
6666
toLiveViewSubscriberAddress(developer), null,
6767
JsonObject().apply { pluginConfig.serviceToken?.let { put("auth-token", it) } },
6868
null, null, TCPServiceDiscoveryBackend.getSocket(project)

plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/discover/TCPServiceDiscoveryBackend.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class TCPServiceDiscoveryBackend : ServiceDiscoveryBackend {
171171
}
172172
val headers = JsonObject().apply { pluginConfig.serviceToken?.let { put("auth-token", it) } }
173173
FrameHelper.sendFrame(
174-
BridgeEventType.SEND.name.toLowerCase(),
174+
BridgeEventType.SEND.name.lowercase(),
175175
PlatformAddress.MARKER_CONNECTED,
176176
replyAddress, headers, true, JsonObject.mapFrom(pc), socket!!
177177
)
@@ -191,7 +191,7 @@ class TCPServiceDiscoveryBackend : ServiceDiscoveryBackend {
191191
val headers = JsonObject()
192192
resp.headers().entries().forEach { headers.put(it.key, it.value) }
193193
FrameHelper.sendFrame(
194-
BridgeEventType.SEND.name.toLowerCase(),
194+
BridgeEventType.SEND.name.lowercase(),
195195
address, replyAddress, headers, true, resp.body(), socket!!
196196
)
197197
}

plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/instrument/log/VariableParser.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ object VariableParser {
9191

9292
@JvmStatic
9393
fun isVariable(text: String, v: String): Boolean {
94-
val variable = text.toLowerCase().substringAfterLast(SPACE)
94+
val variable = text.lowercase().substringAfterLast(SPACE)
9595
return ((variable.startsWith(DOLLAR) && variable.substring(1) != v
96-
&& v.toLowerCase().contains(variable.substring(1)))
96+
&& v.lowercase().contains(variable.substring(1)))
9797
|| (variable.startsWith("\${") && variable.substring(2) != v
98-
&& v.toLowerCase().contains(variable.substring(2))))
98+
&& v.lowercase().contains(variable.substring(2))))
9999
}
100100
}

plugin/src/main/kotlin/spp/jetbrains/sourcemarker/stat/SourceStatusServiceImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class SourceStatusServiceImpl(val project: Project) : SourceStatusService {
128128
if (waitBefore) delay(repeatMillis)
129129
try {
130130
SourceMarkerPlugin.getInstance(project).init()
131-
} catch (ex: AlreadyDisposedException) {
131+
} catch (ignore: AlreadyDisposedException) {
132132
log.info("${project.name} is disposed, stopping reconnection loop")
133133
break
134134
}

plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/util/AutocompleteField.kt

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import com.intellij.ui.components.JBList
2222
import com.intellij.util.ui.JBUI
2323
import com.intellij.util.ui.UIUtil
2424
import spp.jetbrains.PluginUI
25-
import spp.jetbrains.PluginUI.COMPLETE_COLOR_PURPLE
2625
import spp.jetbrains.PluginUI.SMALLEST_FONT
2726
import spp.jetbrains.icons.PluginIcons
2827
import spp.jetbrains.sourcemarker.element.AutocompleteDropdown
@@ -51,12 +50,13 @@ class AutocompleteField<T : AutocompleteFieldRow>(
5150
private val allLookup: List<T>,
5251
private val lookup: Function<String, List<T>>? = null,
5352
internal val artifactQualifiedName: ArtifactQualifiedName,
54-
private val replaceCommandOnTab: Boolean = false,
55-
private val autocompleteOnEnter: Boolean = true,
56-
private val varColor: Color = COMPLETE_COLOR_PURPLE,
5753
addAutocompleteDropdownInfo: Boolean = false
5854
) : JTextPane(), FocusListener, DocumentListener, KeyListener, MouseMotionListener, MouseListener {
5955

56+
var autocompleteOnTab: Boolean = true
57+
var replaceCommandOnTab: Boolean = false
58+
var autocompleteAndFinishOnEnter: Boolean = false
59+
var varColor: Color = PluginUI.commandHighlightForeground
6060
private val results: MutableList<AutocompleteFieldRow>
6161
private val autocompleteDropdown: AutocompleteDropdown?
6262
private val popup: JWindow
@@ -285,19 +285,24 @@ class AutocompleteField<T : AutocompleteFieldRow>(
285285
}
286286
scrollListToSelected()
287287
} else if (e.keyCode == KeyEvent.VK_TAB) {
288-
if (text.isBlank() || list.selectedValue == null || !replaceCommandOnTab) return
288+
if (text.isBlank() || list.selectedValue == null || (!replaceCommandOnTab && !autocompleteOnTab)) return
289289
val autocompleteRow = list.selectedValue
290-
if (autocompleteRow is LiveCommandFieldRow && autocompleteRow.liveCommand.params.isNotEmpty()) {
291-
if (getText().lowercase().startsWith(autocompleteRow.liveCommand.getTriggerName().lowercase() + " ")) {
292-
return //do nothing
290+
if (replaceCommandOnTab) {
291+
if (autocompleteRow is LiveCommandFieldRow && autocompleteRow.liveCommand.params.isNotEmpty()) {
292+
if (getText().lowercase().startsWith(autocompleteRow.liveCommand.getTriggerName().lowercase() + " ")) {
293+
return //do nothing
294+
}
295+
setText(autocompleteRow.getText() + " ")
296+
} else {
297+
setText(autocompleteRow.getText())
293298
}
294-
setText(autocompleteRow.getText() + " ")
295299
} else {
296-
setText(autocompleteRow.getText())
300+
val userInput = text.substringAfterLast(" ")
301+
setText(text.substring(0, text.length - userInput.length) + autocompleteRow.getText())
297302
}
298303
caretPosition = getText().length
299304
} else if (e.keyCode == KeyEvent.VK_ENTER) {
300-
if (!autocompleteOnEnter) {
305+
if (!autocompleteAndFinishOnEnter) {
301306
ready = true
302307
actualText = text
303308
hideAutocompletePopup()

plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/util/ControlBarCellRenderer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class ControlBarCellRenderer(
7373
"*methodName*",
7474
getShortFunctionSignature(autocompleteField.artifactQualifiedName.identifier)
7575
)
76-
} catch (ex: Exception) {
76+
} catch (ignore: Exception) {
7777
formattedDescription.replace("*methodName*", "anonymous")
7878
}
7979
}

0 commit comments

Comments
 (0)