Package org.apache.sling.ide.eclipse.ui.nav.model

Examples of org.apache.sling.ide.eclipse.ui.nav.model.JcrNode


  }

  @Override
  public String getDescription(Object element) {
    if (element instanceof JcrNode) {
      JcrNode jcrNode = (JcrNode)element;
      return jcrNode.getDescription();
    } else {
      // fallback to the default
      return null;
    }
  }
View Full Code Here


  @Override
  public int compare(Viewer viewer, Object e1, Object e2) {
    if (!(e1 instanceof JcrNode) || !(e2 instanceof JcrNode)) {
      return super.compare(viewer, e1, e2);
    }
    JcrNode node1 = (JcrNode) e1;
    JcrNode node2 = (JcrNode) e2;
    JcrNode parent = node1.getParent();
    Object[] children = parent.getChildren(false);
    for (int i = 0; i < children.length; i++) {
      Object aChild = children[i];
      if (aChild==node1) {
        return -1;
      } else if (aChild==node2) {
View Full Code Here

    if (fInViewPart) {
      ISelection selection = treeViewer.getSelection();
      if (selection instanceof IStructuredSelection) {
        IStructuredSelection iss = (IStructuredSelection)selection;
        if (iss.getFirstElement() instanceof JcrNode) {
          final JcrNode node = (JcrNode)iss.getFirstElement();
          final IFile file = node.getFileForEditor();
          if (file!=null) {
            actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, new OpenFileAction(getActivePage()) {
              @Override
              public void run() {
                try {
View Full Code Here

        // test children of '/'
        Object[] children = contentProvider.getChildren(syncDirNode);
        assertChildrenHavePaths(children, "/content");

        // test children of '/content'
        JcrNode contentNode = (JcrNode) children[0];
        Object[] children2 = contentProvider.getChildren(contentNode);
        assertChildrenHavePaths(children2, "/content/test-root");

        // test children of '/content/test-root'
        JcrNode testRootNode = (JcrNode) children2[0];
        Object[] children3 = contentProvider.getChildren(testRootNode);
        assertChildrenHavePaths(children3, "/content/test-root/en");

        // test children of '/content/test-root/en'
        JcrNode enNode = (JcrNode) children3[0];
        Object[] children4 = contentProvider.getChildren(enNode);
        assertChildrenHavePaths(children4, "/content/test-root/en/message", "/content/test-root/en/error",
                "/content/test-root/en/warning");

        // test children of '/content/test-root/en/message'
        JcrNode messageNode = (JcrNode) children4[0];
        Object[] children5 = contentProvider.getChildren(messageNode);
        assertChildrenHavePaths(children5); // no children
    }
View Full Code Here

        // test children of '/'
        Object[] children = contentProvider.getChildren(syncDirNode);
        assertChildrenHavePaths(children, "/content");

        // test children of '/content'
        JcrNode contentNode = (JcrNode) children[0];
        Object[] children2 = contentProvider.getChildren(contentNode);
        assertChildrenHavePaths(children2, "/content/sling:stuff");

        // test children of '/content/sling:stuff
        JcrNode slingStuffNode = (JcrNode) children2[0];
        Object[] children3 = contentProvider.getChildren(slingStuffNode);
        assertChildrenHavePaths(children3); // no children

    }
View Full Code Here

        for (int i = 0; i < children.length; i++) {

            Object child = children[i];
            assertThat("Unexpected type of child", child, CoreMatchers.instanceOf(JcrNode.class));

            JcrNode node = (JcrNode) child;
            assertThat("Unexpected path for child at index " + i, node.getJcrPath(), CoreMatchers.equalTo(paths[i]));
        }
    }
View Full Code Here

    if (selection instanceof IStructuredSelection) {
      IStructuredSelection iss = (IStructuredSelection) selection;
            if (iss.size()==1) {
          Object element = iss.getFirstElement();
          if (element instanceof JcrNode) {
            final JcrNode n = (JcrNode)element;
            if (n.canBeDeleted()) {
              action.setEnabled(true);
              this.node = n;
              return;
            }
          }
View Full Code Here

            public void selectionChanged(IWorkbenchPart part, ISelection selection) {
                if (selection instanceof IStructuredSelection) {
                    IStructuredSelection iss = (IStructuredSelection)selection;
                    Object firstElem = iss.getFirstElement();
                    if (firstElem instanceof JcrNode) {
                        JcrNode jcrNode = (JcrNode)firstElem;
                        setInput(jcrNode);
                        return;
                    }
                }
            }
View Full Code Here

          if (sel instanceof IStructuredSelection) {
              IStructuredSelection iss = (IStructuredSelection)sel;
              Object elem = iss.getFirstElement();
              if (elem instanceof IPropertyDescriptor) {
                  IPropertyDescriptor pd = (IPropertyDescriptor)elem;
                  JcrNode jcrnode = (JcrNode)viewer.getInput();
                  jcrnode.deleteProperty(pd.getDisplayName());
                  refreshContent();
              }
          }
      }
    };
    deleteAction.setText("Delete");
    deleteAction.setToolTipText("Delete a proeprty");
    deleteAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
        getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
    doubleClickAction = new Action() {
      public void run() {
          //TODO doesn't do anything currently..
        ISelection selection = viewer.getSelection();
//        Object obj = ((IStructuredSelection)selection).getFirstElement();
//        showMessage("Double-click detected on "+obj.toString());
      }
    };
   
    showInEditorAction = new Action() {
        public void run() {
           
            JcrNode node = (JcrNode)viewer.getInput();
                final IFile file = node.getFileForEditor();
                if (file!=null) {
                    try {
                        IDE.openEditor(getPage(), file, true);
                    } catch (PartInitException e) {
                        e.printStackTrace(System.out);
View Full Code Here

  }

    void refreshContent() {
        final Object input = viewer.getInput();
        if (input!=null && input instanceof JcrNode) {
            JcrNode jcrnode = (JcrNode)input;
            SyncDir syncDir = jcrnode.getSyncDir();
            JcrNode newnode = syncDir.getNode(jcrnode.getJcrPath());
            if (newnode!=null) {
                viewer.setInput(newnode);
                if (lastEditedNewPropertyName!=null) {
                    // set the selection/focus accordingly
                   
View Full Code Here

TOP

Related Classes of org.apache.sling.ide.eclipse.ui.nav.model.JcrNode

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.