Search in sources :

Example 1 with DiagramConfiguration

use of org.osate.ge.internal.diagram.runtime.DiagramConfiguration in project osate2 by osate.

the class DiagramConfigurationDialog method main.

public static void main(String[] args) {
    final Model model = new Model() {

        @Override
        public RelativeBusinessObjectReference getRelativeBusinessObjectReference(final Object bo) {
            return new RelativeBusinessObjectReference(bo.toString());
        }

        @Override
        public Collection<Object> getChildBusinessObjects(final BusinessObjectContext boc) {
            final Collection<Object> children = new ArrayList<>();
            for (int i = 1; i <= 100; i++) {
                children.add("C" + i);
            }
            return children;
        }

        @Override
        public String getName(final BusinessObjectContext boc) {
            return boc.getBusinessObject().toString();
        }

        @Override
        public ImmutableSet<ContentFilter> getDefaultContentFilters(final Object bo) {
            return ImmutableSet.of(TestContentsFilter.FILTER1);
        }

        @Override
        public Map<String, Collection<String>> getAadlProperties() {
            final Map<String, Collection<String>> result = new HashMap<>();
            result.put("test_ps1", Arrays.asList(new String[] { "a", "c", "b" }));
            result.put("test_ps2", Arrays.asList(new String[] { "a", "b", "c" }));
            result.put("test_ps3", Arrays.asList(new String[] { "d", "f", "e" }));
            return result;
        }

        @Override
        public Object getBusinessObject(final CanonicalBusinessObjectReference ref) {
            return new Object();
        }

        @Override
        public String getContextDescription(final Object contextBo) {
            return "a::b::c (TestType)";
        }

        @Override
        public boolean shouldShowBusinessObject(final Object bo) {
            return !bo.equals("C3");
        }

        @Override
        public Image getImage(final Object bo) {
            return null;
        }

        @Override
        public Object resolve(final Object bo) {
            return bo;
        }

        @Override
        public boolean isProxy(Object bo) {
            return false;
        }
    };
    final DiagramConfiguration diagramConfig = new DiagramConfigurationBuilder(new CustomDiagramType(), false).contextBoReference(new CanonicalBusinessObjectReference("test")).addAadlProperty("test::prop1").addAadlProperty("test_ps2::b").connectionPrimaryLabelsVisible(true).build();
    // Create a test business object tree
    final BusinessObjectNode rootNode = new BusinessObjectNode(null, UUID.randomUUID(), null, null, Completeness.UNKNOWN, true);
    new BusinessObjectNode(rootNode, UUID.randomUUID(), new RelativeBusinessObjectReference("A"), "A", Completeness.UNKNOWN, true);
    new BusinessObjectNode(rootNode, UUID.randomUUID(), new RelativeBusinessObjectReference("B"), "B", Completeness.UNKNOWN, true);
    new BusinessObjectNode(rootNode, UUID.randomUUID(), new RelativeBusinessObjectReference("C"), "C", Completeness.UNKNOWN, true);
    new BusinessObjectNode(rootNode, UUID.randomUUID(), new RelativeBusinessObjectReference("D"), "D", Completeness.UNKNOWN, true);
    // Show the dialog
    final Result result = DiagramConfigurationDialog.show(null, model, diagramConfig, rootNode, new Object[] { "A", "C1", "C2", "C4" });
    if (result == null) {
        System.out.println("Dialog was canceled.");
    } else {
        System.out.println(result.getDiagramConfiguration());
        System.out.println(result.getBusinessObjectTree());
    }
}
Also used : CustomDiagramType(org.osate.ge.aadl2.internal.diagramtypes.CustomDiagramType) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RelativeBusinessObjectReference(org.osate.ge.RelativeBusinessObjectReference) ContentFilter(org.osate.ge.ContentFilter) BusinessObjectNode(org.osate.ge.internal.diagram.runtime.updating.BusinessObjectNode) DiagramConfiguration(org.osate.ge.internal.diagram.runtime.DiagramConfiguration) CanonicalBusinessObjectReference(org.osate.ge.CanonicalBusinessObjectReference) DiagramConfigurationBuilder(org.osate.ge.internal.diagram.runtime.DiagramConfigurationBuilder) Collection(java.util.Collection) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Aggregations

ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 BusinessObjectContext (org.osate.ge.BusinessObjectContext)1 CanonicalBusinessObjectReference (org.osate.ge.CanonicalBusinessObjectReference)1 ContentFilter (org.osate.ge.ContentFilter)1 RelativeBusinessObjectReference (org.osate.ge.RelativeBusinessObjectReference)1 CustomDiagramType (org.osate.ge.aadl2.internal.diagramtypes.CustomDiagramType)1 DiagramConfiguration (org.osate.ge.internal.diagram.runtime.DiagramConfiguration)1 DiagramConfigurationBuilder (org.osate.ge.internal.diagram.runtime.DiagramConfigurationBuilder)1 BusinessObjectNode (org.osate.ge.internal.diagram.runtime.updating.BusinessObjectNode)1