Search in sources :

Example 1 with JcrNode

use of org.apache.sling.ide.eclipse.ui.nav.model.JcrNode in project sling by apache.

the class JcrPropertiesSection method setInput.

@Override
public void setInput(IWorkbenchPart part, ISelection selection) {
    super.setInput(part, selection);
    delegate.setPage(part.getSite().getPage());
    if (selection != null && (selection instanceof IStructuredSelection)) {
        IStructuredSelection iss = (IStructuredSelection) selection;
        if (iss.getFirstElement() instanceof JcrNode) {
            delegate.setInput((JcrNode) iss.getFirstElement());
        }
    }
}
Also used : JcrNode(org.apache.sling.ide.eclipse.ui.nav.model.JcrNode) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 2 with JcrNode

use of org.apache.sling.ide.eclipse.ui.nav.model.JcrNode in project sling by apache.

the class JcrDropAdapterAssistant method validateDrop.

@Override
public IStatus validateDrop(Object target, int operation, TransferData transferType) {
    if (target instanceof JcrNode) {
        JcrNode jcrNode = (JcrNode) target;
        IStatus result = jcrNode.validateDrop(operation, transferType);
        if (!result.isOK()) {
            // check for details to be shown in the status bar
            final String message = result.getMessage();
            if (message != null && message.trim().length() > 0) {
                StatusLineUtils.setErrorMessage(2000, message);
            } else {
                StatusLineUtils.resetErrorMessage();
            }
        } else {
            StatusLineUtils.resetErrorMessage();
        }
        return result;
    }
    return Status.CANCEL_STATUS;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) JcrNode(org.apache.sling.ide.eclipse.ui.nav.model.JcrNode)

Example 3 with JcrNode

use of org.apache.sling.ide.eclipse.ui.nav.model.JcrNode in project sling by apache.

the class Sorter method compare.

@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 (Object child : children) {
        if (child == node1) {
            return -1;
        } else if (child == node2) {
            return 1;
        }
    }
    return 0;
}
Also used : JcrNode(org.apache.sling.ide.eclipse.ui.nav.model.JcrNode)

Example 4 with JcrNode

use of org.apache.sling.ide.eclipse.ui.nav.model.JcrNode in project sling by apache.

the class AbstractClipboardHandler method setEnabled.

@Override
public void setEnabled(Object evaluationContext) {
    ISelection sel = SelectionUtils.getSelectionFromEvaluationContext(evaluationContext);
    JcrNode node = SelectionUtils.getFirst(sel, JcrNode.class);
    setBaseEnabled(node != null && isEnabledFor(node));
}
Also used : JcrNode(org.apache.sling.ide.eclipse.ui.nav.model.JcrNode) ISelection(org.eclipse.jface.viewers.ISelection)

Example 5 with JcrNode

use of org.apache.sling.ide.eclipse.ui.nav.model.JcrNode in project sling by apache.

the class JcrNewNodeHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ISelection sel = HandlerUtil.getCurrentSelection(event);
    JcrNode node = SelectionUtils.getFirst(sel, JcrNode.class);
    if (node == null) {
        return null;
    }
    Shell shell = HandlerUtil.getActiveShell(event);
    if (!node.canCreateChild()) {
        MessageDialog.openInformation(shell, "Cannot create node", "Node is not covered by the workspace filter as defined in filter.xml");
        return null;
    }
    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 null;
            }
            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 null;
    }
    try {
        final NewNodeDialog nnd = new NewNodeDialog(shell, node, ntManager);
        if (nnd.open() == IStatus.OK) {
            node.createChild(nnd.getValue(), nnd.getChosenNodeType());
            return null;
        }
    } catch (RepositoryException e1) {
        Activator.getDefault().getPluginLogger().warn("Could not open NewNodeDialog due to " + e1, e1);
    }
    return null;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Repository(org.apache.sling.ide.transport.Repository) JcrNode(org.apache.sling.ide.eclipse.ui.nav.model.JcrNode) NodeType(javax.jcr.nodetype.NodeType) ISelection(org.eclipse.jface.viewers.ISelection) NodeTypeRegistry(org.apache.sling.ide.transport.NodeTypeRegistry) RepositoryException(org.apache.sling.ide.transport.RepositoryException) MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Aggregations

JcrNode (org.apache.sling.ide.eclipse.ui.nav.model.JcrNode)27 ISelection (org.eclipse.jface.viewers.ISelection)10 Test (org.junit.Test)8 SyncDir (org.apache.sling.ide.eclipse.ui.nav.model.SyncDir)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 JcrContentContentProvider (org.apache.sling.ide.eclipse.ui.nav.JcrContentContentProvider)3 Shell (org.eclipse.swt.widgets.Shell)3 PartInitException (org.eclipse.ui.PartInitException)3 IPropertyDescriptor (org.eclipse.ui.views.properties.IPropertyDescriptor)3 Map (java.util.Map)2 Entry (java.util.Map.Entry)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 Point (org.eclipse.swt.graphics.Point)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 NodeType (javax.jcr.nodetype.NodeType)1 PropertyDefinition (javax.jcr.nodetype.PropertyDefinition)1 JcrProperty (org.apache.sling.ide.eclipse.ui.nav.model.JcrProperty)1