View Javadoc
1   /**
2    * This file Copyright (c) 2010-2018 Magnolia International
3    * Ltd.  (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10   * This file is distributed in the hope that it will be
11   * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12   * implied warranty of MERCHANTABILITY or FITNESS FOR A
13   * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14   * Redistribution, except as permitted by whichever of the GPL
15   * or MNA you select, is prohibited.
16   *
17   * 1. For the GPL license (GPL), you can redistribute and/or
18   * modify this file under the terms of the GNU General
19   * Public License, Version 3, as published by the Free Software
20   * Foundation.  You should have received a copy of the GNU
21   * General Public License, Version 3 along with this program;
22   * if not, write to the Free Software Foundation, Inc., 51
23   * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24   *
25   * 2. For the Magnolia Network Agreement (MNA), this file
26   * and the accompanying materials are made available under the
27   * terms of the MNA which accompanies this distribution, and
28   * is available at http://www.magnolia-cms.com/mna.html
29   *
30   * Any modifications to this file must keep this entire header
31   * intact.
32   *
33   */
34  package info.magnolia.ui.dialog.definition;
35  
36  import info.magnolia.annotation.deprecation.MgnlDeprecated;
37  
38  import info.magnolia.ui.api.action.ActionDefinition;
39  import info.magnolia.ui.api.overlay.OverlayLayer.ModalityLevel;
40  import info.magnolia.ui.dialog.DialogBuilder;
41  import info.magnolia.ui.dialog.DialogPresenter;
42  import info.magnolia.ui.dialog.actionarea.definition.ConfiguredEditorActionAreaDefinition;
43  import info.magnolia.ui.dialog.actionarea.definition.EditorActionAreaDefinition;
44  
45  import java.util.LinkedHashMap;
46  import java.util.Map;
47  
48  /**
49   * Implementation of {@link DialogDefinition}.
50   *
51   * @deprecated since 6.0. Use new framework and {@link info.magnolia.ui.dialog.ConfiguredDialogDefinition} instead.
52   */
53  @Deprecated
54  @MgnlDeprecated(since = "6.0.", description = "Use new framework and info.magnolia.ui.dialog.ConfiguredDialogDefinition instead.")
55  public class ConfiguredDialogDefinition implements DialogDefinition {
56  
57      public static final String ACTIONS_NODE_NAME = "actions";
58      public static final String EXTEND_PROPERTY_NAME = "extends";
59  
60      private String id;
61  
62      private String label;
63  
64      private String i18nBasename;
65  
66      private boolean isWide = false;
67  
68      private Map<String, ActionDefinition> actions = new LinkedHashMap<String, ActionDefinition>();
69  
70      private Class<? extends DialogPresenter> presenterClass;
71  
72      private EditorActionAreaDefinition actionArea = new ConfiguredEditorActionAreaDefinition();
73  
74      private ModalityLevel modalityLevel = ModalityLevel.STRONG;
75  
76      private DialogBuilder.Width width = DialogBuilder.Width.medium;
77  
78      @Override
79      public String getId() {
80          return id;
81      }
82  
83      public void setId(String id) {
84          this.id = id;
85      }
86  
87      @Override
88      public String getLabel() {
89          return label;
90      }
91  
92      public void setLabel(String label) {
93          this.label = label;
94      }
95  
96      @Override
97      public String getI18nBasename() {
98          return i18nBasename;
99      }
100 
101     public void setI18nBasename(String i18nBasename) {
102         this.i18nBasename = i18nBasename;
103     }
104 
105     @Override
106     public Map<String, ActionDefinition> getActions() {
107         return actions;
108     }
109 
110     @Override
111     public Class<? extends DialogPresenter> getPresenterClass() {
112         return presenterClass;
113     }
114 
115     public void setActions(Map<String, ActionDefinition> actions) {
116         this.actions = actions;
117     }
118 
119     public void addAction(ActionDefinition actionDefinition) {
120         actions.put(actionDefinition.getName(), actionDefinition);
121     }
122 
123     public void setPresenterClass(Class<? extends DialogPresenter> presenterClass) {
124         this.presenterClass = presenterClass;
125     }
126 
127     @Override
128     public EditorActionAreaDefinition getActionArea() {
129         return actionArea;
130     }
131 
132     public void setActionArea(EditorActionAreaDefinition actionArea) {
133         this.actionArea = actionArea;
134     }
135 
136     /**
137      * @return the currently set {@link ModalityLevel}. If not set, it is {@link ModalityLevel#STRONG} by default.
138      */
139     @Override
140     public ModalityLevel getModalityLevel() {
141         return this.modalityLevel;
142     }
143 
144     public void setModalityLevel(ModalityLevel modalityLevel) {
145         this.modalityLevel = modalityLevel;
146     }
147 
148     /**
149      * @return Whether the dialog should be displayed in a wide mode by default.
150      */
151     @Override
152     public boolean isWide() {
153         return isWide;
154     }
155 
156     public void setWide(boolean isWide){
157         this.isWide = isWide;
158     }
159 
160     @Override
161     public DialogBuilder.Width getWidth() {
162         return isWide ? DialogBuilder.Width.wide : width;
163     }
164 
165     public void setWidth(DialogBuilder.Width width) {
166         this.width = width;
167     }
168 }