Пример #1
0
StateDialog::StateDialog(StateData * d)
    : Q3TabDialog(0, 0, FALSE, Qt::WDestructiveClose), state(d)
{
    d->browser_node->edit_start();

    if (d->browser_node->is_writable()) {
        setOkButton(TR("OK"));
        setCancelButton(TR("Cancel"));
    }
    else {
        setOkButton(QString());
        setCancelButton(TR("Close"));
    }

    setCaption(TR("State dialog"));
    visit = !hasOkButton();

    BrowserNode * bn = state->browser_node;
    Q3Grid * grid;

    //
    // general tab
    //

    grid = new Q3Grid(2, this);
    umltab = grid;
    grid->setMargin(5);
    grid->setSpacing(5);

    new QLabel(TR("name : "), grid);
    edname = new LineEdit(bn->get_name(), grid);
    edname->setReadOnly(visit);

    new QLabel(TR("stereotype : "), grid);
    edstereotype = new Q3ComboBox(!visit, grid);
    edstereotype->insertItem(toUnicode(state->get_stereotype()));

    if (!visit) {
        edstereotype->insertStringList(BrowserState::default_stereotypes());
        edstereotype->insertStringList(ProfiledStereotypes::defaults(UmlState));
        edstereotype->setAutoCompletion(completion());
    }

    edstereotype->setCurrentItem(0);
    QSizePolicy sp = edstereotype->sizePolicy();
    sp.setHorData(QSizePolicy::Expanding);
    edstereotype->setSizePolicy(sp);

    connect(new SmallPushButton(TR("specification :"), grid), SIGNAL(clicked()),
            this, SLOT(menu_specification()));
    edspecification = new Q3ComboBox(FALSE, grid);
    edspecification->setSizePolicy(sp);

    if (visit) {
        if (state->get_specification() == 0)
            edspecification->insertItem("");
        else
            edspecification->insertItem(state->get_specification()->full_name(TRUE));
    }
    else {
        edspecification->insertItem("");
        edspecification->setAutoCompletion(completion());
        BrowserOperation::instances(opers);
        opers.full_names(speclist);
        edspecification->insertStringList(speclist);
        edspecification->setCurrentItem((state->get_specification() == 0)
                                        ? 0
                                        : opers.findRef(state->get_specification()) + 1);
    }

    switch (((BrowserNode *) bn->parent())->get_type()) {
    case UmlState:
    case UmlRegion:
        if ((state->get_reference() != 0) || (bn->firstChild() == 0)) {
            connect(new SmallPushButton(TR("reference :"), grid), SIGNAL(clicked()),
                    this, SLOT(menu_reference()));
            edreference = new Q3ComboBox(FALSE, grid);
            edreference->setSizePolicy(sp);

            if (visit) {
                if (state->get_reference() == 0)
                    edreference->insertItem("");
                else
                    edreference->insertItem(state->get_reference()->full_name(TRUE));
            }
            else {
                edreference->insertItem("");
                edreference->setAutoCompletion(completion());

                if (((BrowserState *) bn)->can_reference()) {
                    BrowserState::instances(states, TRUE);

                    BrowserNode * st = states.first();

                    while (st != 0) {
                        if (!((BrowserState *) bn)->can_reference((BrowserState *) st) ||
                            ((BrowserState *) st)->is_ref()) {
                            states.remove();
                            st = states.current();
                        }
                        else
                            st = states.next();
                    }
                }
                else
                    states.append(state->get_reference());

                states.full_names(reflist);
                edreference->insertStringList(reflist);
                edreference->setCurrentItem((state->get_reference() == 0)
                                            ? 0
                                            : states.findRef(state->get_reference()) + 1);

                connect(edreference, SIGNAL(activated(int)), this, SLOT(ed_ref_activated(int)));
            }

            break;
        }

        // no break
    default:
        edreference = 0;
    }
Пример #2
0
StateDialog::StateDialog(StateData * d)
    : TabDialog(0, 0, FALSE, Qt::WA_DeleteOnClose), state(d)
{
    d->browser_node->edit_start();

    if (d->browser_node->is_writable()) {
        setOkButton(tr("OK"));
        setCancelButton(tr("Cancel"));
    }
    else {
        setOkButton(QString());
        setCancelButton(tr("Close"));
    }

    setWindowTitle(tr("State dialog"));
    visit = !hasOkButton();

    BrowserNode * bn = state->browser_node;
    GridBox * grid;

    //
    // general tab
    //

    grid = new GridBox(2, this);
    umltab = grid;
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(new QLabel(tr("name : "), grid));
    grid->addWidget(edname = new LineEdit(bn->get_name(), grid));
    edname->setReadOnly(visit);

    grid->addWidget(new QLabel(tr("stereotype : "), grid));
    grid->addWidget(edstereotype = new QComboBox( grid));
    edstereotype->setEditable(!visit);
    edstereotype->addItem(toUnicode(state->get_stereotype()));

    if (!visit) {
        edstereotype->addItems(BrowserState::default_stereotypes());
        edstereotype->addItems(ProfiledStereotypes::defaults(UmlState));
        edstereotype->setAutoCompletion(completion());
    }

    edstereotype->setCurrentIndex(0);
    QSizePolicy sp = edstereotype->sizePolicy();
    sp.setHorizontalPolicy(QSizePolicy::Expanding);
    edstereotype->setSizePolicy(sp);
    SmallPushButton* sButton;
    connect(sButton = new SmallPushButton(tr("specification :"), grid), SIGNAL(clicked()),
            this, SLOT(menu_specification()));
    grid->addWidget(sButton);
    grid->addWidget(edspecification = new QComboBox(grid));
    edspecification->setSizePolicy(sp);

    if (visit) {
        if (state->get_specification() == 0)
            edspecification->addItem("");
        else
            edspecification->addItem(state->get_specification()->full_name(TRUE));
    }
    else {
        edspecification->addItem("");
        edspecification->setAutoCompletion(completion());
        BrowserOperation::instances(opers);
        opers.full_names(speclist);
        edspecification->addItems(speclist);
        edspecification->setCurrentIndex((state->get_specification() == 0)
                                         ? 0
                                         : opers.indexOf(state->get_specification()) + 1);
    }

    switch (((BrowserNode *) bn->parent())->get_type()) {
    case UmlState:
    case UmlRegion:
        if ((state->get_reference() != 0) || (bn->firstChild() == 0)) {
            connect(sButton = new SmallPushButton(tr("reference :"), grid), SIGNAL(clicked()),
                    this, SLOT(menu_reference()));
            grid->addWidget(sButton);
            grid->addWidget(edreference = new QComboBox(grid));
            edreference->setSizePolicy(sp);

            if (visit) {
                if (state->get_reference() == 0)
                    edreference->addItem("");
                else
                    edreference->addItem(state->get_reference()->full_name(TRUE));
            }
            else {
                edreference->addItem("");
                edreference->setAutoCompletion(completion());

                if (((BrowserState *) bn)->can_reference()) {
                    BrowserState::instances(states, TRUE);

                    QMutableListIterator<BrowserNode *> it(states);

                    while (it.hasNext()) {
                        BrowserState *state = (BrowserState *)it.next();
                        if (!((BrowserState *) bn)->can_reference(state) ||
                                state->is_ref()) {
                            it.remove();
                        }
                    }
                }
                else
                    states.append(state->get_reference());

                states.full_names(reflist);
                edreference->addItems(reflist);
                edreference->setCurrentIndex((state->get_reference() == 0)
                                             ? 0
                                             : states.indexOf(state->get_reference()) + 1);

                connect(edreference, SIGNAL(activated(int)), this, SLOT(ed_ref_activated(int)));
            }

            break;
        }

        // no break
    default:
        edreference = 0;
    }
Пример #3
0
ActivityDialog::ActivityDialog(ActivityData * d)
    : TabDialog(0, 0, FALSE, Qt::WA_DeleteOnClose), activity(d)
{
    d->browser_node->edit_start();

    if (d->browser_node->is_writable()) {
        setOkButton(tr("OK"));
        setCancelButton(tr("Cancel"));
    }
    else {
        setOkButton(QString());
        setCancelButton(tr("Close"));
    }

    setWindowTitle(tr("Activity dialog"));
    visit = !hasOkButton();

    BrowserNode * bn = activity->browser_node;
    GridBox * grid;

    //
    // general tab
    //

    grid = new GridBox(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(new QLabel(tr("name : "), grid));
    grid->addWidget(edname = new LineEdit(bn->get_name(), grid));
    edname->setReadOnly(visit);

    grid->addWidget(new QLabel(tr("stereotype : "), grid));
    grid->addWidget(edstereotype = new QComboBox(grid));
    edstereotype->setEditable(!visit);
    edstereotype->addItem(toUnicode(activity->get_stereotype()));

    if (!visit) {
        edstereotype->addItems(BrowserActivity::default_stereotypes());
        edstereotype->addItems(ProfiledStereotypes::defaults(UmlActivity));
        edstereotype->setAutoCompletion(completion());
    }

    edstereotype->setCurrentIndex(0);
    QSizePolicy sp = edstereotype->sizePolicy();
    sp.setHorizontalPolicy(QSizePolicy::Expanding);
    edstereotype->setSizePolicy(sp);

    SmallPushButton* sButton;
    connect(sButton = new SmallPushButton(tr("specification :"), grid), SIGNAL(clicked()),
            this, SLOT(menu_specification()));
    grid->addWidget(sButton);
    grid->addWidget(edspecification = new QComboBox(grid));
    edspecification->setSizePolicy(sp);

    if (visit) {
        if (activity->get_specification() == 0)
            edspecification->addItem("");
        else
            edspecification->addItem(activity->get_specification()->full_name(TRUE));
    }
    else {
        edspecification->addItem("");
        edspecification->setAutoCompletion(completion());
        BrowserOperation::instances(opers);
        opers.full_names(list);
        edspecification->addItems(list);
        edspecification->setCurrentIndex((activity->get_specification() == 0)
                                         ? 0
                                         : opers.indexOf(activity->get_specification()) + 1);
    }

    grid->addWidget(new QLabel(grid));
    BButtonGroup * bg;
    grid->addWidget(bg =
            new BButtonGroup(3, Qt::Horizontal, QString(), grid));

    bg->addWidget(readonly_cb = new QCheckBox(tr("read only"), bg));

    if (activity->read_only)
        readonly_cb->setChecked(TRUE);

    readonly_cb->setDisabled(visit);

    bg->addWidget(singlexec_cb = new QCheckBox(tr("single execution"), bg));

    if (activity->single_execution)
        singlexec_cb->setChecked(TRUE);

    singlexec_cb->setDisabled(visit);

    bg->addWidget(active_cb = new QCheckBox(tr("active"), bg));

    if (activity->is_active)
        active_cb->setChecked(TRUE);

    active_cb->setDisabled(visit);

    VVBox * vtab;
    grid->addWidget(vtab = new VVBox(grid));
    vtab->addWidget(new QLabel(tr("description :"), vtab));

    if (! visit)
    {
        connect(sButton = new SmallPushButton(tr("Editor"), vtab), SIGNAL(clicked()),
                this, SLOT(edit_description()));
    vtab->addWidget(sButton);
    }

    grid->addWidget(comment = new MultiLineEdit(grid));
    comment->setReadOnly(visit);
    comment->setText(bn->get_comment());
    //comment->setFont(font);

    grid->addWidget(vtab = new VVBox(grid));
    vtab->addWidget(new QLabel(tr("constraint :"), vtab));

    if (! visit) {
        connect(sButton = new SmallPushButton(tr("Editor"), vtab), SIGNAL(clicked()),
                this, SLOT(edit_constraint()));
        vtab->addWidget(sButton);
    }


    grid->addWidget(constraint = new MultiLineEdit(grid));
    constraint->setReadOnly(visit);
    constraint->setText(activity->constraint);
    //constraint->setFont(font);

    addTab(grid, "Uml");

    // UML / OCL
    init_tab(uml, activity->uml_condition, "Ocl", TRUE);

    // CPP
    init_tab(cpp, activity->cpp_condition, "C++",
             GenerationSettings::cpp_get_default_defs());

    // Java
    init_tab(java, activity->java_condition, "Java",
             GenerationSettings::java_get_default_defs());

    // USER : list key - value

    grid = new GridBox(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    grid->addWidget(kvtable = new KeyValuesTable(bn, grid, visit));
    addTab(grid, tr("Properties"));

    //

    connect(this, SIGNAL(currentChanged(QWidget *)),
            this, SLOT(change_tabs(QWidget *)));

    open_dialog(this);
}