"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CategoryNodeBuilder = exports.Category = exports.WeightedEdgeBuilder = exports.WeightedEdge = exports.TaskNodeBuilder = exports.TaskNode = exports.ActivityNodeBuilder = exports.ActivityNode = void 0;
/********************************************************************************
 * Copyright (c) 2022-2023 STMicroelectronics and others.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * This Source Code may also be made available under the following Secondary
 * Licenses when the conditions for such availability set forth in the Eclipse
 * Public License v. 2.0 are satisfied: GNU General Public License, version 2
 * with the GNU Classpath Exception which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 ********************************************************************************/
const server_1 = require("@eclipse-glsp/server");
const model_types_1 = require("./util/model-types");
class ActivityNode extends server_1.GNode {
    static builder() {
        return new ActivityNodeBuilder(ActivityNode);
    }
}
exports.ActivityNode = ActivityNode;
class ActivityNodeBuilder extends server_1.GNodeBuilder {
    nodeType(nodeType) {
        this.proxy.nodeType = nodeType;
        return this;
    }
}
exports.ActivityNodeBuilder = ActivityNodeBuilder;
class TaskNode extends server_1.GNode {
    static builder() {
        return new TaskNodeBuilder(TaskNode).layout('vbox').addArgs(server_1.ArgsUtil.cornerRadius(5)).addCssClass('task');
    }
}
exports.TaskNode = TaskNode;
class TaskNodeBuilder extends server_1.GNodeBuilder {
    name(name) {
        this.proxy.name = name;
        return this;
    }
    duration(duration) {
        this.proxy.duration = duration;
        return this;
    }
    taskType(tasktype) {
        this.proxy.taskType = tasktype;
        return this;
    }
    references(references) {
        this.proxy.references = references;
        return this;
    }
    children() {
        return this;
    }
    build() {
        this.layout('hbox').addLayoutOption('paddingRight', 10).add(this.createCompartmentIcon()).add(this.createCompartmentHeader());
        return super.build();
    }
    createCompartmentHeader() {
        return new server_1.GLabelBuilder(server_1.GLabel)
            .type(model_types_1.ModelTypes.LABEL_HEADING)
            .id(this.proxy.id + '_classname')
            .text(this.proxy.name)
            .build();
    }
    createCompartmentIcon() {
        return server_1.GCompartment.builder()
            .id(this.proxy.id + '_icon')
            .type(model_types_1.ModelTypes.ICON)
            .build();
    }
}
exports.TaskNodeBuilder = TaskNodeBuilder;
class WeightedEdge extends server_1.GEdge {
    static builder() {
        return new WeightedEdgeBuilder(WeightedEdge).type(model_types_1.ModelTypes.WEIGHTED_EDGE);
    }
}
exports.WeightedEdge = WeightedEdge;
class WeightedEdgeBuilder extends server_1.GEdgeBuilder {
    probability(probability) {
        this.proxy.probability = probability;
        return this;
    }
}
exports.WeightedEdgeBuilder = WeightedEdgeBuilder;
class Category extends ActivityNode {
    static builder() {
        return new CategoryNodeBuilder(Category)
            .layout('vbox')
            .addLayoutOptions({ hAlign: 'center', hGrab: false, vGrab: false })
            .addCssClass('category');
    }
}
exports.Category = Category;
class CategoryNodeBuilder extends ActivityNodeBuilder {
    name(name) {
        this.proxy.name = name;
        return this;
    }
    children() {
        this.proxy.children.push(this.createLabelCompartment());
        this.proxy.children.push(this.createStructCompartment());
        return this;
    }
    createLabelCompartment() {
        const layoutOptions = {};
        return new server_1.GCompartmentBuilder(server_1.GCompartment)
            .type(model_types_1.ModelTypes.COMP_HEADER)
            .id(this.proxy.id + '_header')
            .layout('hbox')
            .addLayoutOptions(layoutOptions)
            .add(this.createCompartmentHeader())
            .build();
    }
    createCompartmentHeader() {
        return new server_1.GLabelBuilder(server_1.GLabel)
            .type(model_types_1.ModelTypes.LABEL_HEADING)
            .id(this.proxy.id + '_classname')
            .text(this.proxy.name)
            .build();
    }
    createStructCompartment() {
        return new server_1.GCompartmentBuilder(server_1.GCompartment)
            .type(model_types_1.ModelTypes.STRUCTURE)
            .id(this.proxy.id + '_struct')
            .layout('freeform')
            .addLayoutOptions({ hAlign: 'left', hGrab: true, vGrab: true })
            .build();
    }
}
exports.CategoryNodeBuilder = CategoryNodeBuilder;
//# sourceMappingURL=graph-extension.js.map