Skip to content
This repository was archived by the owner on Feb 9, 2022. It is now read-only.

Commit 4c77ede

Browse files
ExplvExplv
authored andcommitted
Adding "Show command" option to configuration list
1 parent 9444456 commit 4c77ede

File tree

3 files changed

+50
-10
lines changed

3 files changed

+50
-10
lines changed

osbot_manager/src/bot_parameters/configuration/Configuration.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -378,15 +378,7 @@ public void run(final String osbotPath, final OSBotAccount osBotAccount) throws
378378

379379
try (BufferedWriter br = new BufferedWriter(new FileWriter(logFile))) {
380380

381-
for (final Script script : scripts.get()) {
382-
383-
List<String> command = new ArrayList<>();
384-
385-
Collections.addAll(command, "java", "-jar", osbotPath);
386-
Collections.addAll(command, osBotAccount.toParameterString().split(" "));
387-
Collections.addAll(command, this.toParameterString().split(" "));
388-
Collections.addAll(command, script.toParameterString().split(" "));
389-
381+
for (final List<String> command : getCommands(osbotPath, osBotAccount)) {
390382

391383
final ProcessBuilder processBuilder = new ProcessBuilder(command);
392384
processBuilder.redirectErrorStream(true);
@@ -451,6 +443,24 @@ public void run(final String osbotPath, final OSBotAccount osBotAccount) throws
451443
runThread.start();
452444
}
453445

446+
public List<List<String>> getCommands(final String osbotPath, final OSBotAccount osBotAccount) {
447+
448+
List<List<String>> commands = new ArrayList<>();
449+
450+
for (final Script script : scripts.get()) {
451+
List<String> command = new ArrayList<>();
452+
453+
Collections.addAll(command, "java", "-jar", osbotPath);
454+
Collections.addAll(command, osBotAccount.toParameterString().split(" "));
455+
Collections.addAll(command, this.toParameterString().split(" "));
456+
Collections.addAll(command, script.toParameterString().split(" "));
457+
458+
commands.add(command);
459+
}
460+
461+
return commands;
462+
}
463+
454464
public void stop() {
455465
if (!isRunning()) {
456466
return;

osbot_manager/src/gui/tabs/ConfigurationTab.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ public ConfigurationTab(final ObservableList<RunescapeAccount> runescapeAccounts
128128
MenuItem viewLogOption = new MenuItem("Show log");
129129
viewLogOption.setOnAction(e -> showLog());
130130
contextMenu.getItems().add(viewLogOption);
131+
132+
MenuItem viewCommandOption = new MenuItem("Show command");
133+
viewCommandOption.setOnAction(e -> showCommand());
134+
contextMenu.getItems().add(viewCommandOption);
131135
}
132136

133137
private void start() {
@@ -175,6 +179,32 @@ private void showLog() {
175179
readFileThread.start();
176180
}
177181

182+
private void showCommand() {
183+
Configuration configuration = getTableView().getSelectionModel().getSelectedItem();
184+
185+
Dialog dialog = new Dialog();
186+
dialog.getDialogPane().getButtonTypes().add(ButtonType.CLOSE);
187+
dialog.setResizable(true);
188+
dialog.initModality(Modality.NONE);
189+
190+
TextArea textArea = new TextArea();
191+
AnchorPane.setBottomAnchor(textArea, 0.0);
192+
AnchorPane.setRightAnchor(textArea, 0.0);
193+
AnchorPane.setLeftAnchor(textArea, 0.0);
194+
AnchorPane.setTopAnchor(textArea, 0.0);
195+
AnchorPane anchorPane = new AnchorPane(textArea);
196+
197+
dialog.getDialogPane().setContent(anchorPane);
198+
199+
List<List<String>> configCommands = configuration.getCommands(botSettingsTab.getBot().getOsbotPath(), botSettingsTab.getOsBotAccount());
200+
201+
for (List<String> command : configCommands) {
202+
textArea.appendText(String.join(" ", command) + "\n");
203+
}
204+
205+
dialog.show();
206+
}
207+
178208
private void runConfigurations(final List<Configuration> configurations) {
179209
final int delay = configurations.size() > 1 ? getDelayFromUser() : 0;
180210

osbot_manager/src/main/Version.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
public class Version {
1010

11-
private final static float currentVersion = 7.5f;
11+
private final static float currentVersion = 7.6f;
1212

1313
public static boolean isLatestVersion() {
1414
try {

0 commit comments

Comments
 (0)