use of com.qcadoo.view.internal.api.InternalComponentState in project qcadoo by qcadoo.
the class WindowComponentState method setActiveTab.
@Override
public void setActiveTab(final String tabName) {
InternalComponentState tabComponentState = getChild(tabName);
if (tabComponentState == null) {
String errorMsg = String.format("Can't activate WindowTab with name '%s' - it doesn't exist.", tabName);
throw new IllegalArgumentException(errorMsg);
}
tabComponentState.setVisible(true);
tabsSelectionState.switchTab(tabName);
}
use of com.qcadoo.view.internal.api.InternalComponentState in project qcadoo by qcadoo.
the class ViewDefinitionStateImpl method getStatesAsList.
private List<InternalComponentState> getStatesAsList(final Collection<InternalComponentState> states) {
List<InternalComponentState> list = new ArrayList<>();
list.addAll(states);
for (InternalComponentState state : states) {
if (state instanceof ContainerState) {
list.addAll(getStatesAsList(((ContainerState) state).getChildren().values()));
}
}
return list;
}
use of com.qcadoo.view.internal.api.InternalComponentState in project qcadoo by qcadoo.
the class SmallTabLayoutState method renderContent.
@Override
protected JSONObject renderContent() throws JSONException {
JSONObject state = new JSONObject();
List<String> errorTabs = new LinkedList<String>();
for (Map.Entry<String, InternalComponentState> child : getChildren().entrySet()) {
if (child.getValue().isHasError()) {
for (SmallTabLayoutPatternTab tab : tabs) {
boolean found = false;
for (ComponentPattern tabComponents : tab.getComponents()) {
if (tabComponents.getName().equals(child.getValue().getName())) {
errorTabs.add(tab.getName());
found = true;
break;
}
}
if (found) {
break;
}
}
}
}
JSONArray errors = new JSONArray();
for (String tabName : errorTabs) {
errors.put(tabName);
}
state.put("errors", errors);
return state;
}
use of com.qcadoo.view.internal.api.InternalComponentState in project qcadoo by qcadoo.
the class ViewDefinitionStateImpl method renderContent.
@Override
protected JSONObject renderContent() throws JSONException {
JSONObject json = new JSONObject();
boolean isOk = true;
List<InternalComponentState> states = getStatesAsList(getChildren().values());
for (ComponentState state : states) {
if (state.isHasError()) {
isOk = false;
break;
}
}
json.put("status", isOk ? "ok" : "error");
return json;
}
use of com.qcadoo.view.internal.api.InternalComponentState in project qcadoo by qcadoo.
the class WindowComponentState method renderContent.
@Override
protected JSONObject renderContent() throws JSONException {
JSONObject json = new JSONObject();
List<String> errorTabs = new LinkedList<String>();
for (Map.Entry<String, InternalComponentState> child : getChildren().entrySet()) {
if (child.getValue().isHasError()) {
errorTabs.add(child.getKey());
}
}
JSONArray errors = new JSONArray();
for (String tabName : errorTabs) {
errors.put(tabName);
}
json.put("errors", errors);
json.put(JSON_TABS_SELECTION_STATE, tabsSelectionState.toJson());
if (pattern.getContextualHelpUrl() != null) {
json.put("contextualHelpUrl", pattern.getContextualHelpUrl());
}
if (ribbon != null) {
InternalRibbon diffrenceRibbon = ribbon.getUpdate();
if (diffrenceRibbon != null) {
json.put("ribbon", RibbonUtils.translateRibbon(diffrenceRibbon, getLocale(), pattern));
}
}
if (activeMenu != null) {
json.put(JSON_ACTIVE_MENU, activeMenu);
}
return json;
}
Aggregations