Skip to content

Commit

Permalink
Backup commit
Browse files Browse the repository at this point in the history
  • Loading branch information
georgweiss committed Nov 20, 2024
1 parent c2804d6 commit 47b495b
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
import org.phoebus.logbook.olog.ui.HelpViewer;
import org.phoebus.logbook.olog.ui.LogbookUIPreferences;
import org.phoebus.logbook.olog.ui.PreviewViewer;
import org.phoebus.logbook.olog.ui.menu.SendToLogBookApp;
import org.phoebus.olog.es.api.OlogProperties;
import org.phoebus.olog.es.api.model.OlogLog;
import org.phoebus.security.store.SecureStore;
Expand Down Expand Up @@ -99,16 +98,22 @@ public class LogEntryEditorController {
private final Logger logger = Logger.getLogger(LogEntryEditorController.class.getName());

@FXML
@SuppressWarnings("unused")
private VBox editorPane;
@FXML
@SuppressWarnings("unused")
private VBox errorPane;
@FXML
@SuppressWarnings("unused")
private Button submitButton;
@FXML
@SuppressWarnings("unused")
private Button cancelButton;
@FXML
@SuppressWarnings("unused")
private ProgressIndicator progressIndicator;
@FXML
@SuppressWarnings("unused")
private Label completionMessageLabel;

@SuppressWarnings("unused")
Expand All @@ -119,42 +124,61 @@ public class LogEntryEditorController {
private LogPropertiesEditorController logPropertiesEditorController;

@FXML
@SuppressWarnings("unused")
private Label userFieldLabel;
@FXML
@SuppressWarnings("unused")
private Label passwordFieldLabel;
@FXML
@SuppressWarnings("unused")
private TextField userField;
@FXML
@SuppressWarnings("unused")
private TextField dateField;
@FXML
@SuppressWarnings("unused")
private PasswordField passwordField;
@FXML
@SuppressWarnings("unused")
private Label levelLabel;
@FXML
@SuppressWarnings("unused")
private ComboBox<String> levelSelector;
@FXML
@SuppressWarnings("unused")
private Label titleLabel;
@FXML
@SuppressWarnings("unused")
private TextField titleField;
@FXML
@SuppressWarnings("unused")
private TextArea textArea;
@FXML
@SuppressWarnings("unused")
private Button addLogbooks;
@FXML
@SuppressWarnings("unused")
private Button addTags;
@FXML
@SuppressWarnings("unused")
private ToggleButton logbooksDropdownButton;
@FXML
@SuppressWarnings("unused")
private ToggleButton tagsDropdownButton;
@FXML
@SuppressWarnings("unused")
private Label logbooksLabel;
@FXML
@SuppressWarnings("unused")
private TextField logbooksSelection;
@FXML
@SuppressWarnings("unused")
private TextField tagsSelection;
@FXML
@SuppressWarnings("unused")
private HBox templateControls;
@FXML
@SuppressWarnings("unused")
private ComboBox<LogTemplate> templateSelector;

private final ContextMenu logbookDropDown = new ContextMenu();
Expand Down Expand Up @@ -202,10 +226,6 @@ public class LogEntryEditorController {
*/
private String originalTitle = "";

/**
* Version of remote service
*/
private String serverVersion;

public LogEntryEditorController(LogEntry logEntry, LogEntry inReplyTo, LogEntryCompletionHandler logEntryCompletionHandler) {
this.replyTo = inReplyTo;
Expand Down Expand Up @@ -313,12 +333,12 @@ public void initialize() {
titleField.textProperty().bindBidirectional(titleProperty);
titleProperty.addListener((changeListener, oldVal, newVal) ->
{
if (newVal.trim().isEmpty()) {
if (newVal == null || newVal.trim().isEmpty()) {
titleLabel.setTextFill(Color.RED);
} else {
titleLabel.setTextFill(Color.BLACK);
}
if (!newVal.equals(originalTitle)) {
if (newVal != null && !newVal.equals(originalTitle)) {
isDirty = true;
}
});
Expand Down Expand Up @@ -403,7 +423,7 @@ public void initialize() {
);

selectedTags.addListener((ListChangeListener<String>) change -> {
if(change.getList() == null){
if (change.getList() == null) {
return;
}
List<String> newSelection = new ArrayList<>(change.getList());
Expand All @@ -413,7 +433,7 @@ public void initialize() {
});

selectedLogbooks.addListener((ListChangeListener<String>) change -> {
if(change.getList() == null){
if (change.getList() == null) {
return;
}
List<String> newSelection = new ArrayList<>(change.getList());
Expand Down Expand Up @@ -487,6 +507,7 @@ public void cancel() {
}

@FXML
@SuppressWarnings("unused")
public void showHelp() {
new HelpViewer(LogbookUIPreferences.markup_help).show();
}
Expand All @@ -495,12 +516,14 @@ public void showHelp() {
* Handler for HTML preview button
*/
@FXML
@SuppressWarnings("unused")
public void showHtmlPreview() {
new PreviewViewer(getDescription(), attachmentsEditorController.getAttachments()).show();
}


@FXML
@SuppressWarnings("unused")
public void submit() {

submissionInProgress.set(true);
Expand Down Expand Up @@ -563,6 +586,7 @@ public void submit() {
}

@FXML
@SuppressWarnings("unused")
public void setLevel() {
selectedLevelProperty.set(levelSelector.getSelectionModel().getSelectedItem());
}
Expand All @@ -576,6 +600,7 @@ public String getDescription() {
}

@FXML
@SuppressWarnings("unused")
public void addLogbooks() {
logbooksPopOver.show(addLogbooks);
}
Expand All @@ -597,15 +622,16 @@ private void setSelectedLogbooks(List<String> proposedLogbooks, List<String> exi
private void setSelected(List<String> proposed, List<String> existing, Consumer<String> addFunction, Consumer<String> removeFunction) {
List<String> addedTags = proposed.stream()
.filter(tag -> !existing.contains(tag))
.collect(Collectors.toList());
.toList();
List<String> removedTags = existing.stream()
.filter(tag -> !proposed.contains(tag))
.collect(Collectors.toList());
.toList();
addedTags.forEach(addFunction);
removedTags.forEach(removeFunction);
}

@FXML
@SuppressWarnings("unused")
public void selectLogbooks() {
if (logbooksDropdownButton.isSelected()) {
logbookDropDown.show(logbooksSelection, Side.BOTTOM, 0, 0);
Expand All @@ -615,6 +641,7 @@ public void selectLogbooks() {
}

@FXML
@SuppressWarnings("unused")
public void addTags() {
tagsPopOver.show(addTags);
}
Expand All @@ -634,6 +661,7 @@ private void setSelectedTags(List<String> proposedTags, List<String> existingTag
}

@FXML
@SuppressWarnings("unused")
public void selectTags() {
if (tagsDropdownButton.isSelected()) {
tagDropDown.show(tagsSelection, Side.BOTTOM, 0, 0);
Expand Down Expand Up @@ -666,7 +694,7 @@ private void getServerSideStaticData() {
Collections.sort(availableLogbooksAsStringList);

List<String> preSelectedLogbooks =
logEntry.getLogbooks().stream().map(Logbook::getName).collect(Collectors.toList());
logEntry.getLogbooks().stream().map(Logbook::getName).toList();
List<String> defaultLogbooks = Arrays.asList(LogbookUIPreferences.default_logbooks);
availableLogbooksAsStringList.forEach(logbook -> {
CheckBox checkBox = new CheckBox(logbook);
Expand Down Expand Up @@ -697,7 +725,7 @@ private void getServerSideStaticData() {
Collections.sort(availableLogbooksAsStringList);

List<String> preSelectedTags =
logEntry.getTags().stream().map(Tag::getName).collect(Collectors.toList());
logEntry.getTags().stream().map(Tag::getName).toList();
availableTagsAsStringList.forEach(tag -> {
CheckBox checkBox = new CheckBox(tag);
CustomMenuItem newTag = new CustomMenuItem(checkBox);
Expand Down Expand Up @@ -727,7 +755,6 @@ private void getServerSideStaticData() {
ObjectMapper objectMapper = new ObjectMapper();
try {
JsonNode jsonNode = objectMapper.readTree(serverInfo);
serverVersion = jsonNode.get("version").asText();
attachmentsEditorController.setSizeLimits(jsonNode.get("serverConfig").get("maxFileSize").asText(),
jsonNode.get("serverConfig").get("maxRequestSize").asText());
} catch (Exception e) {
Expand Down Expand Up @@ -797,12 +824,18 @@ private boolean checkConnectivity() {
}
}

private void loadTemplate(LogTemplate logTemplate){
/**
* Loads template to configure UI elements.
* @param logTemplate A {@link LogTemplate} selected by user.
*/
private void loadTemplate(LogTemplate logTemplate) {
titleProperty.set(logTemplate.title());
descriptionProperty.set(logTemplate.source());
logPropertiesEditorController.setProperties(logTemplate.properties());
selectedTags.setAll(logTemplate.tags().stream().map(Tag::getName).toList());
selectedLogbooks.setAll(logTemplate.logbooks().stream().map(Logbook::getName).toList());
levelSelector.getSelectionModel().select(logTemplate.level());
selectedTags.forEach(t -> updateDropDown(tagDropDown, t, true));
selectedLogbooks.forEach(l -> updateDropDown(logbookDropDown, l, true));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public void setProperties(Collection<Property> properties){
return;
}
selectedProperties.addAll(properties);
availableProperties.removeAll(properties);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
<HBox fx:id="templateControls" alignment="CENTER_RIGHT" spacing="5.0">
<children>
<Label prefWidth="80" text="%Templates" />
<ComboBox fx:id="templateSelector" prefWidth="200"/>
<HBox alignment="CENTER_RIGHT" HBox.hgrow="ALWAYS"/>
<ComboBox fx:id="templateSelector" prefWidth="200" visibleRowCount="10" />
<HBox alignment="CENTER_RIGHT" HBox.hgrow="ALWAYS" />
</children>
</HBox>
<HBox alignment="CENTER_RIGHT" spacing="5.0">
Expand Down
18 changes: 14 additions & 4 deletions core/logbook/src/main/java/org/phoebus/logbook/LogTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@
import java.time.Instant;
import java.util.Collection;

/**
* Encapsulates elements representing a log entry template.
* @param id Unique id, determined and set by service when a {@link LogTemplate} is created, i.e. may be <code>null</code>
* @param name A case-insensitive name for the {@link LogTemplate}, must be unique among all saved {@link LogTemplate}s.
* @param owner User id set by service when a {@link LogTemplate} is created, i.e. may be <code>null</code>
* @param createdDate Create date set by service when a {@link LogTemplate} is created, i.e. may be <code>null</code>
* @param modifiedDate Modify date set by service when a {@link LogTemplate} is created, i.e. may be <code>null</code>
* @param title May be <code>null</code>.
* @param source Markdown body content. May be <code>null</code>.
* @param level Must not be <code>null</code> or empty.
* @param logbooks May be <code>null</code> or empty list.
* @param tags May be <code>null</code> or empty list.
* @param properties May be <code>null</code> or empty list.
*/
public record LogTemplate(String id,
String name,
String owner,
Expand All @@ -18,8 +32,4 @@ public record LogTemplate(String id,
Collection<Logbook> logbooks,
Collection<Tag> tags,
Collection<Property> properties){

public LogTemplate(){
this(null, null, null, null, null, null, null, null, null, null, null);
}
}

0 comments on commit 47b495b

Please sign in to comment.