mirror of https://github.com/rusefi/rusefi-1.git
live data progress
This commit is contained in:
parent
742bbb372c
commit
93c9382c86
|
@ -165,7 +165,7 @@ public class CodeWalkthrough {
|
||||||
allTerminals.get(i + 1).getText().equals("->")
|
allTerminals.get(i + 1).getText().equals("->")
|
||||||
) {
|
) {
|
||||||
Token token = allTerminals.get(i + 2).getSymbol();
|
Token token = allTerminals.get(i + 2).getSymbol();
|
||||||
painter.paintForeground(CONFIG, new Range(token, token));
|
painter.paintForeground(CONFIG, Range.create(token, token));
|
||||||
configTokens.add(token);
|
configTokens.add(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,11 +80,13 @@ public class LiveDataParserPanel {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private final VariableValueSource valueSource;
|
private final VariableValueSource valueSource;
|
||||||
|
private final String fileName;
|
||||||
private String sourceCode;
|
private String sourceCode;
|
||||||
|
|
||||||
public LiveDataParserPanel(UIContext uiContext, VariableValueSource valueSource, String fileName) {
|
public LiveDataParserPanel(UIContext uiContext, VariableValueSource valueSource, String fileName) {
|
||||||
this.uiContext = uiContext;
|
this.uiContext = uiContext;
|
||||||
this.valueSource = valueSource;
|
this.valueSource = valueSource;
|
||||||
|
this.fileName = fileName;
|
||||||
|
|
||||||
JScrollPane rightScrollPane = new JScrollPane(text,
|
JScrollPane rightScrollPane = new JScrollPane(text,
|
||||||
VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||||
|
@ -150,28 +152,27 @@ public class LiveDataParserPanel {
|
||||||
|
|
||||||
// todo: technically we do not need to do the complete re-compile on fresh data arrival just repaint!
|
// todo: technically we do not need to do the complete re-compile on fresh data arrival just repaint!
|
||||||
// todo: split compilation and painting/repainting
|
// todo: split compilation and painting/repainting
|
||||||
parseResult = CodeWalkthrough.applyVariables(valueSource, sourceCode, new SourceCodePainter() {
|
try {
|
||||||
@Override
|
parseResult = CodeWalkthrough.applyVariables(valueSource, sourceCode, new SourceCodePainter() {
|
||||||
public void paintBackground(Color color, Range range) {
|
@Override
|
||||||
AttributeSet s = sc.addAttribute(oldSet, StyleConstants.Background, color);
|
public void paintBackground(Color color, Range range) {
|
||||||
styledDocument.setCharacterAttributes(range.getStart(), range.getLength(), s, false);
|
AttributeSet s = sc.addAttribute(oldSet, StyleConstants.Background, color);
|
||||||
}
|
styledDocument.setCharacterAttributes(range.getStart(), range.getLength(), s, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paintForeground(Color color, Range range) {
|
||||||
|
AttributeSet s = sc.addAttribute(oldSet, StyleConstants.Foreground, color);
|
||||||
|
styledDocument.setCharacterAttributes(range.getStart(), range.getLength(), s, false);
|
||||||
|
}
|
||||||
|
}, tree);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
throw new IllegalStateException("While " + fileName, e);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paintForeground(Color color, Range range) {
|
|
||||||
AttributeSet s = sc.addAttribute(oldSet, StyleConstants.Foreground, color);
|
|
||||||
styledDocument.setCharacterAttributes(range.getStart(), range.getLength(), s, false);
|
|
||||||
}
|
|
||||||
}, tree);
|
|
||||||
text.setDocument(styledDocument);
|
text.setDocument(styledDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static JPanel createLiveDataParserContent(UIContext uiContext, LiveDataView view) {
|
|
||||||
LiveDataParserPanel panel = createLiveDataParserPanel(uiContext, view.getLiveDataE(), view.getValues(), view.getFileName());
|
|
||||||
return panel.getContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static LiveDataParserPanel createLiveDataParserPanel(UIContext uiContext, final live_data_e live_data_e, final Field[] values, String fileName) {
|
public static LiveDataParserPanel createLiveDataParserPanel(UIContext uiContext, final live_data_e live_data_e, final Field[] values, String fileName) {
|
||||||
AtomicReference<byte[]> reference = new AtomicReference<>();
|
AtomicReference<byte[]> reference = new AtomicReference<>();
|
||||||
|
|
|
@ -27,6 +27,14 @@ public class Range {
|
||||||
this(context.start, context.stop);
|
this(context.start, context.stop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Range create(Token startToken, Token stopToken) {
|
||||||
|
int start = startToken.getStartIndex();
|
||||||
|
int stop = stopToken.getStopIndex() + 1;
|
||||||
|
if (stop < start)
|
||||||
|
throw new IllegalStateException("Order issue " + startToken + "/" + stopToken);
|
||||||
|
return new Range(startToken, stopToken);
|
||||||
|
}
|
||||||
|
|
||||||
public int getStart() {
|
public int getStart() {
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.rusefi.ldmp.StateDictionary;
|
||||||
import com.rusefi.ui.UIContext;
|
import com.rusefi.ui.UIContext;
|
||||||
import com.rusefi.ui.livedocs.LiveDocsRegistry;
|
import com.rusefi.ui.livedocs.LiveDocsRegistry;
|
||||||
import com.rusefi.ui.util.FrameHelper;
|
import com.rusefi.ui.util.FrameHelper;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@ public class LiveDataParserPanelSandbox {
|
||||||
|
|
||||||
UIContext context = new UIContext();
|
UIContext context = new UIContext();
|
||||||
|
|
||||||
JPanel panel = LiveDataParserPanel.createLiveDataParserContent(context,
|
JPanel panel = createLiveDataParserContent(context,
|
||||||
liveDataView);
|
liveDataView);
|
||||||
|
|
||||||
Field[] values = StateDictionary.INSTANCE.getFields(liveDataView.getLiveDataE());
|
Field[] values = StateDictionary.INSTANCE.getFields(liveDataView.getLiveDataE());
|
||||||
|
@ -36,4 +37,10 @@ public class LiveDataParserPanelSandbox {
|
||||||
|
|
||||||
new FrameHelper().showFrame(panel);
|
new FrameHelper().showFrame(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static JPanel createLiveDataParserContent(UIContext uiContext, LiveDataView view) {
|
||||||
|
LiveDataParserPanel panel = LiveDataParserPanel.createLiveDataParserPanel(uiContext, view.getLiveDataE(), view.getValues(), view.getFileName());
|
||||||
|
return panel.getContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,10 @@ import com.rusefi.enums.live_data_e;
|
||||||
import com.rusefi.ldmp.StateDictionary;
|
import com.rusefi.ldmp.StateDictionary;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* todo: kill this legacy class?
|
||||||
* @see StateDictionary
|
* @see StateDictionary
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public enum LiveDataView {
|
public enum LiveDataView {
|
||||||
// todo: code generate this part of the enum with some BEFORE/AFTER tag?
|
// todo: code generate this part of the enum with some BEFORE/AFTER tag?
|
||||||
AC_CONTROL(live_data_e.LDS_ac_control, AcControl.VALUES),
|
AC_CONTROL(live_data_e.LDS_ac_control, AcControl.VALUES),
|
Loading…
Reference in New Issue