Commit 43919cf3 authored by Ralf Habacker's avatar Ralf Habacker
Browse files

Add support for creation new objects in sequence diagrams

CCBUG:418249
parent 288d6f5d
......@@ -315,6 +315,7 @@ QString toString(IconType type)
case it_Literal_New: return QLatin1String("text-x-generic");
case it_Message_Async: return QLatin1String("umbr-message-asynchronous");
case it_Message_Asynchronous: return QLatin1String("umbr-coll-message-asynchronous");
case it_Message_Creation: return QLatin1String("umbr-message-creation");
case it_Message_Found: return QLatin1String("umbr-message-found");
case it_Message_Lost: return QLatin1String("umbr-message-lost");
case it_Message_Sync: return QLatin1String("umbr-message-synchronous");
......
......@@ -178,6 +178,7 @@ namespace Icon_Utils {
it_Constraint_Unique,
it_Enum_Literal,
it_State_Activity,
it_Message_Creation,
it_Message_Sync,
it_Message_Async,
it_Message_Found,
......
......@@ -179,5 +179,7 @@
<file>pics/cursor-interface-provider.png</file>
<file>pics/cursor-interface-requirement.png</file>
<file>pics/cursor-subsystem.png</file>
<file>pics/cursor-umbr-message-creation.png</file>
<file>pics/umbr-message-creation.png</file>
</qresource>
</RCC>
......@@ -212,6 +212,7 @@ void ListPopupMenu::insert(const MenuType m, KMenu* menu)
case mt_Line_Color: m_actions[m] = menu->addAction(Icon_Utils::SmallIcon(Icon_Utils::it_Color_Line), i18n("Line Color...")); break;
case mt_Logical_Folder: m_actions[m] = menu->addAction(Icon_Utils::BarIcon(Icon_Utils::it_Folder), i18n("Folder")); break;
case mt_MessageAsynchronous: m_actions[m] = menu->addAction(Icon_Utils::SmallIcon(Icon_Utils::it_Message_Async), i18n("Asynchronous Message")); break;
case mt_MessageCreation: m_actions[m] = menu->addAction(Icon_Utils::SmallIcon(Icon_Utils::it_Message_Creation), i18n("Creation Message")); break;
case mt_MessageFound: m_actions[m] = menu->addAction(Icon_Utils::SmallIcon(Icon_Utils::it_Message_Found), i18n("Found Message")); break;
case mt_MessageLost: m_actions[m] = menu->addAction(Icon_Utils::SmallIcon(Icon_Utils::it_Message_Lost), i18n("Lost Message")); break;
case mt_MessageSynchronous: m_actions[m] = menu->addAction(Icon_Utils::SmallIcon(Icon_Utils::it_Message_Sync), i18n("Synchronous Message")); break;
......
......@@ -100,6 +100,7 @@ public:
mt_InterfaceRequired,
mt_Junction,
mt_MessageAsynchronous,
mt_MessageCreation,
mt_MessageFound,
mt_MessageLost,
mt_MessageSynchronous,
......
......@@ -191,6 +191,7 @@ void UMLScenePopupMenu::insertSubMenuNew(Uml::DiagramType::Enum type, KMenu *men
insert(mt_Import_from_File, menu);
insert(mt_Object, menu);
if (m_scene->onWidgetLine(m_scene->pos())) {
insert(mt_MessageCreation, menu);
insert(mt_MessageSynchronous, menu);
insert(mt_MessageAsynchronous, menu);
insert(mt_MessageLost, menu);
......
......@@ -101,6 +101,7 @@ set(ICONS
text
umbr-coll-message-asynchronous
umbr-coll-message-synchronous
umbr-message-creation
umbr-message-asynchronous
umbr-message-synchronous
uniassociation
......@@ -166,6 +167,7 @@ set(CURSOR_ICONS
text
umbr-coll-message-asynchronous
umbr-coll-message-synchronous
umbr-message-creation
umbr-message-asynchronous
umbr-message-found
umbr-message-lost
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="svg1"
sodipodi:version="0.32"
inkscape:version="0.92.2 5c3e80d, 2017-08-06"
width="22pt"
height="22pt"
sodipodi:docname="umbr-message-creation.svg"
version="1.1">
<metadata
id="metadata33">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs3">
<linearGradient
id="linearGradient868">
<stop
style="stop-color:#ffffff;stop-opacity:0.0000000;"
offset="0.0000000"
id="stop869" />
<stop
style="stop-color:#fff;stop-opacity:1;"
offset="1"
id="stop870" />
</linearGradient>
<linearGradient
id="linearGradient893">
<stop
style="stop-color:#19839a;stop-opacity:0.0000000;"
offset="0.0000000"
id="stop894" />
<stop
style="stop-color:#fff;stop-opacity:1;"
offset="1"
id="stop895" />
</linearGradient>
<linearGradient
id="linearGradient830">
<stop
style="stop-color:#ebffff;stop-opacity:0.0000000;"
offset="0.0000000"
id="stop831" />
<stop
style="stop-color:#fff;stop-opacity:1;"
offset="1"
id="stop832" />
</linearGradient>
<linearGradient
id="linearGradient826">
<stop
style="stop-color:#ffff00;stop-opacity:1;"
offset="0"
id="stop827" />
<stop
style="stop-color:#fff;stop-opacity:1;"
offset="1"
id="stop828" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient830"
id="linearGradient829"
x1="1.55"
y1="0.5234375"
x2="0.20422535"
y2="-0.12195122"
spreadMethod="reflect" />
<linearGradient
xlink:href="#linearGradient830"
id="linearGradient834"
x1="-0.31159419"
y1="0.1953125"
x2="0.77536231"
y2="0.9453125" />
<linearGradient
xlink:href="#linearGradient830"
id="linearGradient836" />
<linearGradient
xlink:href="#linearGradient868"
id="linearGradient892"
x1="5.054625"
y1="173.7242"
x2="27.117638"
y2="190.28957"
gradientTransform="matrix(0.19389524,0,0,0.11414126,-0.0500116,0.01104645)"
gradientUnits="userSpaceOnUse" />
<linearGradient
xlink:href="#linearGradient868"
id="linearGradient903"
gradientTransform="matrix(0.08944984,0,0,0.24741733,-0.0500116,0.01104645)"
x1="294.44232"
y1="47.033535"
x2="191.01215"
y2="30.548981"
gradientUnits="userSpaceOnUse" />
<linearGradient
xlink:href="#linearGradient868"
id="linearGradient905"
x1="48.669155"
y1="82.875954"
x2="61.421371"
y2="95.476959"
gradientTransform="matrix(0.19389527,0,0,0.11414123,-0.0500116,0.01104645)"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient868"
id="linearGradient4347"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.08944984,0,0,0.24741733,-0.0500116,0.01104645)"
x1="294.44232"
y1="47.033535"
x2="191.01215"
y2="30.548981" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient868"
id="linearGradient4350"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.19389524,0,0,0.11414126,-0.0500116,0.01104645)"
x1="5.054625"
y1="173.7242"
x2="27.117638"
y2="190.28957" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient868"
id="linearGradient4358"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.19389527,0,0,0.11414123,-0.0500116,0.01104645)"
x1="48.669155"
y1="82.875954"
x2="61.421371"
y2="95.476959" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="16"
inkscape:cx="5.6623167"
inkscape:cy="14.164033"
inkscape:window-width="1680"
inkscape:window-height="989"
gridtolerance="1.0000000px"
inkscape:window-x="1680"
inkscape:window-y="0"
showgrid="true"
inkscape:window-maximized="1"
inkscape:current-layer="svg1"
inkscape:snap-bbox="true"
inkscape:bbox-paths="true"
units="pt"
inkscape:document-units="pt">
<inkscape:grid
id="GridFromPre046Settings"
type="xygrid"
originx="0"
originy="0"
spacingx="1.3333333"
spacingy="1.3333333"
color="#3f3fff"
empcolor="#3f3fff"
opacity="0.15"
empopacity="0.38"
empspacing="5"
units="pt"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true" />
</sodipodi:namedview>
<path
style="fill:none;stroke:#ff0000;stroke-width:2.43596196;stroke-dasharray:4.87192443, 2.43596213;stroke-dashoffset:0"
d="M 25.835251,14.792383 -0.154826,14.731344"
id="path900"
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0" />
<path
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccc"
id="path1009"
d="M 19.145492,19.748464 27.564986,14.752019 19.128543,9.795001"
style="font-size:12px;fill:none;stroke:#ff0000;stroke-width:1.62627995" />
</svg>
......@@ -289,6 +289,7 @@ Uml::AssociationType::Enum ToolBarStateAssociation::getAssociationType()
case WorkToolBar::tbb_Relationship: at = Uml::AssociationType::Relationship; break;
case WorkToolBar::tbb_Dependency: at = Uml::AssociationType::Dependency; break;
case WorkToolBar::tbb_Containment: at = Uml::AssociationType::Containment; break;
case WorkToolBar::tbb_Seq_Message_Creation:
case WorkToolBar::tbb_Seq_Message_Synchronous:
case WorkToolBar::tbb_Seq_Combined_Fragment:
case WorkToolBar::tbb_Seq_Precondition:
......
......@@ -87,6 +87,7 @@ int ToolBarStateFactory::getKey(const WorkToolBar::ToolBar_Buttons &toolbarButto
case WorkToolBar::tbb_Child2Category: return 1;
// Messages
case WorkToolBar::tbb_Seq_Message_Creation: return 2;
case WorkToolBar::tbb_Seq_Message_Synchronous: return 2;
case WorkToolBar::tbb_Seq_Message_Asynchronous: return 2;
case WorkToolBar::tbb_Seq_Message_Found: return 2;
......
......@@ -17,10 +17,12 @@
#include "floatingtextwidget.h"
#include "messagewidget.h"
#include "objectwidget.h"
#include "object_factory.h"
#include "uml.h"
#include "umldoc.h"
#include "umlview.h"
#include "umlscene.h"
#include "widget_factory.h"
// kde includes
#include <KLocalizedString>
......@@ -176,7 +178,25 @@ void ToolBarStateMessages::mouseReleaseEmpty()
{
Uml::SequenceMessage::Enum msgType = getMessageType();
if (m_firstObject && msgType == Uml::SequenceMessage::Lost) {
if (m_firstObject && msgType == Uml::SequenceMessage::Creation) {
xclick = m_pMouseEvent->scenePos().x();
yclick = m_pMouseEvent->scenePos().y();
bool state = m_pUMLScene->getCreateObject();
m_pUMLScene->setCreateObject(false);
UMLObject *object = Object_Factory::createUMLObject(UMLObject::ot_Class);
m_pUMLScene->setCreateObject(state);
ObjectWidget *widget = (ObjectWidget *)Widget_Factory::createWidget(m_pUMLScene, object);
widget->setX(xclick);
widget->activate();
m_pUMLScene->addWidgetCmd(widget);
MessageWidget* message = new MessageWidget(m_pUMLScene, m_firstObject, widget, yclick, msgType);
setupMessageWidget(message, false);
cleanMessage();
xclick = 0;
yclick = 0;
} else if (m_firstObject && msgType == Uml::SequenceMessage::Lost) {
xclick = m_pMouseEvent->scenePos().x();
yclick = m_pMouseEvent->scenePos().y();
......@@ -279,6 +299,9 @@ void ToolBarStateMessages::setSecondWidget(ObjectWidget* secondObject, MessageTy
*/
Uml::SequenceMessage::Enum ToolBarStateMessages::getMessageType()
{
if (getButton() == WorkToolBar::tbb_Seq_Message_Creation) {
return Uml::SequenceMessage::Creation;
}
if (getButton() == WorkToolBar::tbb_Seq_Message_Synchronous) {
return Uml::SequenceMessage::Synchronous;
}
......@@ -288,6 +311,9 @@ Uml::SequenceMessage::Enum ToolBarStateMessages::getMessageType()
else if (getButton() == WorkToolBar::tbb_Seq_Message_Lost) {
return Uml::SequenceMessage::Lost;
}
else if (getButton() == WorkToolBar::tbb_Seq_Message_Creation) {
return Uml::SequenceMessage::Creation;
}
return Uml::SequenceMessage::Asynchronous;
}
......@@ -303,14 +329,16 @@ void ToolBarStateMessages::cleanMessage()
m_messageLine = 0;
}
void ToolBarStateMessages::setupMessageWidget(MessageWidget *message)
void ToolBarStateMessages::setupMessageWidget(MessageWidget *message, bool showOperationDialog)
{
FloatingTextWidget *ft = message->floatingTextWidget();
//TODO cancel doesn't cancel the creation of the message, only cancels setting an operation.
//Shouldn't it cancel also the whole creation?
ft->showOperationDialog();
message->setTextPosition();
m_pUMLScene->addWidgetCmd(ft);
if (showOperationDialog) {
FloatingTextWidget *ft = message->floatingTextWidget();
//TODO cancel doesn't cancel the creation of the message, only cancels setting an operation.
//Shouldn't it cancel also the whole creation?
ft->showOperationDialog();
m_pUMLScene->addWidgetCmd(ft);
message->setTextPosition();
}
UMLApp::app()->executeCommand(new Uml::CmdCreateWidget(message));
emit finished();
}
......
......@@ -109,7 +109,7 @@ protected:
bool m_isObjectWidgetLine;
private:
void setupMessageWidget(MessageWidget *msg);
void setupMessageWidget(MessageWidget *msg, bool showOperationDialog = true);
/**
* x and y clicked for lost and found messages
......
......@@ -3312,6 +3312,10 @@ void UMLScene::slotMenuSelection(QAction* action)
break;
}
case ListPopupMenu::mt_MessageCreation:
m_d->triggerToolBarButton(WorkToolBar::tbb_Seq_Message_Creation);
break;
case ListPopupMenu::mt_MessageSynchronous:
m_d->triggerToolBarButton(WorkToolBar::tbb_Seq_Message_Synchronous);
break;
......
......@@ -502,7 +502,7 @@ void MessageWidget::paintCreation(QPainter *painter, const QStyleOptionGraphicsI
offsetX += 7;
w -= 7;
}
paintArrow(painter, offsetX, lineY, w, Qt::RightArrow);
paintArrow(painter, offsetX, lineY, w, Qt::RightArrow, true);
if (messageOverlapsA) {
offsetX -= 7;
}
......@@ -510,7 +510,7 @@ void MessageWidget::paintCreation(QPainter *painter, const QStyleOptionGraphicsI
if (messageOverlapsA) {
w -= 7;
}
paintArrow(painter, offsetX, lineY, w, Qt::LeftArrow);
paintArrow(painter, offsetX, lineY, w, Qt::LeftArrow, true);
}
UMLWidget::paint(painter, option);
......
......@@ -887,6 +887,7 @@ void UMLWidget::slotMenuSelection(QAction *trigger)
break;
}
case ListPopupMenu::mt_MessageCreation:
case ListPopupMenu::mt_MessageSynchronous:
// MessageWidget *widget = new MessageWidget(umlScene(), this);
// addConnectedWidget(widget, Uml::AssociationType::Coll_Message_Synchronous);
......
......@@ -144,6 +144,7 @@ void WorkToolBar::slotCheckToolBar(Uml::DiagramType::Enum dt)
case Uml::DiagramType::Sequence:
insertHotBtn(tbb_Object);
insertHotBtn(tbb_Seq_Message_Creation);
insertHotBtn(tbb_Seq_Message_Synchronous);
insertHotBtn(tbb_Seq_Message_Asynchronous);
insertHotBtn(tbb_Seq_Message_Found);
......@@ -327,6 +328,7 @@ void WorkToolBar::loadPixmaps()
} buttonInfo[] = {
{ tbb_Arrow, i18nc("selection arrow", "Select"), Icon_Utils::it_Arrow, SLOT(slotArrow()) },
{ tbb_Object, i18n("Object"), Icon_Utils::it_Object, SLOT(slotObject()) },
{ tbb_Seq_Message_Creation, i18n("Creation"), Icon_Utils::it_Message_Creation, SLOT(slotSeq_Message_Creation()) },
{ tbb_Seq_Message_Synchronous, i18n("Synchronous Message"), Icon_Utils::it_Message_Sync, SLOT(slotSeq_Message_Synchronous()) },
{ tbb_Seq_Message_Asynchronous, i18n("Asynchronous Message"), Icon_Utils::it_Message_Async, SLOT(slotSeq_Message_Asynchronous()) },
{ tbb_Seq_Message_Found, i18n("Found Message"), Icon_Utils::it_Message_Found, SLOT(slotSeq_Message_Found()) },
......@@ -430,6 +432,7 @@ void WorkToolBar::slotAssociation() { buttonChanged(tbb_Association
void WorkToolBar::slotContainment() { buttonChanged(tbb_Containment); }
void WorkToolBar::slotColl_Message_Synchronous() { buttonChanged(tbb_Coll_Message_Synchronous); }
void WorkToolBar::slotColl_Message_Asynchronous(){ buttonChanged(tbb_Coll_Message_Asynchronous);}
void WorkToolBar::slotSeq_Message_Creation() { buttonChanged(tbb_Seq_Message_Creation); }
void WorkToolBar::slotSeq_Message_Synchronous() { buttonChanged(tbb_Seq_Message_Synchronous); }
void WorkToolBar::slotSeq_Message_Asynchronous() { buttonChanged(tbb_Seq_Message_Asynchronous); }
void WorkToolBar::slotSeq_Message_Found() { buttonChanged(tbb_Seq_Message_Found); }
......
......@@ -64,6 +64,7 @@ public:
tbb_Containment,
tbb_Coll_Message_Synchronous,
tbb_Coll_Message_Asynchronous,
tbb_Seq_Message_Creation,
tbb_Seq_Message_Synchronous,
tbb_Seq_Message_Asynchronous,
tbb_Seq_Message_Found,
......@@ -170,6 +171,7 @@ public slots:
void slotContainment();
void slotColl_Message_Synchronous();
void slotColl_Message_Asynchronous();
void slotSeq_Message_Creation();
void slotSeq_Message_Synchronous();
void slotSeq_Message_Asynchronous();
void slotSeq_Message_Found();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment