Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move element editor layouts to Glade #277

Merged
merged 39 commits into from
Mar 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f62b34e
Use glade for basic name/line property pages
amolenaar Mar 8, 2020
d47f77d
Render attribute editor from Glade
amolenaar Mar 8, 2020
f4f0254
fixing small issues
amolenaar Mar 8, 2020
4cf351c
Operations editor as glade file
amolenaar Mar 9, 2020
8b6d281
Add glade ui for Dependency editor
amolenaar Mar 9, 2020
46865fb
Clean up imports
amolenaar Mar 9, 2020
1f0f9d6
Fix metaclass tests
amolenaar Mar 9, 2020
08e66b2
Use glade ui for association pane
amolenaar Mar 11, 2020
eaf1906
Remove editor tree creator function
amolenaar Mar 11, 2020
afcce43
Element editor should not create expanders
amolenaar Mar 11, 2020
06f419c
Add glade ui for interface item
amolenaar Mar 11, 2020
6075ce4
Add metamodel in glade file
amolenaar Mar 12, 2020
f064bee
Use glade UI for stereotype editor
amolenaar Mar 12, 2020
93301d9
Fix refresh
amolenaar Mar 12, 2020
e031cd3
Fix stereotype column name
amolenaar Mar 13, 2020
5af5bba
Update Transition editor to use Glade UI
amolenaar Mar 13, 2020
3905420
Add editors for all state items
amolenaar Mar 13, 2020
9ef85c5
Remove show stereotypes toggle if not applicable
amolenaar Mar 13, 2020
e516e19
Update editor for interactions (messages)
amolenaar Mar 13, 2020
3ddd681
Comment via glade
amolenaar Mar 13, 2020
23b6c02
Construct component editor via Glade UI
amolenaar Mar 14, 2020
6db92ad
Update object node editor
amolenaar Mar 14, 2020
26942ed
Update action diagram editors
amolenaar Mar 14, 2020
fed1385
cleanup
amolenaar Mar 15, 2020
3424e2a
Create main window from Glade file
amolenaar Mar 15, 2020
5031da2
Create element editor from glade file
amolenaar Mar 15, 2020
43fccaf
Minor styling updates
amolenaar Mar 15, 2020
b631b5f
Fix error in states property pages
amolenaar Mar 15, 2020
95c6e36
Layout deserializer now creates a new layout
amolenaar Mar 15, 2020
5207245
Editors use builder as local vars
amolenaar Mar 15, 2020
492f195
Move metaclass editor to profile package
amolenaar Mar 15, 2020
209ead9
Convert partition editor to use Glade UI
amolenaar Mar 17, 2020
b116a36
Remove name field from prpoerty pages
amolenaar Mar 17, 2020
20c8c6e
Clean up unused code
amolenaar Mar 17, 2020
0eb2d4b
Fix ordering keys for attribute and operations lists
amolenaar Mar 17, 2020
b6c4f9e
Clean up editable tree model code
amolenaar Mar 17, 2020
4ddf15a
Fix updating association editor
amolenaar Mar 19, 2020
24fe874
Update attribute and operation editor on model change
amolenaar Mar 19, 2020
e9bd1ac
Update translations
amolenaar Mar 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
172 changes: 91 additions & 81 deletions gaphor/diagram/actions/actionspropertypages.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,149 +3,159 @@
from gi.repository import Gtk

from gaphor import UML
from gaphor.core import gettext, transactional
from gaphor.core import transactional
from gaphor.diagram.actions.activitynodes import ForkNodeItem
from gaphor.diagram.actions.objectnode import ObjectNodeItem
from gaphor.diagram.propertypages import (
NamedElementPropertyPage,
NamedItemPropertyPage,
PropertyPages,
create_hbox_label,
)
from gaphor.diagram.propertypages import PropertyPageBase, PropertyPages, new_builder


@PropertyPages.register(ObjectNodeItem)
class ObjectNodePropertyPage(NamedItemPropertyPage):
"""
"""
class ObjectNodePropertyPage(PropertyPageBase):

order = 15

ORDERING_VALUES = ["unordered", "ordered", "LIFO", "FIFO"]

subject: UML.ObjectNode

def construct(self):
page = super().construct()
def __init__(self, item):
self.item = item

subject = self.subject
def construct(self):
subject = self.item.subject

if not subject:
return page

hbox = create_hbox_label(self, page, gettext("Upper bound"))
entry = Gtk.Entry()
entry.set_text(subject.upperBound or "")
entry.connect("changed", self._on_upper_bound_change)
hbox.pack_start(entry, True, True, 0)

hbox = create_hbox_label(self, page, "")
combo = Gtk.ComboBoxText()
for v in self.ORDERING_VALUES:
combo.append_text(v)
combo.set_active(self.ORDERING_VALUES.index(subject.ordering))
combo.connect("changed", self._on_ordering_change)
hbox.pack_start(combo, False, True, 0)

hbox = create_hbox_label(self, page, "")
button = Gtk.CheckButton(gettext("Ordering"))
button.set_active(self.item.show_ordering)
button.connect("toggled", self._on_ordering_show_change)
hbox.pack_start(button, False, True, 0)

return page
return

builder = new_builder("object-node-editor")

upper_bound = builder.get_object("upper-bound")
upper_bound.set_text(subject.upperBound or "")

ordering = builder.get_object("ordering")
ordering.set_active(self.ORDERING_VALUES.index(subject.ordering))

show_ordering = builder.get_object("show-ordering")
show_ordering.set_active(self.item.show_ordering)

builder.connect_signals(
{
"upper-bound-changed": (self._on_upper_bound_change,),
"ordering-changed": (self._on_ordering_change,),
"show-ordering-changed": (self._on_ordering_show_change,),
}
)

return builder.get_object("object-node-editor")

@transactional
def _on_upper_bound_change(self, entry):
value = entry.get_text().strip()
self.subject.upperBound = value
self.item.subject.upperBound = value

@transactional
def _on_ordering_change(self, combo):
value = self.ORDERING_VALUES[combo.get_active()]
self.subject.ordering = value
self.item.subject.ordering = value

@transactional
def _on_ordering_show_change(self, button):
self.item.show_ordering = button.get_active()


@PropertyPages.register(ForkNodeItem)
class JoinNodePropertyPage(NamedItemPropertyPage):
"""
"""
class ForkNodePropertyPage(PropertyPageBase):

subject: UML.JoinNode
order = 20

def __init__(self, item):
self.item = item

def construct(self):
page = super().construct()
builder = new_builder("fork-node-editor")

horizontal = builder.get_object("horizontal")
horizontal.set_active(self.item.matrix[2] != 0)

builder.connect_signals({"horizontal-changed": (self._on_horizontal_change,)})
return builder.get_object("fork-node-editor")

@transactional
def _on_horizontal_change(self, button):
if button.get_active():
self.item.matrix.rotate(math.pi / 2)
else:
self.item.matrix.rotate(-math.pi / 2)
self.item.request_update()


@PropertyPages.register(UML.JoinNode)
class JoinNodePropertyPage(PropertyPageBase):

order = 15

subject: UML.JoinNode

def __init__(self, subject):
self.subject = subject

def construct(self):
subject = self.subject

if not subject:
return page

hbox = Gtk.HBox()
page.pack_start(hbox, False, True, 0)
return

if isinstance(subject, UML.JoinNode):
hbox = create_hbox_label(self, page, gettext("Join specification"))
entry = Gtk.Entry()
entry.set_text(subject.joinSpec or "")
entry.connect("changed", self._on_join_spec_change)
hbox.pack_start(entry, True, True, 0)
builder = new_builder("join-node-editor")

button = Gtk.CheckButton(gettext("Horizontal"))
button.set_active(self.item.matrix[2] != 0)
button.connect("toggled", self._on_horizontal_change)
page.pack_start(button, False, True, 0)
join_spec = builder.get_object("join-spec")
join_spec.set_text(subject.joinSpec or "")

return page
builder.connect_signals({"join-spec-changed": (self._on_join_spec_change,)})
return builder.get_object("join-node-editor")

@transactional
def _on_join_spec_change(self, entry):
value = entry.get_text().strip()
self.subject.joinSpec = value

def _on_horizontal_change(self, button):
if button.get_active():
self.item.matrix.rotate(math.pi / 2)
else:
self.item.matrix.rotate(-math.pi / 2)
self.item.request_update()


@PropertyPages.register(UML.ControlFlow)
@PropertyPages.register(UML.ObjectFlow)
class FlowPropertyPageAbstract(NamedElementPropertyPage):
class FlowPropertyPageAbstract(PropertyPageBase):
"""Flow item element editor."""

subject: UML.ActivityEdge
order = 15

def construct(self):
assert self.watcher
subject: UML.ActivityEdge

page = super().construct()
def __init__(self, subject):
self.subject = subject
self.watcher = subject.watcher() if subject else None

def construct(self):
subject = self.subject

if not subject:
return page
return

builder = new_builder("transition-editor")

hbox = create_hbox_label(self, page, gettext("Guard"))
entry = Gtk.Entry()
entry.set_text(subject.guard or "")
changed_id = entry.connect("changed", self._on_guard_change)
hbox.pack_start(entry, True, True, 0)
guard = builder.get_object("guard")
guard.set_text(subject.guard or "")

def handler(event):
entry.handler_block(changed_id)
v = event.new_value
entry.set_text(v if v else "")
entry.handler_unblock(changed_id)
guard.set_text(v if v else "")

self.watcher.watch("guard", handler).subscribe_all()
entry.connect("destroy", self.watcher.unsubscribe_all)

return page
builder.connect_signals(
{
"guard-changed": (self._on_guard_change,),
"transition-destroy": (self.watcher.unsubscribe_all,),
}
)
return builder.get_object("transition-editor")

@transactional
def _on_guard_change(self, entry):
Expand Down
4 changes: 4 additions & 0 deletions gaphor/diagram/actions/partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def __init__(self, id=None, model=None):
self.min_width = 100
self.min_height = 300

@property
def toplevel(self):
return self._toplevel

def pre_update(self, context):
assert self.canvas

Expand Down
36 changes: 17 additions & 19 deletions gaphor/diagram/actions/partitionpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,32 @@

from gaphor.core import gettext, transactional
from gaphor.diagram.actions.partition import PartitionItem
from gaphor.diagram.propertypages import NamedItemPropertyPage, PropertyPages
from gaphor.diagram.propertypages import PropertyPageBase, PropertyPages, new_builder


@PropertyPages.register(PartitionItem)
class PartitionPropertyPage(NamedItemPropertyPage):
class PartitionPropertyPage(PropertyPageBase):
"""Partition property page."""

order = 15

def __init__(self, item):
self.item = item

def construct(self):
item = self.item

page = super().construct()
if item.toplevel:
return

if item.subject:
if not item._toplevel:
hbox = Gtk.HBox(spacing=12)
button = Gtk.CheckButton(gettext("External"))
button.set_active(item.subject.isExternal)
button.connect("toggled", self._on_external_change)
hbox.pack_start(button, True, True, 0)
page.pack_start(hbox, False, True, 0)
else:
pass
# hbox = Gtk.HBox(spacing=12)
# button = Gtk.CheckButton(_('Dimension'))
# button.set_active(item.subject.isDimension)
# button.connect('toggled', self._on_dimension_change)

return page
builder = new_builder("partition-editor")

external = builder.get_object("external")
external.set_active(item.subject.isExternal)

builder.connect_signals({"external-changed": (self._on_external_change,)})

return builder.get_object("partition-editor")

@transactional
def _on_external_change(self, button):
Expand Down
17 changes: 10 additions & 7 deletions gaphor/diagram/classes/classeseditors.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,16 @@ def update_end_text(text):
end_item = item.tail_end

if end_item:
text = UML.format(
end_item.subject,
visibility=True,
is_derived=True,
type=True,
multiplicity=True,
default=True,
text = (
UML.format(
end_item.subject,
visibility=True,
is_derived=True,
type=True,
multiplicity=True,
default=True,
)
or ""
)
entry = popup_entry(text, update_end_text)
bb = end_item.name_bounds
Expand Down