Package org.openbp.jaspira.propertybrowser.nodes

Examples of org.openbp.jaspira.propertybrowser.nodes.CollectionNode


  public AbstractNode addNewNode()
  {
    if (currentNode == null)
      return null;

    CollectionNode cdn = currentNode.getAssociatedCollectionNode();
    if (cdn == null)
    {
      // Node not associated with a collection, no popup menu
      return null;
    }

    // Get the node we refer to
    AbstractNode objectNode = cdn == currentNode ? currentNode : currentNode.getObjectNode();

    // Open the path to the collection
    TreePath path = getPathByNode(cdn);
    expandPath(path);

    // Add a new member
    AbstractNode newNode = cdn.addNewNodeAfter(objectNode, null);

    if (newNode != null)
    {
      // Open the new list member
      path = getPathByNode(newNode);
View Full Code Here


      firePropertyBrowserEvent(new PropertyBrowserEvent(PropertyBrowserEvent.ELEMENT_DELETED, this, currentNode));
    }
    else
    {
      CollectionNode cdn = currentNode.getAssociatedCollectionNode();
      if (cdn == null)
      {
        // Node not associated with a collection, no popup menu
        return null;
      }

      // Get the node we refer to
      AbstractNode objectNode = currentNode.getObjectNode();

      // Make the collection node remove the element
      newCurrentNode = cdn.removeNode(objectNode);

      firePropertyBrowserEvent(new PropertyBrowserEvent(PropertyBrowserEvent.ELEMENT_DELETED, this, objectNode));
    }

    if (saveImmediately)
View Full Code Here

    {
      // No clipboard data present
      return null;
    }

    CollectionNode cdn = currentNode.getAssociatedCollectionNode();

    if (cdn == null)
    {
      // Node not associated with a collection, no popup menu
      return null;
    }

    CollectionDescriptor cd = cdn.getCollectionDescriptor();
    Class elementClass = cd.getSafeTypeClass();
    DataFlavor elementFlavor = new DataFlavor(elementClass, elementClass.getName());

    // Try to get the type of element we need from the clipboard
    Object o = null;
    try
    {
      o = transferable.getTransferData(elementFlavor);
      o = CopyUtil.copyObject(o, Copyable.COPY_DEEP, null);
    }
    catch (UnsupportedFlavorException e)
    {
      // Do nothing
      return null;
    }
    catch (IOException e)
    {
      // Do nothing
      return null;
    }
    catch (CloneNotSupportedException e)
    {
      // Do nothing
      return null;
    }

    // Get the node we refer to
    AbstractNode objectNode = cdn == currentNode ? currentNode : currentNode.getObjectNode();

    // Open the path to the collection
    TreePath path = getPathByNode(cdn);
    expandPath(path);

    // Add a new member
    AbstractNode newNode = cdn.addNewNodeAfter(objectNode, o);

    firePropertyBrowserEvent(new PropertyBrowserEvent(PropertyBrowserEvent.ELEMENT_PASTED, this, newNode));

    if (newNode != null)
    {
View Full Code Here

  protected void moveNodeUp()
  {
    if (currentNode == null)
      return;

    CollectionNode cdn = currentNode.getAssociatedCollectionNode();
    if (cdn == null)
    {
      // Node not associated with a collection, no popup menu
      return;
    }

    AbstractNode objectNode = currentNode.getObjectNode();
    cdn.moveNodeUp(objectNode);

    if (saveImmediately)
    {
      fireObjectModified();
      saveObject();
View Full Code Here

  protected void moveNodeDown()
  {
    if (currentNode == null)
      return;

    CollectionNode cdn = currentNode.getAssociatedCollectionNode();
    if (cdn == null)
    {
      // Node not associated with a collection, no popup menu
      return;
    }

    AbstractNode objectNode = currentNode.getObjectNode();
    cdn.moveNodeDown(objectNode);

    if (saveImmediately)
    {
      fireObjectModified();
      saveObject();
View Full Code Here

  /**
   * Updates the enabled state of the property browser's actions according to the current node.
   */
  protected void updateActionState()
  {
    CollectionNode cdn = currentNode != null ? currentNode.getAssociatedCollectionNode() : null;

    // Enable/disable actions

    // Add enabled if the collection descriptor allows it
    actions [ACTION_INDEX_ADD].setEnabled(cdn != null && cdn.allowsNodeAddition());

    // Copy enabled if we have an object selected
    actions [ACTION_INDEX_COPY].setEnabled(currentNode instanceof ObjectNode);

    // Cut enabled if we have an object selected and we can remove elements
    actions [ACTION_INDEX_CUT].setEnabled(cdn != null && cdn.allowsNodeRemoval() && cdn.getChildCount() > 0 && currentNode instanceof ObjectNode);

    // Paste enabled if we have an object selected and the current clipboard content
    // is compatible to the object class we manage in the currently selected collection.
    boolean canPaste = false;
    if (cdn != null && cdn.allowsNodeAddition())
    {
      Transferable transferable = ClipboardMgr.getInstance().getCurrentEntry();
      if (transferable != null)
      {
        CollectionDescriptor cd = cdn.getCollectionDescriptor();
        Class elementClass = cd.getSafeTypeClass();
        DataFlavor elementFlavor = new DataFlavor(elementClass, elementClass.getName());
        canPaste = transferable.isDataFlavorSupported(elementFlavor);
      }
    }
    actions [ACTION_INDEX_PASTE].setEnabled(canPaste);

    // Remove enabled if the collection descriptor allows it and the current node is either the collection
    // descriptor node or one of its direct successors
    actions [ACTION_INDEX_REMOVE].setEnabled(cdn != null && cdn.allowsNodeRemoval() && cdn.getChildCount() > 0 && (currentNode instanceof CollectionNode || currentNode instanceof ObjectNode));

    boolean canMoveUp = false;
    boolean canMoveDown = false;

    if (cdn != null && cdn != currentNode && cdn.allowsNodeReordering())
    {
      AbstractNode objectNode = currentNode.getObjectNode();

      int index = cdn.getChildIndex(objectNode);
      int n = cdn.getChildCount();

      canMoveUp = n > 1 && index > 0;
      canMoveDown = n > 1 && index < n - 1;
    }

View Full Code Here

TOP

Related Classes of org.openbp.jaspira.propertybrowser.nodes.CollectionNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.