summaryrefslogtreecommitdiffstats
path: root/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/model/ProjectInfo.java
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/model/ProjectInfo.java')
-rw-r--r--plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/model/ProjectInfo.java117
1 files changed, 117 insertions, 0 deletions
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/model/ProjectInfo.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/model/ProjectInfo.java
new file mode 100644
index 0000000..119782d
--- /dev/null
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/model/ProjectInfo.java
@@ -0,0 +1,117 @@
1/*****************************************************************************
2 * Copyright (c) 2013 Ken Gilmer, Intel Corporation
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Ken Gilmer - initial API and implementation
10 * Ioana Grigoropol (Intel) - adapt class for remote support
11 *******************************************************************************/
12package org.yocto.bc.ui.model;
13
14import java.net.URI;
15import java.net.URISyntaxException;
16
17import org.eclipse.core.runtime.IProgressMonitor;
18import org.eclipse.core.runtime.NullProgressMonitor;
19import org.eclipse.ptp.remote.core.IRemoteServices;
20import org.eclipse.rse.core.model.IHost;
21import org.eclipse.rse.services.files.IFileService;
22import org.yocto.bc.bitbake.ProjectInfoHelper;
23import org.yocto.bc.ui.filesystem.YoctoLocation;
24import org.yocto.remote.utils.RemoteHelper;
25
26public class ProjectInfo implements IModelElement {
27 private String name;
28 private YoctoLocation location;
29 private String init;
30 private IHost connection;
31 private IRemoteServices remoteServices;
32
33 public ProjectInfo() {
34 }
35
36 public String getInitScriptPath() {
37 return init;
38 }
39 public String getProjectName() {
40 return name;
41 }
42 public URI getOriginalURI() {
43 return location.getOriginalURI();
44 }
45
46 public URI getOEFSURI() {
47 return location.getOEFSURI();
48 }
49
50 @Override
51 public void initialize() throws Exception {
52 name = new String();
53 location = new YoctoLocation();
54 init = new String();
55 }
56
57 public void setInitScriptPath(String init) {
58 this.init = init;
59 }
60
61 public void setLocationURI(URI location) {
62 if (this.location == null)
63 this.location = new YoctoLocation();
64 if (location.getScheme().equalsIgnoreCase("oefs")) {
65 if (this.name == null) {
66 String path = location.getPath();
67 this.name = path.substring(path.lastIndexOf("/") + 1);
68 }
69 location = RemoteHelper.retrieveURIFromMetaArea(this.name);
70 }
71 this.location.setOriginalURI(location);
72 try {
73 this.location.setOEFSURI(new URI(ProjectInfoHelper.OEFS_SCHEME + location.getPath() ));
74 } catch (URISyntaxException e) {
75 try {
76 this.location.setOEFSURI(new URI(""));
77 } catch (URISyntaxException e1) {
78 e1.printStackTrace();
79 }
80 e.printStackTrace();
81 }
82 }
83
84 public void setName(String name) {
85 this.name = name;
86 }
87
88 public IHost getConnection() {
89 if (connection == null && RemoteHelper.isInitialized(getOriginalURI())) {
90 connection = RemoteHelper.getRemoteConnectionForURI(location.getOriginalURI(), new NullProgressMonitor());
91 }
92 return connection;
93 }
94
95 public void setConnection(IHost connection) {
96 this.connection = connection;
97 }
98
99 public IRemoteServices getRemoteServices() {
100 return remoteServices;
101 }
102
103 public void setRemoteServices(IRemoteServices remoteServices) {
104 this.remoteServices = remoteServices;
105 }
106
107 public IFileService getFileService(IProgressMonitor monitor){
108 try {
109 if (!RemoteHelper.isInitialized(getOriginalURI()))
110 return null;
111 return RemoteHelper.getConnectedRemoteFileService(connection, monitor);
112 } catch (Exception e) {
113 e.printStackTrace();
114 return null;
115 }
116 }
117}