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 |
|
package info.magnolia.module.blossom.dialog; |
35 |
|
|
36 |
|
import info.magnolia.context.MgnlContext; |
37 |
|
import info.magnolia.i18nsystem.I18nizer; |
38 |
|
import info.magnolia.i18nsystem.SimpleTranslator; |
39 |
|
import info.magnolia.objectfactory.ComponentProvider; |
40 |
|
import info.magnolia.registry.RegistrationException; |
41 |
|
import info.magnolia.ui.api.context.UiContext; |
42 |
|
import info.magnolia.ui.dialog.DialogView; |
43 |
|
import info.magnolia.ui.dialog.actionarea.DialogActionExecutor; |
44 |
|
import info.magnolia.ui.dialog.definition.FormDialogDefinition; |
45 |
|
import info.magnolia.ui.dialog.formdialog.FormBuilder; |
46 |
|
import info.magnolia.ui.dialog.formdialog.FormDialogPresenterImpl; |
47 |
|
import info.magnolia.ui.dialog.formdialog.FormView; |
48 |
|
import info.magnolia.ui.dialog.registry.DialogDefinitionRegistry; |
49 |
|
import info.magnolia.ui.form.EditorCallback; |
50 |
|
import info.magnolia.ui.vaadin.integration.jcr.AbstractJcrNodeAdapter; |
51 |
|
|
52 |
|
import javax.inject.Inject; |
53 |
|
import javax.jcr.Node; |
54 |
|
import javax.jcr.RepositoryException; |
55 |
|
|
56 |
|
import com.vaadin.data.Item; |
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
@since |
62 |
|
|
|
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 6 |
Complexity Density: 0.33 |
|
63 |
|
public class BlossomFormDialogPresenter extends FormDialogPresenterImpl { |
64 |
|
|
65 |
|
private final DialogDefinitionRegistry dialogDefinitionRegistry; |
66 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
67 |
0 |
@Inject... |
68 |
|
public BlossomFormDialogPresenter(DialogDefinitionRegistry dialogDefinitionRegistry, FormBuilder formBuilder, ComponentProvider componentProvider, DialogActionExecutor executor, FormView view, I18nizer i18nizer, SimpleTranslator i18n) { |
69 |
0 |
super(dialogDefinitionRegistry, formBuilder, componentProvider, executor, view, i18nizer, i18n); |
70 |
0 |
this.dialogDefinitionRegistry = dialogDefinitionRegistry; |
71 |
|
} |
72 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.31 |
|
73 |
0 |
@Override... |
74 |
|
public DialogView start(Item item, String dialogId, UiContext uiContext, EditorCallback callback) { |
75 |
0 |
try { |
76 |
|
|
77 |
0 |
DialogCreationContext context = new DialogCreationContext(); |
78 |
0 |
context.setRequest(MgnlContext.getWebContext().getRequest()); |
79 |
0 |
context.setResponse(MgnlContext.getWebContext().getResponse()); |
80 |
0 |
context.setItem(item); |
81 |
0 |
if (item instanceof AbstractJcrNodeAdapter) { |
82 |
0 |
Node node = ((AbstractJcrNodeAdapter) item).getJcrItem(); |
83 |
0 |
if (node != null) { |
84 |
0 |
context.setContentNode(node); |
85 |
0 |
context.setContentPath(node.getPath()); |
86 |
|
} |
87 |
|
} |
88 |
|
|
89 |
0 |
DialogCreationContextHolder.set(context); |
90 |
0 |
FormDialogDefinition dialogDefinition = dialogDefinitionRegistry.getDialogDefinition(dialogId); |
91 |
|
|
92 |
0 |
return start(item, dialogDefinition, uiContext, callback); |
93 |
|
|
94 |
|
} catch (RegistrationException e) { |
95 |
0 |
throw new RuntimeException("No dialog definition found for [" + dialogId + "]", e); |
96 |
|
} catch (RepositoryException e) { |
97 |
0 |
throw new RuntimeException("Failed to access repository", e); |
98 |
|
} finally { |
99 |
0 |
DialogCreationContextHolder.remove(); |
100 |
|
} |
101 |
|
} |
102 |
|
} |