Package org.objectstyle.wolips.componenteditor.actions

Examples of org.objectstyle.wolips.componenteditor.actions.ComponentInserter


    }
  }

  @Override
  public void drop(DropTargetEvent event) {
    ComponentInserter inserter = null;
    boolean selectRange = false;

    IStructuredSelection structuredSelection = (IStructuredSelection) event.data;
    if (structuredSelection != null && !structuredSelection.isEmpty()) {
      IResource resource = (IResource) structuredSelection.getFirstElement();
      if (resource instanceof IFolder) {
        IFolder folder = (IFolder) resource;
        String name = folder.getName();
        if (name.endsWith(".wo")) {
          String componentName = name.substring(0, name.lastIndexOf('.'));
          boolean inline = true;
          inserter = new ComponentInserter(_componentEditor, componentName, inline);
          Wo wo = inserter.getWo();
          if (wo != null) {
            selectRange = wo.isComponentContent();
          }
        }
      }
    }

    if (inserter == null) {
      event.detail = DND.DROP_NONE;
      return;
    }

    IRewriteTarget target = (IRewriteTarget) _componentEditor.getAdapter(IRewriteTarget.class);
    if (target != null) {
      target.beginCompoundChange();
    }

    if (!getTemplateEditor().getSourceEditor().validateEditorInputState()) {
      event.detail = DND.DROP_NONE;
      return;
    }

    if (selectRange) {
      getTemplateEditor().getSelectionProvider().setSelection(new TextSelection(_selection.getOffset(), _selection.getLength()));
    } else {
      getTemplateEditor().getSelectionProvider().setSelection(new TextSelection(_selection.getOffset(), 0));
    }

    inserter.insert();
  }
View Full Code Here

TOP

Related Classes of org.objectstyle.wolips.componenteditor.actions.ComponentInserter

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.