diff --git a/src/main/i18n/de.json b/src/main/i18n/de.json index f6e018b2..a3e2ef35 100644 --- a/src/main/i18n/de.json +++ b/src/main/i18n/de.json @@ -79,6 +79,7 @@ }, "ComponentDiagram": { "Component": "Komponente", + "Subsystem": "Teilsystem", "ComponentDependency": "Abhängigkeit", "ComponentInterface": "Schnittstelle", "ComponentInterfaceProvided": "Bereitgestellte Schnittstelle", diff --git a/src/main/i18n/en.json b/src/main/i18n/en.json index 25d8cf30..b5ebf7ca 100644 --- a/src/main/i18n/en.json +++ b/src/main/i18n/en.json @@ -79,6 +79,7 @@ }, "ComponentDiagram": { "Component": "Component", + "Subsystem": "Subsystem", "ComponentDependency": "Dependency", "ComponentInterface": "Interface", "ComponentInterfaceProvided": "Provided Interface", diff --git a/src/main/packages/common/uml-component/uml-component-component.tsx b/src/main/packages/common/uml-component/uml-component-component.tsx index b8dff706..475ef212 100644 --- a/src/main/packages/common/uml-component/uml-component-component.tsx +++ b/src/main/packages/common/uml-component/uml-component-component.tsx @@ -11,9 +11,6 @@ export const UMLComponentComponent: FunctionComponent = ({ element, child strokeColor={element.strokeColor} fillColor={fillColor || element.fillColor} /> - - {element.name} - = ({ element, child strokeMiterlimit="10" /> + + {element.stereotype && ( + + {`«${element.stereotype}»`} + + )} + + {element.name} + + {children} ); diff --git a/src/main/packages/common/uml-component/uml-component.ts b/src/main/packages/common/uml-component/uml-component.ts index 008bf334..bd1cbbbe 100644 --- a/src/main/packages/common/uml-component/uml-component.ts +++ b/src/main/packages/common/uml-component/uml-component.ts @@ -1,3 +1,9 @@ import { UMLPackage } from '../uml-package/uml-package'; -export abstract class UMLComponent extends UMLPackage {} +export interface IUMLComponent { + stereotype: string; +} + +export abstract class UMLComponent extends UMLPackage implements IUMLComponent { + stereotype = 'component'; +} diff --git a/src/main/packages/components.ts b/src/main/packages/components.ts index 822dbae9..5d7fad87 100644 --- a/src/main/packages/components.ts +++ b/src/main/packages/components.ts @@ -37,6 +37,7 @@ import { UMLPetriNetArcComponent } from './uml-petri-net/uml-petri-net-arc/uml-p import { UMLReachabilityGraphArcComponent } from './uml-reachability-graph/uml-reachability-graph-arc/uml-reachability-graph-arc-component'; import { UMLReachabilityGraphMarkingComponent } from './uml-reachability-graph/uml-reachability-graph-marking/uml-reachability-graph-marking-component'; import { UMLComponentComponent } from './common/uml-component/uml-component-component'; +import { UMLComponentSubsystem } from './uml-component-diagram/uml-component-subsystem/uml-component-subsystem-component'; import { SyntaxTreeTerminalComponent } from './syntax-tree/syntax-tree-terminal/syntax-tree-terminal-component'; import { SyntaxTreeNonterminalComponent } from './syntax-tree/syntax-tree-nonterminal/syntax-tree-nonterminal-component'; import { SyntaxTreeLinkComponent } from './syntax-tree/syntax-tree-link/syntax-tree-link-component'; @@ -86,6 +87,7 @@ export const Components: { [UMLElementType.UseCaseActor]: UMLUseCaseActorComponent, [UMLElementType.UseCaseSystem]: UMLUseCaseSystemComponent, [UMLElementType.Component]: UMLComponentComponent, + [UMLElementType.Subsystem]: UMLComponentSubsystem, [UMLElementType.ComponentInterface]: UMLInterfaceComponent, [UMLElementType.DeploymentNode]: UMLDeploymentNodeComponent, [UMLElementType.DeploymentComponent]: UMLComponentComponent, diff --git a/src/main/packages/popups.ts b/src/main/packages/popups.ts index d8269d9d..0716c135 100644 --- a/src/main/packages/popups.ts +++ b/src/main/packages/popups.ts @@ -55,6 +55,7 @@ export const Popups: { [key in UMLElementType | UMLRelationshipType]: ComponentT [UMLElementType.UseCaseActor]: DefaultPopup, [UMLElementType.UseCaseSystem]: DefaultPopup, [UMLElementType.Component]: DefaultPopup, + [UMLElementType.Subsystem]: DefaultPopup, [UMLElementType.ComponentInterface]: DefaultPopup, [UMLElementType.DeploymentNode]: UMLDeploymentNodeUpdate, [UMLElementType.DeploymentComponent]: DefaultPopup, diff --git a/src/main/packages/uml-component-diagram/component-preview.ts b/src/main/packages/uml-component-diagram/component-preview.ts index c763322c..f931e8d1 100644 --- a/src/main/packages/uml-component-diagram/component-preview.ts +++ b/src/main/packages/uml-component-diagram/component-preview.ts @@ -3,6 +3,7 @@ import { UMLElement } from '../../services/uml-element/uml-element'; import { ComposePreview } from '../compose-preview'; import { UMLComponentInterface } from './uml-component-interface/uml-component-interface'; import { UMLComponentComponent } from './uml-component/uml-component-component'; +import { UMLSubsystem } from './uml-component-subsystem/uml-component-subsystem'; export const composeComponentPreview: ComposePreview = ( layer: ILayer, @@ -19,7 +20,16 @@ export const composeComponentPreview: ComposePreview = ( }; elements.push(umlComponent); - // UML Deployment Artifact + // UML Subsystem + const umlSubsystem = new UMLSubsystem({ name: translate('packages.ComponentDiagram.Subsystem') }); + umlSubsystem.bounds = { + ...umlSubsystem.bounds, + width: umlSubsystem.bounds.width, + height: umlSubsystem.bounds.height, + }; + elements.push(umlSubsystem); + + // UML Component Interface const umlComponentInterface = new UMLComponentInterface({ name: translate('packages.ComponentDiagram.ComponentInterface'), }); diff --git a/src/main/packages/uml-component-diagram/index.ts b/src/main/packages/uml-component-diagram/index.ts index fd041b35..e32b6605 100644 --- a/src/main/packages/uml-component-diagram/index.ts +++ b/src/main/packages/uml-component-diagram/index.ts @@ -1,5 +1,6 @@ export const ComponentElementType = { Component: 'Component', + Subsystem: 'Subsystem', ComponentInterface: 'ComponentInterface', } as const; diff --git a/src/main/packages/uml-component-diagram/uml-component-subsystem/uml-component-subsystem-component.tsx b/src/main/packages/uml-component-diagram/uml-component-subsystem/uml-component-subsystem-component.tsx new file mode 100644 index 00000000..d717de65 --- /dev/null +++ b/src/main/packages/uml-component-diagram/uml-component-subsystem/uml-component-subsystem-component.tsx @@ -0,0 +1,48 @@ +import React, { FunctionComponent } from 'react'; +import { Text } from '../../../components/controls/text/text'; +import { UMLSubsystem } from './uml-component-subsystem'; +import { ThemedPath, ThemedRect } from '../../../components/theme/themedComponents'; + +export const UMLComponentSubsystem: FunctionComponent = ({ element, children, fillColor }) => ( + + + + + + + + {element.stereotype && ( + + {`«${element.stereotype}»`} + + )} + + {element.name} + + + {children} + +); + +interface Props { + element: UMLSubsystem; + fillColor?: string; + children?: React.ReactNode; +} diff --git a/src/main/packages/uml-component-diagram/uml-component-subsystem/uml-component-subsystem.ts b/src/main/packages/uml-component-diagram/uml-component-subsystem/uml-component-subsystem.ts new file mode 100644 index 00000000..0abb1b79 --- /dev/null +++ b/src/main/packages/uml-component-diagram/uml-component-subsystem/uml-component-subsystem.ts @@ -0,0 +1,16 @@ +import { UMLPackage } from '../../common/uml-package/uml-package'; +import { ComponentElementType, ComponentRelationshipType } from '..'; + +export interface IUMLSubsystem { + stereotype: string; +} + +export class UMLSubsystem extends UMLPackage implements IUMLSubsystem { + static supportedRelationships = [ + ComponentRelationshipType.ComponentDependency, + ComponentRelationshipType.ComponentInterfaceProvided, + ComponentRelationshipType.ComponentInterfaceRequired, + ]; + stereotype = 'subsystem'; + type = ComponentElementType.Subsystem; +} diff --git a/src/main/packages/uml-elements.ts b/src/main/packages/uml-elements.ts index f6c8cc6b..f06af75e 100644 --- a/src/main/packages/uml-elements.ts +++ b/src/main/packages/uml-elements.ts @@ -30,6 +30,7 @@ import { UMLReachabilityGraphMarking } from './uml-reachability-graph/uml-reacha import { CommunicationLinkMessage } from './uml-communication-diagram/uml-communication-link/uml-communiction-link-message'; import { UMLDeploymentComponent } from './uml-deployment-diagram/uml-deployment-component/uml-component'; import { UMLComponentComponent } from './uml-component-diagram/uml-component/uml-component-component'; +import { UMLSubsystem } from './uml-component-diagram/uml-component-subsystem/uml-component-subsystem'; import { SyntaxTreeTerminal } from './syntax-tree/syntax-tree-terminal/syntax-tree-terminal'; import { SyntaxTreeNonterminal } from './syntax-tree/syntax-tree-nonterminal/syntax-tree-nonterminal'; import { FlowchartTerminal } from './flowchart/flowchart-terminal/flowchart-terminal'; @@ -72,6 +73,7 @@ export const UMLElements = { [UMLElementType.UseCaseActor]: UMLUseCaseActor, [UMLElementType.UseCaseSystem]: UMLUseCaseSystem, [UMLElementType.Component]: UMLComponentComponent, + [UMLElementType.Subsystem]: UMLSubsystem, [UMLElementType.ComponentInterface]: UMLComponentInterface, [UMLElementType.DeploymentNode]: UMLDeploymentNode, [UMLElementType.DeploymentComponent]: UMLDeploymentComponent, diff --git a/src/tests/unit/packages/uml-component-diagram/uml-component/__snapshots__/uml-component-component-test.tsx.snap b/src/tests/unit/packages/uml-component-diagram/uml-component/__snapshots__/uml-component-component-test.tsx.snap index d8d80fd3..41fecd19 100644 --- a/src/tests/unit/packages/uml-component-diagram/uml-component/__snapshots__/uml-component-component-test.tsx.snap +++ b/src/tests/unit/packages/uml-component-diagram/uml-component/__snapshots__/uml-component-component-test.tsx.snap @@ -14,16 +14,6 @@ exports[`render the uml-component-component 1`] = ` stroke="black" width="100%" /> - - TestComponentComponent - @@ -44,6 +34,30 @@ exports[`render the uml-component-component 1`] = ` stroke-width="1.2" /> + + + «component» + + + TestComponentComponent + +