Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.sensorhub.api.sensor.SensorConfig;
import org.sensorhub.impl.database.system.SystemDriverDatabaseConfig;
import org.sensorhub.impl.datastore.view.ObsSystemDatabaseViewConfig;
import org.sensorhub.impl.processing.SMLProcessConfig;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also can revert this class as no changes were made

import org.sensorhub.impl.security.BasicSecurityRealmConfig;
import org.sensorhub.impl.service.AbstractHttpServiceModule;
import org.sensorhub.impl.service.HttpServer;
Expand Down Expand Up @@ -101,7 +102,8 @@ public void setConfiguration(AdminUIConfig config)
customForms.put(CommandStreamFilter.class.getCanonicalName(), DatabaseFilterConfigForm.class);
customForms.put(ObsFilter.class.getCanonicalName(), DatabaseFilterConfigForm.class);
customForms.put(CommandFilter.class.getCanonicalName(), DatabaseFilterConfigForm.class);



// custom form builders defined in config
for (CustomUIConfig customForm: config.customForms)
{
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.vast.process.ProcessInfo;
import org.vast.sensorML.AbstractProcessImpl;
import org.vast.sensorML.AggregateProcessImpl;
import org.vast.sensorML.LinkImpl;
import org.vast.sensorML.SMLUtils;
import org.vast.swe.SWEHelper;
import com.rits.cloning.Cloner;
Expand Down Expand Up @@ -178,27 +179,28 @@ protected void setupCallbacks()
{
addFunction("onChangeLink", new JavaScriptFunction() {
@Override
public void call(JsonArray args)
{
public void call(JsonArray args) {
Connection conn = new Connection();
conn.id = args.getString(0);
conn.src = args.getString(1);
conn.dest = args.getString(2);
addConnection(conn);
addConnection(conn); // updates UI state
upsertProcessChainLink(conn); // <-- persist to processChain
notifyListeners();
}
}
});

addFunction("onRemoveLink", new JavaScriptFunction() {
@Override
public void call(JsonArray args)
{
public void call(JsonArray args) {
String id = args.getString(0);
getState().connections.remove(id);
removeProcessChainLink(id); // <-- mirror removal
notifyListeners();
}
}
});



addFunction("onChangeElement", new JavaScriptFunction() {
@Override
public void call(JsonArray args)
Expand Down Expand Up @@ -226,34 +228,86 @@ public void call(JsonArray args)
notifyListeners();
}
});

addFunction("onContextMenu", new JavaScriptFunction() {
@Override
public void call(JsonArray args)
{
public void call(JsonArray args) {
String action = args.getString(0);
String blockName = args.getString(1);
String portName = args.getString(2);
if ("addInput".equals(action))
addExternalInput(blockName, portName);
else if ("setInput".equals(action))
setInputValues(blockName, portName);
else if ("setParam".equals(action))
setParamValues(blockName, portName);

// normalize action names coming from the UI
switch (action) {
case "addInput":
case "exposeInput":
case "exposeAsInput":
case "Expose as input":
addExternalInput(blockName, portName);
break;

case "setInput":
case "setValue":
case "Set value":
setInputValues(blockName, portName);
break;

case "setParam":
case "setParameter":
setParamValues(blockName, portName);
break;

default:
// ignore unknowns to avoid NPEs
return;
}
notifyListeners();
}
}
});

}


protected void addExternalInput(String blockName, String portName)
{

protected void upsertProcessChainLink(Connection conn) {
// replace if same id exists
for (int i = 0; i < processChain.getConnectionList().size(); i++) {
Link l = processChain.getConnectionList().get(i);
if (conn.id != null && conn.id.equals(l.getId())) {
l.setSource(conn.src);
l.setDestination(conn.dest);
return;
}
}
// otherwise add a new link
Link l = new LinkImpl();
l.setId(conn.id != null ? conn.id : UUID.randomUUID().toString());
l.setSource(conn.src);
l.setDestination(conn.dest);
processChain.getConnectionList().add(l);
}

protected void removeProcessChainLink(String id) {
if (id == null) return;
List<Link> links = processChain.getConnectionList();
for (int i = links.size() - 1; i >= 0; i--) {
Link l = links.get(i);
if (id.equals(l.getId())) {
links.remove(i);
}
}
}



protected void addExternalInput(String blockName, String portName) {
for (Port p : getState().inputs) {
if (p.path.equals(portName)) return; // already exposed
}
Port port = new Port();
port.path = portName;
getState().inputs.add(port);
}





protected void addExternalParam(String blockName, String portName)
{

Expand All @@ -264,40 +318,33 @@ protected void addExternalOutput(String blockName, String portName)
{

}


protected void setInputValues(String blockName, String portName)
{


protected void setInputValues(String blockName, String portName) {
AbstractProcess process = processChain.getComponent(blockName);
DataComponent paramPort = process.getParameterComponent(portName);
editValues(paramPort);
DataComponent inputPort = process.getInputComponent(portName); // <-- FIXED
editValues("Set Input", inputPort);
}


protected void setParamValues(String blockName, String portName)
{

protected void setParamValues(String blockName, String portName) {
AbstractProcess process = processChain.getComponent(blockName);
DataComponent paramPort = process.getParameterComponent(portName);
editValues(paramPort);
editValues("Set Parameter", paramPort);
}


protected void editValues(DataComponent component)
{
Window popup = new Window("Set Parameter");

protected void editValues(String title, DataComponent component) {
Window popup = new Window(title); // <-- dynamic title
VerticalLayout content = new VerticalLayout();
popup.setContent(content);
popup.center();

// retrieve param component

SWEParamForm form = new SWEParamForm(component);
content.addComponent(form);

// Open it in the UI
getUI().addWindow(popup);
}





protected void addDataSource(ProcessBlock b)
{
getState().dataSources.put(b.name, b);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.regex.Pattern;
import org.sensorhub.api.processing.IProcessProvider;
import org.sensorhub.api.processing.ProcessingException;
import org.sensorhub.impl.processing.StreamDataSource;
import org.sensorhub.ui.api.UIConstants;
import org.vast.process.ProcessInfo;
import com.vaadin.ui.Alignment;
Expand Down Expand Up @@ -65,7 +66,7 @@ public ProcessSelectionPopup(Collection<IProcessProvider> providers, final Proce
setWidth(1000.0f, Unit.PIXELS);
buildDialog(providers, callback);
}


protected void buildDialog(Collection<IProcessProvider> providers, final ProcessSelectionCallback callback)
{
Expand All @@ -81,7 +82,7 @@ protected void buildDialog(Collection<IProcessProvider> providers, final Process
table.addContainerProperty(PROP_DESC, String.class, null);
table.addContainerProperty(PROP_VERSION, String.class, null);
table.addContainerProperty(PROP_AUTHOR, String.class, null);
table.setColumnHeaders(new String[] {"Name", "Description", "Version", "Author"});
table.setColumnHeaders("Name", "Description", "Version", "Author");
table.setColumnWidth(PROP_NAME, 250);
table.setPageLength(10);
table.setMultiSelect(false);
Expand All @@ -97,8 +98,8 @@ protected void buildDialog(Collection<IProcessProvider> providers, final Process

for (ProcessInfo info: provider.getProcessMap().values())
{
// skip data sources as they are inserted separately
if (info.getUri().contains(":datasource:"))
// For simplicity, don't let users choose this one
if (info == StreamDataSource.INFO)
continue;

Object id = table.addItem(new Object[] {
Expand All @@ -112,20 +113,21 @@ protected void buildDialog(Collection<IProcessProvider> providers, final Process
}
layout.addComponent(table);

// link to more modules
Button installNew = new Button("Install More Packages...");
installNew.setStyleName(STYLE_LINK);
layout.addComponent(installNew);
layout.setComponentAlignment(installNew, Alignment.MIDDLE_RIGHT);
installNew.addClickListener(new ClickListener()
{
@Override
public void buttonClick(ClickEvent event)
{
//close();
getUI().addWindow(new DownloadModulesPopup());
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add this back and make sure it works

});
// // link to more modules
// Button installNew = new Button("Install More Packages...");
// installNew.setStyleName(STYLE_LINK);
// layout.addComponent(installNew);
// layout.setComponentAlignment(installNew, Alignment.MIDDLE_RIGHT);
// TODO: Use check OSGi logic
// installNew.addClickListener(new ClickListener()
// {
// @Override
// public void buttonClick(ClickEvent event)
// {
// //close();
// getUI().addWindow(new DownloadModulesPopup());
// }
// });

// buttons bar
HorizontalLayout buttons = new HorizontalLayout();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.sensorhub.ui;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was an extra class

public class SMLProcessPanel {
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,27 @@ public class SWEControlForm extends SWEEditForm
transient Random random = new SecureRandom();


public SWEControlForm(final IStreamingControlInterface controlInput)
public SWEControlForm(final IStreamingControlInterface controlInput) { this(controlInput, null); }

public SWEControlForm(final IStreamingControlInterface controlInput, final ClickListener submitListener)
{
super(controlInput.getCommandDescription().copy());
this.controlInput = controlInput;
this.component.assignNewDataBlock();
buildForm();
buildForm(submitListener);
}


public SWEControlForm(final DataComponent params)
public SWEControlForm(final DataComponent params) { this(params, null); }

public SWEControlForm(final DataComponent params, ClickListener submitListener)
{
super(params.copy());
this.addSpacing = true;
this.controlSink = params;
this.component.setData(params.getData());
buildForm();
buildForm(submitListener);
}


@Override
public void attach()
{
Expand All @@ -77,8 +79,12 @@ public void attach()
}
}

@Override
protected void buildForm() {
buildForm(null);
}

protected void buildForm()
protected void buildForm(ClickListener submitListener)
{
super.buildForm();

Expand Down Expand Up @@ -116,5 +122,8 @@ public void buttonClick(ClickEvent event)
}
}
});

if (submitListener != null)
sendBtn.addClickListener(submitListener);
}
}
Loading
Loading