use of org.apache.sling.ide.eclipse.ui.nav.model.JcrNode in project sling by apache.
the class JcrNodeRenameHandler 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);
InputDialog id = new InputDialog(shell, "Change Node Name", "Enter new name for node '" + node.getDescription() + "':", node.getLabel(), NodeNameValidator.INSTANCE);
if (id.open() == IStatus.OK) {
node.rename(id.getValue());
}
return null;
}
use of org.apache.sling.ide.eclipse.ui.nav.model.JcrNode in project sling by apache.
the class AbstractOpenInBrowserHandler 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);
IModule module = ServerUtil.getModule(node.getProject());
if (module == null) {
MessageDialog.openWarning(shell, "Cannot open browser", "Not configured for any server");
return null;
}
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 null;
}
IServer server = servers[0];
URL url;
try {
url = getUrlToOpen(node, server);
} catch (MalformedURLException e) {
StatusManager.getManager().handle(new Status(Status.WARNING, Activator.PLUGIN_ID, "Url is invalid", e), StatusManager.SHOW);
return null;
}
try {
IWorkbenchBrowserSupport browserSupport = HandlerUtil.getActiveWorkbenchWindow(event).getWorkbench().getBrowserSupport();
browserSupport.createBrowser("org.apache.sling.ide.openOnServer").openURL(url);
} catch (PartInitException e) {
StatusManager.getManager().handle(new Status(Status.WARNING, Activator.PLUGIN_ID, "Failed creating browser instance", e), StatusManager.SHOW | StatusManager.LOG);
}
return null;
}
use of org.apache.sling.ide.eclipse.ui.nav.model.JcrNode in project sling by apache.
the class SightlyNatureTesterTest method testOnProject.
private void testOnProject(boolean hasSightlyNature) throws CoreException {
if (hasSightlyNature) {
projectAdapter.installFacet("sightly", "1.1");
}
final IPath sightlyTemplatePath = Path.fromPortableString("/jcr_root/libs/my/component/html.html");
projectAdapter.createOrUpdateFile(sightlyTemplatePath, new ByteArrayInputStream(("<html />").getBytes()));
// test on resources directly
assertEquals("Test on project", hasSightlyNature, tester.test(projectRule.getProject(), "sightlyNature", new Object[0], null));
assertEquals("Test on folder", hasSightlyNature, tester.test(projectRule.getProject().getFolder("jcr_root"), "sightlyNature", new Object[0], null));
assertEquals("Test on file", hasSightlyNature, tester.test(projectRule.getProject().getFile(sightlyTemplatePath), "sightlyNature", new Object[0], null));
// directly create the root node
SyncDir syncDirNode = new SyncDir((IFolder) projectRule.getProject().findMember("jcr_root"));
assertEquals("Test on sync dir node", hasSightlyNature, tester.test(syncDirNode, "sightlyNature", new Object[0], null));
// test on jcr nodes
JcrContentContentProvider contentProvider = new JcrContentContentProvider();
JcrNode firstChild = (JcrNode) contentProvider.getChildren(syncDirNode)[0];
assertEquals("Test on jcr node", hasSightlyNature, tester.test(firstChild, "sightlyNature", new Object[0], null));
}
use of org.apache.sling.ide.eclipse.ui.nav.model.JcrNode in project sling by apache.
the class AbstractClipboardHandler 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;
}
execute0(node);
return null;
}
use of org.apache.sling.ide.eclipse.ui.nav.model.JcrNode in project sling by apache.
the class JcrNodeDeleteHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
JcrNode node = SelectionUtils.getFirst(selection, JcrNode.class);
if (node == null) {
return null;
}
Shell shell = HandlerUtil.getActiveShellChecked(event);
if (!MessageDialog.openConfirm(shell, "Delete Node", "Do you really want to delete '" + node.getLabel() + "'?")) {
return null;
}
node.delete();
return null;
}
Aggregations