forked from inductiveautomation/ignition-sdk-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add components using model/store delegates and dynamic routes. (induc…
…tiveautomation#28) * wip, tag delegate functional. * tag counter working * add messenger scss, polish, documentation * minor bug fixes and cleanup * remove dev build tasks * update plugin version, minor refactor of util method * uncomment buildscript release repo * minor cleanup, don't write empty string * 8.0.3 final release versions * update npm dependencies
- Loading branch information
Showing
39 changed files
with
3,317 additions
and
1,229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...ctive-component/common/src/main/java/org/fakester/common/component/display/Messenger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.fakester.common.component.display; | ||
|
||
import javax.swing.ImageIcon; | ||
|
||
import com.inductiveautomation.ignition.common.jsonschema.JsonSchema; | ||
import com.inductiveautomation.perspective.common.api.ComponentDescriptor; | ||
import com.inductiveautomation.perspective.common.api.ComponentDescriptorImpl; | ||
import org.fakester.common.RadComponents; | ||
|
||
|
||
/** | ||
* Common meta information about the Messenger component. See {@link Image} for docs on each field. | ||
*/ | ||
public class Messenger { | ||
|
||
public static String COMPONENT_ID = "rad.display.messenger"; | ||
|
||
|
||
public static JsonSchema SCHEMA = | ||
JsonSchema.parse(RadComponents.class.getResourceAsStream("/messenger.props.json")); | ||
|
||
public static ComponentDescriptor DESCRIPTOR = ComponentDescriptorImpl.ComponentBuilder.newBuilder() | ||
.withPaletteCategory(RadComponents.COMPONENT_CATEGORY) | ||
.withPaletteDescription("A component that uses component messaging and data fetching delegates.") | ||
.withId(COMPONENT_ID) | ||
.withModuleId(RadComponents.MODULE_ID) | ||
.withSchema(SCHEMA) // this could alternatively be created purely in Java if desired | ||
.withPaletteName("Gateway Messenger") | ||
.withDefaultMetaName("messenger") | ||
.shouldAddToPalette(true) | ||
.withResources(RadComponents.BROWSER_RESOURCES) | ||
.build(); | ||
} |
29 changes: 29 additions & 0 deletions
29
...tive-component/common/src/main/java/org/fakester/common/component/display/TagCounter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.fakester.common.component.display; | ||
|
||
import com.inductiveautomation.ignition.common.jsonschema.JsonSchema; | ||
import com.inductiveautomation.perspective.common.api.ComponentDescriptor; | ||
import com.inductiveautomation.perspective.common.api.ComponentDescriptorImpl; | ||
import org.fakester.common.RadComponents; | ||
|
||
/** | ||
* Meta information about the TagCounter component. See {@link Image} for docs on each field. | ||
*/ | ||
public class TagCounter { | ||
public static String COMPONENT_ID = "rad.display.tagcounter"; | ||
|
||
public static JsonSchema SCHEMA = | ||
JsonSchema.parse(RadComponents.class.getResourceAsStream("/tagcounter.props.json")); | ||
|
||
public static ComponentDescriptor DESCRIPTOR = ComponentDescriptorImpl.ComponentBuilder.newBuilder() | ||
.withPaletteCategory(RadComponents.COMPONENT_CATEGORY) | ||
.withPaletteDescription("A component that displays the number of tags associated with a gateway.") | ||
.withId(COMPONENT_ID) | ||
.withModuleId(RadComponents.MODULE_ID) | ||
.withSchema(SCHEMA) // this could alternatively be created purely in Java if desired | ||
.withPaletteName("Tag Counter") | ||
.withDefaultMetaName("tagCounter") | ||
.shouldAddToPalette(true) | ||
.withResources(RadComponents.BROWSER_RESOURCES) | ||
.build(); | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
perspective-component/common/src/main/resources/messenger.props.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"messageConfig": { | ||
"type": "object", | ||
"description": "A set of key:value pairs where the key is the cutoff point for when a message should be displayed, and the value is a string containing the message displayed when the 'key' number of messages is reached.", | ||
"propertyNames": { | ||
"pattern": "^[0-9][0-9]*$" | ||
}, | ||
"default": { | ||
"0": "None", | ||
"1": "Messages!", | ||
"5": "Lots of Messages!", | ||
"10": "Literally ten+ messages!", | ||
"25": "Carpal Tunnel Warning!" | ||
} | ||
}, | ||
"style": { | ||
"$ref": "urn:ignition-schema:schemas/style-properties.schema.json", | ||
"default": { | ||
"classes": "" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
perspective-component/common/src/main/resources/tagcounter.props.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"fontSize": { | ||
"type": "string", | ||
"description": "Size of font to display the tag count in, as a valid css size", | ||
"default": "3rem" | ||
}, | ||
"interval": { | ||
"type": "number", | ||
"description": "Rate (in ms) in which to get a new tag count. Only one request will happen at a time.", | ||
"default": 1000 | ||
}, | ||
"style": { | ||
"$ref": "urn:ignition-schema:schemas/style-properties.schema.json", | ||
"default": { | ||
"classes": "" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
plugins { | ||
id 'java' | ||
} | ||
|
||
|
||
dependencies { | ||
compile "com.inductiveautomation.ignitionsdk:designer-launcher:${sdk_version}" | ||
compile "com.inductiveautomation.ignitionsdk:ignition-common:${sdk_version}" | ||
compile project(":designer") // local designer scoped subproject | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 51 additions & 4 deletions
55
perspective-component/designer/src/main/java/org/fakester/designer/RadDesignerHook.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,74 @@ | ||
package org.fakester.designer; | ||
|
||
import com.inductiveautomation.ignition.common.BundleUtil; | ||
import com.inductiveautomation.ignition.common.licensing.LicenseState; | ||
import com.inductiveautomation.ignition.common.util.LoggerEx; | ||
import com.inductiveautomation.ignition.designer.model.AbstractDesignerModuleHook; | ||
import com.inductiveautomation.ignition.designer.model.DesignerContext; | ||
import com.inductiveautomation.perspective.designer.DesignerComponentRegistry; | ||
import com.inductiveautomation.perspective.designer.api.ComponentDesignDelegateRegistry; | ||
import com.inductiveautomation.perspective.designer.api.PerspectiveDesignerInterface; | ||
import org.fakester.common.component.display.Messenger; | ||
import org.fakester.common.component.display.Image; | ||
import org.fakester.common.component.display.TagCounter; | ||
import org.fakester.designer.component.TagCountDesignDelegate; | ||
|
||
|
||
/** | ||
* The 'hook' class for the designer scope of the module. Registered in the ignitionModule configuration of the | ||
* root build.gradle file. | ||
*/ | ||
public class RadDesignerHook extends AbstractDesignerModuleHook { | ||
|
||
private static final LoggerEx logger = LoggerEx.newBuilder().build("RadComponents"); | ||
|
||
public RadDesignerHook() { | ||
LoggerEx.newBuilder().build("RadComponents").info("Registering Rad Components in Designer!"); | ||
static { | ||
BundleUtil.get() | ||
.addBundle("radcomponents", RadDesignerHook.class.getClassLoader(), "radcomponents"); | ||
} | ||
|
||
public RadDesignerHook() { | ||
logger.info("Registering Rad Components in Designer!"); | ||
} | ||
private DesignerContext context; | ||
private DesignerComponentRegistry registry; | ||
private ComponentDesignDelegateRegistry delegateRegistry; | ||
|
||
@Override | ||
public void startup(DesignerContext context, LicenseState activationState) throws Exception { | ||
PerspectiveDesignerInterface.getComponentRegistry(context) | ||
.registerComponent(Image.DESCRIPTOR); | ||
this.context = context; | ||
init(); | ||
} | ||
|
||
private void init() { | ||
logger.debug("Initializing registry entrants..."); | ||
|
||
PerspectiveDesignerInterface pdi = PerspectiveDesignerInterface.get(context); | ||
|
||
registry = pdi.getDesignerComponentRegistry(); | ||
delegateRegistry = pdi.getComponentDesignDelegateRegistry(); | ||
|
||
// register components to get them on the palette | ||
registry.registerComponent(Image.DESCRIPTOR); | ||
registry.registerComponent(TagCounter.DESCRIPTOR); | ||
registry.registerComponent(Messenger.DESCRIPTOR); | ||
|
||
// register design delegates to get the special config UI when a component type is selected in the designer | ||
delegateRegistry.register(TagCounter.COMPONENT_ID, new TagCountDesignDelegate()); | ||
|
||
} | ||
|
||
|
||
@Override | ||
public void shutdown() { | ||
removeComponents(); | ||
} | ||
|
||
private void removeComponents() { | ||
registry.removeComponent(Image.COMPONENT_ID); | ||
registry.removeComponent(TagCounter.COMPONENT_ID); | ||
registry.removeComponent(Messenger.COMPONENT_ID); | ||
|
||
delegateRegistry.remove(TagCounter.COMPONENT_ID); | ||
} | ||
} |
Oops, something went wrong.