You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ri...@apache.org on 2020/06/27 21:48:51 UTC

[incubator-streampipes] 02/03: [STREAMPIPES-166] Add color picker static property to SDK

This is an automated email from the ASF dual-hosted git repository.

riemer pushed a commit to branch STREAMPIPES-145
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git

commit a40f6388828e065aa697905ea202a00d425ea7ff
Author: Dominik Riemer <ri...@fzi.de>
AuthorDate: Sat Jun 27 23:34:40 2020 +0200

    [STREAMPIPES-166] Add color picker static property to SDK
---
 .../org/apache/streampipes/model/util/Cloner.java  |  2 ++
 ...AbstractConfigurablePipelineElementBuilder.java | 30 ++++++++++++++++++++++
 .../sdk/extractor/AbstractParameterExtractor.java  |  4 +++
 3 files changed, 36 insertions(+)

diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/util/Cloner.java b/streampipes-model/src/main/java/org/apache/streampipes/model/util/Cloner.java
index 7d3b871..ee0ca20 100644
--- a/streampipes-model/src/main/java/org/apache/streampipes/model/util/Cloner.java
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/util/Cloner.java
@@ -120,6 +120,8 @@ public class Cloner {
       return new FileStaticProperty((FileStaticProperty) o);
     } else if (o instanceof CodeInputStaticProperty) {
       return new CodeInputStaticProperty((CodeInputStaticProperty) o);
+    } else if (o instanceof ColorPickerStaticProperty) {
+      return new ColorPickerStaticProperty((ColorPickerStaticProperty) o);
     } else {
       return new StaticPropertyAlternative((StaticPropertyAlternative) o);
     }
diff --git a/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/builder/AbstractConfigurablePipelineElementBuilder.java b/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/builder/AbstractConfigurablePipelineElementBuilder.java
index 57646ed..7d67e4a 100644
--- a/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/builder/AbstractConfigurablePipelineElementBuilder.java
+++ b/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/builder/AbstractConfigurablePipelineElementBuilder.java
@@ -169,6 +169,36 @@ public abstract class AbstractConfigurablePipelineElementBuilder<BU extends
     return me();
   }
 
+  /**
+   * Assigns a new color picker parameter which is required by the pipeline
+   * element.
+   * @param label The {@link org.apache.streampipes.sdk.helpers.Label} that describes why this parameter is needed in a
+   *              user-friendly manner.
+   *
+   * @return
+   */
+  public BU requiredColorParameter(Label label) {
+    ColorPickerStaticProperty csp = new ColorPickerStaticProperty(label.getInternalId(), label.getLabel(), label.getDescription());
+    this.staticProperties.add(csp);
+
+    return me();
+  }
+
+  /**
+   * Assigns a new color picker parameter which is required by the pipeline
+   * element.
+   * @param label The {@link org.apache.streampipes.sdk.helpers.Label} that describes why this parameter is needed in a
+   *              user-friendly manner.
+   * @param defaultColor The default color, encoded as an HTML color code
+   * @return
+   */
+  public BU requiredColorParameter(Label label, String defaultColor) {
+    ColorPickerStaticProperty csp = new ColorPickerStaticProperty(label.getInternalId(), label.getLabel(), label.getDescription());
+    csp.setSelectedColor(defaultColor);
+    this.staticProperties.add(csp);
+
+    return me();
+  }
 
   /**
    * @deprecated Use {@link #requiredTextParameter(Label, String)}
diff --git a/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/extractor/AbstractParameterExtractor.java b/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/extractor/AbstractParameterExtractor.java
index e80577b..ab2c51d 100644
--- a/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/extractor/AbstractParameterExtractor.java
+++ b/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/extractor/AbstractParameterExtractor.java
@@ -92,6 +92,10 @@ public abstract class AbstractParameterExtractor<T extends InvocableStreamPipesE
     return getStaticPropertyByName(internalName,CodeInputStaticProperty.class).getValue();
   }
 
+  public String selectedColor(String internalName) {
+    return getStaticPropertyByName(internalName, ColorPickerStaticProperty.class).getSelectedColor();
+  }
+
   public String fileContentsAsString(String internalName) throws IOException {
     String filename =
             getStaticPropertyByName(internalName, FileStaticProperty.class).getLocationPath();