blob: 79be4e87701db4641f419f269cff07a0ab2b77e8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
/*******************************************************************************
* Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.tcf.te.launch.core.persistence.projects;
import java.util.List;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.tcf.te.launch.core.interfaces.IReferencedProjectItem;
import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification;
import org.eclipse.tcf.te.launch.core.lm.interfaces.IReferencedProjectLaunchAttributes;
import org.eclipse.tcf.te.launch.core.persistence.AbstractItemListPersistenceDelegate;
import org.eclipse.tcf.te.launch.core.persistence.AbstractItemListXMLParser;
/**
* Referenced projects persistence delegate.
*/
public class ReferencedProjectsPersistenceDelegate {
private static final String TAG_PROJECT = "referencedProject"; //$NON-NLS-1$
private static final AbstractItemListPersistenceDelegate<IReferencedProjectItem> delegate =
new AbstractItemListPersistenceDelegate<IReferencedProjectItem>(TAG_PROJECT, IReferencedProjectLaunchAttributes.ATTR_REFERENCED_PROJECTS) {
@Override
protected AbstractItemListXMLParser<IReferencedProjectItem> getXMLParser() {
return new AbstractItemListXMLParser<IReferencedProjectItem>(TAG_PROJECT) {
@Override
protected Class<?> getReadClass() {
return IReferencedProjectItem.class;
}
};
}
};
/**
* Saves the selected referenced project items to the specified launch configuration working copy. If the
* selected referenced project items are <code>null</code> or empty, the attribute will be removed from
* the specified launch configuration working copy.
*
* @param wc The launch configuration working copy. Must not be <code>null</code>.
* @param items The referenced project items to save or <code>null</code>.
*/
public final static void setReferencedProjects(ILaunchConfigurationWorkingCopy wc, IReferencedProjectItem[] items) {
delegate.setItems(wc, items);
}
/**
* Saves the selected referenced project items to the specified launch specification. If the selected
* referenced project items are <code>null</code> or empty, the attribute will be removed from the
* specified launch specification.
*
* @param launchSpec The launch specification. Must not be <code>null</code>.
* @param items The referenced project items to save or <code>null</code>.
*/
public final static void setReferencedProjects(ILaunchSpecification launchSpec, IReferencedProjectItem[] items) {
delegate.setItems(launchSpec, items);
}
/**
* Writes the given referenced project items into a string encoded in XML.
*
* @param items The referenced project items to encode. Must not be <code>null</code>.
* @return The full XML representation of the given items or <code>null</code>.
*/
public final static String encodeReferencedProjectItems(IReferencedProjectItem[] items) {
return delegate.encodeItems(items);
}
/**
* Reads the selected referenced project items from the given XML encoded string.
*
* @param encodedItems The selected referenced project items encoded as XML string. Must not be <code>null</code>.
* @return The selected referenced project items or an empty array.
*/
public final static IReferencedProjectItem[] decodeReferencedProjectItems(String encodedItems) {
List<IReferencedProjectItem> list = delegate.decodeItems(encodedItems);
return list.toArray(new IReferencedProjectItem[list.size()]);
}
/**
* Returns the list of configured referenced project items from the given launch configuration.
* <p>
* If the given launch configuration is <code>null</code> and the method will return an empty
* array.
*
* @param configuration The launch configuration or <code>null</code>.
* @return The list of configured referenced project items or an empty array.
*/
public static final IReferencedProjectItem[] getReferencedProjects(ILaunchConfiguration configuration) {
List<IReferencedProjectItem> list = delegate.getItems(configuration);
return list.toArray(new IReferencedProjectItem[list.size()]);
}
/**
* Returns the list of configured referenced project items from the given launch specification.
* <p>
* If the given launch specification is <code>null</code> and the method will return an empty
* array.
*
* @param launchSpec The launch specification or <code>null</code>.
* @return The list of configured referenced project items or an empty array.
*/
public static final IReferencedProjectItem[] getReferencedProjects(ILaunchSpecification launchSpec) {
List<IReferencedProjectItem> list = delegate.getItems(launchSpec);
return list.toArray(new IReferencedProjectItem[list.size()]);
}
}
|