use of org.eclipse.core.runtime.IStatus 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.eclipse.core.runtime.IStatus in project sling by apache.
the class JcrNode method validateDrop.
public IStatus validateDrop(int operation, TransferData transferType) {
Repository repository = ServerUtil.getDefaultRepository(getProject());
NodeTypeRegistry ntManager = (repository == null) ? null : repository.getNodeTypeRegistry();
if (ntManager == null) {
return new Status(IStatus.CANCEL, Activator.PLUGIN_ID, 1, "Cannot drop element here because corresponding server is not started! (Needed to determine node types)", null);
}
// let's support plain files first
try {
if (getPrimaryType().equals("nt:file")) {
// hard-code the most prominent case: cannot drop onto a file
return new Status(IStatus.CANCEL, Activator.PLUGIN_ID, 1, "Cannot drop element onto nt:file", null);
}
if (ntManager.isAllowedPrimaryChildNodeType(getPrimaryType(), "nt:file")) {
return Status.OK_STATUS;
} else {
return Status.CANCEL_STATUS;
}
} catch (RepositoryException e) {
Activator.getDefault().getPluginLogger().error("validateDrop: Got Exception while " + "verifying nodeType: " + e, e);
return Status.CANCEL_STATUS;
}
}
use of org.eclipse.core.runtime.IStatus in project sling by apache.
the class JcrNode method handleDropResource.
private IStatus handleDropResource(IFolder targetFolder, IResource droppedResourceRoot, int detail) throws CoreException {
if (targetFolder == null) {
return new Status(IStatus.CANCEL, Activator.PLUGIN_ID, 1, "Cannot drop on this type of element (yet)", null);
}
if (droppedResourceRoot == null) {
throw new IllegalArgumentException("droppedResourceRoot must not be null");
}
IFile copyToFile = targetFolder.getFile(droppedResourceRoot.getName());
IPath copyToPath = copyToFile.getFullPath();
switch(detail) {
case DND.DROP_COPY:
{
droppedResourceRoot.copy(copyToPath, true, new NullProgressMonitor());
break;
}
case DND.DROP_MOVE:
{
droppedResourceRoot.move(copyToPath, true, new NullProgressMonitor());
break;
}
default:
{
throw new IllegalStateException("Unknown drop action (detail: " + detail + ")");
}
}
return Status.OK_STATUS;
}
use of org.eclipse.core.runtime.IStatus in project sling by apache.
the class JcrNode method handleDrop.
public IStatus handleDrop(Object data, int detail) throws CoreException {
IFolder folder = (IFolder) this.resource;
if (data instanceof IStructuredSelection) {
IStructuredSelection sel = (IStructuredSelection) data;
Object firstElem = sel.getFirstElement();
if (firstElem instanceof IResource) {
IResource resource = (IResource) firstElem;
return handleDropResource(folder, resource, detail);
} else if (firstElem instanceof JcrNode) {
JcrNode node = (JcrNode) firstElem;
return handleDropNode(folder, node, detail);
} else {
return new Status(IStatus.CANCEL, Activator.PLUGIN_ID, 1, "Cannot drop on this type of element (yet) [1]", null);
}
} else {
return new Status(IStatus.CANCEL, Activator.PLUGIN_ID, 1, "Cannot drop this type of selection", null);
}
}
use of org.eclipse.core.runtime.IStatus in project sling by apache.
the class SlingWstServer method waitForServerToStart.
public void waitForServerToStart(long duration, TimeUnit timeUnit) throws InterruptedException {
final CountDownLatch startLatch = new CountDownLatch(1);
final IStatus[] statusHolder = new IStatus[1];
server.start(ILaunchManager.RUN_MODE, new IOperationListener() {
@Override
public void done(IStatus result) {
statusHolder[0] = result;
startLatch.countDown();
}
});
boolean success = startLatch.await(duration, timeUnit);
assertThat("Server did not start in " + duration + " " + timeUnit, success, equalTo(true));
assertThat("Unexpected IStatus when starting server", statusHolder[0], IStatusIsOk.isOk());
}
Aggregations