Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if not self.active:
import traceback
traceback.print_stack()
register_action(YellowAction)
class BlueAction(RadioAction):
id = 'Blue'
label = 'B_lue'
group = 'color'
tooltip = 'Makes the world turn blue'
def execute(self):
print self.label, self.active
register_action(BlueAction)
class OneAction(RadioAction):
id = 'One'
label = 'One'
group = 'count'
tooltip = 'Makes the world turn one'
def execute(self):
print self.label, self.active
register_action(OneAction)
class TwoAction(RadioAction):
id = 'Two'
label = 'Two'
group = 'count'
def execute(self):
print self.label, self.active
register_action(OneAction)
class TwoAction(RadioAction):
id = 'Two'
label = 'Two'
group = 'count'
tooltip = 'Makes the world turn two'
def execute(self):
print self.label, self.active
register_action(TwoAction)
class NewRadioAction(RadioAction):
pass
class StartAction(NewRadioAction):
id = 'start'
name = 'middle'
names = ('start', 'middle', 'end')
labels = ('Start', 'Middle', 'End')
stock_ids = ('gtk-open', 'gtk-close', 'gtk-save')
def execute(self):
print 'StartAction', self.active
class ObjectAction(Action):
from gaphor import UML
from gaphor.misc.action import Action, CheckAction, RadioAction, register_action
class RunAction(Action):
id = 'EditorRun'
label = '_Run'
tooltip='Execute the code'
stock_id = 'gtk-execute'
def init(self, window):
self._window = window
def execute(self):
self._window.run()
register_action(RunAction)
class ClearAction(Action):
id = 'EditorClear'
label = '_Clear'
stock_id = 'gtk-clear'
def init(self, window):
self._window = window
def execute(self):
self._window.clear_results()
register_action(ClearAction)
def execute(self):
pass
#if isinstance(self._element, UML.Diagram):
# self._element.unlink()
class SelectRowAction(Action):
id = 'SelectRow'
def init(self, window):
pass
def execute(self):
pass
register_action(SelectRowAction)
class TabChangeAction(Action):
id = 'TabChange'
def init(self, window):
pass
register_action(TabChangeAction)
class UndoStackAction(Action):
"""
Dummy action that triggers the undo and redo actions to update
themselves.
"""
id = 'UndoStack'
label = 'Non-Navigable'
end_name = 'tail_end'
group = 'tail_navigable'
navigable = False
register_action(TailNotNavigableAction, 'ItemFocus')
class TailUnknownNavigationAction(NavigableAction):
id = 'Tail_unknownNavigation'
label = 'Unknown'
end_name = 'tail_end'
group = 'tail_navigable'
navigable = None
register_action(TailUnknownNavigationAction, 'ItemFocus')
class AggregationAction(RadioAction):
def init(self, window):
self._window = window
def update(self):
try:
item = get_parent_focus_item(self._window)
if isinstance(item, items.AssociationItem):
end = getattr(item, self.end_name)
if end.subject:
self.active = (end.subject.aggregation == self.aggregation)
except NoFocusItemError:
pass
diagram = diagram_tab.get_diagram()
for item in diagram_tab.get_view().selected_items:
if isinstance(item, items.ClassItem):
self.create_missing_relationships(item, diagram,
items.AssociationItem)
if isinstance(item, ClassifierItem):
self.create_missing_relationships(item, diagram,
items.ImplementationItem)
self.create_missing_relationships(item, diagram,
items.GeneralizationItem)
self.create_missing_relationships(item, diagram,
items.DependencyItem)
register_action(CreateLinksAction, 'ItemFocus', 'ItemSelect')
class RotateAction(Action):
id = 'Rotate'
label = 'Rotate'
tooltip = 'Rotate item'
def init(self, window):
self._window = window
def update(self):
try:
item = get_parent_focus_item(self._window)
#self.active = isinstance(item, items.AssemblyConnectorItem) \
self.active = isinstance(item, items.InterfaceItem) and item.is_folded()
label = 'Shared'
group = 'head_aggregation'
end_name = 'head_end'
aggregation = 'shared'
register_action(HeadSharedAction, 'ItemFocus')
class HeadCompositeAction(AggregationAction):
id = 'Head_AggregationComposite'
label = 'Composite'
group = 'head_aggregation'
end_name = 'head_end'
aggregation = 'composite'
register_action(HeadCompositeAction, 'ItemFocus')
class TailNoneAction(AggregationAction):
id = 'Tail_AggregationNone'
label = 'None'
group = 'tail_aggregation'
end_name = 'tail_end'
aggregation = 'none'
register_action(TailNoneAction, 'ItemFocus')
class TailSharedAction(AggregationAction):
id = 'Tail_AggregationShared'
label = 'Shared'
group = 'tail_aggregation'
def execute(self):
filename = self._window.get_filename()
filesel = gtk.FileChooserDialog(title=_('Save Gaphor model as'),
action=gtk.FILE_CHOOSER_ACTION_SAVE,
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_SAVE,gtk.RESPONSE_OK))
if filename:
filesel.set_current_name(filename)
response = filesel.run()
filename = None
if response == gtk.RESPONSE_OK:
filename = filesel.get_filename()
filesel.destroy()
self.save(filename)
weave_method(SaveAsAction.save, ErrorHandlerAspect, message='Could not save model to file.')
register_action(SaveAsAction)
class SaveAction(SaveAsAction):
id = 'FileSave'
stock_id = 'gtk-save'
tooltip = 'Save the model to a file'
def execute(self):
filename = self._window.get_filename()
if filename:
self.save(filename)
else:
SaveAsAction.execute(self)
register_action(SaveAction)
label = 'Navigable'
end_name = 'head_end'
group = 'head_navigable'
navigable = True
register_action(HeadNavigableAction, 'ItemFocus')
class HeadNotNavigableAction(NavigableAction):
id = 'Head_isNotNavigable'
label = 'Non-Navigable'
end_name = 'head_end'
group = 'head_navigable'
navigable = False
register_action(HeadNotNavigableAction, 'ItemFocus')
class HeadUnknownNavigationAction(NavigableAction):
id = 'Head_unknownNavigation'
label = 'Unknown'
end_name = 'head_end'
group = 'head_navigable'
navigable = None
register_action(HeadUnknownNavigationAction, 'ItemFocus')
class TailNavigableAction(NavigableAction):
id = 'Tail_isNavigable'
label = 'Navigable'
end_name = 'tail_end'
@transactional
def execute(self):
if self.active:
item = get_parent_focus_item(self._window)
item.set_dependency_type(self.dependency_type)
#item.auto_dependency = False
self.action_manager.execute('AutoDependency', active=False)
class DependencyTypeDependencyAction(DependencyTypeAction):
id = 'DependencyTypeDependency'
label = 'Dependency'
group = 'dependency_type'
dependency_type = UML.Dependency
register_action(DependencyTypeDependencyAction, 'ItemFocus')
class DependencyTypeUsageAction(DependencyTypeAction):
id = 'DependencyTypeUsage'
label = 'Usage'
group = 'dependency_type'
dependency_type = UML.Usage
register_action(DependencyTypeUsageAction, 'ItemFocus')
class DependencyTypeRealizationAction(DependencyTypeAction):
id = 'DependencyTypeRealization'
label = 'Realization'
group = 'dependency_type'
dependency_type = UML.Realization