You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by st...@apache.org on 2013/08/28 17:06:13 UTC
svn commit: r1518244 - in
/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/actions:
./ JcrNodeRenameAction.java
Author: stefanegli
Date: Wed Aug 28 15:06:12 2013
New Revision: 1518244
URL: http://svn.apache.org/r1518244
Log:
SLING-2985 : temporary rename action shown in the toolbar to rename a child-node within a .content.xml
Added:
sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/actions/
sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/actions/JcrNodeRenameAction.java (with props)
Added: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/actions/JcrNodeRenameAction.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/actions/JcrNodeRenameAction.java?rev=1518244&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/actions/JcrNodeRenameAction.java (added)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/actions/JcrNodeRenameAction.java Wed Aug 28 15:06:12 2013
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.ide.eclipse.ui.actions;
+
+import org.apache.sling.ide.eclipse.ui.nav.model.JcrNode;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+
+/** Testing action which renames a jcr node **/
+public class JcrNodeRenameAction implements IWorkbenchWindowActionDelegate {
+ private IWorkbenchWindow window;
+ private ISelection selection;
+ private JcrNode node;
+ /**
+ * The constructor.
+ */
+ public JcrNodeRenameAction() {
+ }
+
+ /**
+ * The action has been activated. The argument of the
+ * method represents the 'real' action sitting
+ * in the workbench UI.
+ * @see IWorkbenchWindowActionDelegate#run
+ */
+ public void run(IAction action) {
+ if (this.node==null) {
+ return;
+ }
+ InputDialog id = new InputDialog(window.getShell(), "Change JCR node name",
+ "Enter new name for JCR node '"+node.getDescription()+"':", node.getName(), new IInputValidator() {
+
+ @Override
+ public String isValid(String newText) {
+ if (newText!=null && newText.trim().length()>0 && newText.trim().equals(newText)) {
+ return null;
+ } else {
+ return "Invalid input";
+ }
+ }
+ });
+ if (id.open() == IStatus.OK) {
+ node.rename(id.getValue());
+ }
+ }
+
+ /**
+ * Selection in the workbench has been changed. We
+ * can change the state of the 'real' action here
+ * if we want, but this can only happen after
+ * the delegate has been created.
+ * @see IWorkbenchWindowActionDelegate#selectionChanged
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection iss = (IStructuredSelection) selection;
+ Object element = iss.getFirstElement();
+ if (element instanceof JcrNode) {
+ final JcrNode n = (JcrNode)element;
+ if (n.canBeRenamed()) {
+ action.setEnabled(true);
+ this.node = n;
+ return;
+ }
+ }
+ }
+ action.setEnabled(false);
+ this.node = null;
+ }
+
+ /**
+ * We can use this method to dispose of any system
+ * resources we previously allocated.
+ * @see IWorkbenchWindowActionDelegate#dispose
+ */
+ public void dispose() {
+ }
+
+ /**
+ * We will cache window object in order to
+ * be able to provide parent shell for the message dialog.
+ * @see IWorkbenchWindowActionDelegate#init
+ */
+ public void init(IWorkbenchWindow window) {
+ this.window = window;
+ }
+}
\ No newline at end of file
Propchange: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/actions/JcrNodeRenameAction.java
------------------------------------------------------------------------------
svn:mime-type = text/plain