Skip to content

Commit

Permalink
Merge branch 'master' into CSSTUDIO-2072
Browse files Browse the repository at this point in the history
  • Loading branch information
abrahamwolk committed Jul 30, 2024
2 parents ff62232 + e44953c commit c26d641
Show file tree
Hide file tree
Showing 285 changed files with 105,429 additions and 2,898 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v1
- name: Setup Maven and Java Action
uses: s4u/setup-maven-action@v1.13.0
with:
java-version: '17'
maven-version: '3.9.6'
- name: Build
run: mvn --batch-mode install
run: mvn --batch-mode install -DskipTests
5 changes: 3 additions & 2 deletions .github/workflows/build_latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v1
- name: Setup Maven and Java Action
uses: s4u/setup-maven-action@v1.13.0
with:
java-version: '17'
maven-version: '3.9.6'
- name: Build
run: mvn --batch-mode install -DskipTests

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ant clean run

## Developing with Eclipse

Download Eclipse Oxygen 4.7.1a or later from http://download.eclipse.org/eclipse/downloads/
Download "Eclipse for Java Developers" from https://www.eclipse.org/downloads/packages/

Start Eclipse like this:

Expand All @@ -85,6 +85,10 @@ Check Eclipse Preferences:

### Use plain Java configuration

This approach uses the Eclipse-specific `.classpath` and `.project` files,
which may lag the maven-based settings or be incomplete,
but for the time being can still be used.

Use `File`, `Import`, `General`, `Existing Projects into Workspace`.
Select the phoebus root directory, and check the option to "Search for nested projects".

Expand Down
2 changes: 1 addition & 1 deletion app/3d-viewer/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
</classpathentry>
<classpathentry kind="src" path="/core-ui"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-framework"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
2 changes: 1 addition & 1 deletion app/alarm/datasource/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/classes" path="src/test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry combineaccessrules="false" kind="src" path="/phoebus-target"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-framework"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-types"/>
Expand Down
17 changes: 17 additions & 0 deletions app/alarm/freetts-annunciator/.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-alarm-freetts-annunciator</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>
5 changes: 3 additions & 2 deletions app/alarm/freetts-annunciator/build.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<project default="app-alarm-ui">
<project default="app-alarm-freetts-annunciator">
<import file="../../../dependencies/ant_settings.xml"/>

<target name="app-alarm-freetts-annunciator">
Expand All @@ -7,7 +7,8 @@
<src path="${src}"/>
<classpath>
<path refid="app-classpath"/>
<pathelement path="../model/${build}/app-alarm-ui-${version}.jar"/>
<pathelement path="../model/${build}/app-alarm-model-${version}.jar"/>
<pathelement path="../ui/${build}/app-alarm-ui-${version}.jar"/>
</classpath>
</javac>

Expand Down
1 change: 1 addition & 0 deletions app/alarm/logging-ui/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/core-types"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-util"/>
<classpathentry combineaccessrules="false" kind="src" path="/app-alarm-model"/>
<classpathentry combineaccessrules="false" kind="src" path="/app-alarm-ui"/>
<classpathentry kind="output" path="target/classes" />
</classpath>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
AlarmInformation=Informations sur l'alarme
Command=Commande
Config=Configuration
ConfigurationInfo=Informations sur la configuration
ConfigurationInfoNotFound=Informations sur la configuration introuvables.
Configurations=Configurations :
CurrentMessage=Message actuel
CurrentSeverity=Gravité actuelle
EndTime=Heure de fin
Host=Hôte
Message=Message
MessageTime=Heure du message
Mode=Mode
NoSearchResults=Aucun résultat de recherche
Query=Requête :
Search=Rechercher
Configuration=Configuration(s) :
Severity=Gravité
StartTime=Heure de début
Time=Heure
User=Utilisateur
Value=Valeur
2 changes: 1 addition & 1 deletion app/alarm/model/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/classes" path="src/test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry combineaccessrules="false" kind="src" path="/phoebus-target"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-framework"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-util"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public Map<String, String> sourceMap() {
map.put("config", getConfig());
map.put("user", getUser());
map.put("host", getHost());
map.put("enabled", enabled.toString());
map.put("enabled", String.valueOf(enabled.enabled));
map.put("latching", Boolean.toString(isLatching()));
map.put("config_msg", toString());
map.put("message_time", formatter.withZone(ZoneId.of("UTC")).format(getMessage_time()));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Disabled=Désactivé
Disconnected=Déconnecté
NoPV=Pas de PV

2 changes: 1 addition & 1 deletion app/alarm/ui/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<classpathentry kind="src" output="target/classes" path="src/test/java"/>
<classpathentry kind="src" path="src/main/python"/>
<classpathentry kind="src" path="src/test/python"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry combineaccessrules="false" kind="src" path="/phoebus-target"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-framework"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-types"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
package org.phoebus.applications.alarm.ui;

import java.net.URI;
import java.util.HashMap;
import java.util.Map;

/** Alarm URI helpers
*
Expand All @@ -23,18 +25,32 @@ public class AlarmURI
/** URI schema used to refer to an alarm config */
public static final String SCHEMA = "alarm";

/** Nme to use for item as query parameter */
public static final String QUERY_PARAMETER_ITEM_NAME = "itemName";

/** @param server Kafka server host:port
* @param config_name Alarm configuration root
* @return URI used to access that alarm configuration, "alarm://host:port/config_name"
*/
public static URI createURI(final String server, final String config_name)
{
return URI.create(SCHEMA + "://" + server + "/" + config_name);
public static URI createURI(final String server, final String config_name) {
return createURI(server, config_name, null);
}

/** @param server Kafka server host:port
* @param config_name Alarm configuration root
* @param rawQuery raw query for URI
* @return URI used to access that alarm configuration, "alarm://host:port/config_name?rawQuery"
*/
public static URI createURI(final String server, final String config_name, String rawQuery) {
if (rawQuery != null && rawQuery.length() > 0)
return URI.create(SCHEMA + "://" + server + "/" + config_name + "?" + rawQuery);
else
return URI.create(SCHEMA + "://" + server + "/" + config_name);
}

/** Parse alarm configuration parameters from URI
* @param resource "alarm://localhost:9092/Accelerator"
* @return [ "localhost:9092", "Accelerator" ]
* @param resource "alarm://localhost:9092/Accelerator" or "alarm://localhost:9092/Accelerator?param=value"
* @return ["localhost:9092", "Accelerator", null] or ["localhost:9092", "Accelerator", "param=value"]
* @throws Exception on error
*/
public static String[] parseAlarmURI(final URI resource) throws Exception
Expand All @@ -55,10 +71,35 @@ public static String[] parseAlarmURI(final URI resource) throws Exception
if (port < 0)
port = 9092;
String config_name = resource.getPath();
String rawQuery = resource.getRawQuery();
if (config_name.startsWith("/"))
config_name = config_name.substring(1);
if (config_name.isEmpty())
throw new Exception("Missing alarm config name in " + resource + ", expecting " + SCHEMA + "://{host}:{port}/{config_name}");
return new String[] { resource.getHost() + ":" + port, config_name };
return new String[] { resource.getHost() + ":" + port, config_name, rawQuery };
}

/**
* Return a map with parameter names and values as key-value pairs for raw query of given resource.
* @param resource "alarm://localhost:9092/Accelerator" or "alarm://localhost:9092/Accelerator?param=value"
* @return map with parameter names as keys and parameter values as values for raw query
*/
public static Map<String, String> getRawQueryParametersValues(URI resource) {
Map<String, String> map = new HashMap<>();
String[] queryParametersValues = resource.getRawQuery() != null ? resource.getRawQuery().split("&") : null;
if (queryParametersValues != null) {
for (String queryParameterValue : queryParametersValues) {
String[] parameterValue = queryParameterValue.split("=");
if (parameterValue != null) {
if (parameterValue.length == 2) {
map.put(parameterValue[0], parameterValue[1]);
} else if (parameterValue.length == 1) {
map.put(parameterValue[0], null);
}
}
}
}
return map;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import static org.phoebus.applications.alarm.AlarmSystem.logger;

import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
Expand All @@ -31,16 +33,15 @@
import org.phoebus.applications.alarm.model.AlarmTreeItem;
import org.phoebus.applications.alarm.model.SeverityLevel;
import org.phoebus.applications.alarm.ui.AlarmUI;
import org.phoebus.applications.alarm.ui.AlarmURI;
import org.phoebus.ui.javafx.JFXUtil;
import org.phoebus.ui.javafx.UpdateThrottle;

import javafx.application.Platform;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Label;
import javafx.scene.control.MenuItem;
import javafx.scene.paint.Color;
import javafx.scene.shape.StrokeLineCap;
import javafx.scene.shape.StrokeLineJoin;
Expand Down Expand Up @@ -104,8 +105,6 @@ public AlarmAreaView(final AlarmClient model)

areaFilter = new AreaFilter(AlarmSystem.alarm_area_level);
model.addListener(this);

createContextMenu();
}

// AlarmClientModelListener
Expand Down Expand Up @@ -205,6 +204,23 @@ private void recreateItems(final List<String> items)
for (String item_name : items)
{
final Label view_item = newAreaLabel(item_name);

// context menu content for alarm model item instead of alarm area
// link to item in tree view
view_item.setOnContextMenuRequested(event -> {
// need to clear and repopulate context menu since alarm area is recreated multiple times
// (but number of times unknown)
for (int i=menu.getItems().size()-1; i>0; i--) {
if (menu.getItems().get(i).getClass().equals(OpenTreeViewAction.class)) {
menu.getItems().remove(i);
}
}

OpenTreeViewAction otva = new OpenTreeViewAction(alarmConfigName, AlarmURI.QUERY_PARAMETER_ITEM_NAME + "=" + URLEncoder.encode(item_name, StandardCharsets.UTF_8));
menu.getItems().add(otva);
menu.show(this.getScene().getWindow(), event.getScreenX(), event.getScreenY());
});

itemViewMap.put(item_name, view_item);
updateItem(item_name);
final int column = index % AlarmSystem.alarm_area_column_count;
Expand Down Expand Up @@ -241,19 +257,10 @@ private void updateItem(final String item_name)
view_item.setStyle("-fx-alignment: center; -fx-border-color: black; -fx-border-width: 2; -fx-border-radius: 10; -fx-background-insets: 1; -fx-background-radius: 10; -fx-text-fill: " + JFXUtil.webRGB(AlarmUI.getAlarmAreaPanelColor(severityLevel)) + "; -fx-background-color: " + JFXUtil.webRGB(AlarmUI.getAlarmAreaPanelBackgroundColor(severityLevel)));
}

private void createContextMenu()
{
final ObservableList<MenuItem> menu_items = menu.getItems();

menu_items.add(new OpenTreeViewAction(alarmConfigName));
this.setOnContextMenuRequested(event ->
menu.show(this.getScene().getWindow(), event.getScreenX(), event.getScreenY())
);
}

/** @return Context menu */
public ContextMenu getMenu()
{
return menu;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,24 @@
* @author Evan Smith
*/
@SuppressWarnings("nls")
public class OpenTreeViewAction extends MenuItem
{
public class OpenTreeViewAction extends MenuItem {

/**
* Constructor
* @param alarmConfigName The alarm configuration name
*/
public OpenTreeViewAction(String alarmConfigName)
{
public OpenTreeViewAction(String alarmConfigName) {
this(alarmConfigName, null);
}

/**
* Constructor
* @param alarmConfigName The alarm configuration name
* @param alarmRawQuery raw query for alarm (null if no such information is available)
*/
public OpenTreeViewAction(String alarmConfigName, String alarmRawQuery) {
final AlarmTreeMenuEntry entry = new AlarmTreeMenuEntry();
entry.setResource(AlarmURI.createURI(AlarmSystem.server, alarmConfigName));
entry.setResource(AlarmURI.createURI(AlarmSystem.server, alarmConfigName, alarmRawQuery));
setText(entry.getName());
setGraphic(new ImageView(entry.getIcon()));
setOnAction(event ->
Expand All @@ -45,4 +52,5 @@ public OpenTreeViewAction(String alarmConfigName)
}
});
}

}
Loading

0 comments on commit c26d641

Please sign in to comment.