use of com.extjs.gxt.ui.client.core.XTemplate in project geo-platform by geosdi.
the class RecordsContainer method prepareColumnModel.
@Override
public ColumnModel prepareColumnModel() {
List<ColumnConfig> configs = Lists.<ColumnConfig>newArrayList();
StringBuilder templateBuilder = new StringBuilder();
templateBuilder.append("<p><b>");
templateBuilder.append(CatalogFinderConstants.INSTANCE.RecordsContainer_xTemplateAbstractText());
templateBuilder.append(":</b> {ABSTRACT_TEXT}</p><br>");
templateBuilder.append("<p><b>");
templateBuilder.append(CatalogFinderConstants.INSTANCE.RecordsContainer_xTemplateKeywordsText());
templateBuilder.append(":</b><br></p>");
templateBuilder.append("<tpl for=\"SUBJECTS\">");
templateBuilder.append("<div>{.}</div>");
templateBuilder.append("</tpl>");
XTemplate tpl = XTemplate.create(templateBuilder.toString());
rowExpander = new RowExpander(tpl);
configs.add(rowExpander);
ColumnConfig titleColumn = new ColumnConfig();
titleColumn.setId(RecordKeyValue.TITLE.toString());
titleColumn.setHeaderHtml(CatalogFinderConstants.INSTANCE.RecordsContainer_titleColumnHeaderText());
titleColumn.setWidth(490);
titleColumn.setFixed(true);
titleColumn.setResizable(false);
configs.add(titleColumn);
selectionModel = new CheckBoxSelectionModel<FullRecord>();
selectionModel.setSelectionMode(SelectionMode.SINGLE);
configs.add(selectionModel.getColumn());
return new ColumnModel(configs);
}
use of com.extjs.gxt.ui.client.core.XTemplate in project geo-platform by geosdi.
the class CatalogGridLayersWidget method prepareColumnModel.
@Override
public ColumnModel prepareColumnModel() {
List<ColumnConfig> configs = Lists.<ColumnConfig>newArrayList();
XTemplate tpl = XTemplate.create("<p><b>Abstract:</b> {abstractText}</p>");
rowExpander = new RowExpander(tpl);
configs.add(rowExpander);
ColumnConfig name = new ColumnConfig();
name.setId(GPLayerGrid.GPLayerBeanKeyValue.GPLAYER_NAME.getValue());
name.setHeaderHtml(CatalogFinderConstants.INSTANCE.CatalogGridLayersWidget_layerNameHeaderText());
name.setWidth(200);
configs.add(name);
ColumnConfig title = new ColumnConfig();
title.setId(GPLayerGrid.GPLayerBeanKeyValue.GPLAYER_LABEL.getValue());
title.setHeaderHtml(CatalogFinderConstants.INSTANCE.CatalogGridLayersWidget_titleHeaderText());
title.setWidth(150);
configs.add(title);
return new ColumnModel(configs);
}
use of com.extjs.gxt.ui.client.core.XTemplate in project geo-platform by geosdi.
the class GridLayersWidget method prepareColumnModel.
@Override
public ColumnModel prepareColumnModel() {
List<ColumnConfig> configs = Lists.<ColumnConfig>newArrayList();
XTemplate tpl = XTemplate.create("<p><b>Abstract:</b> {abstractText}</p>");
rowExpander = new RowExpander(tpl);
configs.add(rowExpander);
ColumnConfig name = new ColumnConfig();
name.setId(GPLayerBeanKeyValue.GPLAYER_NAME.getValue());
name.setHeaderHtml(ServerModuleConstants.INSTANCE.GridLayersWidget_layerNameHeaderText());
name.setWidth(200);
configs.add(name);
ColumnConfig title = new ColumnConfig();
title.setId(GPLayerBeanKeyValue.GPLAYER_LABEL.getValue());
title.setHeaderHtml(ServerModuleConstants.INSTANCE.GridLayersWidget_titleHeaderText());
title.setWidth(150);
configs.add(title);
return new ColumnModel(configs);
}
use of com.extjs.gxt.ui.client.core.XTemplate in project jahia by Jahia.
the class VisibilityTabItem method init.
@Override
public void init(NodeHolder engine, AsyncTabItem tab, String language) {
if (engine.getNode() == null) {
return;
}
final GWTJahiaNode node = engine.getNode();
tab.setLayout(new RowLayout());
tab.setProcessed(true);
final boolean editable = (!engine.isExistingNode() || (PermissionsUtils.isPermitted("jcr:modifyProperties", engine.getNode()) && !engine.getNode().isLocked()));
LayoutContainer header = new LayoutContainer(new FillLayout(Style.Orientation.VERTICAL));
tab.add(header, new RowData(1, 25, new Margins(5)));
final HorizontalPanel timeZonePanel = new HorizontalPanel();
timeZonePanel.setVerticalAlign(Style.VerticalAlignment.MIDDLE);
timeZonePanel.add(new HTML(Messages.get("label.visibility.timeZone", "All the visibility conditions are using the server timezone") + ": " + JahiaGWTParameters.getServerDisplayableTimeZone()));
header.add(timeZonePanel);
LayoutContainer top = new LayoutContainer(new FillLayout(Style.Orientation.VERTICAL));
tab.add(top, new RowData(1, 60, new Margins(5)));
final HorizontalPanel statusPanel = new HorizontalPanel();
statusPanel.setVerticalAlign(Style.VerticalAlignment.MIDDLE);
top.add(statusPanel);
statusBar = new StatusBar(node, statusPanel, editable);
HorizontalPanel addPanel = new HorizontalPanel();
addPanel.setVerticalAlign(Style.VerticalAlignment.MIDDLE);
if (editable) {
top.add(addPanel);
}
addPanel.add(new HTML(Messages.get("label.visibility.allConditionsMatch", "All conditions should match") + ": "));
allConditionsMatch = new CheckBox();
allConditionsMatch.setEnabled(editable);
allConditionsMatch.addListener(Events.Change, new Listener<ComponentEvent>() {
public void handleEvent(ComponentEvent event) {
changed = true;
refreshConditionsList();
statusBar.update();
}
});
addPanel.add(allConditionsMatch);
addPanel.add(new HTML(" " + Messages.get("label.visibility.addCondition", "Add new condition") + ": "));
final ListStore<GWTJahiaNodeType> typesStore = new ListStore<GWTJahiaNodeType>();
final ComboBox<GWTJahiaNodeType> types = new ComboBox<GWTJahiaNodeType>();
types.setDisplayField("label");
types.setStore(typesStore);
types.setTypeAhead(true);
types.setTriggerAction(ComboBox.TriggerAction.ALL);
types.setForceSelection(true);
types.setEditable(false);
types.setWidth(250);
types.setEnabled(editable);
addPanel.add(types);
final Map<String, GWTJahiaNodeType> typesMap = new HashMap<String, GWTJahiaNodeType>();
final Button add = new Button();
add.setIcon(StandardIconsProvider.STANDARD_ICONS.plusRound());
add.setEnabled(false);
addPanel.add(add);
conditionsStore = new ListStore<GWTJahiaNode>();
deleted = new ArrayList<GWTJahiaNode>();
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ColumnConfig name = new ColumnConfig("name", Messages.get("label.title"), 500);
name.setRenderer(new GridCellRenderer<GWTJahiaNode>() {
public Object render(GWTJahiaNode condition, String property, com.extjs.gxt.ui.client.widget.grid.ColumnData config, int rowIndex, int colIndex, ListStore<GWTJahiaNode> store, Grid<GWTJahiaNode> grid) {
String typeName = condition.getNodeTypes().get(0);
XTemplate tpl = typesMap.get(typeName).get("compiledTemplate");
convertStringToDate(condition);
return tpl.applyTemplate(com.extjs.gxt.ui.client.util.Util.getJsObject(condition));
}
});
name.setFixed(true);
configs.add(name);
ColumnConfig conditionStatus = new ColumnConfig("status", Messages.get("label.status"), 100);
conditionStatus.setRenderer(new GridCellRenderer<GWTJahiaNode>() {
public Object render(GWTJahiaNode model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<GWTJahiaNode> gwtJahiaNodeListStore, Grid<GWTJahiaNode> gwtJahiaNodeGrid) {
Boolean match = model.get("conditionMatch");
if (match != null) {
if (match.equals(Boolean.TRUE)) {
AbstractImagePrototype icon = ToolbarIconProvider.getInstance().getIcon("visibilityStatusGreen");
return icon.getHTML();
} else {
AbstractImagePrototype icon = ToolbarIconProvider.getInstance().getIcon("visibilityStatusRed");
return icon.getHTML();
}
}
AbstractImagePrototype icon = ToolbarIconProvider.getInstance().getIcon("visibilityStatusUnknown");
return icon.getHTML();
}
});
configs.add(conditionStatus);
if (editable) {
ColumnConfig remove = new ColumnConfig("remove", Messages.get("label.remove"), 100);
remove.setRenderer(new GridCellRenderer<GWTJahiaNode>() {
public Object render(final GWTJahiaNode condition, String property, com.extjs.gxt.ui.client.widget.grid.ColumnData config, final int rowIndex, final int colIndex, ListStore<GWTJahiaNode> listStore, final Grid<GWTJahiaNode> grid) {
final Button button;
if (condition.get("node-removed") == null || condition.isMarkedForDeletion()) {
button = new Button(Messages.get("label.remove"));
button.addStyleName("button-remove");
button.setIcon(StandardIconsProvider.STANDARD_ICONS.minusRound());
} else {
button = new Button(Messages.get("label.undelete"));
button.addStyleName("button-undelete");
button.setIcon(StandardIconsProvider.STANDARD_ICONS.restore());
}
button.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent buttonEvent) {
conditionsStore.remove(condition);
propertiesEditorMap.remove(condition.getPath());
if (condition.get("new-node") == null) {
deleted.add(condition);
condition.set("node-removed", Boolean.TRUE);
}
changed = true;
refreshConditionsList();
statusBar.update();
}
});
return button;
}
});
configs.add(remove);
}
// ColumnConfig publicationInfo = new ColumnConfig("publish", Messages.get("label.publish"), 100);
// publicationInfo.setRenderer(new GridCellRenderer<GWTJahiaNode>() {
// public Object render(final GWTJahiaNode conditionNode, String property, ColumnData config, int rowIndex, int colIndex,
// ListStore<GWTJahiaNode> store, Grid<GWTJahiaNode> grid) {
// final GWTJahiaPublicationInfo info = conditionNode.getAggregatedPublicationInfo();
// HorizontalPanel p = new HorizontalPanel();
// p.setVerticalAlign(Style.VerticalAlignment.MIDDLE);
// Integer infoStatus;
// if (info != null) {
// if (conditionNode.get("node-modified") != null) {
// infoStatus = GWTJahiaPublicationInfo.MODIFIED;
// } else {
// infoStatus = info.getStatus();
// }
// } else {
// infoStatus = GWTJahiaPublicationInfo.NOT_PUBLISHED;
// }
// PropertiesEditor pe = propertiesEditorMap.get(conditionNode.getPath());
// if (pe != null) {
// if (pe.getProperties(false, true, true).isEmpty()) {
// infoStatus = GWTJahiaPublicationInfo.MODIFIED;
// }
// }
//
// Image res = GWTJahiaPublicationInfo.renderPublicationStatusImage(infoStatus);
// p.add(res);
// final CheckBox checkbox = new CheckBox();
// if (infoStatus == GWTJahiaPublicationInfo.PUBLISHED) {
// checkbox.setEnabled(false);
// }
// checkbox.addListener(Events.Change, new Listener<ComponentEvent>() {
// public void handleEvent(ComponentEvent event) {
// conditionNode.set("node-published", checkbox.getValue());
// }
// });
// p.add(checkbox);
// return p;
// }
// });
// configs.add(publicationInfo);
ColumnModel cm = new ColumnModel(configs);
final Grid<GWTJahiaNode> conditions = new Grid<GWTJahiaNode>(conditionsStore, cm);
conditions.setAutoExpandColumn("name");
tab.add(conditions, new RowData(1, 0.5));
final LayoutContainer form = new LayoutContainer(new FitLayout());
form.setEnabled(editable);
tab.add(form, new RowData(1, 0.5));
final GridSelectionModel<GWTJahiaNode> selectionModel = conditions.getSelectionModel();
selectionModel.setSelectionMode(Style.SelectionMode.SINGLE);
selectionModel.addSelectionChangedListener(new SelectionChangedListener<GWTJahiaNode>() {
public void selectionChanged(SelectionChangedEvent<GWTJahiaNode> event) {
form.removeAll();
final GWTJahiaNode conditionNode = selectionModel.getSelectedItem();
if (conditionNode != null) {
PropertiesEditor pe = propertiesEditorMap.get(conditionNode.getPath());
if (pe != null) {
form.add(pe);
form.layout();
} else {
if (conditionNode.get("new-node") != null) {
final GWTJahiaNodeType type = types.getSelection().get(0);
JahiaContentManagementService.App.getInstance().initializeCreateEngine(type.getName(), node.getPath(), null, new BaseAsyncCallback<GWTJahiaCreateEngineInitBean>() {
public void onSuccess(GWTJahiaCreateEngineInitBean result) {
PropertiesEditor pe = new PropertiesEditor(Arrays.asList(type), new HashMap<String, GWTJahiaNodeProperty>(), Arrays.asList("content"));
pe.setChoiceListInitializersValues(result.getChoiceListInitializersValues());
pe.renderNewFormPanel();
propertiesEditorMap.put(conditionNode.getPath(), pe);
form.add(pe);
form.layout();
addFieldListener(pe, conditions, conditionNode);
}
});
} else {
JahiaContentManagementService.App.getInstance().initializeEditEngine(conditionNode.getPath(), false, new BaseAsyncCallback<GWTJahiaEditEngineInitBean>() {
public void onSuccess(GWTJahiaEditEngineInitBean result) {
if (result == null) {
return;
}
PropertiesEditor pe = new PropertiesEditor(result.getNodeTypes(), result.getProperties(), Arrays.asList("content"));
pe.setChoiceListInitializersValues(result.getInitializersValues());
pe.renderNewFormPanel();
propertiesEditorMap.put(conditionNode.getPath(), pe);
form.add(pe);
form.layout();
addFieldListener(pe, conditions, conditionNode);
}
});
}
}
}
}
});
add.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
GWTJahiaNode newCondition = new GWTJahiaNode();
List<GWTJahiaNodeType> nodeTypes = types.getSelection();
String nodeTypeName = nodeTypes.get(0).getName();
newCondition.setNodeTypes(Arrays.asList(nodeTypeName));
String nodeName = nodeTypeName + new Date().getTime();
newCondition.setName(nodeName);
newCondition.setPath(node.getPath() + "/j:conditionalVisibility/" + nodeName);
newCondition.set("new-node", Boolean.TRUE);
conditionsStore.add(newCondition);
selectionModel.select(Arrays.asList(newCondition), false);
changed = true;
refreshConditionsList();
statusBar.update();
}
});
if (editable) {
types.addSelectionChangedListener(new SelectionChangedListener<GWTJahiaNodeType>() {
@Override
public void selectionChanged(SelectionChangedEvent<GWTJahiaNodeType> se) {
add.enable();
}
});
}
JahiaContentManagementService.App.getInstance().getVisibilityInformation(node.getPath(), new BaseAsyncCallback<ModelData>() {
public void onSuccess(ModelData result) {
List<GWTJahiaNodeType> l = (List<GWTJahiaNodeType>) result.get("types");
typesStore.add(l);
types.setSelection(Arrays.asList(l.get(0)));
for (GWTJahiaNodeType type : l) {
typesMap.put(type.getName(), type);
XTemplate tpl = XTemplate.create((String) type.get("xtemplate"));
tpl.compile();
type.set("compiledTemplate", tpl);
}
conditionsStore.add((List<GWTJahiaNode>) result.get("conditions"));
refreshConditionsList();
allConditionsMatch.setOriginalValue(result.<Boolean>get("j:forceMatchAllConditions"));
allConditionsMatch.setValue(result.<Boolean>get("j:forceMatchAllConditions"));
statusBar.initStatusBar((GWTJahiaPublicationInfo) result.get("publicationInfo"), (Boolean) result.get("liveStatus"));
}
});
tab.layout();
}
use of com.extjs.gxt.ui.client.core.XTemplate in project jahia by Jahia.
the class MainModule method refreshInfoLayer.
public void refreshInfoLayer() {
infoLayers.removeAll();
handleTranslateStatus();
if (!activeLayers.isEmpty()) {
infoLayers.setMainModule(this);
List<Module> modules = ModuleHelper.getModules();
String lastUnpublished = null;
if (modules != null) {
for (Module m : modules) {
if (m instanceof AreaModule || !m.getPath().endsWith("*")) {
GWTJahiaNode currentNode = m.getNode();
if (currentNode != null) {
List<LayoutContainer> images = new ArrayList<LayoutContainer>();
if (activeLayers.containsKey("acl") && currentNode.isHasAcl()) {
AbstractImagePrototype icon = ToolbarIconProvider.getInstance().getIcon("viewACLStatus");
LayoutContainer layoutContainer = new LayoutContainer(new CenterLayout());
layoutContainer.add(icon.createImage());
images.add(layoutContainer);
}
if (activeLayers.containsKey("publication")) {
GWTJahiaPublicationInfo info = currentNode.getAggregatedPublicationInfo();
if (lastUnpublished == null || !currentNode.getPath().startsWith(lastUnpublished)) {
if (info.isLocked()) {
AbstractImagePrototype icon = ToolbarIconProvider.getInstance().getIcon("publication/locked");
LayoutContainer layoutContainer = new LayoutContainer(new CenterLayout());
layoutContainer.add(icon.createImage());
images.add(layoutContainer);
}
if (info.getStatus() == GWTJahiaPublicationInfo.NOT_PUBLISHED || info.getStatus() == GWTJahiaPublicationInfo.UNPUBLISHED) {
lastUnpublished = currentNode.getPath();
if (info.getStatus() == GWTJahiaPublicationInfo.UNPUBLISHED) {
AbstractImagePrototype icon = ToolbarIconProvider.getInstance().getIcon("publication/unpublished");
LayoutContainer layoutContainer = new LayoutContainer(new CenterLayout());
layoutContainer.add(icon.createImage());
images.add(layoutContainer);
} else {
AbstractImagePrototype icon = ToolbarIconProvider.getInstance().getIcon("publication/notpublished");
LayoutContainer layoutContainer = new LayoutContainer(new CenterLayout());
layoutContainer.add(icon.createImage());
images.add(layoutContainer);
}
} else if (info.getStatus() == GWTJahiaPublicationInfo.MODIFIED) {
AbstractImagePrototype icon = ToolbarIconProvider.getInstance().getIcon("publication/modified");
LayoutContainer layoutContainer = new LayoutContainer(new CenterLayout());
layoutContainer.add(icon.createImage());
images.add(layoutContainer);
} else if (info.getStatus() == GWTJahiaPublicationInfo.MANDATORY_LANGUAGE_UNPUBLISHABLE) {
AbstractImagePrototype icon = ToolbarIconProvider.getInstance().getIcon("publication/mandatorylanguageunpublishable");
LayoutContainer layoutContainer = new LayoutContainer(new CenterLayout());
layoutContainer.add(icon.createImage());
images.add(layoutContainer);
} else if (info.getStatus() == GWTJahiaPublicationInfo.MANDATORY_LANGUAGE_VALID) {
AbstractImagePrototype icon = ToolbarIconProvider.getInstance().getIcon("publication/mandatorylanguagevalid");
LayoutContainer layoutContainer = new LayoutContainer(new CenterLayout());
layoutContainer.add(icon.createImage());
images.add(layoutContainer);
}
}
}
if (activeLayers.containsKey("visibility")) {
Map<GWTJahiaNode, ModelData> visibility = currentNode.getVisibilityInfo();
if (!visibility.isEmpty()) {
if (currentNode.isVisible()) {
AbstractImagePrototype icon = ToolbarIconProvider.getInstance().getIcon("visibilityStatusGreen");
Image image = icon.createImage();
LayoutContainer layoutContainer = new LayoutContainer(new CenterLayout());
layoutContainer.add(image);
Set<Map.Entry<GWTJahiaNode, ModelData>> entries = visibility.entrySet();
StringBuilder toolTip = new StringBuilder();
for (Map.Entry<GWTJahiaNode, ModelData> entry : entries) {
if (toolTip.length() > 0) {
toolTip.append("<br/>");
}
XTemplate tpl = XTemplate.create((String) entry.getValue().get("xtemplate"));
toolTip.append(tpl.applyTemplate(com.extjs.gxt.ui.client.util.Util.getJsObject(entry.getKey())));
}
layoutContainer.setToolTip(toolTip.toString());
images.add(layoutContainer);
} else {
AbstractImagePrototype icon = ToolbarIconProvider.getInstance().getIcon("visibilityStatusRed");
LayoutContainer layoutContainer = new LayoutContainer(new CenterLayout());
layoutContainer.add(icon.createImage());
Set<Map.Entry<GWTJahiaNode, ModelData>> entries = visibility.entrySet();
StringBuilder toolTip = new StringBuilder();
for (Map.Entry<GWTJahiaNode, ModelData> entry : entries) {
if (toolTip.length() > 0) {
toolTip.append("<br/>");
}
XTemplate tpl = XTemplate.create((String) entry.getValue().get("xtemplate"));
toolTip.append(tpl.applyTemplate(com.extjs.gxt.ui.client.util.Util.getJsObject(entry.getKey())));
}
layoutContainer.setToolTip(toolTip.toString());
images.add(layoutContainer);
}
}
}
if (!images.isEmpty()) {
infoLayers.addInfoLayer(m, images, null, true, "1");
}
}
}
}
}
}
}
Aggregations