Package org.openbp.core.model.item

Examples of org.openbp.core.model.item.Item


    try
    {
      if (content.isDataFlavorSupported(ClientFlavors.ITEM))
      {
        // We need to copy the item from the clipboard, since we are about to modify it.
        Item source = (Item) content.getTransferData(ClientFlavors.ITEM);

        // Serialize to a byte array
        ByteArrayOutputStream os = new ByteArrayOutputStream(4096);
        XMLDriver.getInstance().serialize(source, os);
        byte[] bytes = os.toByteArray();
        ByteArrayInputStream is = new ByteArrayInputStream(bytes);
        Item item = (Item) XMLDriver.getInstance().deserializeStream(null, is);

        item.setGeneratorInfo(source.getGeneratorInfo());

        // TODONOW Item item = (Item) source.clone();

        Model model = getSelectedModel(ItemBrowserPlugin.GUESS_MODEL | ItemBrowserPlugin.USE_CURRENT_MODEL);
        item.setModel(model);

        item.maintainReferences(ModelObject.SYNC_GLOBAL_REFNAMES | ModelObject.RESOLVE_LOCAL_REFS);

        // Find a new name for the item; we generate the name by appending a running number to the item type
        String oldName = item.getName();
        ItemUtil.ensureUniqueItemName(item, model);
        String newName = item.getName();

        if (item instanceof JavaActivityItem)
        {
          // In case of activity items, change the name of the action
          // implementation class also when renaming the activity
          JavaActivityItem activity = (JavaActivityItem) item;
          String oldClassName = activity.getHandlerDefinition().getHandlerClassName();
          if (oldClassName != null && oldName != null)
          {
            // ...substitute ".OldName" to ".NewName"
            String className = StringUtil.substitute(oldClassName, "." + oldName, "." + newName);

            // Update the object
            activity.getHandlerDefinition().setHandlerClassName(className);
          }
        }

        // Get the item type editor associated with this item
        ItemEditor editor = ItemEditorRegistry.getInstance().lookupItemEditor(item.getItemType());
        if (editor != null)
        {
          // For compatibility with pre-2.0 process items
          StandardItemEditor.ensureProcessType(item);

          // Open the item wizard for the item
          final Item newItem = editor.openItem(item, EditedItemStatus.COPIED);
          if (newItem != null)
          {
            if (ModelConnector.getInstance().saveItem(item, true))
            {
              SwingUtilities.invokeLater(new Runnable()
View Full Code Here


    TreeNode treeNode = (TreeNode) path.getLastPathComponent();
    if (treeNode instanceof ItemTree.ItemNode)
    {
      ItemTree.ItemNode itemnode = (ItemTree.ItemNode) treeNode;

      Item item = itemnode.getItem();
      dragImage = ItemIconMgr.getMultiIcon(ItemIconMgr.getInstance().getIcon(item, FlexibleSize.MEDIUM));
      return new BasicTransferable(item);
    }

    return null;
View Full Code Here

   * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
   */
  public void focusGained(FocusEvent e)
  {
    // Display current item in property browser
    Item item = getSelectedItem();
    firePropertyBrowserEvent(item);
  }
View Full Code Here

   */
  public void handleItemTreeEvent(ItemTreeEvent e)
  {
    if (e.eventType == ItemTreeEvent.SELECTION_CHANGED)
    {
      Item item = getSelectedItem();

      // Update buttons and context menu
      updateActionStatus(item);

      // Update cut/copy/past buttons
      fireEvent("global.clipboard.updatestatus");

      // Display in property browser
      firePropertyBrowserEvent(item);
    }

    else if (e.eventType == ItemTreeEvent.POPUP)
    {
      // Select the object below the cursor first

      // Right-click
      Item item = getSelectedItem();

      MouseEvent me = e.mouseEvent;
      showPopup(item, me.getComponent(), me.getX(), me.getY());
    }

    else if (e.eventType == ItemTreeEvent.OPEN)
    {
      // Double-click or ENTER -> Open the item
      // (except for models; double-clicking a model expands the tree)
      Item item = getSelectedItem();

      if (item != null && !(item instanceof Model))
      {
        // Open the item using the primary association
        fireEvent("plugin.association.open", new BasicTransferable(item));
View Full Code Here

  {
    String title = null;
    String desc = null;
    MultiIcon icon = null;
    boolean readOnly = false;
    Item originalItem = item;

    if (item != null)
    {
      // We fire an ask event to determine if this item is currently beeing edited
      // If so, we will display the edited instance (probably a copy of the original item)
      AskEvent ae = new AskEvent(this, "global.edit.geteditedinstance", item);
      fireEvent(ae);
      Item editedItem = (Item) ae.getAnswer();
      if (editedItem != null)
      {
        // We will use the edited item instead of the current one as node provider (may be newer!)
        item = editedItem;
      }
View Full Code Here

    actionMap.put("space", new AbstractAction("space")
    {
      public void actionPerformed(ActionEvent e)
      {
        // SPACE shows the popup menu for the current item
        Item item = getSelectedItem();

        // Show the popup directly below the current row
        TreePath [] paths = itemTree.getSelectionPaths();
        if (paths != null && paths.length > 0)
        {
View Full Code Here

        selectedGenerator.saveSettings(context);
      }

      if (save)
      {
        Item item = context.getItem();

        // First, serialize the generator settings and store them in the item
        String info = null;
        GeneratorSettings settings = context.getGeneratorSettings();
        if (settings != null && selectedGenerator != null)
        {
          settings.beforeSerialization();

          StringBuffer sb = new StringBuffer();
          StringBufferOutputStream os = new StringBufferOutputStream(sb);
          try
          {
            selectedGenerator.getXmlDriver().serialize(settings, os);
          }
          catch (XMLDriverException e)
          {
            ExceptionUtil.printTrace(e);
          }

          info = sb.toString().trim();
          if (info.equals(""))
          {
            info = null;
          }
          else
          {
            // Remove xml method tag (or else the XML parser will complain)
            info = StringUtil.substitute(info, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "");
            info = StringUtil.substitute(info, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>", "");
          }
        }
        item.setGeneratorInfo(info);

        // Add the item if the item is new and has not been saved yet; otherwise update the item
        // Placeholders serve for the creation of placeholder nodes only and are never saved.
        if (! (item instanceof PlaceholderItem))
        {
          boolean add = context.isNewItem() && ! context.isItemSaved();
          if (! ModelConnector.getInstance().saveItem(item, add))
          {
            event.cancel = true;
            return false;
          }
        }

        // Mark the item as saved. Do not initialize the item any more after saving.
        context.setItemSaved(true);
        context.setEmptyItem(false);

        // Get a reference to the saved item that is managed by the model for name uniqueness check and restoration purposes
        Item original;
        if (item instanceof Model)
        {
          original = ModelConnector.getInstance().getModelByQualifier(item.getQualifier());
        }
        else
View Full Code Here

      }

      if (o instanceof ActivityItem || o instanceof ProcessItem || o instanceof ComplexTypeItem)
      {
        // Open actions and processes in the item wizard
        Item item = (Item) o;

        ItemEditor editor = ItemEditorRegistry.getInstance().lookupItemEditor(item.getItemType());
        if (editor != null)
        {
          // For compatibility with pre-2.0 process items
          StandardItemEditor.ensureProcessType(item);
View Full Code Here

    public void actionPerformed(ActionEvent ae)
    {
      // Gets the model
      Model model = getSelectedModel(ItemBrowserPlugin.GUESS_MODEL | ItemBrowserPlugin.USE_CURRENT_MODEL);

      Item item = ItemCreationUtil.createItem(model, null, null, itd, null);
      if (item != null)
      {
        final Item newItem = item;
        SwingUtilities.invokeLater(new Runnable()
        {
          public void run()
          {
            setSelectedObject(newItem);
View Full Code Here

  {
    if (name == null)
      // Nothing to resolve
      return null;

    Item item;

    if (ModelQualifier.isAbsolute(name))
    {
      // Check if it's an absolute item name
      ModelQualifier qualifier = (new ModelQualifier(name));
View Full Code Here

TOP

Related Classes of org.openbp.core.model.item.Item

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.