Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoopur Gupta2019-09-16 13:19:46 +0000
committerNoopur Gupta2019-09-16 13:23:29 +0000
commita7975082f940e577c1ebb82439ba61d3b7e31673 (patch)
tree9452c023e4dd0c6346ccd2f5c8fe19299bab7e50
parent9538b4b05dccabb96732b7d057c9ce4df81c5448 (diff)
downloadeclipse.platform.ui-a7975082f940e577c1ebb82439ba61d3b7e31673.tar.gz
eclipse.platform.ui-a7975082f940e577c1ebb82439ba61d3b7e31673.tar.xz
eclipse.platform.ui-a7975082f940e577c1ebb82439ba61d3b7e31673.zip
Revert "Bug 548877 [Project Explorer] Rename resource should be inline"Y20190919-0900S4_13_0_RC2aR4_13I20190916-1045
-rw-r--r--bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/RenameResourceAction.java66
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/LTKLauncher.java35
2 files changed, 42 insertions, 59 deletions
diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/RenameResourceAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/RenameResourceAction.java
index 46306f6a4fc..bad73dd666c 100644
--- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/RenameResourceAction.java
+++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/RenameResourceAction.java
@@ -94,8 +94,6 @@ public class RenameResourceAction extends WorkspaceAction {
*/
private IPath newPath;
- private String newName;
-
private String[] modelProviderIds;
private static final String CHECK_RENAME_TITLE = IDEWorkbenchMessages.RenameResourceAction_checkTitle;
@@ -432,13 +430,7 @@ public class RenameResourceAction extends WorkspaceAction {
textEditor.setBounds(2, inset, Math.min(textSize.x, parentSize.x - 4),
parentSize.y - 2 * inset);
textEditorParent.redraw();
- int startOfFileExtension = resource.getName().lastIndexOf('.'); // $NON-NLS-1$
- if (startOfFileExtension == -1) {
- textEditor.selectAll();
- } else {
- textEditor.setSelection(0, startOfFileExtension);
- }
-
+ textEditor.selectAll();
textEditor.setFocus();
}
@@ -448,23 +440,23 @@ public class RenameResourceAction extends WorkspaceAction {
if (currentResource == null || !currentResource.exists()) {
return;
}
-
- if (this.navigatorTree != null) {
- runWithInlineEditor();
- } else {
- if (LTKLauncher.openRenameWizard(null, getStructuredSelection())) {
- return;
- }
+ if (LTKLauncher.openRenameWizard(getStructuredSelection())) {
+ return;
+ }
+ if (this.navigatorTree == null) {
// Do a quick read only and null check
if (!checkReadOnlyAndNull(currentResource)) {
return;
}
- newName = queryNewResourceName(currentResource);
+ String newName = queryNewResourceName(currentResource);
if (newName == null || newName.isEmpty()) {
return;
}
- newPath = currentResource.getFullPath().removeLastSegments(1).append(newName);
+ newPath = currentResource.getFullPath().removeLastSegments(1)
+ .append(newName);
super.run();
+ } else {
+ runWithInlineEditor();
}
}
@@ -493,6 +485,7 @@ public class RenameResourceAction extends WorkspaceAction {
return resources.get(0);
}
return null;
+
}
/**
@@ -521,10 +514,11 @@ public class RenameResourceAction extends WorkspaceAction {
// Cache the resource to avoid selection loss since a selection of
// another item can trigger this method
inlinedResource = resource;
- newName = textEditor.getText();
+ final String newName = textEditor.getText();
// Run this in an async to make sure that the operation that triggered
- // this action is completed. Otherwise problems occur when the icon of
- // the item being renamed is clicked (i.e., which causes the rename
+ // this action is completed. Otherwise this leads to problems when the
+ // icon of the item being renamed is clicked (i.e., which causes the
+ // rename
// text widget to lose focus and trigger this method).
Runnable query = () -> {
try {
@@ -536,18 +530,17 @@ public class RenameResourceAction extends WorkspaceAction {
if (!status.isOK()) {
displayError(status.getMessage());
} else {
- if (!LTKLauncher.openRenameWizard(newName, getStructuredSelection())) {
- // LTK Launcher couldnt rename the resource
- IPath newPath = inlinedResource.getFullPath().removeLastSegments(1).append(newName);
- runWithNewPath(newPath, inlinedResource);
- }
+ IPath newPath = inlinedResource.getFullPath()
+ .removeLastSegments(1).append(newName);
+ runWithNewPath(newPath, inlinedResource);
}
}
inlinedResource = null;
// Dispose the text widget regardless
disposeTextWidget();
// Ensure the Navigator tree has focus, which it may not if
- // the text widget previously had focus.
+ // the
+ // text widget previously had focus.
if (navigatorTree != null && !navigatorTree.isDisposed()) {
navigatorTree.setFocus();
}
@@ -634,21 +627,28 @@ public class RenameResourceAction extends WorkspaceAction {
// check for overwrite
IWorkspaceRoot workspaceRoot = resources[0].getWorkspace()
.getRoot();
-
IResource newResource = workspaceRoot.findMember(newPath);
boolean go = true;
if (newResource != null) {
go = checkOverwrite(getShell(), newResource);
}
if (go) {
- MoveResourcesOperation op = new MoveResourcesOperation(resources[0], newPath,
+ MoveResourcesOperation op = new MoveResourcesOperation(
+ resources[0],
+ newPath,
IDEWorkbenchMessages.RenameResourceAction_operationTitle);
op.setModelProviderIds(getModelProviderIds());
try {
- PlatformUI.getWorkbench().getOperationSupport().getOperationHistory().execute(op, monitor,
- WorkspaceUndoUtil.getUIInfoAdapter(getShell()));
+ PlatformUI
+ .getWorkbench()
+ .getOperationSupport()
+ .getOperationHistory()
+ .execute(
+ op,
+ monitor,
+ WorkspaceUndoUtil
+ .getUIInfoAdapter(getShell()));
} catch (ExecutionException e) {
- IDEWorkbenchPlugin.log(e.getMessage(), e);
if (e.getCause() instanceof CoreException) {
errorStatus[0] = ((CoreException) e.getCause())
.getStatus();
@@ -662,4 +662,4 @@ public class RenameResourceAction extends WorkspaceAction {
}
};
}
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/LTKLauncher.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/LTKLauncher.java
index 94d3a11d785..140350544b3 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/LTKLauncher.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/LTKLauncher.java
@@ -15,10 +15,6 @@
package org.eclipse.ui.internal.ide.actions;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Map.Entry;
-
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.NotEnabledException;
@@ -41,7 +37,7 @@ public class LTKLauncher {
private static final String LTK_DELETE_ID = "org.eclipse.ltk.ui.refactoring.commands.deleteResources"; //$NON-NLS-1$
private static final String LTK_MOVE_ID = "org.eclipse.ltk.ui.refactoring.commands.moveResources"; //$NON-NLS-1$
private static final String LTK_RENAME_ID = "org.eclipse.ltk.ui.refactoring.commands.renameResource"; //$NON-NLS-1$
- private static final String LTK_RENAME_COMMAND_NEWNAME_PARAMETER_KEY = "org.eclipse.ltk.ui.refactoring.commands.renameResource.newName.parameter.key"; //$NON-NLS-1$
+
/**
* Open the LTK delete resources wizard if available.
*
@@ -52,7 +48,7 @@ public class LTKLauncher {
*/
public static boolean openDeleteWizard(
IStructuredSelection structuredSelection) {
- return runCommand(LTK_DELETE_ID, structuredSelection, Collections.emptyMap());
+ return runCommand(LTK_DELETE_ID, structuredSelection);
}
/**
@@ -65,34 +61,24 @@ public class LTKLauncher {
*/
public static boolean openMoveWizard(
IStructuredSelection structuredSelection) {
- return runCommand(LTK_MOVE_ID, structuredSelection, Collections.emptyMap());
+ return runCommand(LTK_MOVE_ID, structuredSelection);
}
/**
* Open the LTK rename resource wizard if available.
*
- * @param newName The new name to give the resource. If null is
- * given, then the LTK rename resource wizard will
- * prompt the user for a new name.
- *
- * @param structuredSelection The action current selection.
+ * @param structuredSelection
+ * The action current selection.
*
* @return <code>true</code> if we can launch the wizard
*/
- public static boolean openRenameWizard(String newName,
+ public static boolean openRenameWizard(
IStructuredSelection structuredSelection) {
- Map<String, Object> commandParameters;
- if (newName != null) {
- commandParameters = Collections.singletonMap(LTK_RENAME_COMMAND_NEWNAME_PARAMETER_KEY, newName);
- } else {
- commandParameters = Collections.emptyMap();
- }
- return runCommand(LTK_RENAME_ID, structuredSelection, commandParameters);
+ return runCommand(LTK_RENAME_ID, structuredSelection);
}
- private static boolean runCommand(String commandId, IStructuredSelection selection,
- Map<String, Object> commandParameters) {
-
+ private static boolean runCommand(String commandId,
+ IStructuredSelection selection) {
ICommandService commandService = PlatformUI
.getWorkbench().getService(ICommandService.class);
Command cmd = commandService.getCommand(commandId);
@@ -107,9 +93,6 @@ public class LTKLauncher {
c = new EvaluationContext(handlerService
.createContextSnapshot(false), selection.toList());
c.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection);
- for (Entry<String, Object> entry : commandParameters.entrySet()) {
- c.addVariable(entry.getKey(), entry.getValue());
- }
}
try {
if (c != null) {

Back to the top