Author: yzhishko
Date: 2010-06-07 10:11:32 -0400 (Mon, 07 Jun 2010)
New Revision: 22600
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/RefactoringChangesFactory.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/model/JSF2ComponentModelManager.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/JSF2RenameParticipant.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/JSf2MoveParticipant.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/RefactoringActionFactory.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/RefactoringActionManager.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/CompositeAttributeRenameDescriptor.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/CompositeAttributeRenameProcessor.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/CompositeAttributeRenameRefactoringWizard.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/IRenameDescriptor.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/RenameAction.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/RenameRefactoring.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/RenameUserInterfaceManager.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/RenameUserInterfaceStarter.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/core/StructuredChanges.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/core/StructuredTextFileChange.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/view/StructuredChangesPreviewViewer.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/JSFUIMessages.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/messages.properties
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/JSFAutoTestCase.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/jsf2/refactor/JSF2AbstractRefactorTest.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/jsf2/refactor/JSF2AttributeRenameTest.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/jsf2/refactor/JSF2MoveParticipantTest.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/jsf2/refactor/JSF2RenameParticipantTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-6276 - preview for JSF 2 refactoring was created.
SWTBot tests were added.
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/model/JSF2ComponentModelManager.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/model/JSF2ComponentModelManager.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/model/JSF2ComponentModelManager.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -15,37 +15,25 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.jdt.internal.core.JarEntryFile;
-import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
-import org.eclipse.ui.ide.IDE;
import org.eclipse.wst.html.core.internal.encoding.HTMLModelLoader;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument;
-import org.eclipse.wst.validation.ValidationFramework;
import org.eclipse.wst.xml.core.internal.document.ElementImpl;
import org.eclipse.wst.xml.core.internal.parser.XMLSourceParser;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.core.internal.provisional.format.DocumentNodeFormatter;
import org.jboss.tools.jsf.JSFModelPlugin;
-import org.jboss.tools.jsf.jsf2.util.JSF2ComponentUtil;
import org.jboss.tools.jsf.jsf2.util.JSF2ResourceUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -95,172 +83,6 @@
return file;
}
- public void renameCompositeComponents(IResource resource, String URI,
- String oldName, String newName) throws CoreException {
- if (resource instanceof IFile) {
- IFile file = (IFile) resource;
- renameCompositeComponentsInFile(file, URI, oldName, newName);
- } else if (resource instanceof IProject) {
- IResource[] children = ((IProject) resource).members();
- if (children != null) {
- for (int i = 0; i < children.length; i++) {
- renameCompositeComponents(children[i], URI, oldName,
- newName);
- }
- }
- } else if (resource instanceof IFolder) {
- IResource[] children = ((IFolder) resource).members();
- if (children != null) {
- for (int i = 0; i < children.length; i++) {
- renameCompositeComponents(children[i], URI, oldName,
- newName);
- }
- }
- }
- }
-
- private boolean isFileCorrect(IFile file) {
- if (file == null) {
- return false;
- }
- if (!"xhtml".equals(file.getFileExtension()) &&
!"jsp".equals(file.getFileExtension())) { //$NON-NLS-1$ //$NON-NLS-2$
- IContentType contentType = IDE.getContentType(file);
- if (contentType == null) {
- return false;
- }
- String id = contentType.getId();
- if (!"org.eclipse.jst.jsp.core.jspsource".equals(id) &&
!"org.eclipse.wst.html.core.htmlsource".equals(id)) { //$NON-NLS-1$
//$NON-NLS-2$
- return false;
- }
- }
- return true;
- }
-
- private void renameCompositeComponentsInFile(final IFile file,
- final String URI, final String oldName, final String newName) {
- if (!isFileCorrect(file)) {
- return;
- }
- updateFileContent(new EditableDOMFile() {
-
- @Override
- public IFile getFile() {
- return file;
- }
-
- @Override
- protected void edit(IDOMModel model) throws CoreException,
- IOException {
- IDOMDocument document = model.getDocument();
- Map<String, List<Element>> compositeComponentsMap = JSF2ComponentUtil
- .findCompositeComponents(document);
- List<Element> compositeComponents = compositeComponentsMap
- .get(URI);
- if (compositeComponents != null) {
- for (Element element : compositeComponents) {
- if (oldName.equals(element.getLocalName())) {
- renameElement((IDOMElement) element, oldName,
- newName);
- }
- }
- model.save();
- ValidationFramework.getDefault().validate(file,
- new NullProgressMonitor());
- }
- }
- });
- }
-
- public void renameURIs(IResource resource, Map<String, String> urisMap)
- throws CoreException {
- if (resource instanceof IFile) {
- IFile file = (IFile) resource;
- renameURIsInFile(file, urisMap);
- } else if (resource instanceof IProject) {
- IResource[] children = ((IProject) resource).members();
- if (children != null) {
- for (int i = 0; i < children.length; i++) {
- renameURIs(children[i], urisMap);
- }
- }
- } else if (resource instanceof IFolder) {
- IResource[] children = ((IFolder) resource).members();
- if (children != null) {
- for (int i = 0; i < children.length; i++) {
- renameURIs(children[i], urisMap);
- }
- }
- }
- }
-
- private void renameURIsInFile(final IFile file,
- final Map<String, String> urisMap) {
- if (!isFileCorrect(file)) {
- return;
- }
- updateFileContent(new EditableDOMFile() {
-
- @Override
- public IFile getFile() {
- return file;
- }
-
- @Override
- protected void edit(IDOMModel model) throws CoreException,
- IOException {
- IDOMDocument document = model.getDocument();
- IDOMAttr[] uriAttrs = JSF2ComponentUtil
- .findURIContainers(document);
- for (int i = 0; i < uriAttrs.length; i++) {
- if (urisMap.containsKey(uriAttrs[i].getValue())) {
- renameURIAttr(uriAttrs[i], urisMap.get(uriAttrs[i]
- .getValue()));
- }
- }
- model.save();
- ValidationFramework.getDefault().validate(file,
- new NullProgressMonitor());
- }
-
- });
- }
-
- private void renameURIAttr(IDOMAttr idomAttr, final String replaceValue) {
- int startOffset = idomAttr.getStartOffset();
- String attrValue = idomAttr.getValue();
- IStructuredDocument document = idomAttr.getStructuredDocument();
- String value = document.getText().substring(idomAttr.getStartOffset());
- value = value.substring(0, value.indexOf(attrValue)
- + idomAttr.getValue().length());
- try {
- document.replace(startOffset + value.indexOf(attrValue), attrValue
- .length(), replaceValue);
- } catch (BadLocationException e) {
- JSFModelPlugin.getPluginLog().logError(e);
- }
- idomAttr.getName();
- }
-
- private void renameElement(final IDOMElement element, final String oldName,
- final String newName) {
- String sourceString = element.getSource();
- IStructuredDocument structuredDocument = element
- .getStructuredDocument();
- int startOffset = element.getStartOffset();
- int endStartOffset = element.getEndStartOffset();
- int endOffset = element.getEndOffset();
- try {
- if (endOffset != endStartOffset) {
- structuredDocument.replace(sourceString.lastIndexOf(oldName)
- + startOffset, oldName.length(), newName);
- }
- structuredDocument.replace(element.getStartOffset()
- + sourceString.indexOf(oldName), oldName.length(), newName);
- } catch (BadLocationException e) {
- JSFModelPlugin.getPluginLog().logError(e);
- }
- }
-
private void updateJSF2CompositeComponent(IDOMDocument componentDoc,
String[] attrNames) {
IDOMElement[] interfaceElement = new IDOMElement[1];
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/JSF2RenameParticipant.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/JSF2RenameParticipant.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/JSF2RenameParticipant.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -23,7 +23,7 @@
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
import org.eclipse.ui.ide.IDE;
-import org.jboss.tools.jsf.jsf2.model.JSF2ComponentModelManager;
+import org.jboss.tools.jsf.jsf2.refactoring.core.StructuredChanges;
import org.jboss.tools.jsf.jsf2.util.JSF2ResourceUtil;
import org.jboss.tools.jsf.messages.JSFUIMessages;
@@ -54,12 +54,13 @@
}
oldFileName = oldFileName.substring(0, oldFileName.lastIndexOf('.'));
newFileName = newFileName.substring(0, newFileName.lastIndexOf('.'));
- JSF2ComponentModelManager.getManager().renameCompositeComponents(
- project, URI, oldFileName, newFileName);
+ StructuredChanges changes = RefactoringChangesFactory
+ .createRenameCompositeComponentsChanges(project, URI,
+ oldFileName, newFileName);
project = null;
URI = null;
oldFileName = null;
- return null;
+ return changes;
}
@Override
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/JSf2MoveParticipant.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/JSf2MoveParticipant.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/JSf2MoveParticipant.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -27,7 +27,6 @@
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
import org.eclipse.ltk.core.refactoring.participants.MoveParticipant;
import org.jboss.tools.jsf.JSFModelPlugin;
-import org.jboss.tools.jsf.jsf2.model.JSF2ComponentModelManager;
import org.jboss.tools.jsf.jsf2.util.JSF2ResourceUtil;
import org.jboss.tools.jsf.messages.JSFUIMessages;
@@ -52,7 +51,7 @@
public Change createChange(IProgressMonitor pm) throws CoreException,
OperationCanceledException {
if (project != null) {
- JSF2ComponentModelManager.getManager().renameURIs(project, urisMap);
+ return RefactoringChangesFactory.createRenameURIChanges(project, urisMap);
}
return null;
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/RefactoringActionFactory.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/RefactoringActionFactory.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/RefactoringActionFactory.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
package org.jboss.tools.jsf.jsf2.refactoring;
import org.eclipse.core.resources.IFile;
@@ -12,6 +23,12 @@
import org.jboss.tools.jsf.jsf2.refactoring.action.rename.IRenameDescriptor;
import org.jboss.tools.jsf.jsf2.util.JSF2ResourceUtil;
+/**
+ *
+ * @author yzhishko
+ *
+ */
+
@SuppressWarnings("restriction")
public class RefactoringActionFactory {
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/RefactoringActionManager.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/RefactoringActionManager.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/RefactoringActionManager.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
package org.jboss.tools.jsf.jsf2.refactoring;
import java.util.HashSet;
@@ -12,10 +23,17 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.jboss.tools.jsf.JSFModelPlugin;
import org.jboss.tools.jsf.jsf2.refactoring.action.rename.IRenameDescriptor;
import org.jboss.tools.jsf.jsf2.refactoring.action.rename.RenameUserInterfaceManager;
import org.jboss.tools.jsf.messages.JSFUIMessages;
+/**
+ *
+ * @author yzhishko
+ *
+ */
+
@SuppressWarnings("restriction")
public class RefactoringActionManager {
@@ -68,7 +86,8 @@
starter.activate(descriptor.getRenameRefactoring(), parent,
RefactoringSaveHelper.SAVE_NOTHING);
} catch (CoreException e) {
- e.printStackTrace();
+ JSFModelPlugin.getPluginLog().logError(e);
}
}
+
}
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/RefactoringChangesFactory.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/RefactoringChangesFactory.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/RefactoringChangesFactory.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -0,0 +1,227 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jsf.jsf2.refactoring;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jdt.internal.corext.refactoring.changes.TextChangeCompatibility;
+import org.eclipse.ltk.core.refactoring.GroupCategory;
+import org.eclipse.ltk.core.refactoring.GroupCategorySet;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
+import org.jboss.tools.jsf.jsf2.model.JSF2ComponentModelManager;
+import org.jboss.tools.jsf.jsf2.refactoring.core.StructuredChanges;
+import org.jboss.tools.jsf.jsf2.refactoring.core.StructuredTextFileChange;
+import org.jboss.tools.jsf.jsf2.util.JSF2ComponentUtil;
+import org.jboss.tools.jsf.messages.JSFUIMessages;
+import org.w3c.dom.Element;
+
+/**
+ *
+ * @author yzhishko
+ *
+ */
+
+@SuppressWarnings("restriction")
+public class RefactoringChangesFactory {
+
+ private static final GroupCategorySet CATEGORY_COMPOSITE_URI_RENAME = new
GroupCategorySet(
+ new GroupCategory(
+ "org.jboss.tools.jsf.jsf2.refactoring.rename.composite.uri.type",
JSFUIMessages.Refactoring_JSF_2_Rename_Composite_URI_Changes,
JSFUIMessages.Refactoring_JSF_2_Changes_Rename_Composite_URI)); //$NON-NLS-1$
+
+ private static final GroupCategorySet CATEGORY_COMPOSITE_COMPONENT_RENAME = new
GroupCategorySet(
+ new GroupCategory(
+ "org.jboss.tools.jsf.jsf2.refactoring.rename.composite.uri.type",
JSFUIMessages.Refactoring_JSF_2_Rename_Composite_Component_Changes,
JSFUIMessages.Refactoring_JSF_2_Changes_Rename_Composite_Component)); //$NON-NLS-1$
+
+ public static StructuredChanges createRenameURIChanges(IResource resource,
+ Map<String, String> urisMap) throws CoreException {
+ StructuredChanges changes = new StructuredChanges(
+ JSFUIMessages.Refactoring_JSF_2_Rename_Composite_URI_Changes);
+ createRenameURIChangesRecursively(resource, urisMap, changes);
+ if (changes.getChildren() == null || changes.getChildren().length == 0) {
+ return null;
+ }
+ return changes;
+ }
+
+ public static StructuredChanges createRenameCompositeComponentsChanges(
+ IResource resource, String uri, String oldFileName,
+ String newFileName) throws CoreException {
+ StructuredChanges changes = new StructuredChanges(
+ JSFUIMessages.Refactoring_JSF_2_Rename_Composite_Component_Changes);
+ createRenameComponentChangesRecursively(resource, uri, oldFileName,
+ newFileName, changes);
+ if (changes.getChildren() == null || changes.getChildren().length == 0) {
+ return null;
+ }
+ return changes;
+ }
+
+ private static void createRenameComponentChangesRecursively(
+ IResource resource, String uri, String oldFileName,
+ String newFileName, StructuredChanges changes) throws CoreException {
+ if (resource instanceof IFile) {
+ IFile file = (IFile) resource;
+ StructuredTextFileChange change = createRanameComponentChange(file,
+ uri, oldFileName, newFileName);
+ if (change != null) {
+ changes.add(change);
+ }
+ } else if (resource instanceof IProject) {
+ IResource[] children = ((IProject) resource).members();
+ if (children != null) {
+ for (int i = 0; i < children.length; i++) {
+ createRenameComponentChangesRecursively(children[i], uri,
+ oldFileName, newFileName, changes);
+ }
+ }
+ } else if (resource instanceof IFolder) {
+ IResource[] children = ((IFolder) resource).members();
+ if (children != null) {
+ for (int i = 0; i < children.length; i++) {
+ createRenameComponentChangesRecursively(children[i], uri,
+ oldFileName, newFileName, changes);
+ }
+ }
+ }
+ }
+
+ private static StructuredTextFileChange createRanameComponentChange(
+ IFile file, String uri, String oldName, String newName) {
+ if (!isFileCorrect(file)) {
+ return null;
+ }
+ StructuredTextFileChange fileChange = null;
+ Map<String, List<Element>> compositeComponentsMap = JSF2ComponentUtil
+ .findCompositeComponents(JSF2ComponentModelManager
+ .getReadableDOMDocument(file));
+ List<Element> compositeComponents = compositeComponentsMap.get(uri);
+ if (compositeComponents != null) {
+ for (Element element : compositeComponents) {
+ if (oldName.equals(element.getLocalName())) {
+ if (element instanceof IDOMElement) {
+ IDOMElement domElement = (IDOMElement) element;
+ if (fileChange == null) {
+ fileChange = new StructuredTextFileChange(file
+ .getFullPath().toOSString(), file);
+ }
+ ReplaceEdit[] edits = createReplaceEditsForElement(domElement, oldName, newName);
+ for (int i = 0; i < edits.length; i++) {
+ TextChangeCompatibility.addTextEdit(fileChange,
+ JSFUIMessages.Refactoring_JSF_2_Rename_Composite_Component,
+ edits[i], CATEGORY_COMPOSITE_COMPONENT_RENAME);
+ }
+ }
+ }
+ }
+ }
+ return fileChange;
+ }
+
+ private static ReplaceEdit[] createReplaceEditsForElement(IDOMElement element, String
oldName, String newName){
+ List<ReplaceEdit> edits = new ArrayList<ReplaceEdit>();
+ String sourceString = element.getSource();
+ int startOffset = element.getStartOffset();
+ int endStartOffset = element.getEndStartOffset();
+ int endOffset = element.getEndOffset();
+ if (endOffset != endStartOffset) {
+ ReplaceEdit edit = new ReplaceEdit(sourceString.lastIndexOf(oldName) + startOffset,
oldName.length(), newName);
+ edits.add(edit);
+ }
+ ReplaceEdit edit = new ReplaceEdit(startOffset + sourceString.indexOf(oldName),
oldName.length(), newName);
+ edits.add(edit);
+ return edits.toArray(new ReplaceEdit[0]);
+ }
+
+ private static void createRenameURIChangesRecursively(IResource resource,
+ Map<String, String> urisMap, StructuredChanges changes)
+ throws CoreException {
+ if (resource instanceof IFile) {
+ IFile file = (IFile) resource;
+ StructuredTextFileChange change = createRanameURIChange(file,
+ urisMap);
+ if (change != null) {
+ changes.add(change);
+ }
+ } else if (resource instanceof IProject) {
+ IResource[] children = ((IProject) resource).members();
+ if (children != null) {
+ for (int i = 0; i < children.length; i++) {
+ createRenameURIChangesRecursively(children[i], urisMap,
+ changes);
+ }
+ }
+ } else if (resource instanceof IFolder) {
+ IResource[] children = ((IFolder) resource).members();
+ if (children != null) {
+ for (int i = 0; i < children.length; i++) {
+ createRenameURIChangesRecursively(children[i], urisMap,
+ changes);
+ }
+ }
+ }
+ }
+
+ private static StructuredTextFileChange createRanameURIChange(IFile file,
+ Map<String, String> urisMap) {
+ if (!isFileCorrect(file)) {
+ return null;
+ }
+ StructuredTextFileChange fileChange = null;
+ IDOMAttr[] uriAttrs = JSF2ComponentUtil
+ .findURIContainers(JSF2ComponentModelManager
+ .getReadableDOMDocument(file));
+ for (IDOMAttr uriAttr : uriAttrs) {
+ String valueToBeReplaced = uriAttr.getValue();
+ if (urisMap.containsKey(valueToBeReplaced)) {
+ if (fileChange == null) {
+ fileChange = new StructuredTextFileChange(file
+ .getFullPath().toOSString(), file);
+ }
+ ReplaceEdit edit = new ReplaceEdit(uriAttr
+ .getValueRegionStartOffset() + 1, valueToBeReplaced
+ .length(), urisMap.get(valueToBeReplaced));
+ TextChangeCompatibility.addTextEdit(fileChange,
+ JSFUIMessages.Refactoring_JSF_2_Rename_Composite_URI,
+ edit, CATEGORY_COMPOSITE_URI_RENAME);
+ }
+ }
+ return fileChange;
+ }
+
+ private static boolean isFileCorrect(IFile file) {
+ if (file == null) {
+ return false;
+ }
+ if (!"xhtml".equals(file.getFileExtension()) &&
!"jsp".equals(file.getFileExtension())) { //$NON-NLS-1$ //$NON-NLS-2$
+ IContentType contentType = IDE.getContentType(file);
+ if (contentType == null) {
+ return false;
+ }
+ String id = contentType.getId();
+ if (!"org.eclipse.jst.jsp.core.jspsource".equals(id) &&
!"org.eclipse.wst.html.core.htmlsource".equals(id)) { //$NON-NLS-1$
//$NON-NLS-2$
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/CompositeAttributeRenameDescriptor.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/CompositeAttributeRenameDescriptor.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/CompositeAttributeRenameDescriptor.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
package org.jboss.tools.jsf.jsf2.refactoring.action.rename;
import org.eclipse.core.resources.IFile;
@@ -4,6 +15,11 @@
import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
+/**
+ *
+ * @author yzhishko
+ *
+ */
@SuppressWarnings("restriction")
public class CompositeAttributeRenameDescriptor implements IRenameDescriptor{
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/CompositeAttributeRenameProcessor.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/CompositeAttributeRenameProcessor.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/CompositeAttributeRenameProcessor.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
package org.jboss.tools.jsf.jsf2.refactoring.action.rename;
import java.util.List;
@@ -32,6 +43,12 @@
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+/**
+ *
+ * @author yzhishko
+ *
+ */
+
@SuppressWarnings("restriction")
public class CompositeAttributeRenameProcessor extends RenameProcessor
implements INameUpdating {
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/CompositeAttributeRenameRefactoringWizard.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/CompositeAttributeRenameRefactoringWizard.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/CompositeAttributeRenameRefactoringWizard.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
package org.jboss.tools.jsf.jsf2.refactoring.action.rename;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
@@ -5,6 +16,12 @@
import org.eclipse.ltk.core.refactoring.Refactoring;
import org.jboss.tools.jsf.messages.JSFUIMessages;
+/**
+ *
+ * @author yzhishko
+ *
+ */
+
@SuppressWarnings("restriction")
public class CompositeAttributeRenameRefactoringWizard extends
org.eclipse.jdt.internal.ui.refactoring.reorg.RenameRefactoringWizard {
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/IRenameDescriptor.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/IRenameDescriptor.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/IRenameDescriptor.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
package org.jboss.tools.jsf.jsf2.refactoring.action.rename;
import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
@@ -2,2 +13,8 @@
+/**
+ *
+ * @author yzhishko
+ *
+ */
+
public interface IRenameDescriptor {
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/RenameAction.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/RenameAction.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/RenameAction.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
package org.jboss.tools.jsf.jsf2.refactoring.action.rename;
import org.eclipse.core.commands.AbstractHandler;
@@ -18,6 +29,12 @@
import org.jboss.tools.jsf.jsf2.refactoring.RefactoringActionManager;
import org.jboss.tools.jsf.messages.JSFUIMessages;
+/**
+ *
+ * @author yzhishko
+ *
+ */
+
@SuppressWarnings("restriction")
public class RenameAction extends AbstractHandler implements
IEditorActionDelegate {
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/RenameRefactoring.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/RenameRefactoring.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/RenameRefactoring.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
package org.jboss.tools.jsf.jsf2.refactoring.action.rename;
import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring;
@@ -2,2 +13,8 @@
+/**
+ *
+ * @author yzhishko
+ *
+ */
+
@SuppressWarnings("deprecation")
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/RenameUserInterfaceManager.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/RenameUserInterfaceManager.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/RenameUserInterfaceManager.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
package org.jboss.tools.jsf.jsf2.refactoring.action.rename;
import org.eclipse.jdt.internal.ui.refactoring.UserInterfaceManager;
@@ -2,2 +13,8 @@
+/**
+ *
+ * @author yzhishko
+ *
+ */
+
@SuppressWarnings("restriction")
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/RenameUserInterfaceStarter.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/RenameUserInterfaceStarter.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/action/rename/RenameUserInterfaceStarter.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
package org.jboss.tools.jsf.jsf2.refactoring.action.rename;
import org.eclipse.jdt.internal.ui.refactoring.UserInterfaceStarter;
@@ -2,2 +13,8 @@
+/**
+ *
+ * @author yzhishko
+ *
+ */
+
@SuppressWarnings("restriction")
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/core/StructuredChanges.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/core/StructuredChanges.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/core/StructuredChanges.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
package org.jboss.tools.jsf.jsf2.refactoring.core;
import org.eclipse.ltk.core.refactoring.Change;
@@ -3,4 +14,10 @@
import org.eclipse.ltk.core.refactoring.CompositeChange;
+/**
+ *
+ * @author yzhishko
+ *
+ */
+
public class StructuredChanges extends CompositeChange {
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/core/StructuredTextFileChange.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/core/StructuredTextFileChange.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/core/StructuredTextFileChange.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
package org.jboss.tools.jsf.jsf2.refactoring.core;
import org.eclipse.core.resources.IFile;
@@ -11,6 +22,12 @@
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.jboss.tools.common.text.ext.IMultiPageEditor;
+/**
+ *
+ * @author yzhishko
+ *
+ */
+
public class StructuredTextFileChange extends TextFileChange{
public StructuredTextFileChange(String name, IFile file) {
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/view/StructuredChangesPreviewViewer.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/view/StructuredChangesPreviewViewer.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/refactoring/view/StructuredChangesPreviewViewer.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
package org.jboss.tools.jsf.jsf2.refactoring.view;
import org.eclipse.ltk.internal.ui.refactoring.TextEditChangePreviewViewer;
@@ -2,2 +13,8 @@
+/**
+ *
+ * @author yzhishko
+ *
+ */
+
@SuppressWarnings("restriction")
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/JSFUIMessages.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/JSFUIMessages.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/JSFUIMessages.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -140,6 +140,12 @@
public static String Refactoring_JSF_2_Rename_Composite_Attr;
public static String Refactoring_JSF_2_Invalid_Attr;
public static String Refactoring_JSF_2_Isnt_Available;
+ public static String Refactoring_JSF_2_Rename_Composite_URI_Changes;
+ public static String Refactoring_JSF_2_Changes_Rename_Composite_URI;
+ public static String Refactoring_JSF_2_Rename_Composite_URI;
+ public static String Refactoring_JSF_2_Rename_Composite_Component_Changes;
+ public static String Refactoring_JSF_2_Changes_Rename_Composite_Component;
+ public static String Refactoring_JSF_2_Rename_Composite_Component;
static {
// load message values from bundle file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/messages.properties
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/messages.properties 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/messages.properties 2010-06-07
14:11:32 UTC (rev 22600)
@@ -116,4 +116,10 @@
Refactoring_JSF_2_Rename_Composite_Attr_Name=Rename composite attribute name
Refactoring_JSF_2_Rename_Composite_Attr=Rename composite attribute
Refactoring_JSF_2_Invalid_Attr=Attribute name is not valid
-Refactoring_JSF_2_Isnt_Available=Refactoring is not available in the current place
\ No newline at end of file
+Refactoring_JSF_2_Isnt_Available=Refactoring is not available in the current place
+Refactoring_JSF_2_Rename_Composite_URI_Changes=Rename composite URI changes
+Refactoring_JSF_2_Changes_Rename_Composite_URI=Changes to rename composite URI
+Refactoring_JSF_2_Rename_Composite_URI=Rename composite URI
+Refactoring_JSF_2_Rename_Composite_Component_Changes=Rename composite component changes
+Refactoring_JSF_2_Changes_Rename_Composite_Component=Changes to rename composite
component
+Refactoring_JSF_2_Rename_Composite_Component=Rename composite component
\ No newline at end of file
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/JSFAutoTestCase.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/JSFAutoTestCase.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/JSFAutoTestCase.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -89,9 +89,16 @@
protected String loadFileContent(String resourceRelativePath) throws IOException {
File file = new File(getPathToResources(resourceRelativePath));
StringBuilder builder = new StringBuilder(""); //$NON-NLS-1$
- Scanner scanner = new Scanner(file);
- while (scanner.hasNextLine()) {
- builder.append(scanner.nextLine()+"\n"); //$NON-NLS-1$
+ Scanner scanner = null;
+ try {
+ scanner = new Scanner(file);
+ while (scanner.hasNextLine()) {
+ builder.append(scanner.nextLine()+"\n"); //$NON-NLS-1$
+ }
+ } catch (IOException e) {
+ if (scanner != null) {
+ scanner.close();
+ }
}
return builder.toString();
}
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/jsf2/refactor/JSF2AbstractRefactorTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/jsf2/refactor/JSF2AbstractRefactorTest.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/jsf2/refactor/JSF2AbstractRefactorTest.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -97,5 +97,5 @@
bot.sleep(2000);
editor.saveAndClose();
}
-
+
}
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/jsf2/refactor/JSF2AttributeRenameTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/jsf2/refactor/JSF2AttributeRenameTest.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/jsf2/refactor/JSF2AttributeRenameTest.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -4,6 +4,7 @@
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotStyledText;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.jboss.tools.ui.bot.test.WidgetVariables;
@@ -16,13 +17,15 @@
checkContent();
}
- private void renameCompositeAttribute() {
+ private void renameCompositeAttribute() throws IOException {
SWTBotEclipseEditor editor = bot
.editorByTitle("echo.xhtml").toTextEditor(); //$NON-NLS-1$
editor.selectRange(9, 29, 1);
bot.menu("Refactor").menu("Rename").click(); //$NON-NLS-1$
//$NON-NLS-2$
bot.shell("Rename Composite Attribute").activate(); //$NON-NLS-1$
bot.textWithLabel("New name:").setText("echo1"); //$NON-NLS-1$
//$NON-NLS-2$
+ bot.button("Preview >").click(); //$NON-NLS-1$
+ checkPreview();
bot.button("OK").click(); //$NON-NLS-1$
}
@@ -77,4 +80,16 @@
super.tearDown();
}
+ private void checkPreview() throws IOException {
+ delay();
+ SWTBotTree tree = bot.tree();
+ tree
+ .expandNode("Composite attribute name changes").expandNode("echo.xhtml
- " + projectProperties.getProperty("JSFProjectName") +
"/WebContent/resources/mycomp").expandNode("Rename composite attribute
name"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ tree
+ .expandNode("Composite attribute name
changes").expandNode("jsf2TestPage.xhtml - " +
projectProperties.getProperty("JSFProjectName") +
"/WebContent").expandNode("Rename composite attribute"); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ SWTBotStyledText styledText = bot.styledText(0);
+ assertEquals(loadFileContent("refactor/compositeComponent.html"),
styledText.getText()); //$NON-NLS-1$
+ System.out.println(styledText.getText());
+ }
+
}
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/jsf2/refactor/JSF2MoveParticipantTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/jsf2/refactor/JSF2MoveParticipantTest.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/jsf2/refactor/JSF2MoveParticipantTest.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -42,7 +42,8 @@
tree = innerBot.tree();
tree
.expandNode(projectProperties.getProperty("JSFProjectName")).expandNode("WebContent").expandNode("resources").expandNode("mycomp1").select();
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- delay();
+ bot.button("Preview >").click(); //$NON-NLS-1$
+ checkPreview();
bot.button("OK").click(); //$NON-NLS-1$
delay();
}
@@ -83,5 +84,12 @@
delay();
super.tearDown();
}
+
+ private void checkPreview(){
+ delay();
+ SWTBotTree tree = bot.tree();
+ tree
+ .expandNode("Rename composite URI
changes").expandNode("jsf2TestPage.xhtml - " +
projectProperties.getProperty("JSFProjectName") +
"/WebContent").expandNode("Rename composite URI"); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ }
}
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/jsf2/refactor/JSF2RenameParticipantTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/jsf2/refactor/JSF2RenameParticipantTest.java 2010-06-07
14:05:12 UTC (rev 22599)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/jsf2/refactor/JSF2RenameParticipantTest.java 2010-06-07
14:11:32 UTC (rev 22600)
@@ -22,6 +22,8 @@
.expandNode(projectProperties.getProperty("JSFProjectName")).expandNode("WebContent").expandNode("resources").expandNode("mycomp").expandNode("echo.xhtml").select();
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
bot.menu("Refactor").menu("Rename...").click(); //$NON-NLS-1$
//$NON-NLS-2$
bot.textWithLabel("New name:").setText("echo1.xhtml");
//$NON-NLS-1$ //$NON-NLS-2$
+ bot.button("Preview >").click(); //$NON-NLS-1$
+ checkPreview();
bot.button("OK").click(); //$NON-NLS-1$
delay();
}
@@ -59,4 +61,11 @@
super.tearDown();
}
+ private void checkPreview() {
+ delay();
+ SWTBotTree tree = bot.tree();
+ tree
+ .expandNode("Rename composite component
changes").expandNode("jsf2TestPage.xhtml - " +
projectProperties.getProperty("JSFProjectName") +
"/WebContent").expandNode("Rename composite component"); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ }
+
}