01: package org.romaframework.module.designer.view.domain.dnd.util;
02:
03: import java.net.URL;
04: import java.util.ArrayList;
05: import java.util.Iterator;
06: import java.util.List;
07:
08: import nextapp.echo2.app.Extent;
09: import nextapp.echo2.app.ResourceImageReference;
10: import nextapp.echo2.contrib.app.dnd.DropTarget;
11:
12: import org.romaframework.aspect.view.area.AreaModeManager;
13: import org.romaframework.core.flow.ObjectContext;
14:
15: import echopointng.ContainerEx;
16: import echopointng.LabelEx;
17:
18: public class SourceManager {
19: private List<LabelEx> sources = new ArrayList<LabelEx>();
20:
21: public SourceManager() {
22: initSources();
23: }
24:
25: public void addSourceToTarget(DropTarget dropper) {
26: Iterator<LabelEx> labels = sources.iterator();
27: while (labels.hasNext()) {
28: LabelEx label = labels.next();
29: dropper.addDragSource(label);
30: }
31: }
32:
33: private void initSources() {
34: if (sources.isEmpty()) {
35: Iterator<String> areas = ObjectContext.getInstance()
36: .getComponent(AreaModeManager.class)
37: .getComponentNames().iterator();
38: while (areas.hasNext()) {
39: String name = areas.next();
40: if (!name.equals("placeholder")) {
41: URL image = ClassLoader
42: .getSystemResource("org/romaframework/module/designer/view/image/"
43: + name + ".png");
44: LabelEx label = new LabelEx();
45: if (image != null)
46: label.setIcon(new ResourceImageReference(
47: "org/romaframework/module/designer/view/image/"
48: + name + ".png"));
49: label.setText(name);
50: sources.add(label);
51: }
52: }
53: }
54: }
55:
56: public ContainerEx addSources() {
57: ContainerEx container = new ContainerEx();
58: Iterator<LabelEx> labels = sources.iterator();
59: while (labels.hasNext()) {
60: LabelEx label = labels.next();
61: container.add(label);
62: LabelEx separator = new LabelEx(" ");
63: separator.setWidth(new Extent(10));
64: separator.setHeight(new Extent(15));
65: container.add(separator);
66: }
67: return container;
68: }
69: }
|