|
Lines 11-17
Link Here
|
| 11 |
|
11 |
|
| 12 |
package org.eclipse.ptp.rm.lml.internal.core.model; |
12 |
package org.eclipse.ptp.rm.lml.internal.core.model; |
| 13 |
|
13 |
|
| 14 |
import java.io.OutputStream; |
|
|
| 15 |
import java.math.BigInteger; |
14 |
import java.math.BigInteger; |
| 16 |
import java.util.ArrayList; |
15 |
import java.util.ArrayList; |
| 17 |
import java.util.HashMap; |
16 |
import java.util.HashMap; |
|
Lines 20-58
Link Here
|
| 20 |
import java.util.List; |
19 |
import java.util.List; |
| 21 |
import java.util.Map; |
20 |
import java.util.Map; |
| 22 |
|
21 |
|
| 23 |
import javax.xml.bind.JAXBContext; |
22 |
import org.eclipse.ptp.rm.lml.core.ILMLCoreConstants; |
| 24 |
import javax.xml.bind.JAXBElement; |
|
|
| 25 |
import javax.xml.bind.JAXBException; |
| 26 |
import javax.xml.bind.Marshaller; |
| 27 |
import javax.xml.namespace.QName; |
| 28 |
|
| 29 |
import org.eclipse.ptp.rm.lml.core.events.ILguiUpdatedEvent; |
23 |
import org.eclipse.ptp.rm.lml.core.events.ILguiUpdatedEvent; |
| 30 |
import org.eclipse.ptp.rm.lml.core.listeners.ILguiListener; |
24 |
import org.eclipse.ptp.rm.lml.core.listeners.ILguiListener; |
| 31 |
import org.eclipse.ptp.rm.lml.core.model.ILguiItem; |
25 |
import org.eclipse.ptp.rm.lml.core.model.ILguiItem; |
|
|
26 |
import org.eclipse.ptp.rm.lml.core.util.JAXBUtil; |
| 32 |
import org.eclipse.ptp.rm.lml.internal.core.elements.AbslayoutType; |
27 |
import org.eclipse.ptp.rm.lml.internal.core.elements.AbslayoutType; |
| 33 |
import org.eclipse.ptp.rm.lml.internal.core.elements.ChartType; |
|
|
| 34 |
import org.eclipse.ptp.rm.lml.internal.core.elements.ChartgroupType; |
| 35 |
import org.eclipse.ptp.rm.lml.internal.core.elements.ChartlayoutType; |
28 |
import org.eclipse.ptp.rm.lml.internal.core.elements.ChartlayoutType; |
| 36 |
import org.eclipse.ptp.rm.lml.internal.core.elements.ColumnType; |
|
|
| 37 |
import org.eclipse.ptp.rm.lml.internal.core.elements.ColumnlayoutType; |
29 |
import org.eclipse.ptp.rm.lml.internal.core.elements.ColumnlayoutType; |
| 38 |
import org.eclipse.ptp.rm.lml.internal.core.elements.ComponentType; |
30 |
import org.eclipse.ptp.rm.lml.internal.core.elements.ComponentType; |
| 39 |
import org.eclipse.ptp.rm.lml.internal.core.elements.ComponentlayoutType; |
31 |
import org.eclipse.ptp.rm.lml.internal.core.elements.ComponentlayoutType; |
| 40 |
import org.eclipse.ptp.rm.lml.internal.core.elements.DataType; |
|
|
| 41 |
import org.eclipse.ptp.rm.lml.internal.core.elements.GobjectType; |
32 |
import org.eclipse.ptp.rm.lml.internal.core.elements.GobjectType; |
| 42 |
import org.eclipse.ptp.rm.lml.internal.core.elements.InfoboxType; |
|
|
| 43 |
import org.eclipse.ptp.rm.lml.internal.core.elements.InfoboxlayoutType; |
33 |
import org.eclipse.ptp.rm.lml.internal.core.elements.InfoboxlayoutType; |
| 44 |
import org.eclipse.ptp.rm.lml.internal.core.elements.LayoutType; |
|
|
| 45 |
import org.eclipse.ptp.rm.lml.internal.core.elements.LguiType; |
34 |
import org.eclipse.ptp.rm.lml.internal.core.elements.LguiType; |
| 46 |
import org.eclipse.ptp.rm.lml.internal.core.elements.Nodedisplay; |
|
|
| 47 |
import org.eclipse.ptp.rm.lml.internal.core.elements.NodedisplaylayoutType; |
35 |
import org.eclipse.ptp.rm.lml.internal.core.elements.NodedisplaylayoutType; |
| 48 |
import org.eclipse.ptp.rm.lml.internal.core.elements.ObjectFactory; |
36 |
import org.eclipse.ptp.rm.lml.internal.core.elements.ObjectFactory; |
| 49 |
import org.eclipse.ptp.rm.lml.internal.core.elements.PaneType; |
|
|
| 50 |
import org.eclipse.ptp.rm.lml.internal.core.elements.SchemeType; |
| 51 |
import org.eclipse.ptp.rm.lml.internal.core.elements.SplitlayoutType; |
| 52 |
import org.eclipse.ptp.rm.lml.internal.core.elements.TableType; |
37 |
import org.eclipse.ptp.rm.lml.internal.core.elements.TableType; |
| 53 |
import org.eclipse.ptp.rm.lml.internal.core.elements.TablelayoutType; |
38 |
import org.eclipse.ptp.rm.lml.internal.core.elements.TablelayoutType; |
| 54 |
import org.eclipse.ptp.rm.lml.internal.core.elements.TextboxType; |
|
|
| 55 |
import org.eclipse.ptp.rm.lml.internal.core.elements.UsagebarType; |
| 56 |
import org.eclipse.ptp.rm.lml.internal.core.elements.UsagebarlayoutType; |
39 |
import org.eclipse.ptp.rm.lml.internal.core.elements.UsagebarlayoutType; |
| 57 |
|
40 |
|
| 58 |
/** |
41 |
/** |
|
Lines 64-69
Link Here
|
| 64 |
* functions, which allow to merge layouts to one lml-model |
47 |
* functions, which allow to merge layouts to one lml-model |
| 65 |
*/ |
48 |
*/ |
| 66 |
public class LayoutAccess extends LguiHandler { |
49 |
public class LayoutAccess extends LguiHandler { |
|
|
50 |
/* |
| 51 |
* create an objectfactory for all functions in this class |
| 52 |
*/ |
| 53 |
private static ObjectFactory objectFactory = new ObjectFactory(); |
| 54 |
|
| 55 |
private static final String LAYOUT_ENDING = "_layout";//$NON-NLS-1$ |
| 56 |
|
| 57 |
private static String DEAFULT_ABS = "abs_default";//$NON-NLS-1$ |
| 58 |
|
| 59 |
private static JAXBUtil jaxbUtil = JAXBUtil.getInstance(); |
| 60 |
|
| 67 |
/** |
61 |
/** |
| 68 |
* This method merges the layout information given by the "layout"-instance |
62 |
* This method merges the layout information given by the "layout"-instance |
| 69 |
* with the layout, which is included in "data". Component-layouts in "data" |
63 |
* with the layout, which is included in "data". Component-layouts in "data" |
|
Lines 85-96
Link Here
|
| 85 |
if (data == null || layout == null) { |
79 |
if (data == null || layout == null) { |
| 86 |
return data; |
80 |
return data; |
| 87 |
} |
81 |
} |
| 88 |
final LguiItem lgui = new LguiItem(data); |
82 |
final LguiItem lguiData = new LguiItem(data); |
| 89 |
final LayoutAccess la = new LayoutAccess(lgui, lgui.getLguiType()); |
|
|
| 90 |
// Replace component-layouts |
83 |
// Replace component-layouts |
| 91 |
for (final JAXBElement<?> el : layout.getObjectsAndRelationsAndInformation()) { |
84 |
for (final Object object : jaxbUtil.getObjects(layout)) { |
| 92 |
if (el.getValue() instanceof ComponentlayoutType) { |
85 |
if (object instanceof ComponentlayoutType) { |
| 93 |
la.replaceComponentLayout((ComponentlayoutType) el.getValue()); |
86 |
jaxbUtil.replaceComponentLayout(data, lguiData, (ComponentlayoutType) object); |
| 94 |
} |
87 |
} |
| 95 |
} |
88 |
} |
| 96 |
|
89 |
|
|
Lines 115-322
Link Here
|
| 115 |
* } } |
108 |
* } } |
| 116 |
**/ |
109 |
**/ |
| 117 |
|
110 |
|
| 118 |
// Overwrite layouts with the same name |
111 |
JAXBUtil.replaceGlobalLayout(layout, data); |
| 119 |
for (final JAXBElement<?> el : layout.getObjectsAndRelationsAndInformation()) { |
|
|
| 120 |
if (el.getValue() instanceof LayoutType) { |
| 121 |
if (!replaceGlobalLayout((LayoutType) el.getValue(), data)) { |
| 122 |
// If not replaced, insert it |
| 123 |
data.getObjectsAndRelationsAndInformation().add(el); |
| 124 |
} |
| 125 |
} |
| 126 |
} |
| 127 |
|
| 128 |
return data; |
112 |
return data; |
| 129 |
} |
113 |
} |
| 130 |
|
|
|
| 131 |
/** |
| 132 |
* Replace a global layout within the lml-model by a new one |
| 133 |
* |
| 134 |
* @param newlayout |
| 135 |
* new layout, which replaces the old in model with the same id |
| 136 |
* @param model |
| 137 |
* lgui-instance, which is changed |
| 138 |
*/ |
| 139 |
@SuppressWarnings("unchecked") |
| 140 |
public static boolean replaceGlobalLayout(LayoutType newlayout, LguiType model) { |
| 141 |
|
| 142 |
final List<JAXBElement<?>> all = model.getObjectsAndRelationsAndInformation(); |
| 143 |
|
| 144 |
// Go through all objects, search for layouttypes with newlayout.getId |
| 145 |
// as id and replace them with this layout |
| 146 |
for (int i = 0; i < all.size(); i++) { |
| 147 |
final JAXBElement<?> aobj = all.get(i); |
| 148 |
if (aobj.getValue() instanceof LayoutType) { |
| 149 |
final LayoutType old = (LayoutType) aobj.getValue(); |
| 150 |
if (old.getId().equals(newlayout.getId())) { |
| 151 |
((JAXBElement<LayoutType>) aobj).setValue(newlayout); |
| 152 |
return true; |
| 153 |
} |
| 154 |
} |
| 155 |
} |
| 156 |
|
| 157 |
return false; |
| 158 |
} |
| 159 |
|
| 160 |
/** |
| 161 |
* Search for gid-attributes of a pane and put it into neededComponents |
| 162 |
* Recursively search all graphical objects referenced by this pane |
| 163 |
* |
| 164 |
* @param p |
| 165 |
* part of SplitLayout, which is scanned for gid-attributes |
| 166 |
* @param neededComponents |
| 167 |
* resulting Hashset |
| 168 |
*/ |
| 169 |
private static void collectComponents(PaneType p, HashSet<String> neededComponents) { |
| 170 |
|
| 171 |
if (p.getGid() != null) { |
| 172 |
neededComponents.add(p.getGid()); |
| 173 |
} else { |
| 174 |
// top and bottom components? |
| 175 |
if (p.getBottom() != null) { |
| 176 |
collectComponents(p.getBottom(), neededComponents); |
| 177 |
collectComponents(p.getTop(), neededComponents); |
| 178 |
} else {// Left and right |
| 179 |
collectComponents(p.getLeft(), neededComponents); |
| 180 |
collectComponents(p.getRight(), neededComponents); |
| 181 |
} |
| 182 |
} |
| 183 |
|
| 184 |
} |
| 185 |
|
| 186 |
/** |
| 187 |
* Take a graphical object and minimize the data so that this instance is |
| 188 |
* valid against the LML-Schema but at the same time as small as possible. |
| 189 |
* |
| 190 |
* @param gobj |
| 191 |
* @return a copy of gobj with minimal size, only attributes in GobjectType |
| 192 |
* are copied and lower special elements which are needed to make |
| 193 |
* lml-model valid |
| 194 |
*/ |
| 195 |
@SuppressWarnings("unchecked") |
| 196 |
private static JAXBElement<GobjectType> minimizeGobjectType(GobjectType gobj) { |
| 197 |
|
| 198 |
String qname = "table"; //$NON-NLS-1$ |
| 199 |
final Class<GobjectType> c = (Class<GobjectType>) gobj.getClass(); |
| 200 |
|
| 201 |
GobjectType value = objectFactory.createGobjectType(); |
| 202 |
|
| 203 |
if (gobj instanceof TableType) { |
| 204 |
final TableType tt = objectFactory.createTableType(); |
| 205 |
final TableType orig = (TableType) gobj; |
| 206 |
tt.setContenttype(orig.getContenttype()); |
| 207 |
// copy all columns with pattern to table |
| 208 |
for (final ColumnType col : orig.getColumn()) { |
| 209 |
if (col.getPattern() != null) { |
| 210 |
tt.getColumn().add(col); |
| 211 |
} |
| 212 |
} |
| 213 |
|
| 214 |
value = tt; |
| 215 |
|
| 216 |
qname = "table"; //$NON-NLS-1$ |
| 217 |
} else if (gobj instanceof UsagebarType) { |
| 218 |
final UsagebarType ut = objectFactory.createUsagebarType(); |
| 219 |
|
| 220 |
ut.setCpucount(BigInteger.valueOf(0)); |
| 221 |
|
| 222 |
value = ut; |
| 223 |
|
| 224 |
qname = "usagebar"; //$NON-NLS-1$ |
| 225 |
} else if (gobj instanceof TextboxType) { |
| 226 |
final TextboxType ut = objectFactory.createTextboxType(); |
| 227 |
|
| 228 |
ut.setText(""); //$NON-NLS-1$ |
| 229 |
|
| 230 |
value = ut; |
| 231 |
|
| 232 |
qname = "text"; //$NON-NLS-1$ |
| 233 |
} else if (gobj instanceof InfoboxType) { |
| 234 |
final InfoboxType ut = objectFactory.createInfoboxType(); |
| 235 |
|
| 236 |
value = ut; |
| 237 |
|
| 238 |
qname = "infobox"; //$NON-NLS-1$ |
| 239 |
} else if (gobj instanceof Nodedisplay) {// Create minimal nodedisplay |
| 240 |
final Nodedisplay ut = objectFactory.createNodedisplay(); |
| 241 |
|
| 242 |
value = ut; |
| 243 |
final SchemeType scheme = objectFactory.createSchemeType(); |
| 244 |
scheme.getEl1().add(objectFactory.createSchemeElement1()); |
| 245 |
ut.setScheme(scheme); |
| 246 |
|
| 247 |
final DataType dat = objectFactory.createDataType(); |
| 248 |
dat.getEl1().add(objectFactory.createDataElement1()); |
| 249 |
ut.setData(dat); |
| 250 |
|
| 251 |
qname = "nodedisplay"; //$NON-NLS-1$ |
| 252 |
} else if (gobj instanceof ChartType) { |
| 253 |
final ChartType ut = objectFactory.createChartType(); |
| 254 |
|
| 255 |
value = ut; |
| 256 |
|
| 257 |
qname = "chart"; //$NON-NLS-1$ |
| 258 |
} else if (gobj instanceof ChartgroupType) { |
| 259 |
final ChartgroupType ut = objectFactory.createChartgroupType(); |
| 260 |
// Add lower chart-elements to the minimized chart-group |
| 261 |
final ChartgroupType orig = (ChartgroupType) gobj; |
| 262 |
// Go through all charts minimize them and add them to ut |
| 263 |
for (final ChartType chart : orig.getChart()) { |
| 264 |
final ChartType min = (ChartType) (minimizeGobjectType(chart).getValue()); |
| 265 |
ut.getChart().add(min); |
| 266 |
} |
| 267 |
|
| 268 |
value = ut; |
| 269 |
|
| 270 |
qname = "chartgroup"; //$NON-NLS-1$ |
| 271 |
} |
| 272 |
|
| 273 |
value.setDescription(gobj.getDescription()); |
| 274 |
value.setId(gobj.getId()); |
| 275 |
value.setTitle(gobj.getTitle()); |
| 276 |
|
| 277 |
final JAXBElement<GobjectType> res = new JAXBElement<GobjectType>(new QName(qname), c, value); |
| 278 |
|
| 279 |
return res; |
| 280 |
} |
| 281 |
|
| 282 |
/** |
| 283 |
* @param obj |
| 284 |
* LguiType-instance |
| 285 |
* @param output |
| 286 |
* OutputStream to save xml-representation of obj in |
| 287 |
* @throws JAXBException |
| 288 |
*/ |
| 289 |
@SuppressWarnings("unused") |
| 290 |
private static void objToLML(LguiType obj, OutputStream output) throws JAXBException { |
| 291 |
|
| 292 |
final JAXBContext jc = JAXBContext.newInstance("lml"); //$NON-NLS-1$ |
| 293 |
|
| 294 |
final Marshaller mar = jc.createMarshaller(); |
| 295 |
|
| 296 |
mar.setProperty("jaxb.schemaLocation", "http://www.llview.de lgui.xsd"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 297 |
|
| 298 |
final QName tagname = new QName("http://www.llview.de", "lgui", "lml"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
| 299 |
|
| 300 |
final JAXBElement<LguiType> rootel = new JAXBElement<LguiType>(tagname, LguiType.class, obj); |
| 301 |
|
| 302 |
mar.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); |
| 303 |
|
| 304 |
mar.marshal(rootel, output); |
| 305 |
} |
| 306 |
|
| 307 |
// DefaultLayouts |
| 308 |
private final UsagebarlayoutType defaultUsagebar; |
| 309 |
|
| 310 |
private final ChartlayoutType defaultChart; |
| 311 |
|
| 312 |
private final TablelayoutType defaultTable; |
| 313 |
|
| 314 |
private final InfoboxlayoutType defaultInfobox; |
| 315 |
|
| 316 |
/* |
| 317 |
* create an objectfactory for all functions in this class |
| 318 |
*/ |
| 319 |
private static ObjectFactory objectFactory = new ObjectFactory(); |
| 320 |
|
114 |
|
| 321 |
/** |
115 |
/** |
| 322 |
* @param lguiItem |
116 |
* @param lguiItem |
|
Lines 326-335
Link Here
|
| 326 |
*/ |
120 |
*/ |
| 327 |
public LayoutAccess(ILguiItem lguiItem, LguiType lgui) { |
121 |
public LayoutAccess(ILguiItem lguiItem, LguiType lgui) { |
| 328 |
super(lguiItem, lgui); |
122 |
super(lguiItem, lgui); |
| 329 |
defaultUsagebar = objectFactory.createUsagebarlayoutType(); |
|
|
| 330 |
defaultChart = objectFactory.createChartlayoutType(); |
| 331 |
defaultTable = objectFactory.createTablelayoutType(); |
| 332 |
defaultInfobox = objectFactory.createInfoboxlayoutType(); |
| 333 |
|
123 |
|
| 334 |
this.lguiItem.addListener(new ILguiListener() { |
124 |
this.lguiItem.addListener(new ILguiListener() { |
| 335 |
public void handleEvent(ILguiUpdatedEvent e) { |
125 |
public void handleEvent(ILguiUpdatedEvent e) { |
|
Lines 339-383
Link Here
|
| 339 |
} |
129 |
} |
| 340 |
|
130 |
|
| 341 |
/** |
131 |
/** |
| 342 |
* Add a new created layout to the model |
132 |
* Generates an absolute layout without needing a layout tag. Active components are placed in a grid on the screen. Use this |
| 343 |
* |
133 |
* function, if no layout was specified by the lml-file. |
| 344 |
* @param layout |
|
|
| 345 |
* absolute or splitlayout |
| 346 |
*/ |
| 347 |
public void addLayoutTag(LayoutType layout) { |
| 348 |
|
| 349 |
if (layout.getId() == null) { |
| 350 |
layout.setId(""); //$NON-NLS-1$ |
| 351 |
} |
| 352 |
|
| 353 |
JAXBElement<? extends LayoutType> jaxbel = null; |
| 354 |
// Create jaxbelement corresponding to the class-type |
| 355 |
if (layout instanceof AbslayoutType) { |
| 356 |
|
| 357 |
final AbslayoutType abslayout = (AbslayoutType) layout; |
| 358 |
|
| 359 |
jaxbel = new JAXBElement<AbslayoutType>(new QName("abslayout"), AbslayoutType.class, abslayout); //$NON-NLS-1$ |
| 360 |
|
| 361 |
} else if (layout instanceof SplitlayoutType) { |
| 362 |
|
| 363 |
final SplitlayoutType splitlayout = (SplitlayoutType) layout; |
| 364 |
|
| 365 |
jaxbel = new JAXBElement<SplitlayoutType>(new QName("splitlayout"), SplitlayoutType.class, splitlayout); //$NON-NLS-1$ |
| 366 |
|
| 367 |
} else { |
| 368 |
return; |
| 369 |
} |
| 370 |
|
| 371 |
lgui.getObjectsAndRelationsAndInformation().add(jaxbel); |
| 372 |
|
| 373 |
lguiItem.notifyListeners(); |
| 374 |
|
| 375 |
} |
| 376 |
|
| 377 |
/** |
| 378 |
* Generates an absolute layout without needing a layout tag. Active |
| 379 |
* components are placed in a grid on the screen. Use this function, if no |
| 380 |
* layout was specified by the lml-file. |
| 381 |
* |
134 |
* |
| 382 |
* @param width |
135 |
* @param width |
| 383 |
* width in pixels of the area, on which this layout is shown |
136 |
* width in pixels of the area, on which this layout is shown |
|
Lines 387-512
Link Here
|
| 387 |
*/ |
140 |
*/ |
| 388 |
public AbslayoutType generateDefaultAbsoluteLayout(int width, int height) { |
141 |
public AbslayoutType generateDefaultAbsoluteLayout(int width, int height) { |
| 389 |
|
142 |
|
| 390 |
// Collect active components |
143 |
final ArrayList<GobjectType> activeObjects = new ArrayList<GobjectType>(); |
| 391 |
final List<GobjectType> gobjects = lguiItem.getOverviewAccess().getGraphicalObjects(); |
|
|
| 392 |
|
| 393 |
final ArrayList<GobjectType> activeobjects = new ArrayList<GobjectType>(); |
| 394 |
// Go through all graphical objects |
144 |
// Go through all graphical objects |
| 395 |
for (final GobjectType gobj : gobjects) { |
145 |
for (final GobjectType gobject : lguiItem.getOverviewAccess().getGraphicalObjects()) { |
| 396 |
// Get layouts for this object, normally there is only one |
146 |
// Get layouts for this object, normally there is only one |
| 397 |
final List<ComponentlayoutType> layouts = getComponentLayoutByGID(gobj.getId()); |
147 |
final List<ComponentlayoutType> layouts = getComponentLayoutByGid(gobject |
|
|
148 |
.getId()); |
| 398 |
|
149 |
|
| 399 |
if (layouts.size() == 0) {// assume gobj to be active if there is no |
150 |
if (layouts.size() == 0) {// assume gobject to be active if there is |
| 400 |
// componentlayout |
151 |
// no componentlayout |
| 401 |
activeobjects.add(gobj); |
152 |
activeObjects.add(gobject); |
| 402 |
} |
153 |
} |
| 403 |
|
154 |
|
| 404 |
// Search for a componentlayout which declares gobj to be active |
155 |
// Search for a componentlayout which declares gobject to be active |
| 405 |
for (final ComponentlayoutType complayout : layouts) { |
156 |
for (final ComponentlayoutType componentLayout : layouts) { |
| 406 |
if (complayout.isActive()) { |
157 |
if (componentLayout.isActive()) { |
| 407 |
activeobjects.add(gobj); |
158 |
activeObjects.add(gobject); |
| 408 |
break; |
159 |
break; |
| 409 |
} |
160 |
} |
| 410 |
} |
161 |
} |
| 411 |
} |
162 |
} |
| 412 |
|
163 |
|
| 413 |
// Now activeobjects contains all active graphical objects, which have |
164 |
// Now activeObjects contains all active graphical objects, which have |
| 414 |
// to be arranged on the screen |
165 |
// to be arranged on the screen |
| 415 |
|
166 |
|
| 416 |
final AbslayoutType res = objectFactory.createAbslayoutType(); |
167 |
final AbslayoutType result = objectFactory.createAbslayoutType(); |
| 417 |
|
168 |
|
| 418 |
res.setId("abs_default"); //$NON-NLS-1$ |
169 |
result.setId(DEAFULT_ABS); |
| 419 |
|
170 |
|
| 420 |
// Try to create as many columns as rows |
171 |
// Try to create as many columns as rows |
| 421 |
int columns = (int) Math.round(Math.sqrt(activeobjects.size())); |
172 |
int columns = (int) Math.round(Math.sqrt(activeObjects.size())); |
| 422 |
|
173 |
|
| 423 |
if (columns == 0) { |
174 |
if (columns == 0) { |
| 424 |
columns = 1; |
175 |
columns = 1; |
| 425 |
} |
176 |
} |
| 426 |
|
177 |
|
| 427 |
int rows = (int) Math.ceil((double) activeobjects.size() / columns); |
178 |
int rows = (int) Math.ceil((double) activeObjects.size() / columns); |
| 428 |
|
179 |
|
| 429 |
if (rows == 0) { |
180 |
if (rows == 0) { |
| 430 |
rows = 1; |
181 |
rows = 1; |
| 431 |
} |
182 |
} |
| 432 |
// Calculate width and height of graphical objects |
183 |
// Calculate width and height of graphical objects |
| 433 |
int index = 0; |
184 |
int index = 0; |
| 434 |
final int rectwidth = width / columns; |
185 |
final int rectWidth = width / columns; |
| 435 |
final int rectheight = height / rows; |
186 |
final int rectHeight = height / rows; |
| 436 |
|
187 |
|
| 437 |
for (final GobjectType gobj : activeobjects) { |
188 |
for (final GobjectType gobject : activeObjects) { |
| 438 |
|
189 |
|
| 439 |
final ComponentType pos = objectFactory.createComponentType(); |
190 |
final ComponentType component = objectFactory.createComponentType(); |
| 440 |
pos.setGid(gobj.getId()); |
191 |
component.setGid(gobject.getId()); |
| 441 |
// Positioning the component |
192 |
// Positioning the component |
| 442 |
pos.setW(BigInteger.valueOf(rectwidth)); |
193 |
component.setW(BigInteger.valueOf(rectWidth)); |
| 443 |
pos.setH(BigInteger.valueOf(rectheight)); |
194 |
component.setH(BigInteger.valueOf(rectHeight)); |
| 444 |
|
195 |
|
| 445 |
pos.setX(BigInteger.valueOf((index % columns) * rectwidth)); |
196 |
component.setX(BigInteger.valueOf((index % columns) * rectWidth)); |
| 446 |
pos.setY(BigInteger.valueOf((index / columns) * rectheight)); |
197 |
component.setY(BigInteger.valueOf((index / columns) * rectHeight)); |
| 447 |
|
198 |
|
| 448 |
// Add this component position to the layout |
199 |
// Add this component position to the layout |
| 449 |
res.getComp().add(pos); |
200 |
result.getComp().add(component); |
| 450 |
|
201 |
|
| 451 |
index++; |
202 |
index++; |
| 452 |
} |
203 |
} |
| 453 |
|
204 |
|
| 454 |
return res; |
205 |
return result; |
| 455 |
} |
|
|
| 456 |
|
| 457 |
public String[] getActiveNodedisplayLayoutGid() { |
| 458 |
final ArrayList<String> nodedisplayID = new ArrayList<String>(); |
| 459 |
final List<NodedisplaylayoutType> nodedisplayLayouts = getNodedisplayLayouts(); |
| 460 |
for (final NodedisplaylayoutType nodedisplayLayout : nodedisplayLayouts) { |
| 461 |
if (nodedisplayLayout.isActive()) { |
| 462 |
nodedisplayID.add(nodedisplayLayout.getGid()); |
| 463 |
} |
| 464 |
} |
| 465 |
return nodedisplayID.toArray(new String[nodedisplayID.size()]); |
| 466 |
} |
| 467 |
|
| 468 |
public String[] getActiveTableLayoutsGid() { |
| 469 |
final ArrayList<String> tableLayoutsId = new ArrayList<String>(); |
| 470 |
final List<TablelayoutType> tableLayouts = getTableLayouts(); |
| 471 |
for (final TablelayoutType tableLayout : tableLayouts) { |
| 472 |
if (tableLayout.isActive()) { |
| 473 |
tableLayoutsId.add(tableLayout.getGid()); |
| 474 |
} |
| 475 |
} |
| 476 |
return tableLayoutsId.toArray(new String[tableLayoutsId.size()]); |
| 477 |
} |
206 |
} |
| 478 |
|
207 |
|
| 479 |
/** |
208 |
/** |
| 480 |
* Simply returns the first layout found for a chart with the given id or a |
209 |
* Simply returns the first layout found for a chart with the given id or a default-layout |
| 481 |
* default-layout |
|
|
| 482 |
* |
210 |
* |
| 483 |
* @param chartID |
211 |
* @param chartId |
| 484 |
* @return defaultlayout for a chart or first layout for chart with id |
212 |
* @return defaultlayout for a chart or first layout for chart with id |
| 485 |
* chartid given by lml-file |
213 |
* chartid given by lml-file |
| 486 |
*/ |
214 |
*/ |
| 487 |
public ChartlayoutType getChartLayout(String chartID) { |
215 |
public ChartlayoutType getChartLayout(String chartId) { |
| 488 |
final List<ChartlayoutType> chartLayouts = getChartLayouts(); |
216 |
for (final ChartlayoutType chartLayout : getChartLayouts()) { |
| 489 |
for (final ChartlayoutType chartLayout : chartLayouts) { |
217 |
if (chartLayout.getGid().equals(chartId)) { |
| 490 |
if (chartLayout.getGid().equals(chartID)) { |
|
|
| 491 |
return chartLayout; |
218 |
return chartLayout; |
| 492 |
} |
219 |
} |
| 493 |
} |
220 |
} |
| 494 |
return defaultChart; |
221 |
return objectFactory.createChartlayoutType(); |
| 495 |
} |
222 |
} |
| 496 |
|
223 |
|
| 497 |
public List<ChartlayoutType> getChartLayouts() { |
224 |
public List<ChartlayoutType> getChartLayouts() { |
| 498 |
final List<ChartlayoutType> chartLayouts = new LinkedList<ChartlayoutType>(); |
225 |
final List<ChartlayoutType> chartLayouts = new LinkedList<ChartlayoutType>(); |
| 499 |
for (final ComponentlayoutType tag : getComponentLayouts()) { |
226 |
for (final ComponentlayoutType layout : getComponentLayouts()) { |
| 500 |
if (tag instanceof ChartlayoutType) { |
227 |
if (layout instanceof ChartlayoutType) { |
| 501 |
chartLayouts.add((ChartlayoutType) tag); |
228 |
chartLayouts.add((ChartlayoutType) layout); |
| 502 |
} |
229 |
} |
| 503 |
} |
230 |
} |
| 504 |
return chartLayouts; |
231 |
return chartLayouts; |
| 505 |
} |
232 |
} |
| 506 |
|
233 |
|
| 507 |
/** |
234 |
/** |
| 508 |
* Search in component-layouts for layout for the graphical object with id |
235 |
* Search in component-layouts for layout for the graphical object with gid. |
| 509 |
* gid. |
|
|
| 510 |
* |
236 |
* |
| 511 |
* @param gid |
237 |
* @param gid |
| 512 |
* id of corresponding graphical object, for which layouts are |
238 |
* id of corresponding graphical object, for which layouts are |
|
Lines 514-534
Link Here
|
| 514 |
* @return list of componentlayouts corresponding to the graphical object id |
240 |
* @return list of componentlayouts corresponding to the graphical object id |
| 515 |
* gid |
241 |
* gid |
| 516 |
*/ |
242 |
*/ |
| 517 |
public List<ComponentlayoutType> getComponentLayoutByGID(String gid) { |
243 |
public List<ComponentlayoutType> getComponentLayoutByGid(String gid) { |
| 518 |
|
244 |
final ArrayList<ComponentlayoutType> result = new ArrayList<ComponentlayoutType>(); |
| 519 |
final List<ComponentlayoutType> complayouts = getComponentLayouts(); |
245 |
for (final ComponentlayoutType layout : getComponentLayouts()) { |
| 520 |
|
246 |
if (layout.getGid() != null && layout.getGid().equals(gid)) { |
| 521 |
final ArrayList<ComponentlayoutType> res = new ArrayList<ComponentlayoutType>(); |
247 |
result.add(layout); |
| 522 |
|
|
|
| 523 |
for (final ComponentlayoutType alayout : complayouts) { |
| 524 |
|
| 525 |
if (alayout.getGid() != null && alayout.getGid().equals(gid)) { |
| 526 |
|
| 527 |
res.add(alayout); |
| 528 |
} |
248 |
} |
| 529 |
} |
249 |
} |
| 530 |
|
250 |
return result; |
| 531 |
return res; |
|
|
| 532 |
} |
251 |
} |
| 533 |
|
252 |
|
| 534 |
/** |
253 |
/** |
|
Lines 538-552
Link Here
|
| 538 |
*/ |
257 |
*/ |
| 539 |
public List<ComponentlayoutType> getComponentLayouts() { |
258 |
public List<ComponentlayoutType> getComponentLayouts() { |
| 540 |
final List<ComponentlayoutType> layouts = new LinkedList<ComponentlayoutType>(); |
259 |
final List<ComponentlayoutType> layouts = new LinkedList<ComponentlayoutType>(); |
| 541 |
for (final JAXBElement<?> tag : lgui.getObjectsAndRelationsAndInformation()) { |
260 |
for (final Object object : jaxbUtil.getObjects(lgui)) { |
| 542 |
if (tag.getValue() instanceof ComponentlayoutType) { |
261 |
if (object instanceof ComponentlayoutType) { |
| 543 |
layouts.add((ComponentlayoutType) tag.getValue()); |
262 |
layouts.add((ComponentlayoutType) object); |
| 544 |
} |
263 |
} |
| 545 |
} |
264 |
} |
| 546 |
return layouts; |
265 |
return layouts; |
| 547 |
} |
266 |
} |
| 548 |
|
267 |
|
| 549 |
public TablelayoutType getDefaultTableLayout(String gid) { |
268 |
public TablelayoutType getDefaultTableLayoutFromTable(String gid) { |
| 550 |
TablelayoutType tableLayout = getTableLayout(gid); |
269 |
TablelayoutType tableLayout = getTableLayout(gid); |
| 551 |
if (tableLayout == null) { |
270 |
if (tableLayout == null) { |
| 552 |
tableLayout = new TablelayoutType(); |
271 |
tableLayout = new TablelayoutType(); |
|
Lines 554-561
Link Here
|
| 554 |
getTableLayouts().add(tableLayout); |
273 |
getTableLayouts().add(tableLayout); |
| 555 |
} |
274 |
} |
| 556 |
if (tableLayout.getColumn().size() <= 0) { |
275 |
if (tableLayout.getColumn().size() <= 0) { |
| 557 |
tableLayout.setId(gid + "_layout"); //$NON-NLS-1$ |
276 |
tableLayout.setId(gid + LAYOUT_ENDING); |
| 558 |
tableLayout.setGid(gid); |
|
|
| 559 |
final TableType table = lguiItem.getTableHandler().getTable(gid); |
277 |
final TableType table = lguiItem.getTableHandler().getTable(gid); |
| 560 |
if (table != null) { |
278 |
if (table != null) { |
| 561 |
for (int i = 0; i < table.getColumn().size(); i++) { |
279 |
for (int i = 0; i < table.getColumn().size(); i++) { |
|
Lines 573-614
Link Here
|
| 573 |
} |
291 |
} |
| 574 |
|
292 |
|
| 575 |
public Map<String, String> getInactiveComponents() { |
293 |
public Map<String, String> getInactiveComponents() { |
| 576 |
final List<ComponentlayoutType> objects = getComponentLayouts(); |
|
|
| 577 |
final ArrayList<String> inactive = new ArrayList<String>(); |
| 578 |
final Map<String, String> inactiveMap = new HashMap<String, String>(); |
294 |
final Map<String, String> inactiveMap = new HashMap<String, String>(); |
| 579 |
for (final ComponentlayoutType object : objects) { |
295 |
for (final ComponentlayoutType object : getComponentLayouts()) { |
| 580 |
if (!object.isActive()) { |
296 |
if (!object.isActive()) { |
| 581 |
if (object.getClass().getSimpleName().equals("TablelayoutType")) { //$NON-NLS-1$ |
297 |
if (object instanceof TablelayoutType) { |
| 582 |
final TableType table = lguiItem.getTableHandler().getTable(object.getGid()); |
298 |
final TableType table = lguiItem.getTableHandler().getTable(object.getGid()); |
| 583 |
if (table != null) { |
299 |
if (table != null) { |
| 584 |
inactiveMap.put(table.getTitle(), object.getGid()); |
300 |
inactiveMap.put(table.getTitle(), object.getGid()); |
| 585 |
} |
301 |
} |
| 586 |
} else if (object.getClass().getSimpleName().equals("NodedisplaylayoutType")) { //$NON-NLS-1$ |
302 |
} else if (object instanceof NodedisplaylayoutType) { |
| 587 |
inactiveMap |
303 |
inactiveMap |
| 588 |
.put(lguiItem.getNodedisplayAccess().getNodedisplayById(object.getGid()).getTitle(), object.getGid()); |
304 |
.put(lguiItem.getNodedisplayAccess().getNodedisplayById(object.getGid()).getTitle(), object.getGid()); |
| 589 |
} |
305 |
} |
| 590 |
inactive.add(object.getGid()); |
|
|
| 591 |
} |
306 |
} |
| 592 |
} |
307 |
} |
| 593 |
return inactiveMap; |
308 |
return inactiveMap; |
| 594 |
} |
309 |
} |
| 595 |
|
310 |
|
| 596 |
/** |
311 |
/** |
| 597 |
* Simply returns the first layout found for a infobox with the given id or |
312 |
* Simply returns the first layout found for a infobox with the given id or a default-layout |
| 598 |
* a default-layout |
|
|
| 599 |
* |
313 |
* |
| 600 |
* @param infoID |
314 |
* @param infoID |
| 601 |
* @return defaultlayout for a table or first layout for table with id |
315 |
* @return defaultlayout for a table or first layout for table with id |
| 602 |
* tableid given by lml-file |
316 |
* tableid given by lml-file |
| 603 |
*/ |
317 |
*/ |
| 604 |
public InfoboxlayoutType getInfoboxLayout(String infoID) { |
318 |
public InfoboxlayoutType getInfoboxLayout(String infoId) { |
| 605 |
final List<InfoboxlayoutType> infoboxLayouts = getInfoboxLayout(); |
319 |
for (final InfoboxlayoutType infoboxLayout : getInfoboxLayout()) { |
| 606 |
for (final InfoboxlayoutType infoboxLayout : infoboxLayouts) { |
320 |
if (infoboxLayout.getGid().equals(infoId)) { |
| 607 |
if (infoboxLayout.getGid().equals(infoID)) { |
|
|
| 608 |
return infoboxLayout; |
321 |
return infoboxLayout; |
| 609 |
} |
322 |
} |
| 610 |
} |
323 |
} |
| 611 |
return defaultInfobox; |
324 |
return objectFactory.createInfoboxlayoutType(); |
| 612 |
} |
325 |
} |
| 613 |
|
326 |
|
| 614 |
public ColumnlayoutType[] getLayoutColumsToCids(BigInteger[] cids, String gid) { |
327 |
public ColumnlayoutType[] getLayoutColumsToCids(BigInteger[] cids, String gid) { |
|
Lines 626-724
Link Here
|
| 626 |
} |
339 |
} |
| 627 |
|
340 |
|
| 628 |
/** |
341 |
/** |
| 629 |
* Remove all real data from model return only layout-information and data, |
342 |
* Remove all real data from model return only layout-information and data, which is needed to make lml-model valid |
| 630 |
* which is needed to make lml-model valid |
|
|
| 631 |
* |
343 |
* |
| 632 |
* @param model |
344 |
* @param model |
| 633 |
* lml-model with data and layout-information |
345 |
* lml-model with data and layout-information |
| 634 |
* @return |
346 |
* @return |
| 635 |
*/ |
347 |
*/ |
| 636 |
public LguiType getLayoutFromModel() { |
348 |
public LguiType getLayoutFromModel() { |
|
|
349 |
final LguiType result = objectFactory.createLguiType(); |
| 637 |
|
350 |
|
| 638 |
// This is gid for all nodedisplaylayouts in requests => id for all |
351 |
final HashSet<String> components = new HashSet<String>(); |
| 639 |
// nodedisplays |
|
|
| 640 |
final String dummystring = "__dummy_nd__";//$NON-NLS-1$ |
| 641 |
|
352 |
|
| 642 |
final LguiType res = objectFactory.createLguiType(); |
353 |
jaxbUtil.getLayoutComponents(result, lgui, components); |
| 643 |
|
354 |
|
| 644 |
final HashSet<String> neededComponents = new HashSet<String>(); |
355 |
final List<GobjectType> gobjectList = new LinkedList<GobjectType>(); |
| 645 |
|
356 |
for (final Object object : jaxbUtil.getObjects(lgui)) { |
| 646 |
for (final JAXBElement<?> tag : lgui.getObjectsAndRelationsAndInformation()) { |
|
|
| 647 |
|
| 648 |
final Object value = tag.getValue(); |
| 649 |
|
| 650 |
// add normal global layouts |
| 651 |
if (value instanceof LayoutType) { |
| 652 |
res.getObjectsAndRelationsAndInformation().add(tag); |
| 653 |
|
| 654 |
if (value instanceof SplitlayoutType) { |
| 655 |
final SplitlayoutType splitlayout = (SplitlayoutType) value; |
| 656 |
// Collect needed components from layout recursively |
| 657 |
if (splitlayout.getLeft() != null) { |
| 658 |
collectComponents(splitlayout.getLeft(), neededComponents); |
| 659 |
collectComponents(splitlayout.getRight(), neededComponents); |
| 660 |
} |
| 661 |
} else if (value instanceof AbslayoutType) { |
| 662 |
|
| 663 |
final AbslayoutType abslayout = (AbslayoutType) value; |
| 664 |
// Just traverse comp-list for gid-attributes |
| 665 |
for (final ComponentType comp : abslayout.getComp()) { |
| 666 |
neededComponents.add(comp.getGid()); |
| 667 |
} |
| 668 |
|
| 669 |
} |
| 670 |
|
| 671 |
} else if (value instanceof ComponentlayoutType) { |
| 672 |
if (((ComponentlayoutType) value).isActive()) { |
| 673 |
res.getObjectsAndRelationsAndInformation().add(tag); |
| 674 |
|
| 675 |
final ComponentlayoutType complayout = (ComponentlayoutType) value; |
| 676 |
neededComponents.add(complayout.getGid()); |
| 677 |
|
| 678 |
// Workaround for nodedisplay |
| 679 |
if (value instanceof NodedisplaylayoutType) { |
| 680 |
final NodedisplaylayoutType nlayout = (NodedisplaylayoutType) value; |
| 681 |
nlayout.setGid(dummystring); |
| 682 |
} |
| 683 |
|
| 684 |
} |
| 685 |
} |
| 686 |
|
| 687 |
} |
| 688 |
|
| 689 |
final HashMap<String, GobjectType> idtoGobject = new HashMap<String, GobjectType>(); |
| 690 |
// Search needed components in data-tag to discover, which type the |
| 691 |
// needed components have |
| 692 |
for (final JAXBElement<?> tag : lgui.getObjectsAndRelationsAndInformation()) { |
| 693 |
|
| 694 |
final Object value = tag.getValue(); |
| 695 |
// is it a graphical object? |
357 |
// is it a graphical object? |
| 696 |
if (value instanceof GobjectType) { |
358 |
if (object instanceof GobjectType) { |
| 697 |
final GobjectType gobj = (GobjectType) value; |
359 |
if (components.contains(((GobjectType) object).getId())) { |
| 698 |
if (neededComponents.contains(gobj.getId())) { |
360 |
gobjectList.add((GobjectType) object); |
| 699 |
idtoGobject.put(gobj.getId(), gobj); |
|
|
| 700 |
} |
361 |
} |
| 701 |
} |
362 |
} |
| 702 |
} |
363 |
} |
| 703 |
|
364 |
|
| 704 |
// Add all gobjects in idtoGobject to the result, so that lml-modell is |
365 |
// Add all gobjects in idtoGobject to the result, so that lml-model is |
| 705 |
// valid |
366 |
// valid |
| 706 |
for (final GobjectType gobj : idtoGobject.values()) { |
367 |
for (final GobjectType gobject : gobjectList) { |
| 707 |
final JAXBElement<GobjectType> min = minimizeGobjectType(gobj); |
368 |
result.getObjectsAndRelationsAndInformation().add(JAXBUtil.minimizeGobjectType(gobject, objectFactory)); |
| 708 |
|
|
|
| 709 |
// Workaround for nodedisplay |
| 710 |
final GobjectType newgobj = min.getValue(); |
| 711 |
if (newgobj instanceof Nodedisplay) { |
| 712 |
((Nodedisplay) newgobj).setId(dummystring); |
| 713 |
} |
| 714 |
|
| 715 |
res.getObjectsAndRelationsAndInformation().add(min); |
| 716 |
} |
369 |
} |
| 717 |
|
370 |
|
| 718 |
// Set layout-attribute |
371 |
// Set layout-attribute |
| 719 |
res.setLayout(true); |
372 |
result.setLayout(true); |
| 720 |
|
373 |
|
| 721 |
return res; |
374 |
return result; |
| 722 |
} |
375 |
} |
| 723 |
|
376 |
|
| 724 |
/** |
377 |
/** |
|
Lines 728-756
Link Here
|
| 728 |
*/ |
381 |
*/ |
| 729 |
public List<NodedisplaylayoutType> getNodedisplayLayouts() { |
382 |
public List<NodedisplaylayoutType> getNodedisplayLayouts() { |
| 730 |
final List<NodedisplaylayoutType> nodedisplayLayouts = new LinkedList<NodedisplaylayoutType>(); |
383 |
final List<NodedisplaylayoutType> nodedisplayLayouts = new LinkedList<NodedisplaylayoutType>(); |
| 731 |
for (final ComponentlayoutType tag : getComponentLayouts()) { |
384 |
for (final ComponentlayoutType layout : getComponentLayouts()) { |
| 732 |
if (tag instanceof NodedisplaylayoutType) { |
385 |
if (layout instanceof NodedisplaylayoutType) { |
| 733 |
nodedisplayLayouts.add((NodedisplaylayoutType) tag); |
386 |
nodedisplayLayouts.add((NodedisplaylayoutType) layout); |
| 734 |
} |
387 |
} |
| 735 |
} |
388 |
} |
| 736 |
return nodedisplayLayouts; |
389 |
return nodedisplayLayouts; |
|
|
390 |
|
| 737 |
} |
391 |
} |
| 738 |
|
392 |
|
| 739 |
/** |
393 |
/** |
| 740 |
* Getting the layout of a given table, the identifier of the layout is the |
394 |
* Getting the layout of a given table, the identifier of the layout is the shared ID of table and layout. |
| 741 |
* shared ID of table and layout. |
|
|
| 742 |
* |
395 |
* |
| 743 |
* @param tablelayoutID |
396 |
* @param tablelayoutID |
| 744 |
* ID of the desired tablelayout |
397 |
* ID of the desired tablelayout |
| 745 |
* @return Corresponding layout of a table |
398 |
* @return Corresponding layout of a table |
| 746 |
*/ |
399 |
*/ |
| 747 |
public TablelayoutType getTableLayout(String tablelayoutID) { |
400 |
public TablelayoutType getTableLayout(String tablelayoutId) { |
| 748 |
for (final TablelayoutType tag : getTableLayouts()) { |
401 |
for (final TablelayoutType layout : getTableLayouts()) { |
| 749 |
if (tag.getGid().equals(tablelayoutID)) { |
402 |
if (layout.getGid().equals(tablelayoutId)) { |
| 750 |
return tag; |
403 |
return layout; |
| 751 |
} |
404 |
} |
| 752 |
} |
405 |
} |
| 753 |
return defaultTable; |
406 |
return objectFactory.createTablelayoutType(); |
| 754 |
} |
407 |
} |
| 755 |
|
408 |
|
| 756 |
/** |
409 |
/** |
|
Lines 760-885
Link Here
|
| 760 |
*/ |
413 |
*/ |
| 761 |
public List<TablelayoutType> getTableLayouts() { |
414 |
public List<TablelayoutType> getTableLayouts() { |
| 762 |
final List<TablelayoutType> tableLayouts = new LinkedList<TablelayoutType>(); |
415 |
final List<TablelayoutType> tableLayouts = new LinkedList<TablelayoutType>(); |
| 763 |
for (final ComponentlayoutType tag : getComponentLayouts()) { |
416 |
for (final ComponentlayoutType layout : getComponentLayouts()) { |
| 764 |
if (tag instanceof TablelayoutType) { |
417 |
if (layout instanceof TablelayoutType) { |
| 765 |
tableLayouts.add((TablelayoutType) tag); |
418 |
tableLayouts.add((TablelayoutType) layout); |
| 766 |
} |
419 |
} |
| 767 |
} |
420 |
} |
| 768 |
return tableLayouts; |
421 |
return tableLayouts; |
| 769 |
} |
422 |
} |
| 770 |
|
423 |
|
| 771 |
/** |
424 |
/** |
| 772 |
* This function is only for easier understanding this class Textboxlayouts |
425 |
* This function is only for easier understanding this class Textboxlayouts are identical to infoboxlayouts, so you could call |
| 773 |
* are identical to infoboxlayouts, so you could call |
|
|
| 774 |
* getInfoboxLayout(textid) and would get the same result. |
426 |
* getInfoboxLayout(textid) and would get the same result. |
| 775 |
* |
427 |
* |
| 776 |
* @param textID |
428 |
* @param textID |
| 777 |
* id of a textbox |
429 |
* id of a textbox |
| 778 |
* @return layout for a textbox with an info-tag in it |
430 |
* @return layout for a textbox with an info-tag in it |
| 779 |
*/ |
431 |
*/ |
| 780 |
public InfoboxlayoutType getTextboxLayout(String textID) { |
432 |
public InfoboxlayoutType getTextboxLayout(String textId) { |
| 781 |
return getInfoboxLayout(textID); |
433 |
return getInfoboxLayout(textId); |
| 782 |
} |
434 |
} |
| 783 |
|
435 |
|
| 784 |
/** |
436 |
/** |
| 785 |
* Simply returns the first layout found for a usagebar with the given id or |
437 |
* Simply returns the first layout found for a usagebar with the given id or a default-layout |
| 786 |
* a default-layout |
|
|
| 787 |
* |
438 |
* |
| 788 |
* @param usagebarID |
439 |
* @param usagebarId |
| 789 |
* @return defaultlayout for a usagebar or first layout for usagebar with id |
440 |
* @return defaultlayout for a usagebar or first layout for usagebar with id |
| 790 |
* usagebarid given by lml-file |
441 |
* usagebarid given by lml-file |
| 791 |
*/ |
442 |
*/ |
| 792 |
public UsagebarlayoutType getUsagebarLayout(String usagebarID) { |
443 |
public UsagebarlayoutType getUsagebarLayout(String usagebarId) { |
| 793 |
final List<UsagebarlayoutType> usagebarLayouts = getUsagebarLayouts(); |
|
|
| 794 |
// Over all objects in lml-file |
444 |
// Over all objects in lml-file |
| 795 |
for (final UsagebarlayoutType usagebarLayout : usagebarLayouts) { |
445 |
for (final UsagebarlayoutType usagebarLayout : getUsagebarLayouts()) { |
| 796 |
if (usagebarLayout.getGid().equals(usagebarID)) { |
446 |
if (usagebarLayout.getGid().equals(usagebarId)) { |
| 797 |
return usagebarLayout; |
447 |
return usagebarLayout; |
| 798 |
} |
448 |
} |
| 799 |
} |
449 |
} |
| 800 |
return defaultUsagebar; |
450 |
return objectFactory.createUsagebarlayoutType(); |
| 801 |
} |
451 |
} |
| 802 |
|
452 |
|
| 803 |
public List<UsagebarlayoutType> getUsagebarLayouts() { |
453 |
public List<UsagebarlayoutType> getUsagebarLayouts() { |
| 804 |
final List<UsagebarlayoutType> usagebarLayouts = new LinkedList<UsagebarlayoutType>(); |
454 |
final List<UsagebarlayoutType> usagebarLayouts = new LinkedList<UsagebarlayoutType>(); |
| 805 |
for (final ComponentlayoutType tag : getComponentLayouts()) { |
455 |
for (final ComponentlayoutType layout : getComponentLayouts()) { |
| 806 |
if (tag instanceof UsagebarlayoutType) { |
456 |
if (layout instanceof UsagebarlayoutType) { |
| 807 |
usagebarLayouts.add((UsagebarlayoutType) tag); |
457 |
usagebarLayouts.add((UsagebarlayoutType) layout); |
| 808 |
} |
458 |
} |
| 809 |
} |
459 |
} |
| 810 |
return usagebarLayouts; |
460 |
return usagebarLayouts; |
| 811 |
} |
|
|
| 812 |
|
| 813 |
/** |
| 814 |
* Replace all componentlayouts for a graphical object with given gid |
| 815 |
* through newlayout.getGid() with newlayout |
| 816 |
* |
| 817 |
* @param newLayout |
| 818 |
* new layout, which is placed into the positions of old layouts |
| 819 |
*/ |
| 820 |
@SuppressWarnings("unchecked") |
| 821 |
public void replaceComponentLayout(ComponentlayoutType newlayout) { |
| 822 |
if (newlayout == null) { |
| 823 |
return; |
| 824 |
} |
| 825 |
final String gid = newlayout.getGid(); |
| 826 |
|
| 827 |
final List<JAXBElement<?>> allobjects = lgui.getObjectsAndRelationsAndInformation(); |
| 828 |
|
| 829 |
boolean replaced = false; |
| 830 |
|
| 831 |
// Over all objects in lml-file |
| 832 |
for (int i = 0; i < allobjects.size(); i++) { |
| 833 |
final JAXBElement<?> aobj = allobjects.get(i); |
| 834 |
|
| 835 |
// Over all Componentlayouts |
| 836 |
if (aobj.getValue() instanceof ComponentlayoutType) { |
| 837 |
|
| 838 |
final ComponentlayoutType alayout = (ComponentlayoutType) aobj.getValue(); |
| 839 |
|
| 840 |
if (alayout.getGid() != null && alayout.getGid().equals(gid)) { |
| 841 |
|
| 842 |
if (!replaced) { |
| 843 |
|
| 844 |
((JAXBElement<ComponentlayoutType>) aobj).setValue(newlayout); |
| 845 |
lguiItem.notifyListeners(); |
| 846 |
replaced = true; |
| 847 |
} else {// Delete this object |
| 848 |
allobjects.remove(aobj); |
| 849 |
// One step back |
| 850 |
i--; |
| 851 |
} |
| 852 |
} |
| 853 |
|
| 854 |
} |
| 855 |
} |
| 856 |
|
| 857 |
if (!replaced) {// Insert new layout, if there was nothing to replace |
| 858 |
// Takes any componentlayout |
| 859 |
JAXBElement<?> newel = null; |
| 860 |
|
| 861 |
// Differ between several layouts, create different JAXBElements |
| 862 |
if (newlayout instanceof TablelayoutType) { |
| 863 |
newel = new JAXBElement<TablelayoutType>(new QName("tablelayout"), TablelayoutType.class, //$NON-NLS-1$ |
| 864 |
(TablelayoutType) newlayout); |
| 865 |
} else if (newlayout instanceof NodedisplaylayoutType) { |
| 866 |
newel = new JAXBElement<NodedisplaylayoutType>(new QName("nodedisplaylayout"), NodedisplaylayoutType.class, //$NON-NLS-1$ |
| 867 |
(NodedisplaylayoutType) newlayout); |
| 868 |
} |
| 869 |
|
| 870 |
if (newel != null) { |
| 871 |
lgui.getObjectsAndRelationsAndInformation().add(newel); |
| 872 |
lguiItem.notifyListeners(); |
| 873 |
} |
| 874 |
} |
| 875 |
|
| 876 |
} |
| 877 |
|
| 878 |
/** |
| 879 |
* Setting Changes in the Layout. |
| 880 |
*/ |
| 881 |
public void setChangesLayoutColumn() { |
| 882 |
|
| 883 |
} |
461 |
} |
| 884 |
|
462 |
|
| 885 |
public String setComponentActive(String gid, boolean active) { |
463 |
public String setComponentActive(String gid, boolean active) { |
|
Lines 887-895
Link Here
|
| 887 |
final ComponentlayoutType component = getComponent(gid); |
465 |
final ComponentlayoutType component = getComponent(gid); |
| 888 |
if (component != null) { |
466 |
if (component != null) { |
| 889 |
if (component instanceof TablelayoutType) { |
467 |
if (component instanceof TablelayoutType) { |
| 890 |
type = "table"; //$NON-NLS-1$ |
468 |
type = ILMLCoreConstants.TABLE_ELEMENT; |
| 891 |
} else if (component instanceof NodedisplaylayoutType) { |
469 |
} else if (component instanceof NodedisplaylayoutType) { |
| 892 |
type = "nodedisplay"; //$NON-NLS-1$ |
470 |
type = ILMLCoreConstants.NODEDISPLAY_ELEMENT; |
| 893 |
} |
471 |
} |
| 894 |
component.setActive(active); |
472 |
component.setActive(active); |
| 895 |
} |
473 |
} |
|
Lines 897-904
Link Here
|
| 897 |
} |
475 |
} |
| 898 |
|
476 |
|
| 899 |
private ComponentlayoutType getComponent(String gid) { |
477 |
private ComponentlayoutType getComponent(String gid) { |
| 900 |
final List<ComponentlayoutType> objects = getComponentLayouts(); |
478 |
for (final ComponentlayoutType object : getComponentLayouts()) { |
| 901 |
for (final ComponentlayoutType object : objects) { |
|
|
| 902 |
if (object.getGid().equals(gid)) { |
479 |
if (object.getGid().equals(gid)) { |
| 903 |
return object; |
480 |
return object; |
| 904 |
} |
481 |
} |
|
Lines 908-916
Link Here
|
| 908 |
|
485 |
|
| 909 |
private List<InfoboxlayoutType> getInfoboxLayout() { |
486 |
private List<InfoboxlayoutType> getInfoboxLayout() { |
| 910 |
final List<InfoboxlayoutType> infoboxLayouts = new LinkedList<InfoboxlayoutType>(); |
487 |
final List<InfoboxlayoutType> infoboxLayouts = new LinkedList<InfoboxlayoutType>(); |
| 911 |
for (final ComponentlayoutType tag : getComponentLayouts()) { |
488 |
for (final ComponentlayoutType layout : getComponentLayouts()) { |
| 912 |
if (tag instanceof InfoboxlayoutType) { |
489 |
if (layout instanceof InfoboxlayoutType) { |
| 913 |
infoboxLayouts.add((InfoboxlayoutType) tag); |
490 |
infoboxLayouts.add((InfoboxlayoutType) layout); |
| 914 |
} |
491 |
} |
| 915 |
} |
492 |
} |
| 916 |
return infoboxLayouts; |
493 |
return infoboxLayouts; |