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());
}
}
}
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;
}
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;
}
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));
}
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;
}
Aggregations