equal
deleted
inserted
replaced
34 import org.symbian.tools.mtw.core.projects.IMTWProject; |
34 import org.symbian.tools.mtw.core.projects.IMTWProject; |
35 import org.symbian.tools.mtw.ui.deployment.IDeploymentTarget; |
35 import org.symbian.tools.mtw.ui.deployment.IDeploymentTarget; |
36 import org.symbian.tools.mtw.ui.deployment.IDeploymentTargetType; |
36 import org.symbian.tools.mtw.ui.deployment.IDeploymentTargetType; |
37 |
37 |
38 public class ProjectMemo { |
38 public class ProjectMemo { |
39 private static final String DEPLOYMENT_PROVIDER = "providerId"; |
39 private static final String TARGET_TYPE = "typeId"; |
40 private static final String TARGET = "targetId"; |
40 private static final String TARGET = "targetId"; |
41 private static final String TARGET_CONFIGURATION = "target"; |
41 private static final String TARGET_CONFIGURATION = "target"; |
42 private static final String MEMO_TYPE = "deployment"; |
42 private static final String MEMO_TYPE = "deployment"; |
43 |
43 |
44 private final IMTWProject project; |
44 private final IMTWProject project; |
49 } |
49 } |
50 |
50 |
51 public synchronized void setDeploymentTarget(String providerId, IDeploymentTarget target) { |
51 public synchronized void setDeploymentTarget(String providerId, IDeploymentTarget target) { |
52 try { |
52 try { |
53 checkMemento(); |
53 checkMemento(); |
54 memento.putString(DEPLOYMENT_PROVIDER, providerId); |
54 memento.putString(TARGET_TYPE, providerId); |
55 memento.putString(TARGET, target.getId()); |
55 memento.putString(TARGET, target.getId()); |
56 final IMemento child = memento.createChild(TARGET_CONFIGURATION); |
56 IMemento child = null; |
|
57 IMemento[] children = memento.getChildren(TARGET_CONFIGURATION); |
|
58 for (IMemento memento : children) { |
|
59 if (providerId.equals(memento.getString(TARGET_TYPE)) |
|
60 && target.getId().equals(memento.getString(TARGET))) { |
|
61 child = memento; |
|
62 } |
|
63 } |
|
64 if (child == null) { |
|
65 child = memento.createChild(TARGET_CONFIGURATION); |
|
66 child.putString(TARGET_TYPE, providerId); |
|
67 child.putString(TARGET, target.getId()); |
|
68 } |
57 target.save(child); |
69 target.save(child); |
58 saveMemento(); |
70 saveMemento(); |
59 } catch (CoreException e) { |
71 } catch (CoreException e) { |
60 MTWCoreUI.log(e); |
72 MTWCoreUI.log(e); |
61 } catch (IOException e) { |
73 } catch (IOException e) { |
91 } |
103 } |
92 |
104 |
93 public IDeploymentTarget getPreviousDeploymentTarget() { |
105 public IDeploymentTarget getPreviousDeploymentTarget() { |
94 try { |
106 try { |
95 checkMemento(); |
107 checkMemento(); |
96 String type = memento.getString(DEPLOYMENT_PROVIDER); |
108 String type = memento.getString(TARGET_TYPE); |
97 if (type != null) { |
109 if (type != null) { |
98 final IDeploymentTargetType provider = MTWCoreUI.getDefault().getDeploymentTypesRegistry() |
110 final IDeploymentTargetType provider = MTWCoreUI.getDefault().getDeploymentTypesRegistry() |
99 .getType(type); |
111 .getType(type); |
100 if (provider != null) { |
112 if (provider != null) { |
101 IDeploymentTarget target = provider.findTarget(project, memento.getString(TARGET)); |
113 IDeploymentTarget target = provider.findTarget(project, memento.getString(TARGET)); |
102 if (target != null) { |
114 if (target != null) { |
103 IMemento child = memento.getChild(TARGET_CONFIGURATION); |
|
104 if (child != null) { |
|
105 target.load(child); |
|
106 } |
|
107 return target; |
115 return target; |
108 } |
116 } |
109 } |
117 } |
110 } |
118 } |
111 } catch (CoreException e) { |
119 } catch (CoreException e) { |
114 MTWCoreUI.log(e); |
122 MTWCoreUI.log(e); |
115 } |
123 } |
116 return null; |
124 return null; |
117 } |
125 } |
118 |
126 |
|
127 public IMemento getMemo(String targetType, IDeploymentTarget target) { |
|
128 if (memento != null) { |
|
129 IMemento[] children = memento.getChildren(TARGET_CONFIGURATION); |
|
130 for (IMemento memento : children) { |
|
131 if (targetType.equals(memento.getString(TARGET_TYPE)) |
|
132 && target.getId().equals(memento.getString(TARGET))) { |
|
133 return memento; |
|
134 } |
|
135 } |
|
136 } |
|
137 return null; |
|
138 } |
|
139 |
119 } |
140 } |