diff --git a/apptools/naming/ui/__init__.py b/apptools/naming/ui/__init__.py deleted file mode 100644 index dd56fdd8c..000000000 --- a/apptools/naming/ui/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# ------------------------------------------------------------------------------ -# Copyright (c) 2005, Enthought, Inc. -# All rights reserved. -# -# This software is provided without warranty under the terms of the BSD -# license included in enthought/LICENSE.txt and may be redistributed only -# under the conditions described in the aforementioned license. The license -# is also available online at http://www.enthought.com/licenses/BSD.txt -# Thanks for using Enthought open source! -# -# Author: Enthought, Inc. -# Description: -# ------------------------------------------------------------------------------ diff --git a/apptools/naming/ui/api.py b/apptools/naming/ui/api.py deleted file mode 100644 index f10fc340a..000000000 --- a/apptools/naming/ui/api.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------------------------------------------------ -# Copyright (c) 2005, Enthought, Inc. -# All rights reserved. -# -# This software is provided without warranty under the terms of the BSD -# license included in enthought/LICENSE.txt and may be redistributed only -# under the conditions described in the aforementioned license. The license -# is also available online at http://www.enthought.com/licenses/BSD.txt -# Thanks for using Enthought open source! -# -# Author: Enthought, Inc. -# Description: -# ------------------------------------------------------------------------------ -from .context_monitor import ContextMonitor -from .context_node_type import ContextNodeType -from .explorer import Explorer, explore -from .naming_node_manager import NamingNodeManager -from .naming_tree import NamingTree -from .naming_tree_model import NamingTreeModel -from .object_node_type import ObjectNodeType diff --git a/apptools/naming/ui/context_monitor.py b/apptools/naming/ui/context_monitor.py deleted file mode 100644 index 30868e5a5..000000000 --- a/apptools/naming/ui/context_monitor.py +++ /dev/null @@ -1,108 +0,0 @@ -# ------------------------------------------------------------------------------ -# Copyright (c) 2005, Enthought, Inc. -# All rights reserved. -# -# This software is provided without warranty under the terms of the BSD -# license included in enthought/LICENSE.txt and may be redistributed only -# under the conditions described in the aforementioned license. The license -# is also available online at http://www.enthought.com/licenses/BSD.txt -# Thanks for using Enthought open source! -# -# Author: Enthought, Inc. -# Description: -# ------------------------------------------------------------------------------ -""" A monitor that detects changes to a naming context. """ - - -# Enthought library imports. -from pyface.tree.api import NodeMonitor - - -class ContextMonitor(NodeMonitor): - """ A monitor that detects changes to a naming context. """ - - ########################################################################### - # 'NodeMonitor' interface. - ########################################################################### - - def start(self): - """ Start listening to changes to the object. """ - - context = self.node.obj - - context.on_trait_change(self._on_object_added, "object_added") - context.on_trait_change(self._on_object_changed, "object_changed") - context.on_trait_change(self._on_object_removed, "object_removed") - context.on_trait_change(self._on_object_renamed, "object_renamed") - context.on_trait_change(self._on_context_changed, "context_changed") - - return - - def stop(self): - """ Stop listening to changes to the object. """ - - context = self.node.obj - - context.on_trait_change( - self._on_object_added, "object_added", remove=True - ) - - context.on_trait_change( - self._on_object_changed, "object_changed", remove=True - ) - - context.on_trait_change( - self._on_object_removed, "object_removed", remove=True - ) - - context.on_trait_change( - self._on_object_renamed, "object_renamed", remove=True - ) - - context.on_trait_change( - self._on_context_changed, "context_changed", remove=True - ) - - return - - ########################################################################### - # Private interface. - ########################################################################### - - #### Trait event handlers ################################################# - - def _on_object_added(self, event): - """ Called when an object has been added to the context. """ - - self.fire_nodes_inserted([event.new_binding]) - - return - - def _on_object_changed(self, event): - """ Called when an object in the context has been changed. """ - - # fixme: Can we get enough information to fire a 'nodes_replaced' - # event? Something a little more granular than this! - self.fire_structure_changed() - - return - - def _on_object_removed(self, event): - """ Called when an object has been removed from the context. """ - - self.fire_nodes_removed([event.old_binding]) - - return - - def _on_object_renamed(self, event): - """ Called when an object has been renamed in the context. """ - - self.fire_nodes_replaced([event.old_binding], [event.new_binding]) - - return - - def _on_context_changed(self, event): - """ Called when a context has changed dramatically. """ - self.fire_structure_changed() - - return diff --git a/apptools/naming/ui/context_node_type.py b/apptools/naming/ui/context_node_type.py deleted file mode 100644 index e463d31b3..000000000 --- a/apptools/naming/ui/context_node_type.py +++ /dev/null @@ -1,96 +0,0 @@ -# ------------------------------------------------------------------------------ -# Copyright (c) 2005, Enthought, Inc. -# All rights reserved. -# -# This software is provided without warranty under the terms of the BSD -# license included in enthought/LICENSE.txt and may be redistributed only -# under the conditions described in the aforementioned license. The license -# is also available online at http://www.enthought.com/licenses/BSD.txt -# Thanks for using Enthought open source! -# -# Author: Enthought, Inc. -# Description: -# ------------------------------------------------------------------------------ -""" The node type for contexts in a naming system. """ - -from __future__ import print_function - -# Enthought library imports. -from apptools.naming.api import Context -from pyface.tree.api import NodeType - -# Local imports. -from .context_monitor import ContextMonitor - - -class ContextNodeType(NodeType): - """ The node type for contexts in a naming system. """ - - ########################################################################### - # 'NodeType' interface. - ########################################################################### - - # 'node' in this case is a 'Binding' instance whose 'obj' trait is a - # 'Context' instance. - def is_type_for(self, node): - """ Returns True if this node type recognizes a node. """ - - return isinstance(node.obj, Context) - - def allows_children(self, node): - """ Does the node allow children (ie. a folder vs a file). """ - - return True - - def has_children(self, node): - """ Returns True if a node has children, otherwise False. """ - - return len(node.obj.list_names("")) > 0 - - def get_children(self, node): - """ Returns the children of a node. """ - - return node.obj.list_bindings("") - - def get_drag_value(self, node): - """ Get the value that is dragged for a node. """ - - return node.obj - - def is_editable(self, node): - """ Returns True if the node is editable, otherwise False. """ - - # You can't rename the root context! - return node.context is not None - - def get_text(self, node): - """ Returns the label text for a node. """ - - return node.name - - def can_set_text(self, node, text): - """ Returns True if the node's label can be set. """ - - # The parent context will NOT be None here (see 'is_editable'). - parent = node.context - - return len(text.strip()) > 0 and text not in parent.list_names("") - - def set_text(self, node, text): - """ Sets the label text for a node. """ - - print("Setting text on", node.name, node.obj) - print("Context details", node.obj.name, node.obj.path) - - # Do the rename in the naming system. - node.context.rename(node.name, text) - - # Update the binding. - node.name = text - - return - - def get_monitor(self, node): - """ Returns a monitor that detects changes to a node. """ - - return ContextMonitor(node=node) diff --git a/apptools/naming/ui/explorer.py b/apptools/naming/ui/explorer.py deleted file mode 100644 index dbe8cea05..000000000 --- a/apptools/naming/ui/explorer.py +++ /dev/null @@ -1,95 +0,0 @@ -# ------------------------------------------------------------------------------ -# Copyright (c) 2005, Enthought, Inc. -# All rights reserved. -# -# This software is provided without warranty under the terms of the BSD -# license included in enthought/LICENSE.txt and may be redistributed only -# under the conditions described in the aforementioned license. The license -# is also available online at http://www.enthought.com/licenses/BSD.txt -# Thanks for using Enthought open source! -# -# Author: Enthought, Inc. -# Description: -# ------------------------------------------------------------------------------ -""" A naming system explorer. """ - - -# Enthought library imports. -from apptools.naming.api import Binding, PyContext -from pyface.api import PythonShell, SplitApplicationWindow -from traits.api import Float, Instance, Str - -# Local imports. -from .naming_tree import NamingTree - - -# Factory function for exploring a Python namespace. -def explore(obj): - """ View a Python object as a naming context. """ - - root = Binding(name="root", obj=PyContext(namespace=obj)) - - explorer = Explorer(root=root, size=(1200, 400)) - explorer.open() - - return - - -class Explorer(SplitApplicationWindow): - """ The main application window. """ - - #### 'Window' interface ################################################### - - title = Str("Naming System Explorer") - - #### 'SplitApplicationWindow' interface ################################### - - # The direction in which the panel is split. - direction = Str("vertical") - - # The ratio of the size of the left/top pane to the right/bottom pane. - ratio = Float(0.3) - - # The root binding (usually a binding to a context!). - root = Instance(Binding) - - ########################################################################### - # Protected 'SplitApplicationWindow' interface. - ########################################################################### - - def _create_lhs(self, parent): - """ Creates the left hand side or top depending on the style. """ - - return self._create_tree(parent, self.root) - - def _create_rhs(self, parent): - """ Creates the panel containing the selected preference page. """ - - return self._create_python_shell(parent) - - ########################################################################### - # Private interface. - ########################################################################### - - def _create_tree(self, parent, root): - """ Creates the tree. """ - - self._tree = tree = NamingTree(parent, root=root) - - return tree.control - - def _create_python_shell(self, parent): - """ Creates the Python shell. """ - - self._python_shell = python_shell = PythonShell(parent) - - # Bind useful names. - python_shell.bind("widget", self._tree) - python_shell.bind("w", self._tree) - python_shell.bind("window", self) - python_shell.bind("explore", explore) - - # Execute useful commands to bind useful names ;^) - python_shell.execute_command("from apptools.naming.api import *") - - return python_shell.control diff --git a/apptools/naming/ui/images/closed_folder.png b/apptools/naming/ui/images/closed_folder.png deleted file mode 100644 index 302fb33a0..000000000 Binary files a/apptools/naming/ui/images/closed_folder.png and /dev/null differ diff --git a/apptools/naming/ui/images/document.png b/apptools/naming/ui/images/document.png deleted file mode 100644 index 2d7f2d601..000000000 Binary files a/apptools/naming/ui/images/document.png and /dev/null differ diff --git a/apptools/naming/ui/images/image_LICENSE.txt b/apptools/naming/ui/images/image_LICENSE.txt deleted file mode 100644 index 9315e5c53..000000000 --- a/apptools/naming/ui/images/image_LICENSE.txt +++ /dev/null @@ -1,14 +0,0 @@ -The icons are mostly derived work from other icons. As such they are -licensed accordingly to the original license: - - GV: Gael Varoquaux: BSD-like - -Unless stated in this file, icons are work of enthought, and are released -under BSD-like license. -Files and orginal authors: ----------------------------------------------------------------- - closed_folder.png | GV - document.png | GV - open_folder.png | GV - - diff --git a/apptools/naming/ui/images/open_folder.png b/apptools/naming/ui/images/open_folder.png deleted file mode 100644 index e06d13c46..000000000 Binary files a/apptools/naming/ui/images/open_folder.png and /dev/null differ diff --git a/apptools/naming/ui/naming_node_manager.py b/apptools/naming/ui/naming_node_manager.py deleted file mode 100644 index cdd08db29..000000000 --- a/apptools/naming/ui/naming_node_manager.py +++ /dev/null @@ -1,51 +0,0 @@ -# ------------------------------------------------------------------------------ -# Copyright (c) 2005, Enthought, Inc. -# All rights reserved. -# -# This software is provided without warranty under the terms of the BSD -# license included in enthought/LICENSE.txt and may be redistributed only -# under the conditions described in the aforementioned license. The license -# is also available online at http://www.enthought.com/licenses/BSD.txt -# Thanks for using Enthought open source! -# -# Author: Enthought, Inc. -# Description: -# ------------------------------------------------------------------------------ -""" The node manager for a naming tree. """ - - -# Enthought library imports. -from pyface.tree.api import NodeManager - - -class NamingNodeManager(NodeManager): - """ The node manager for a naming tree. """ - - ########################################################################### - # 'NodeManager' interface. - ########################################################################### - - def get_key(self, node): - """ Generates a unique key for a node. """ - - # fixme: This scheme does NOT allow the same object to be in the tree - # in more than one place. - return self._get_hash_value(node.obj) - - ########################################################################### - # Private interface. - ########################################################################### - - def _get_hash_value(self, obj): - """ Returns a hash value for an object. """ - - # We do it like this 'cos, for example, using id() on a string - # doesn't give us what we want, but things like lists aren't - # hashable, so we can't always use hash()). - try: - hash_value = hash(obj) - - except: - hash_value = id(obj) - - return hash_value diff --git a/apptools/naming/ui/naming_tree.py b/apptools/naming/ui/naming_tree.py deleted file mode 100644 index 1aa0f7229..000000000 --- a/apptools/naming/ui/naming_tree.py +++ /dev/null @@ -1,72 +0,0 @@ -# ------------------------------------------------------------------------------ -# Copyright (c) 2005, Enthought, Inc. -# All rights reserved. -# -# This software is provided without warranty under the terms of the BSD -# license included in enthought/LICENSE.txt and may be redistributed only -# under the conditions described in the aforementioned license. The license -# is also available online at http://www.enthought.com/licenses/BSD.txt -# Thanks for using Enthought open source! -# -# Author: Enthought, Inc. -# Description: -# ------------------------------------------------------------------------------ -""" A tree view of a naming system. """ - - -# Enthought library imports. -from apptools.naming.api import OperationNotSupportedError -from pyface.tree.api import NodeTree -from traits.api import Instance - -# Local imports. -from .naming_tree_model import NamingTreeModel - - -class NamingTree(NodeTree): - """ A tree view of a naming system. """ - - #### 'Tree' interface ##################################################### - - # The model that provides the data for the tree. - model = Instance(NamingTreeModel) - - ########################################################################### - # 'Tree' interface. - ########################################################################### - - #### Trait initializers ################################################### - - def _model_default(self): - """ Initializes the model trait. """ - - return NamingTreeModel() - - ########################################################################### - # 'NamingTree' interface. - ########################################################################### - - def ensure_visible(self, node): - """ Make sure that the specified node is visible. """ - - try: - components = node.namespace_name.split("/") - - # Make sure that the tree is expanded down to the context that - # contains the node. - binding = self.root - for atom in components[:-1]: - binding = binding.obj.lookup_binding(atom) - self.expand(binding) - - # The context is expanded so we know that the node will be in the - # node to Id map. - wxid = self._node_to_id_map.get(self.model.get_key(node), None) - self.control.EnsureVisible(wxid) - - # We need 'namespace_name' to make this work. If we don't have it - # then we simply cannot do this! - except OperationNotSupportedError: - binding = None - - return binding diff --git a/apptools/naming/ui/naming_tree_model.py b/apptools/naming/ui/naming_tree_model.py deleted file mode 100644 index 7e8804e25..000000000 --- a/apptools/naming/ui/naming_tree_model.py +++ /dev/null @@ -1,54 +0,0 @@ -# ------------------------------------------------------------------------------ -# Copyright (c) 2005, Enthought, Inc. -# All rights reserved. -# -# This software is provided without warranty under the terms of the BSD -# license included in enthought/LICENSE.txt and may be redistributed only -# under the conditions described in the aforementioned license. The license -# is also available online at http://www.enthought.com/licenses/BSD.txt -# Thanks for using Enthought open source! -# -# Author: Enthought, Inc. -# Description: -# ------------------------------------------------------------------------------ -""" The model for a tree view of a naming system. """ - - -# Enthought library imports. -from apptools.naming.api import Binding -from pyface.tree.api import NodeTreeModel -from traits.api import Instance - -# Local imports. -from .context_node_type import ContextNodeType -from .naming_node_manager import NamingNodeManager -from .object_node_type import ObjectNodeType - - -class NamingTreeModel(NodeTreeModel): - """ The model for a tree view of a naming system. """ - - #### 'TreeModel' interface ################################################ - - # The root of the model. - root = Instance(Binding) - - #### 'NodeTreeModel' interface ############################################ - - # The node manager looks after all node types. - node_manager = Instance(NamingNodeManager) - - ########################################################################### - # 'NodeTreeModel' interface. - ########################################################################### - - #### Trait initializers ################################################### - - def _node_manager_default(self): - """ Initializes the node manaber trait. """ - - node_manager = NamingNodeManager() - node_manager.add_node_type(ContextNodeType()) - node_manager.add_node_type(ObjectNodeType()) - - return node_manager diff --git a/apptools/naming/ui/object_node_type.py b/apptools/naming/ui/object_node_type.py deleted file mode 100644 index 30897e5f1..000000000 --- a/apptools/naming/ui/object_node_type.py +++ /dev/null @@ -1,74 +0,0 @@ -# ------------------------------------------------------------------------------ -# Copyright (c) 2005, Enthought, Inc. -# All rights reserved. -# -# This software is provided without warranty under the terms of the BSD -# license included in enthought/LICENSE.txt and may be redistributed only -# under the conditions described in the aforementioned license. The license -# is also available online at http://www.enthought.com/licenses/BSD.txt -# Thanks for using Enthought open source! -# -# Author: Enthought, Inc. -# Description: -# ------------------------------------------------------------------------------ -""" The node type for NON-contexts in a naming system. """ - - -# Enthought library imports. -from apptools.naming.api import Context -from pyface.tree.api import NodeType - - -class ObjectNodeType(NodeType): - """ The node type for NON-contexts in a naming system. """ - - ########################################################################### - # 'NodeType' interface. - ########################################################################### - - # 'node' in this case is a 'Binding' instance. - def is_type_for(self, node): - """ Returns True if this node type recognized a node. """ - - return True - - def allows_children(self, node): - """ Does the node allow children (ie. a folder vs a file). """ - - return False - - def get_drag_value(self, node): - """ Get the value that is dragged for a node. """ - - return node.obj - - def is_editable(self, node): - """Returns True if the node is editable, otherwise False. - - If the node is editable, its text can be set via the UI. - - """ - - return True - - def get_text(self, node): - """ Returns the label text for a node. """ - - return node.name - - def can_set_text(self, node, text): - """ Returns True if the node's label can be set. """ - - # The parent context will NOT be None here (an object is ALWAYS - # contained in a context). - parent = node.context - - return len(text.strip()) > 0 and text not in parent.list_names("") - - def set_text(self, node, text): - """ Sets the label text for a node. """ - - node.context.rename(node.name, text) - node.name = text - - return diff --git a/docs/releases/upcoming/233.removal.rst b/docs/releases/upcoming/233.removal.rst new file mode 100644 index 000000000..89d0d8c48 --- /dev/null +++ b/docs/releases/upcoming/233.removal.rst @@ -0,0 +1 @@ +Remove ``apptools.naming.ui`` sub package (#233) \ No newline at end of file diff --git a/examples/naming/explorer.py b/examples/naming/explorer.py deleted file mode 100644 index 14b6b3251..000000000 --- a/examples/naming/explorer.py +++ /dev/null @@ -1,47 +0,0 @@ -#------------------------------------------------------------------------------ -# Copyright (c) 2005, Enthought, Inc. -# All rights reserved. -# -# This software is provided without warranty under the terms of the BSD -# license included in enthought/LICENSE.txt and may be redistributed only -# under the conditions described in the aforementioned license. The license -# is also available online at http://www.enthought.com/licenses/BSD.txt -# Thanks for using Enthought open source! -# -# Author: Enthought, Inc. -# Description: -#------------------------------------------------------------------------------ -""" A naming system explorer. """ - -# Enthought library imports. -from apptools.naming.api import Binding -from apptools.naming.api import PyContext -from apptools.naming.ui.explorer import Explorer -from pyface.api import GUI -from traits.api import HasTraits, Instance, List, Str - - -class Foo(HasTraits): - name = Str() - names = List(Str()) - - -class Bar(HasTraits): - foo = Instance(Foo) - - -# Application entry point. -if __name__ == '__main__': - - # Create the GUI (this does NOT start the GUI event loop). - gui = GUI() - - # Create the root context. - root = PyContext(namespace=Bar(foo=Foo(name="Hello", names=["1", "2"]))) - - # Create and open the main window. - window = Explorer(root=Binding(name='Root', obj=root)) - window.open() - - # Start the GUI event loop. - gui.start_event_loop() diff --git a/image_LICENSE.txt b/image_LICENSE.txt index 54a66ddd7..8dbf5c87f 100644 --- a/image_LICENSE.txt +++ b/image_LICENSE.txt @@ -3,19 +3,9 @@ licensed accordingly to the original license: Project License File ---------------------------------------------------------------------------- -GV: Gael Varoquaux BSD-like LICENSE.txt Enthought BSD-like LICENSE.txt Nuvola LGPL image_LICENSE_Nuvola.txt OOo LGPL image_LICENSE_OOo.txt Unless stated in this file, icons are work of Enthought, and are released under BSD-like license. -Files and original authors: ----------------------------------------------------------------- -apptools/help: - help_action.png | GV - -apptools/naming/ui/images (and examples/naming/images): - closed_folder.png | GV - document.png | GV - open_folder.png | GV diff --git a/setup.py b/setup.py index e9958dd65..0893c58cc 100644 --- a/setup.py +++ b/setup.py @@ -299,7 +299,6 @@ def get_long_description(): 'apptools': [ 'logger/plugin/*.ini', 'logger/plugin/view/images/*.png', - 'naming/ui/images/*.png', 'preferences/tests/*.ini' ] },