Commit 79669fb8 authored by Kristof Szabados's avatar Kristof Szabados
Browse files

findFilesForLocation is also deprecated + URIUtils is better for getting the...


findFilesForLocation is also deprecated + URIUtils is better for getting the path part of a URI than the getPath function of the URI object.
Signed-off-by: Kristof Szabados's avatarkristof <Kristof.Szabados@ericsson.com>
parent 3d1f3c7f
......@@ -7,6 +7,8 @@
******************************************************************************/
package org.eclipse.titan.common.fieldeditors;
import static org.eclipse.titan.common.utils.StringUtils.isNullOrEmpty;
import java.net.URI;
import java.util.ArrayList;
import java.util.Iterator;
......@@ -43,9 +45,6 @@ import org.eclipse.ui.console.MessageConsole;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.ui.ide.dialogs.PathVariableSelectionDialog;
import static org.eclipse.titan.common.utils.StringUtils.isNullOrEmpty;
/**
* @author Kristof Szabados
* */
......@@ -255,13 +254,13 @@ public class TITANResourceLocatorFieldEditor extends StringFieldEditor {
if (type == IResource.FILE) {
final FileDialog dialog = new FileDialog(getTextControl().getShell());
dialog.setText("Select the target file.");
Path path = new Path(resolvedPath.getPath());
IPath path = URIUtil.toPath(resolvedPath);
dialog.setFilterPath(path.removeLastSegments(1).toOSString());
selection = dialog.open();
} else {
final DirectoryDialog dialog = new DirectoryDialog(getTextControl().getShell());
dialog.setMessage("Select the target folder.");
dialog.setFilterPath(resolvedPath.getPath());
dialog.setFilterPath(URIUtil.toPath(resolvedPath).toOSString());
selection = dialog.open();
}
if (selection != null) {
......@@ -286,8 +285,8 @@ public class TITANResourceLocatorFieldEditor extends StringFieldEditor {
}
final URI path = URIUtil.toURI(target);
final URI resolvedPath = TITANPathUtilities.resolvePathURI(target, rootPath);
final String message = "Resolved location: " + resolvedPath.getPath();
final URI resolvedPath = TITANPathUtilities.resolvePathURI(target, rootPath);
final String message = "Resolved location: " + URIUtil.toPath(resolvedPath);
resolvedPathLabelText.setText(message);
......@@ -317,23 +316,16 @@ public class TITANResourceLocatorFieldEditor extends StringFieldEditor {
}
final IPathVariableManager pathVariableManager = ResourcesPlugin.getWorkspace().getPathVariableManager();
final IPath path2 = new Path(result);
IPath resolvedPath = pathVariableManager.resolvePath(path2);
if (!resolvedPath.isValidPath(resolvedPath.toOSString())) {
//FIXME more precise error message
setErrorMessage("Invalid value");
return false;
}
URI uri = URIUtil.toURI(result);
URI resolvedURI = pathVariableManager.resolveURI(uri);
if (rootPath != null && !resolvedPath.isAbsolute()) {
final IPath path = new Path(target);
final String temp = PathUtil.getAbsolutePath(rootPath, path.toOSString());
if (temp != null) {
resolvedPath = new Path(temp);
if (!resolvedPath.isAbsolute()) {
setErrorMessage("Could not be resolved to an absolute path");
return false;
}
if (rootPath != null && !resolvedURI.isAbsolute()) {
URI root = URIUtil.toURI(rootPath);
URI absoluteURI = root.resolve(resolvedURI);
if (absoluteURI != null && !absoluteURI.isAbsolute()) {
setErrorMessage("Could not be resolved to an absolute path");
return false;
}
}
......
......@@ -14,6 +14,7 @@ import java.util.List;
import java.util.Map;
import org.antlr.v4.runtime.tree.ParseTree;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
......@@ -153,7 +154,7 @@ public final class ConfigFileHandler {
private void processFile(final Path actualFile) {
final CfgAnalyzer analyzer = new CfgAnalyzer();
final IWorkspaceRoot wroot = ResourcesPlugin.getWorkspace().getRoot();
final IFile[] files = wroot.findFilesForLocation(actualFile);
final IFile[] files = wroot.findFilesForLocationURI(URIUtil.toURI(actualFile));
if (files.length == 0) {
ErrorReporter.logError("The file " + actualFile.toOSString()
......
......@@ -22,6 +22,7 @@ import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
......@@ -781,7 +782,7 @@ public final class InternalMakefileGenerator {
String tempProjectLocation = location.toOSString();
for (String temp : optionList) {
URI uri = TITANPathUtilities.resolvePathURI(temp, tempProjectLocation);
temp = PathConverter.convert(uri.getPath(), reportDebugInformation,
temp = PathConverter.convert(URIUtil.toPath(uri).toOSString(), reportDebugInformation,
TITANDebugConsole.getConsole());
contents.append(" -I").append(temp);
}
......@@ -835,7 +836,7 @@ public final class InternalMakefileGenerator {
String tempProjectLocation = location.toOSString();
for (String option : optionList) {
URI uri = TITANPathUtilities.resolvePathURI(option, tempProjectLocation);
option = PathConverter.convert(uri.getPath(), true, TITANDebugConsole.getConsole());
option = PathConverter.convert(URIUtil.toPath(uri).toOSString(), true, TITANDebugConsole.getConsole());
contents.append(" -I").append(option);
}
}
......@@ -2112,7 +2113,7 @@ public final class InternalMakefileGenerator {
String tempProjectLocation = location.toOSString();
for (String option : optionList) {
URI uri = TITANPathUtilities.resolvePathURI(option, tempProjectLocation);
option = PathConverter.convert(uri.getPath(), reportDebugInformation,
option = PathConverter.convert(URIUtil.toPath(uri).toOSString(), reportDebugInformation,
TITANDebugConsole.getConsole());
contents.append(' ').append(option);
}
......@@ -2138,7 +2139,7 @@ public final class InternalMakefileGenerator {
String tempProjectLocation = location.toOSString();
for (String temp : optionList) {
URI uri = TITANPathUtilities.resolvePathURI(temp, tempProjectLocation);
temp = PathConverter.convert(uri.getPath(), true, TITANDebugConsole.getConsole());
temp = PathConverter.convert(URIUtil.toPath(uri).toOSString(), true, TITANDebugConsole.getConsole());
contents.append(" -L").append(temp);
}
}
......@@ -2244,7 +2245,7 @@ public final class InternalMakefileGenerator {
String temp = ResourceUtils.getPersistentProperty(project, ProjectBuildPropertyData.QUALIFIER, MakefileCreationData.TARGET_EXECUTABLE_PROPERTY);
if (temp != null && temp.trim().length() > 0) {
URI resolvedURI = TITANPathUtilities.resolvePathURI(temp, projectLocation);
etsName = PathConverter.convert(resolvedURI.getPath(), reportDebugInformation, TITANDebugConsole.getConsole());
etsName = PathConverter.convert(URIUtil.toPath(resolvedURI).toOSString(), reportDebugInformation, TITANDebugConsole.getConsole());
} else {
temp = project.getName();
if (Platform.OS_WIN32.equals(Platform.getOS())) {
......
......@@ -7,7 +7,9 @@
******************************************************************************/
package org.eclipse.titan.designer.wizards.projectFormat;
import org.eclipse.core.runtime.IPath;
import java.net.URI;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
......@@ -26,8 +28,8 @@ import org.eclipse.swt.widgets.Text;
* */
public class EditPathVariableDialog extends Dialog {
private String name;
private IPath oldValue;
private IPath actualValue;
private URI oldValue;
private URI actualValue;
private Text newValue;
private final ModifyListener modifyListener = new ModifyListener() {
......@@ -38,7 +40,7 @@ public class EditPathVariableDialog extends Dialog {
}
};
public EditPathVariableDialog(final Shell shell, final String name, final IPath oldValue, final IPath actualValue) {
public EditPathVariableDialog(final Shell shell, final String name, final URI oldValue, final URI actualValue) {
super(shell);
setShellStyle(shell.getStyle() | SWT.RESIZE);
this.name = name;
......@@ -52,7 +54,7 @@ public class EditPathVariableDialog extends Dialog {
newShell.setText("Errors during loading path variables.");
}
public IPath getActualValue() {
public URI getActualValue() {
return actualValue;
}
......@@ -101,7 +103,7 @@ public class EditPathVariableDialog extends Dialog {
String temp = newValue.getText();
Path tempPath = new Path(temp);
if (tempPath.isValidPath(temp)) {
actualValue = tempPath;
actualValue = URIUtil.toURI(tempPath);
getButton(OK).setEnabled(true);
} else {
getButton(OK).setEnabled(false);
......
......@@ -7,7 +7,9 @@
******************************************************************************/
package org.eclipse.titan.designer.wizards.projectFormat;
import org.eclipse.core.runtime.IPath;
import java.net.URI;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
......@@ -26,7 +28,7 @@ import org.eclipse.swt.widgets.Text;
* */
public class NewPathVariableDialog extends Dialog {
private String name;
private IPath actualValue;
private URI actualValue;
private Text newValue;
private final ModifyListener modifyListener = new ModifyListener() {
......@@ -37,7 +39,7 @@ public class NewPathVariableDialog extends Dialog {
}
};
public NewPathVariableDialog(final Shell shell, final String name, final IPath actualValue) {
public NewPathVariableDialog(final Shell shell, final String name, final URI actualValue) {
super(shell);
setShellStyle(shell.getStyle() | SWT.RESIZE);
this.name = name;
......@@ -50,7 +52,7 @@ public class NewPathVariableDialog extends Dialog {
newShell.setText("Errors during loading path variables.");
}
public IPath getActualValue() {
public URI getActualValue() {
return actualValue;
}
......@@ -90,7 +92,7 @@ public class NewPathVariableDialog extends Dialog {
String temp = newValue.getText();
Path tempPath = new Path(temp);
if (tempPath.isValidPath(temp)) {
actualValue = tempPath;
actualValue = URIUtil.toURI(tempPath);
getButton(OK).setEnabled(true);
} else {
getButton(OK).setEnabled(false);
......
......@@ -748,7 +748,7 @@ public class TpdImporter {
if (headless) {
try {
pathVariableManager.setValue(variableName, new Path(variableValue));
pathVariableManager.setURIValue(variableName, URIUtil.toURI(variableValue));
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace("While setting path variable `" + variableName + "' in headless mode", e);
}
......@@ -758,22 +758,22 @@ public class TpdImporter {
public void run() {
try {
if (pathVariableManager.isDefined(variableName)) {
IPath path = pathVariableManager.getValue(variableName);
if (!variableValue.equals(path.toString())) {
EditPathVariableDialog dialog = new EditPathVariableDialog(shell, variableName, path, new Path(
URI uri = pathVariableManager.getURIValue(variableName);
if (!variableValue.equals(URIUtil.toPath(uri))) {
EditPathVariableDialog dialog = new EditPathVariableDialog(shell, variableName, uri, URIUtil.toURI(
variableValue));
if (Window.OK == dialog.open()) {
IPath actualValue = dialog.getActualValue();
pathVariableManager.setValue(variableName, actualValue);
URI actualValue = dialog.getActualValue();
pathVariableManager.setURIValue(variableName, actualValue);
}
}
} else {
// check whether we have non null shell
if (shell != null) {
NewPathVariableDialog dialog = new NewPathVariableDialog(shell, variableName, new Path(variableValue));
NewPathVariableDialog dialog = new NewPathVariableDialog(shell, variableName, URIUtil.toURI(variableValue));
if (Window.OK == dialog.open()) {
IPath actualValue = dialog.getActualValue();
pathVariableManager.setValue(variableName, actualValue);
URI actualValue = dialog.getActualValue();
pathVariableManager.setURIValue(variableName, actualValue);
}
}
}
......
......@@ -283,7 +283,7 @@ public abstract class BaseExecutor {
String path = configuration.getAttribute(attribute, (String) null);
if (!isNullOrEmpty(path)) {
URI uri = TITANPathUtilities.resolvePathURI(path, projectLocation);
path = uri.getPath();
path = URIUtil.toPath(uri).toOSString();
}
return path;
}
......@@ -535,7 +535,7 @@ public abstract class BaseExecutor {
path = TITANPathUtilities.resolvePathURI(controller.workingdirectory(), actualProject.getLocation().toOSString());
}
}
String workingDirResult = PathConverter.convert(oldStyleWorkingDir ? controller.workingdirectory() : path.getPath(), true, TITANConsole.getConsole());
String workingDirResult = PathConverter.convert(oldStyleWorkingDir ? controller.workingdirectory() : URIUtil.toPath(path).toOSString(), true, TITANConsole.getConsole());
command = command.replace(REPLACEABLEHOSTWORKIGNDIRECTORY, workingDirResult);
boolean oldStyleExecutable = true;
......@@ -548,7 +548,7 @@ public abstract class BaseExecutor {
path = TITANPathUtilities.resolvePathURI(controller.executable(), actualProject.getLocation().toOSString());
}
}
String executableResult = PathConverter.convert(oldStyleExecutable ? controller.executable() : path.getPath(), true, TITANConsole.getConsole());
String executableResult = PathConverter.convert(oldStyleExecutable ? controller.executable() : URIUtil.toPath(path).toOSString(), true, TITANConsole.getConsole());
String result = PathUtil.getRelativePath(workingDirResult, executableResult);
if (!result.equals(executableResult)) {
result = "./" + result;
......
......@@ -153,7 +153,7 @@ public final class HostControllerDialog extends Dialog {
} else {
workingDirPath = TITANPathUtilities.resolvePathURI(workingdirectoryText.getStringValue(), project.getLocation().toOSString());
}
example = example.replace(REPLACEABLEHOSTWORKIGNDIRECTORY, workingDirPath.getPath());
example = example.replace(REPLACEABLEHOSTWORKIGNDIRECTORY, URIUtil.toPath(workingDirPath).toOSString());
URI executablePath;
if (null == project) {
......@@ -161,7 +161,7 @@ public final class HostControllerDialog extends Dialog {
} else {
executablePath = TITANPathUtilities.resolvePathURI(executableText.getStringValue(), project.getLocation().toOSString());
}
String path = PathUtil.getRelativePath(workingDirPath.getPath(), executablePath.getPath());
String path = PathUtil.getRelativePath(URIUtil.toPath(workingDirPath).toOSString(), URIUtil.toPath(executablePath).toOSString());
example = example.replace(REPLACEABLEHOSTEXECUTABLE, path);
String hostName;
......
......@@ -482,7 +482,7 @@ public abstract class BaseMainControllerTab extends AbstractLaunchConfigurationT
MessageConsoleStream stream = TITANConsole.getConsole().newMessageStream();
Process proc;
String exename = PathConverter.convert(executableFileName.getPath(), true, TITANDebugConsole.getConsole());
String exename = PathConverter.convert(file.getPath(), true, TITANDebugConsole.getConsole());
StringBuilder lastParam = new StringBuilder(exename);
lastParam.append(" -v");
List<String> shellCommand;
......@@ -629,7 +629,7 @@ public abstract class BaseMainControllerTab extends AbstractLaunchConfigurationT
if (file.exists() && file.isFile()) {
exceptions.clear();
ConfigFileHandler configHandler = new ConfigFileHandler();
configHandler.readFromFile(uri.getPath());
configHandler.readFromFile(file.getPath());
if (configHandler.parseExceptions().isEmpty()) {
Map<String, String> env = new HashMap<String, String>(System.getenv());
Map<String, String> tempEnvironmentalVariables;
......@@ -654,7 +654,7 @@ public abstract class BaseMainControllerTab extends AbstractLaunchConfigurationT
}
configurationFileIsValid = false;
exceptions.clear();
exceptions.add(new Exception("The path `" + uri.getPath() + "' does not seem to be correct."));
exceptions.add(new Exception("The path `" + URIUtil.toPath(uri) + "' does not seem to be correct."));
automaticExecuteSectionExecution.setEnabled(false);
}
......
......@@ -7,10 +7,19 @@
******************************************************************************/
package org.eclipse.titan.executor.views.notification;
import static org.eclipse.titan.executor.views.executormonitor.ExecutorMonitorView.EXECUTORMONITOR_VIEW_ID;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.List;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
......@@ -38,15 +47,6 @@ import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.part.ViewPart;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.List;
import static org.eclipse.titan.executor.views.executormonitor.ExecutorMonitorView.EXECUTORMONITOR_VIEW_ID;
/**
* @author Kristof Szabados
* */
......@@ -302,7 +302,7 @@ public final class NotificationView extends ViewPart implements ISelectionListen
}
final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
final IFile[] outputFiles = root.findFilesForLocation(new Path(filePath));
final IFile[] outputFiles = root.findFilesForLocationURI(URIUtil.toURI(filePath));
ResourceUtils.refreshResources(Arrays.asList(outputFiles));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment