我尝试使用gradle antlr插件,但遇到了几个问题.
我有一个语法文件叫wls.g4:
grammar WlsScript;
@header {
package hu.pmi.wls.antlr.ws;
}
program
: 'statementList'? EOF
;
// Several more grammar and lexer rules
Run Code Online (Sandbox Code Playgroud)
(注意:我将statementList设为一个关键字,只是为了制作一个正确的语法而不包括整个语法.;-))
该文件位于/ src/main/antlr(作为antlr生成语法文件的默认源文件夹).
以下是来自的代码段build.gradle:
project('common') {
apply plugin: 'antlr'
dependencies {
// Some dependencies
antlr "org.antlr:antlr4:4.5"
}
}
Run Code Online (Sandbox Code Playgroud)
当我使用generateGrammarSourcegradle任务(从antlr插件中提交)生成源文件时,它会生成build/generated-src/antlr/main默认文件夹中的文件.
出了什么问题,它没有创建java包的文件夹(hu/pmi/wls/antlr/ws在我们的例子中),因此源将错误地定位在Eclipse中.
我的主要问题是如何强制任务以包结构的方式生成源文件?换句话说,如何配置gradle任务以使用语法中的包声明?
谢谢!
我想知道如何绑定绑定源可能为null的值.
我有一个属性:
private ObjectProperty<Operation> operation = new SimpleObjectProperty<>(null);
Run Code Online (Sandbox Code Playgroud)
我还有一个文本字段:
@FXML
private Text txtCurrentOperation;
Run Code Online (Sandbox Code Playgroud)
我想将textProperty字段绑定到操作对象的值.
我的第一个想法是使用FluentAPI和when/then/otherwise构造,但是热切地评估了解决方案:
Bindings.when(operation.isNotNull())
.then("null")
.otherwise(operation.get().getName()));
Run Code Online (Sandbox Code Playgroud)
将抛出一个NPE,因为otherwise无论结果是什么,都会评估参数when.
我的下一个想法是以某种方式使用lambda:
txtCurrentOperation.textProperty().bind(() ->
new SimpleStringProperty(
operation.isNotNull().get() ? "Null" : operation.get().getName()
));
Run Code Online (Sandbox Code Playgroud)
但绑定没有启用lambda的解决方案.(后来我意识到它不可能,因为真正的工作倒退了:绑定对象(操作)的更改将触发绑定器的更新(字段文本属性).)
我发现一些文章建议使用属性的"极值"值而不是null.但是Operation是一个复杂且重量级的组件,因此构造一个表示null的人工实例并非易事.更重要的是,这似乎是我的锅炉代码,绑定机制旨在帮助消除.
我的下一个尝试是逻辑交换绑定方向并将侦听器添加到操作属性,并让它以编程方式更新字段.只要更新的需要仅依赖于操作对象实例,它就可以工作并且相当简单:
operation.addListener((e) -> {
txtCurrentOperation.setText(operation.isNull().get() ?
"Null" : operation.get().getName());
});
operation.set(oper);
Run Code Online (Sandbox Code Playgroud)
它相对简单,但不起作用:它抛出"无法设置绑定值".异常,我不明白为什么控件的text属性被视为绑定.
我没有想法了.经过多次搜索,我仍然无法根据源是否为空来解决更新文本字段的简单问题.
这似乎是如此简单和日常的问题,我相信我错过了解决方案.
我在JavaFX中遇到了一个可能的错误,但是时间很短,我正在寻找一种解决方法.
我有一堆包含图表和工具栏的窗口:
public void createGui() {
root = new VBox();
ToolBar toolbar = new ToolBar();
Button btnConfig = new Button(bundle.getString("chartWindow.menu.configure"));
btnConfig.setOnAction(e -> doChartConfig());
toolbar.getItems().addAll(btnConfig);
chartPane = new VBox();
root.getChildren().setAll(toolbar, chartPane);
VBox.setVgrow(chartPane, Priority.ALWAYS);
scene = new Scene(root);
setScene(scene);
updateChart(); // Creates a chart
}
Run Code Online (Sandbox Code Playgroud)
我必须从代码中调整它们的大小.(平铺打开的图表.)简化的平铺代码是:
// bounds is the user available area of the monitors(s)
double windowWidth = bounds.getWidth() / tileRule.columns;
double windowHeight = bounds.getHeight() / tileRule.rows;
int r = 0;
int c = 0;
for (Window w : sel) { …Run Code Online (Sandbox Code Playgroud) 我想创建一个具有部分透明背景的视图(舞台、窗口)。我有一个包含 alpha 通道的图像
我在 JavaFx 中使用了这种场景,我必须将场景填充设置为 null,将根节点背景颜色设置为透明。我用 TornadoFX 尝试了同样的方法:
class NextRoundView : View("Következ? kör") {
override val root = vbox {
style {
backgroundColor = multi(Color.TRANSPARENT)
backgroundImage = multi(URI.create("/common/rope-bg-500x300.png"))
backgroundRepeat = multi(BackgroundRepeat.NO_REPEAT
to BackgroundRepeat.NO_REPEAT)
}
prefWidth = 500.0
prefHeight = 300.0
spacing = 20.0
padding = insets(50, 20)
text("A text") {
font = Font.font(40.0)
alignment = Pos.CENTER
}
button("OK")
{
font = Font.font(20.0)
action {
close()
}
}
sceneProperty().addListener{ _,_,n ->
n.fill = null
}
}
}
Run Code Online (Sandbox Code Playgroud)
我这样调用视图:
NextRoundView().apply { …Run Code Online (Sandbox Code Playgroud) 我曾经在 Windows、Linux 和 WSL 上的 Artemis 中创建代理。从来没有出现过问题。除了我的一台装有 Windows 并运行 WSL2 的计算机。
我在安装 artemis 时做了同样的事情:
sudo groupadd artemis
sudo useradd -s /bin/false -g artemis -d /opt/artemis artemis
cd /opt
sudo wget https://archive.apache.org/dist/activemq/activemq-artemis/2.12.0/apache-artemis-2.12.0-bin.tar.gz
sudo tar -xvzf apache-artemis-2.12.0-bin.tar.gz
sudo mv apache-artemis-2.12.0 artemis
sudo chown -R artemis: artemis
sudo chmod o+x /opt/artemis/bin/
sudo rm apache-artemis-2.12.0-bin.tar.gz
Run Code Online (Sandbox Code Playgroud)
它安装了,但是当我尝试创建自己的代理实例时:
/opt/artemis/bin/artemis create --user app --password pwd --allow-anonymous test
Run Code Online (Sandbox Code Playgroud)
我收到以下错误消息:
Cannot initialize queue:Function not implemented
Run Code Online (Sandbox Code Playgroud)
我已经尝试了好几次,甚至卸载了artemis并删除了用户和组并重新启动了整个过程,但结果总是相同的。
我不知道有什么区别或如何解决问题。任何帮助将不胜感激!
更新 1:没有太多日志,但打开详细模式会给出以下几行:
Executing org.apache.activemq.artemis.cli.commands.Create create --verbose --user app --password pwd --allow-anonymous test …Run Code Online (Sandbox Code Playgroud)