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

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


  public void run(IAction action) {
    if (selection==null || !(selection instanceof IStructuredSelection)) {
      return;
    }
    IStructuredSelection ss = (IStructuredSelection)selection;
    JcrNode node = (JcrNode) ss.getFirstElement();
   
        IWorkbenchPage page = targetPart.getSite().getPage();
        IModule module = ServerUtil.getModule(node.getProject());
        if (module==null) {
      MessageDialog.openWarning(shell, "Cannot open browser", "Not configured for any server");
          return;
        }
        IServer[] servers = ServerUtil.getServersByModule(module, new NullProgressMonitor());
        if (servers==null || servers.length==0) {
      MessageDialog.openWarning(shell, "Cannot open browser", "Not configured for any server");
          return;
        }
        IServer server = servers[0];
        final String url = node.getURLForBrowser(server)+".html";
    try {
      IEditorInput input = new WebBrowserEditorInput(url);
      page.openEditor(input, "org.apache.sling.ide.eclipse.ui.editors.WebBrowser", true);
    } catch (PartInitException e1) {
      //TODO proper logging
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.canBeCopiedToClipboard()) {
              action.setEnabled(true);
              this.node = n;
              return;
            }
          }
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.canBeRenamed()) {
              action.setEnabled(true);
              this.node = n;
              return;
            }
          }
View Full Code Here

    public void run(IAction action) {
        if (selection==null || !(selection instanceof IStructuredSelection)) {
            return;
        }
        IStructuredSelection ss = (IStructuredSelection)selection;
        JcrNode node = (JcrNode) ss.getFirstElement();
        if (!node.canCreateChild()) {
            MessageDialog.openInformation(shell, "Cannot create node",
                    "Node is not covered by the workspace filter as defined in filter.xml");
            return;
        }
        Repository repository = ServerUtil.getDefaultRepository(node.getProject());
        NodeTypeRegistry ntManager = (repository==null) ? null : repository.getNodeTypeRegistry();
        if (ntManager == null) {
           
            if (!doNotAskAgain) {
                MessageDialog dialog = new MessageDialog(null,  "Unable to validate node type", null,
                        "Unable to validate node types since project " + node.getProject().getName() + " is not associated with a server or the server is not started.",
                        MessageDialog.QUESTION_WITH_CANCEL,
                        new String[] {"Cancel", "Continue (do not ask again)", "Continue"}, 1) {
                    @Override
                    protected void configureShell(Shell shell) {
                        super.configureShell(shell);
                        setShellStyle(getShellStyle() | SWT.SHEET);
                    }
                };
                int choice = dialog.open();
                if (choice <= 0) {
                    return;
                }
                if (choice==1) {
                    doNotAskAgain = true;
                }
            }

        }
        final NodeType nodeType = node.getNodeType();
        if (nodeType!=null && nodeType.getName()!=null && nodeType.getName().equals("nt:file")) {
            MessageDialog.openInformation(shell, "Cannot create node", "Node of type nt:file cannot have children");
            return;
        }
       
        try {
            final NewNodeDialog nnd = new NewNodeDialog(shell, node, ntManager);
            if (nnd.open() == IStatus.OK) {
                node.createChild(nnd.getValue(), nnd.getChosenNodeType());
                return;
            }
        } catch (RepositoryException e1) {
            Activator.getDefault().getPluginLogger().warn(
                    "Could not open NewNodeDialog due to "+e1, e1);
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.canBePastedTo(clipboard)) {
              action.setEnabled(true);
              this.node = n;
              return;
            }
          }
View Full Code Here

    }
    public void dispose() {
    }
    public Object[] getElements(Object parent) {
        if (parent instanceof JcrNode) {
            JcrNode node = (JcrNode)parent;
            final IPropertyDescriptor[] pds = node.getProperties().getPropertyDescriptors();
                return pds;
        } else {
            return new String[] {};
        }
    }
View Full Code Here

                int propertyType = newRow.getType();
                String type = PropertyType.nameFromValue(propertyType);
                cell.setText(type);
            } else if (element instanceof IPropertyDescriptor) {
                IPropertyDescriptor pd = (IPropertyDescriptor)element;
                JcrNode jcrNode = (JcrNode)viewer.getInput();
                Map.Entry me = (Entry) pd.getId();
                final String propertyName = String.valueOf(me.getKey());
                int propertyType = jcrNode.getPropertyType(propertyName);
                if (propertyType<=-1 || propertyType==PropertyType.UNDEFINED) {
                    cell.setText("");
                } else {
                    final JcrProperty property = jcrNode.getProperty(propertyName);
                    String type = PropertyType.nameFromValue(propertyType);
                    if (property!=null && property.isMultiple()) {
                        type = type + "[]";
                    }
                    cell.setText(type);
                }
            } else {
                cell.setText("");
            }
            return;
        } else if (index==2) {
            updateValue(cell);
            return;
        } else {
            final Object element = cell.getElement();
            if (element instanceof NewRow) {
                NewRow newRow = (NewRow)element;
                cell.setText("");
            } else if (element instanceof IPropertyDescriptor) {
                IPropertyDescriptor pd = (IPropertyDescriptor)element;
                JcrNode jcrNode = (JcrNode)viewer.getInput();
                Map.Entry me = (Entry) pd.getId();
                PropertyDefinition prd = jcrNode.getPropertyDefinition(String.valueOf(me.getKey()));
                if (index==3) {
                    // protected
                    if (prd!=null) {
                        cell.setText(String.valueOf(prd.isProtected()));
                    } else {
                        cell.setText("false");
                    }
                } else if (index==4) {
                    // mandatory
                    if (prd!=null) {
                        cell.setText(String.valueOf(prd.isMandatory()));
                    } else {
                        cell.setText("false");
                    }
                } else if (index==5) {
                    // multiple
                    if (prd!=null) {
                        cell.setText(String.valueOf(prd.isMultiple()));
                    } else {
                        cell.setText(String.valueOf(jcrNode.getProperty(String.valueOf(me.getKey())).isMultiple()));
                    }
                } else if (index==6) {
                    // auto creatd
                    if (prd!=null) {
                        cell.setText(String.valueOf(prd.isAutoCreated()));
View Full Code Here

        } else if (element instanceof IPropertyDescriptor){
            if (cell.getColumnIndex()>2 && cell.getColumnIndex()!=5) {
                return false;
            }
            IPropertyDescriptor pd = (IPropertyDescriptor)element;
            JcrNode jcrNode = (JcrNode)viewer.getInput();
            Map.Entry me = (Entry) pd.getId();
            if (me.getKey().equals("jcr:primaryType")) {
                return cell.getColumnIndex()==2;
            } else {
                return true;
View Full Code Here

        if (element instanceof NewRow) {
            NewRow newRow = (NewRow)element;
            cell.setText(String.valueOf(newRow.getValue()));
        } else if (element instanceof IPropertyDescriptor) {
            IPropertyDescriptor pd = (IPropertyDescriptor)element;
            JcrNode jcrNode = (JcrNode)viewer.getInput();
//            jcrNode.getProperties().getPropertyValue(pd);
            Map.Entry me = (Entry) pd.getId();
            final String rawValue = String.valueOf(me.getValue());
            int index = rawValue.indexOf("}");
            if (index!=-1) {
View Full Code Here

    @Override
    public void decorate(Object element, IDecoration decoration) {

        if (element instanceof JcrNode) {
            JcrNode node = (JcrNode) element;
            if (node.getPrimaryType() != null) {
                decoration.addSuffix(" [" + node.getPrimaryType() + "]");
            }

            if (node instanceof SyncDir) {
                decoration.addOverlay(SharedImages.CONTENT_OVERLAY, IDecoration.BOTTOM_RIGHT);
            }
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.