Skip to content

Commit

Permalink
- allow to set class operation to be abstract
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/arjan/backup/gaphor/trunk/gaphor@559 a8418922-720d-0410-834f-a69b97ada669
  • Loading branch information
wrobell committed May 25, 2005
1 parent b56059b commit 0279c6e
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 5 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2005-05-25 wrobell <wrobell@pld-linux.org>
* gaphor/diagram/itemactions.py, gaphor/diagram/operation.py,
gaphor/ui/namespace.py: allow to set class operation to be abstract

2005-05-25 wrobell <wrobell@pld-linux.org>
* gaphor/ui/namespace.py: change font of diagram names to bold and
abstract classifiers to italic in tree view
Expand Down
29 changes: 29 additions & 0 deletions gaphor/diagram/itemactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,35 @@ def execute(self):
register_action(AbstractClassAction, 'ItemFocus')


class AbstractOperationAction(CheckAction):
id = 'AbstractOperation'
label = 'Abstract Operation'
tooltip='Abstract Operation'

def init(self, window):
self._window = window

def update(self):
try:
get_parent_focus_item(self._window)
item = self._window.get_current_diagram_view() \
.focus_item.item
except NoFocusItemError:
pass
else:
if isinstance(item, OperationItem):
self.active = item.subject and item.subject.isAbstract

def execute(self):
item = self._window.get_current_diagram_view() \
.focus_item.item
if item and item.subject:
item.subject.isAbstract = self.active

weave_method(AbstractOperationAction.execute, UndoTransactionAspect)
register_action(AbstractOperationAction, 'ItemFocus')


# NOTE: attributes and operations can now only be created on classes,
# actors and use-cases are also classifiers, but we can't add
# attrs and opers via the UI right now.
Expand Down
23 changes: 21 additions & 2 deletions gaphor/diagram/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import gobject
import pango
import diacanvas
from gaphor.diagram import initialize_item
from feature import FeatureItem
Expand All @@ -12,6 +13,7 @@
class OperationItem(FeatureItem):

popup_menu = FeatureItem.popup_menu + (
'AbstractOperation',
'EditItem',
'DeleteOperation',
'MoveUp',
Expand All @@ -20,19 +22,36 @@ class OperationItem(FeatureItem):
'CreateOperation'
)

FONT_ABSTRACT='sans italic 10'

def __init__(self, id=None):
FeatureItem.__init__(self, id)

def on_subject_notify(self, pspec, notifiers=()):
FeatureItem.on_subject_notify(self, pspec, ('name', 'visibility')
+ notifiers)
FeatureItem.on_subject_notify(self, pspec,
('name', 'visibility', 'isAbstract')
+ notifiers)
if self.subject:
self.on_subject_notify__isAbstract(self.subject)
# TODO: Handle subject.returnResult[*] and subject.formalParameter[*]

def postload(self):
FeatureItem.postload(self)
self.on_subject_notify__isAbstract(self.subject)

def on_subject_notify__name(self, subject, pspec):
#log.debug('setting text %s' % self.subject.render() or '')
self._expression.set_text(self.subject.render() or '')
self.request_update()

def on_subject_notify__isAbstract(self, subject, pspec=None):
subject = self.subject
if subject.isAbstract:
self._expression.set_font_description(pango.FontDescription(self.FONT_ABSTRACT))
else:
self._expression.set_font_description(pango.FontDescription(self.FONT))
self.request_update()

on_subject_notify__visibility = on_subject_notify__name
on_subject_notify__taggedValue_value = on_subject_notify__name

Expand Down
10 changes: 7 additions & 3 deletions gaphor/ui/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def new_node_from_element(self, element, parent_node):
self.row_inserted(path, self.get_iter(path))

element.connect('name', self.on_name_changed)
if isinstance(element, UML.Classifier):
if isinstance(element, UML.Classifier) \
or isinstance(element, UML.Operation):
element.connect('isAbstract', self.on_element_changed)

if isinstance(element, UML.Namespace):
Expand All @@ -73,8 +74,10 @@ def detach_notifiers_from_node(self, node):

element.disconnect(self.on_name_changed)

if isinstance(element, UML.Classifier):
if isinstance(element, UML.Classifier) \
or isinstance(element, UML.Operation):
element.disconnect(self.on_element_changed)

if isinstance(element, UML.Namespace):
element.disconnect(self.on_ownedmember_changed)
for child in node[1]:
Expand Down Expand Up @@ -451,7 +454,8 @@ def _set_text (self, column, cell, model, iter, data):

if isinstance(value, UML.Diagram):
text = '<b>%s</b>' % text
elif isinstance(value, UML.Classifier) and value.isAbstract:
elif (isinstance(value, UML.Classifier)
or isinstance(value, UML.Operation)) and value.isAbstract:
text = '<i>%s</i>' % text

cell.set_property('markup', text)
Expand Down

0 comments on commit 0279c6e

Please sign in to comment.