Class NewResourceAction
java.lang.Object
javax.swing.AbstractAction
com.inductiveautomation.ignition.designer.tabbedworkspace.NewResourceAction
- All Implemented Interfaces:
ActionListener
,Serializable
,Cloneable
,EventListener
,Action
- Direct Known Subclasses:
ReportingResourceWorkspace.NewReportResourceAction
This action will pop up the
CreateResourceDialog
. There are two ways that implementations of this abstract
class are meant to be used:
1. The legacy way: override createPrototype()
and return your object. It will be serialized using Ignition's
default XML serialization and the resulting bytes will be stored in the resources as data.bin
2. The Ignition 8.0 way: Override configureResource(ProjectResourceBuilder)
and invoke methods on the
resource builder. Don't worry about setting project name, resource path, or scope - these will be set automatically.
After the resource is created it will be opened in your workspace.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Consumer<ProjectResourceBuilder>
protected boolean
protected final ResourceFolderNode
protected final TabbedResourceWorkspace
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
-
Constructor Summary
ConstructorsConstructorDescriptionNewResourceAction
(TabbedResourceWorkspace workspace, ResourceFolderNode folder) NewResourceAction
(TabbedResourceWorkspace workspace, ResourceFolderNode folder, Consumer<ProjectResourceBuilder> builderConsumer) Alternative constructor to avoid to subclassing/overriding configureResource -
Method Summary
Modifier and TypeMethodDescriptionvoid
actionPerformed
(ActionEvent event) protected void
configureResource
(ProjectResourceBuilder builder) The default implementation of this simply calls putData() with the prototype bytes in order to be backwards compatible with the legacy method of project resources only having one binary file in them.protected Object
protected byte[]
protected ResourceFolderNode
Provides an opportunity for subclasses to provide the parent folder lazilyprotected abstract String
protected void
onAfterResourceAdded
(ProjectResource resource) Do more things after the resource is created here, if you want.Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
Field Details
-
workspace
-
folder
-
canceled
protected boolean canceled -
builderConsumer
-
-
Constructor Details
-
NewResourceAction
-
NewResourceAction
public NewResourceAction(TabbedResourceWorkspace workspace, ResourceFolderNode folder, Consumer<ProjectResourceBuilder> builderConsumer) Alternative constructor to avoid to subclassing/overriding configureResource
-
-
Method Details
-
actionPerformed
-
onAfterResourceAdded
Do more things after the resource is created here, if you want.- Throws:
Exception
-
getFolder
Provides an opportunity for subclasses to provide the parent folder lazily -
configureResource
The default implementation of this simply calls putData() with the prototype bytes in order to be backwards compatible with the legacy method of project resources only having one binary file in them.To make a more modern project resource with specific named files init, override this method and do not use
createPrototype()
- Throws:
Exception
-
createPrototypeBytes
- Throws:
Exception
-
createPrototype
-
newResourceName
-