Java 类com.intellij.uiDesigner.SimpleTransferable 实例源码

项目:intellij-ce-playground    文件:DesignDropTargetListener.java   
public void dragEnter(DropTargetDragEvent dtde) {
  try {
    DraggedComponentList dcl = DraggedComponentList.fromTransferable(dtde.getTransferable());
    if (dcl != null) {
      myDraggedComponentList = dcl;
      myComponentDragObject = dcl;
      processDragEnter(dcl, dtde.getLocation(), dtde.getDropAction());
      dtde.acceptDrag(dtde.getDropAction());
      myLastPoint = dtde.getLocation();
    }
    else {
      ComponentItem componentItem = SimpleTransferable.getData(dtde.getTransferable(), ComponentItem.class);
      if (componentItem != null) {
        myComponentDragObject = new ComponentItemDragObject(componentItem);
        dtde.acceptDrag(dtde.getDropAction());
        myLastPoint = dtde.getLocation();
      }
    }
  }
  catch (Exception e) {
    LOG.error(e);
  }
}
项目:tools-idea    文件:DesignDropTargetListener.java   
public void dragEnter(DropTargetDragEvent dtde) {
  try {
    DraggedComponentList dcl = DraggedComponentList.fromTransferable(dtde.getTransferable());
    if (dcl != null) {
      myDraggedComponentList = dcl;
      myComponentDragObject = dcl;
      processDragEnter(dcl, dtde.getLocation(), dtde.getDropAction());
      dtde.acceptDrag(dtde.getDropAction());
      myLastPoint = dtde.getLocation();
    }
    else {
      ComponentItem componentItem = SimpleTransferable.getData(dtde.getTransferable(), ComponentItem.class);
      if (componentItem != null) {
        myComponentDragObject = new ComponentItemDragObject(componentItem);
        dtde.acceptDrag(dtde.getDropAction());
        myLastPoint = dtde.getLocation();
      }
    }
  }
  catch (Exception e) {
    LOG.error(e);
  }
}
项目:consulo-ui-designer    文件:DesignDropTargetListener.java   
public void dragEnter(DropTargetDragEvent dtde)
{
    try
    {
        DraggedComponentList dcl = DraggedComponentList.fromTransferable(dtde.getTransferable());
        if(dcl != null)
        {
            myDraggedComponentList = dcl;
            myComponentDragObject = dcl;
            processDragEnter(dcl, dtde.getLocation(), dtde.getDropAction());
            dtde.acceptDrag(dtde.getDropAction());
            myLastPoint = dtde.getLocation();
        }
        else
        {
            ComponentItem componentItem = SimpleTransferable.getData(dtde.getTransferable(), ComponentItem.class);
            if(componentItem != null)
            {
                myComponentDragObject = new ComponentItemDragObject(componentItem);
                dtde.acceptDrag(dtde.getDropAction());
                myLastPoint = dtde.getLocation();
            }
        }
    }
    catch(Exception e)
    {
        LOG.error(e);
    }
}
项目:intellij-ce-playground    文件:DesignDropTargetListener.java   
public void drop(final DropTargetDropEvent dtde) {
  try {
    ComponentTree componentTree = DesignerToolWindowManager.getInstance(myEditor).getComponentTree();
    if (componentTree != null) {
      componentTree.setDropTargetComponent(null);
    }


    final DraggedComponentList dcl = DraggedComponentList.fromTransferable(dtde.getTransferable());
    if (dcl != null) {
      CommandProcessor.getInstance().executeCommand(myEditor.getProject(),
                                                    new Runnable() {
                                                      public void run() {
                                                        if (processDrop(dcl, dtde.getLocation(), dtde.getDropAction())) {
                                                          myEditor.refreshAndSave(true);
                                                        }
                                                      }
                                                    }, UIDesignerBundle.message("command.drop.components"), null);
    }
    else {
      ComponentItem componentItem = SimpleTransferable.getData(dtde.getTransferable(), ComponentItem.class);
      if (componentItem != null) {
        myEditor.getMainProcessor().setInsertFeedbackEnabled(false);
        new InsertComponentProcessor(myEditor).processComponentInsert(dtde.getLocation(), componentItem);
        ApplicationManager.getApplication().invokeLater(new Runnable() {
          public void run() {
            PaletteToolWindowManager.getInstance(myEditor).clearActiveItem();
            myEditor.getActiveDecorationLayer().removeFeedback();
            myEditor.getLayeredPane().setCursor(null);
            myEditor.getGlassLayer().requestFocus();
            myEditor.getMainProcessor().setInsertFeedbackEnabled(true);
          }
        });
      }
    }
    myDraggedComponentsCopy = null;
    myEditor.repaintLayeredPane();
  }
  catch (Exception e) {
    LOG.error(e);
  }
}
项目:tools-idea    文件:DesignDropTargetListener.java   
public void drop(final DropTargetDropEvent dtde) {
  try {
    if (myComponentTree != null) {
      myComponentTree.setDropTargetComponent(null);
    }


    final DraggedComponentList dcl = DraggedComponentList.fromTransferable(dtde.getTransferable());
    if (dcl != null) {
      CommandProcessor.getInstance().executeCommand(myEditor.getProject(),
                                                    new Runnable() {
                                                      public void run() {
                                                        if (processDrop(dcl, dtde.getLocation(), dtde.getDropAction())) {
                                                          myEditor.refreshAndSave(true);
                                                        }
                                                      }
                                                    }, UIDesignerBundle.message("command.drop.components"), null);
    }
    else {
      ComponentItem componentItem = SimpleTransferable.getData(dtde.getTransferable(), ComponentItem.class);
      if (componentItem != null) {
        myEditor.getMainProcessor().setInsertFeedbackEnabled(false);
        new InsertComponentProcessor(myEditor).processComponentInsert(dtde.getLocation(), componentItem);
        ApplicationManager.getApplication().invokeLater(new Runnable() {
          public void run() {
            PaletteManager.getInstance(myEditor.getProject()).clearActiveItem();
            myEditor.getActiveDecorationLayer().removeFeedback();
            myEditor.getLayeredPane().setCursor(null);
            myEditor.getGlassLayer().requestFocus();
            myEditor.getMainProcessor().setInsertFeedbackEnabled(true);
          }
        });
      }
    }
    myDraggedComponentsCopy = null;
    myEditor.repaintLayeredPane();
  }
  catch (Exception e) {
    LOG.error(e);
  }
}
项目:consulo-ui-designer    文件:DesignDropTargetListener.java   
public void drop(final DropTargetDropEvent dtde)
{
    try
    {
        ComponentTree componentTree = DesignerToolWindowManager.getInstance(myEditor).getComponentTree();
        if(componentTree != null)
        {
            componentTree.setDropTargetComponent(null);
        }


        final DraggedComponentList dcl = DraggedComponentList.fromTransferable(dtde.getTransferable());
        if(dcl != null)
        {
            CommandProcessor.getInstance().executeCommand(myEditor.getProject(), new Runnable()
            {
                public void run()
                {
                    if(processDrop(dcl, dtde.getLocation(), dtde.getDropAction()))
                    {
                        myEditor.refreshAndSave(true);
                    }
                }
            }, UIDesignerBundle.message("command.drop.components"), null);
        }
        else
        {
            ComponentItem componentItem = SimpleTransferable.getData(dtde.getTransferable(), ComponentItem.class);
            if(componentItem != null)
            {
                myEditor.getMainProcessor().setInsertFeedbackEnabled(false);
                new InsertComponentProcessor(myEditor).processComponentInsert(dtde.getLocation(), componentItem);
                ApplicationManager.getApplication().invokeLater(new Runnable()
                {
                    public void run()
                    {
                        PaletteToolWindowManager.getInstance(myEditor).clearActiveItem();
                        myEditor.getActiveDecorationLayer().removeFeedback();
                        myEditor.getLayeredPane().setCursor(null);
                        myEditor.getGlassLayer().requestFocus();
                        myEditor.getMainProcessor().setInsertFeedbackEnabled(true);
                    }
                });
            }
        }
        myDraggedComponentsCopy = null;
        myEditor.repaintLayeredPane();
    }
    catch(Exception e)
    {
        LOG.error(e);
    }
}
项目:consulo-ui-designer    文件:ComponentTree.java   
@Override
public void drop(DropTargetDropEvent dtde)
{
    try
    {
        final DraggedComponentList dcl = DraggedComponentList.fromTransferable(dtde.getTransferable());
        ComponentItem componentItem = SimpleTransferable.getData(dtde.getTransferable(), ComponentItem.class);
        if(dcl != null || componentItem != null)
        {
            final TreePath path = getPathForLocation((int) dtde.getLocation().getX(), (int) dtde.getLocation().getY());
            final RadComponent targetComponent = getComponentFromPath(path);
            if(!myEditor.ensureEditable())
            {
                return;
            }
            if(targetComponent instanceof RadContainer)
            {
                final ComponentDropLocation dropLocation = ((RadContainer) targetComponent).getDropLocation(null);
                if(dcl != null)
                {
                    if(!FormEditingUtil.isDropOnChild(dcl, dropLocation))
                    {
                        RadComponent[] components = dcl.getComponents().toArray(new RadComponent[dcl.getComponents().size()]);
                        RadContainer[] originalParents = dcl.getOriginalParents();
                        final GridConstraints[] originalConstraints = dcl.getOriginalConstraints();
                        for(int i = 0; i < components.length; i++)
                        {
                            originalParents[i].removeComponent(components[i]);
                        }
                        dropLocation.processDrop(myEditor, components, null, dcl);
                        for(int i = 0; i < originalConstraints.length; i++)
                        {
                            if(originalParents[i].getLayoutManager().isGrid())
                            {
                                FormEditingUtil.deleteEmptyGridCells(originalParents[i], originalConstraints[i]);
                            }
                        }
                    }
                }
                else
                {
                    new InsertComponentProcessor(myEditor).processComponentInsert(componentItem, dropLocation);
                }
            }
            myEditor.refreshAndSave(true);
        }
        setDropTargetComponent(null);
    }
    catch(Exception e)
    {
        LOG.error(e);
    }
}