Author: yradtsevich
Date: 2011-07-07 13:11:57 -0400 (Thu, 07 Jul 2011)
New Revision: 32721
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/VpeResourcesDialogFactory.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FileUtil.java
Log:
https://issues.jboss.org/browse/JBIDE-8719 : Show default root folder in Page Desigh
Options Dialog on top of the Actual Run-Time Folders tab content
- changed resolving of default WebRoot folder path
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/VpeResourcesDialogFactory.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/VpeResourcesDialogFactory.java 2011-07-07
16:53:35 UTC (rev 32720)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/VpeResourcesDialogFactory.java 2011-07-07
17:11:57 UTC (rev 32721)
@@ -11,6 +11,7 @@
package org.jboss.tools.vpe.editor.preferences;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.IPath;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
@@ -18,15 +19,21 @@
import org.eclipse.ui.editors.text.ILocationProvider;
import org.jboss.tools.common.resref.core.ResourceReference;
import org.jboss.tools.vpe.VpePlugin;
+import org.jboss.tools.vpe.editor.util.FileUtil;
import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
import org.jboss.tools.vpe.messages.VpeUIMessages;
import org.jboss.tools.vpe.resref.core.VpeResourcesDialog;
public class VpeResourcesDialogFactory {
public static void openVpeResourcesDialog(IEditorInput input) {
+ IPath absoluteDefaultPath = null;
Object fileLocation = null;
if (input instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput) input).getFile();
+ IFolder absoluteDefaultFolder = FileUtil.getDefaultWebRootFolder(file);
+ if (absoluteDefaultFolder != null) {
+ absoluteDefaultPath = absoluteDefaultFolder.getLocation();
+ }
fileLocation = file;
} else if (input instanceof ILocationProvider) {
ILocationProvider provider = (ILocationProvider) input;
@@ -35,9 +42,9 @@
fileLocation = path;
}
}
+
+ IPath relativeDafaultPath = VpeStyleUtil.getInputParentPath(input);
if (null != fileLocation) {
- IPath absoluteDefaultPath = VpeStyleUtil.getRootPath(input);
- IPath relativeDafaultPath = VpeStyleUtil.getInputParentPath(input);
VpeResourcesDialog dialogNew =
new VpeResourcesDialog(
PlatformUI.getWorkbench().getDisplay().getActiveShell(),
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FileUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FileUtil.java 2011-07-07
16:53:35 UTC (rev 32720)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FileUtil.java 2011-07-07
17:11:57 UTC (rev 32721)
@@ -23,6 +23,7 @@
import org.eclipse.core.resources.IContainer;
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.resources.ResourcesPlugin;
@@ -256,14 +257,9 @@
} else {
//WebArtifactEdit edit = WebArtifactEdit
// .getWebArtifactEditForRead(includeFile.getProject());
- IVirtualComponent com = ComponentCore
- .createComponent(includeFile.getProject());
- if (com != null) {
- IVirtualFolder webRootFolder = com.getRootFolder().getFolder(
- new Path("/")); //$NON-NLS-1$
- IContainer folder = webRootFolder.getUnderlyingFolder();
- IPath path = folder.getFullPath().append(fileName);
- file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ IFolder defaultWebRootFolder = getDefaultWebRootFolder(includeFile);
+ if (defaultWebRootFolder != null) {
+ file = defaultWebRootFolder.getFile(fileName);
} else {
/* Yahor Radtsevich (yradtsevich):
* Fix of JBIDE-4416: assume that the parent directory
@@ -286,7 +282,28 @@
}
return file;
}
+
+ public static IFolder getDefaultWebRootFolder(IFile file) {
+ IProject project = file.getProject();
+ if (project == null) {
+ return null;
+ }
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ if (component == null) {
+ return null;
+ }
+
+ IVirtualFolder webRootFolder = component.getRootFolder()
+ .getFolder(new Path("/")); //$NON-NLS-1$
+ IPath defaultWebRootPath = webRootFolder.getUnderlyingFolder().getFullPath();
+ if (defaultWebRootPath == null) {
+ return null;
+ }
+
+ return ResourcesPlugin.getWorkspace().getRoot().getFolder(defaultWebRootPath);
+ }
+
/**
* Appends {@code relatedFilePath} to the parent directory of
* {@code baseFile}.