Skip to content

Commit

Permalink
Merge branch 'master' into ordered_actions
Browse files Browse the repository at this point in the history
  • Loading branch information
shroffk authored Aug 2, 2024
2 parents e053815 + 105f8af commit 12df56b
Show file tree
Hide file tree
Showing 41 changed files with 1,426 additions and 587 deletions.
14 changes: 14 additions & 0 deletions app/display/actions/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="src" path="src/test/java"/>
<classpathentry combineaccessrules="false" kind="src" path="/phoebus-target"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-framework"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-ui"/>
<classpathentry combineaccessrules="false" kind="src" path="/app-display-model"/>
<classpathentry combineaccessrules="false" kind="src" path="/app-display-representation-javafx"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
17 changes: 17 additions & 0 deletions app/display/actions/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>app-display-actions</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ public void writeToXML(ModelWriter modelWriter, XMLStreamWriter writer) throws E
writer.writeEndElement();
}

@Override
public boolean matchesAction(String actionId) {
return actionId.equalsIgnoreCase(OPEN_FILE);
}

@Override
public Image getImage() {
return ImageCache.getImage(ActionsDialog.class, "/icons/open_file.png");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ public void writeToXML(ModelWriter modelWriter, XMLStreamWriter writer) throws E
writer.writeEndElement();
}

@Override
public boolean matchesAction(String actionId) {
return actionId.equalsIgnoreCase(OPEN_WEBPAGE);
}

@Override
public Image getImage() {
return ImageCache.getImage(ActionsDialog.class, "/icons/web_browser.png");
Expand Down
1 change: 1 addition & 0 deletions app/display/convert-edm/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<classpathentry combineaccessrules="false" kind="src" path="/core-formula"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-vtype"/>
<classpathentry combineaccessrules="false" kind="src" path="/app-display-model"/>
<classpathentry combineaccessrules="false" kind="src" path="/app-display-actions"/>
<classpathentry combineaccessrules="false" kind="src" path="/app-display-editor"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
1 change: 1 addition & 0 deletions app/display/convert-medm/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/core-ui"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-util"/>
<classpathentry combineaccessrules="false" kind="src" path="/app-display-model"/>
<classpathentry combineaccessrules="false" kind="src" path="/app-display-actions"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void readFromXML(final ModelReader modelReader, final Element propertyXml
// the action type id.
ServiceLoader<ActionInfo> loader = ServiceLoader.load(ActionInfo.class);
Optional<ServiceLoader.Provider<ActionInfo>> optionalActionInfo =
loader.stream().filter(p -> p.get().matchesAction(type)).findFirst();
loader.stream().filter(p -> p.get().getType().equalsIgnoreCase(type) || p.get().matchesAction(type)).findFirst();
if (optionalActionInfo.isPresent()) {
actionInfo = optionalActionInfo.get().get();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@
import org.w3c.dom.Element;

import javax.xml.stream.XMLStreamWriter;
import java.util.Comparator;
import java.util.List;

public interface ActionInfo {
public interface ActionInfo extends Comparable<ActionInfo> {

/**
* If action type is not sufficient to determine match, implementations may add additional logic
* to resolve match. For instance: legacy display formats may use a different string to define the action type.
* @param actionId Action id, e.g. open_display.
* @return <code>true</code> if the input string is implemented by the {@link ActionInfo}.
*/
Expand All @@ -42,8 +45,7 @@ default boolean matchesAction(String actionId) {
}

/**
* The id/type of action, which is either a fully qualified class name, or a legacy identifier
* string like 'open_display'. Must be unique between all implementations.
* Non-null identifier, must be unique between all implementations.
*
* @return The action 'type'.
*/
Expand Down Expand Up @@ -125,4 +127,18 @@ default List<MenuItem> getContextMenuItems(Widget widget) {
* @return The {@link ActionInfo} object with committed values.
*/
ActionInfo commit();

/**
* Comparator for the sake of sorting {@link ActionInfo}s. Uses {@link ActionInfo#getDescription()}.
* @param other the object to be compared.
* @return Any occurrence of <code>null</code> in the {@link ActionInfo#getDescription()}
* fields will return 0. Otherwise, comparison of {@link ActionInfo#getDescription()}.
*/
@Override
default int compareTo(ActionInfo other){
if(getDescription() == null || other.getDescription() == null){
return 0;
}
return getDescription().compareTo(other.getDescription());
}
}
1 change: 1 addition & 0 deletions app/display/navigation/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<classpathentry combineaccessrules="false" kind="src" path="/core-util"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-ui"/>
<classpathentry combineaccessrules="false" kind="src" path="/app-display-model"/>
<classpathentry combineaccessrules="false" kind="src" path="/app-display-actions"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static org.csstudio.display.builder.representation.ToolkitRepresentation.logger;

import java.util.Comparator;
import java.util.List;
import java.util.ServiceLoader;
import java.util.logging.Level;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -104,7 +105,7 @@ protected void updateItem(final ActionsDialogActionItem actionsDialogActionItem,
logger.log(Level.WARNING, "Error displaying " + actionsDialogActionItem, ex);
}
}
};
}

/** Initialize */
@FXML
Expand Down
1 change: 1 addition & 0 deletions app/display/runtime/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<classpathentry combineaccessrules="false" kind="src" path="/app-display-representation-javafx"/>
<classpathentry combineaccessrules="false" kind="src" path="/app-display-representation"/>
<classpathentry combineaccessrules="false" kind="src" path="/app-display-model"/>
<classpathentry combineaccessrules="false" kind="src" path="/app-display-actions"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-email"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-types"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-ui"/>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions app/save-and-restore/app/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,12 @@ The search result table of the Search And Filter view also supports a contect me

.. image:: images/search-result-context-menu.png

Invoke a restore operation from search result
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Snapshot and composite snapshot items in the search result table support an additional context menu item users can
choose in order to perform a restore operation.

Snapshot View Context Menu
--------------------------

Expand Down Expand Up @@ -416,4 +422,36 @@ Authorization uses a role-based approach like so:

Roles are defined and managed on the service. Role (group) membership is managed in Active Directory or LDAP.

Integration with the Display Builder application
------------------------------------------------

It is possible to configure Display Builder actions to interact with the Save-And-Restore application. Such actions are available as either items
in the context menu of a Display Builder widget, or actions associated with an Action Button widget, or both.

When Save-And-Restore actions are executed, the application is launched or put in focus. The following action types
are supported:

* | Open a configuration, snapshot or composite snapshot node in the Save-And-Restore application.
| This can be used to quickly access a particular node in order to invoke a restore operation.
* | Open a named filter in the Save-And-Restore application.
| This will open/show the search and filter view and automatically perform the search associated with the named filter.
| This feature can be used to quickly navigate from a Display Builder screen to a view containing a set of commonly used snapshots.
Configuring actions
^^^^^^^^^^^^^^^^^^^

When configuring an action in the Display Builder editor, supported actions are available from a list:

.. image:: images/select_action.png
:width: 70%

For the open node action, user may either paste the unique id of a node into the input field, or launch a
browser to select a node:

.. image:: images/open_node.png
:width: 70%

For the open filter action, user can select from a drop-down list showing existing named filters:

.. image:: images/open_filter.png
:width: 70%
5 changes: 5 additions & 0 deletions app/save-and-restore/app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
<artifactId>save-and-restore-model</artifactId>
<version>4.7.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.phoebus</groupId>
<artifactId>app-display-model</artifactId>
<version>4.7.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
@SuppressWarnings("unused")
public class Messages {

public static String actionOpenFilterDescription;
public static String actionOpenNodeDescription;
public static String alertContinue;
public static String alertAddingPVsToConfiguration;
public static String authenticationFailed;
Expand All @@ -38,7 +40,7 @@ public class Messages {
public static String contextMenuCompareSnapshots;
public static String contextMenuDelete;
public static String copy;
public static String Edit;

public static String contextMenuAddToCompositeSnapshot;
public static String contextMenuNewFolder;
public static String contextMenuNewCompositeSnapshot;
Expand Down Expand Up @@ -69,6 +71,7 @@ public class Messages {
public static String duplicatePVNamesAdditionalItems;
public static String duplicatePVNamesCheckFailed;
public static String duplicatePVNamesFoundInSelection;
public static String Edit;
public static String editFilter;
public static String errorActionFailed;
public static String errorAddTagFailed;
Expand All @@ -81,9 +84,11 @@ public class Messages {
public static String exportConfigurationLabel;
public static String exportSnapshotLabel;
public static String exportSnapshotFailed;
public static String faildDeleteFilter;
public static String failedDeleteFilter;
public static String failedGetFilters;
public static String failedSaveFilter;
public static String failedToPasteObjects;
public static String filterNotFound;
public static String findSnapshotReferences;
public static String importConfigurationLabel;
public static String importSnapshotLabel;
Expand Down Expand Up @@ -114,10 +119,10 @@ public class Messages {
public static String promptRenameNodeContent;

public static String pvName;
public static String nodeSelectionForCompositeSnapshot;
public static String nodeSelectionForConfiguration;
public static String noValueAvailable;
public static String readbackPVName;
public static String restore;
public static String restoreFailed;
public static String restoreFailedPVs;
public static String saveFilter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,29 @@ public AppInstance create() {
return create(null);
}


@Override
public AppInstance create(URI uri) {

// Check if save & restore app is already running
for (Stage stage : DockStage.getDockStages()) {
for (DockPane pane : DockStage.getDockPanes(stage)) {
for (DockItem tab : pane.getDockItems()) {
if (tab.getApplication().getAppDescriptor().getName().equals(NAME)) {
instance = null;
for (Stage stage : DockStage.getDockStages()) {
for (DockPane pane : DockStage.getDockPanes(stage)) {
for (DockItem tab : pane.getDockItems()) {
if (tab.getApplication().getAppDescriptor().getName().equals(NAME)) {
tab.select();
if(uri != null){
((SaveAndRestoreInstance)tab.getApplication()).openResource(uri);
}
instance = tab.getApplication();
return instance;
}
}
}
}

instance = new SaveAndRestoreInstance(this, uri);
return instance;
}
}
}
}
if(instance == null){
instance = new SaveAndRestoreInstance(this);
}

((SaveAndRestoreInstance)instance).raise();
if(uri != null){
((SaveAndRestoreInstance)instance).openResource(uri);
}

return instance;
}

public AppInstance getInstance(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,37 +38,25 @@ public class SaveAndRestoreInstance implements AppInstance {

private final AppDescriptor appDescriptor;
private final SaveAndRestoreController saveAndRestoreController;
private DockItem tab;

public SaveAndRestoreInstance(AppDescriptor appDescriptor, URI uri) {
public SaveAndRestoreInstance(AppDescriptor appDescriptor) {
this.appDescriptor = appDescriptor;

DockItem tab = null;
tab = null;

FXMLLoader loader = new FXMLLoader();
try {
ResourceBundle resourceBundle = NLS.getMessages(Messages.class);
loader.setResources(resourceBundle);
loader.setLocation(SaveAndRestoreApplication.class.getResource("ui/SaveAndRestoreUI.fxml"));
loader.setControllerFactory(clazz -> {
try {
if (clazz.isAssignableFrom(SaveAndRestoreController.class)) {
return clazz.getConstructor(URI.class).newInstance(uri);
}
} catch (Exception e) {
Logger.getLogger(SaveAndRestoreInstance.class.getName()).log(Level.WARNING, "Failed to load Save & Restore UI", e);
}
return null;
});
tab = new DockItem(this, loader.load());
} catch (Exception e) {
Logger.getLogger(SaveAndRestoreApplication.class.getName()).log(Level.SEVERE, "Failed loading fxml", e);
}

saveAndRestoreController = loader.getController();

tab.setOnCloseRequest(event -> saveAndRestoreController.handleTabClosed());

DockPane.getActiveDockPane().addTab(tab);
}

@Override
Expand All @@ -88,4 +76,12 @@ public void openResource(URI uri) {
public void secureStoreChanged(List<ScopedAuthenticationToken> validTokens){
saveAndRestoreController.secureStoreChanged(validTokens);
}

public void raise(){
if(!DockPane.getActiveDockPane().getDockItems().contains(tab)){
DockPane.getActiveDockPane().addTab(tab);
}

tab.select();
}
}
Loading

0 comments on commit 12df56b

Please sign in to comment.