use of org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy in project linuxtools by eclipse.
the class FileProxyTest method testLocalFileProxy.
@Test
public void testLocalFileProxy() {
IRemoteFileProxy fileProxy = null;
try {
fileProxy = proxyManager.getFileProxy(localProject.getProject());
assertTrue("Should have returned a remote launcher", fileProxy instanceof LocalFileProxy);
} catch (CoreException e) {
fail("Should have returned a launcher: " + e.getCause());
}
/*
* Test getDirectorySeparator()
*/
String ds = fileProxy.getDirectorySeparator();
assertNotNull(ds);
/*
* Test getResource()
*/
IFileStore actualFileStore = fileProxy.getResource(localProject.getProject().getLocation().toOSString());
assertNotNull(actualFileStore);
IFileStore expectedFileStore = null;
try {
expectedFileStore = EFS.getStore(localProject.getLocationURI());
} catch (CoreException e) {
fail("Unabled to get FileStore to local project: " + e.getMessage());
}
assertEquals("FileStore to local project folder diverge", expectedFileStore, actualFileStore);
assertTrue(actualFileStore.fetchInfo().isDirectory());
actualFileStore = fileProxy.getResource("/filenotexits");
assertNotNull(actualFileStore);
IFileInfo fileInfo = actualFileStore.fetchInfo();
assertNotNull(fileInfo);
assertFalse(fileInfo.exists());
/*
* Test getWorkingDir()
*/
URI workingDir = fileProxy.getWorkingDir();
assertNotNull(workingDir);
assertEquals(localProject.getLocationURI(), workingDir);
/*
* Test toPath()
*/
assertEquals(localProject.getProject().getLocation().toOSString(), fileProxy.toPath(localProject.getLocationURI()));
}
use of org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy in project linuxtools by eclipse.
the class RuntimeProcessFactory method exec.
/**
* Execute one command using the path selected in 'Linux Tools Path' preference page
* in the informed project.
* @param cmdarray An array with the command to be executed and its params.
* @param envp An array with extra enviroment variables to be used when running
* the command
* @param dir The directory used as current directory to run the command.
* @param project The current project. If null, only system path will be
* used to look for the command.
* @param pty PTY for use with Eclipse Console.
* @return The process started by exec.
* @throws IOException If problem executing the command occured.
*
* @since 3.0
*/
public Process exec(String[] cmdarray, String[] envp, IFileStore dir, IProject project, PTY pty) throws IOException {
Process p = null;
try {
cmdarray = fillPathCommand(cmdarray, project);
String command = cmdarray[0];
URI uri = URI.create(command);
IPath changeToDir = null;
IPath path;
IRemoteCommandLauncher launcher;
envp = updateEnvironment(envp, project);
if (project != null) {
IRemoteFileProxy proxy = RemoteProxyManager.getInstance().getFileProxy(project);
path = new Path(proxy.toPath(uri));
launcher = RemoteProxyManager.getInstance().getLauncher(project);
if (dir != null) {
changeToDir = new Path(proxy.toPath(dir.toURI()));
}
} else {
path = new Path(uri.getPath());
launcher = RemoteProxyManager.getInstance().getLauncher(uri);
if (dir != null) {
changeToDir = new Path(dir.toURI().getPath());
}
}
List<String> cmdlist = new ArrayList<>(Arrays.asList(cmdarray));
cmdlist.remove(0);
cmdlist.toArray(cmdarray);
cmdarray = cmdlist.toArray(new String[0]);
if (pty == null) {
p = launcher.execute(path, cmdarray, envp, changeToDir, new NullProgressMonitor());
} else {
p = launcher.execute(path, cmdarray, envp, changeToDir, new NullProgressMonitor(), pty);
}
} catch (CoreException e) {
e.printStackTrace();
}
return p;
}
use of org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy in project linuxtools by eclipse.
the class KernelBrowserView method refresh.
/**
* Updates the kernel source displayed to the user with the new kernel source tree. Usually
* a response to the user changing the preferences related to the kernel source location, requiring
* that the application update the kernel source information.
*/
@Override
public void refresh() {
displayLoadingMessage();
IPreferenceStore p = IDEPlugin.getDefault().getPreferenceStore();
String kernelSource = p.getString(IDEPreferenceConstants.P_KERNEL_SOURCE);
if (kernelSource == null || kernelSource.length() < 1) {
// $NON-NLS-1$
displayMessage(Localization.getString("KernelBrowserView.NoKernelSourceFound"));
return;
}
String localOrRemote = p.getString(IDEPreferenceConstants.P_REMOTE_LOCAL_KERNEL_SOURCE);
URI kernelLocationURI = null;
IRemoteFileProxy proxy = null;
boolean remote = localOrRemote.equals(PathPreferencePage.REMOTE);
if (remote) {
boolean error = false;
try {
kernelLocationURI = IDEPlugin.getDefault().createRemoteUri(kernelSource);
if (kernelLocationURI == null) {
error = true;
} else {
proxy = RemoteProxyManager.getInstance().getFileProxy(kernelLocationURI);
if (!validateProxy(proxy, kernelSource)) {
error = true;
}
}
} catch (CoreException e2) {
error = true;
}
if (error) {
// $NON-NLS-1$
displayMessage(Localization.getString("KernelBrowserView.KernelSourceDirNotFound"));
return;
}
}
KernelRefreshJob refreshJob = new KernelRefreshJob(remote, kernelLocationURI, proxy, kernelSource);
refreshJob.setPriority(Job.SHORT);
refreshJob.schedule();
}
use of org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy in project linuxtools by eclipse.
the class KernelSourceTree method buildKernelTree.
/**
* Builds the kernel tree from file parameter direct and stores the excluded string array.
*
* @param direct The file to include into the tree.
* @param excluded The string array to store as excluded.
*/
public void buildKernelTree(String direct, String[] excluded) {
if (direct == null || direct.isEmpty()) {
kernelTree = null;
return;
}
try {
URI locationURI = new URI(direct);
IRemoteFileProxy proxy = RemoteProxyManager.getInstance().getFileProxy(locationURI);
this.buildKernelTree(locationURI, excluded, proxy, null);
} catch (URISyntaxException e) {
kernelTree = null;
} catch (CoreException e) {
kernelTree = null;
}
}
use of org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy in project linuxtools by eclipse.
the class ProfileUIUtils method openEditorAndSelect.
/**
* Open a file in the Editor at the specified offset, highlighting the given length
*
* @param path : Absolute path pointing to the file which will be opened.
* @param line - line number to select, 0 to not select a line
* @param project - current project object
* @throws BadLocationException - Line number not valid in file
* @throws PartInitException if the editor could not be initialized
* @throws CoreException if the proxy cannot be initialized
* @since 3.1
*/
public static void openEditorAndSelect(String path, int line, IProject project) throws PartInitException, BadLocationException, CoreException {
IWorkbenchPage activePage = ProfileUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
IRemoteFileProxy proxy = null;
proxy = RemoteProxyManager.getInstance().getFileProxy(project);
IFileStore file = proxy.getResource(path);
if (file.fetchInfo().exists()) {
IEditorPart editor = IDE.openEditorOnFileStore(activePage, file);
if (editor instanceof ITextEditor) {
ITextEditor textEditor = (ITextEditor) editor;
if (line > 0) {
IDocumentProvider provider = textEditor.getDocumentProvider();
IDocument document = provider.getDocument(textEditor.getEditorInput());
// zero-indexed
int start = document.getLineOffset(line - 1);
textEditor.selectAndReveal(start, 0);
}
}
}
}
Aggregations