use of com.extjs.gxt.ui.client.widget.form.ComboBox in project jahia by Jahia.
the class CustomizedPreviewActionItem method onComponentSelection.
@Override
public void onComponentSelection() {
final Window window = new Window();
window.addStyleName("customized-preview");
window.setSize(500, 430);
window.setPlain(true);
window.setModal(true);
window.setBlinkModal(true);
window.setBorders(false);
window.setHeadingHtml(Messages.get("label.preview.window.title", "Customized preview"));
window.setLayout(new FitLayout());
window.setButtonAlign(Style.HorizontalAlignment.CENTER);
window.setBodyBorder(false);
// data proxy
RpcProxy<PagingLoadResult<GWTJahiaNode>> proxy = new RpcProxy<PagingLoadResult<GWTJahiaNode>>() {
@Override
protected void load(Object pageLoaderConfig, AsyncCallback<PagingLoadResult<GWTJahiaNode>> callback) {
if (userSearchField != null) {
String newSearch = userSearchField.getText().trim().replace("'", "''");
String query = "select * from [jnt:user] as u where (isdescendantnode(u,'/users/') or isdescendantnode(u,'/sites/" + JahiaGWTParameters.getSiteKey().replace("'", "''") + "/users/'))";
if (newSearch.length() > 0) {
query += " and (CONTAINS(u.*,'*" + newSearch + "*') OR LOWER(u.[j:nodename]) LIKE '*" + newSearch.toLowerCase() + "*') ";
}
query += " ORDER BY u.[j:nodename]";
// reset offset to 0 if the search value has changed
int offset = lastUserSearchValue != null && lastUserSearchValue.equals(newSearch) ? ((PagingLoadConfig) pageLoaderConfig).getOffset() : 0;
final JahiaContentManagementServiceAsync service = JahiaContentManagementService.App.getInstance();
service.searchSQL(query, ((PagingLoadConfig) pageLoaderConfig).getLimit(), offset, null, GWTJahiaNode.DEFAULT_USER_FIELDS, false, callback);
// remember last searched value
lastUserSearchValue = newSearch;
}
}
};
final BasePagingLoader<PagingLoadResult<GWTJahiaNode>> loader = new BasePagingLoader<PagingLoadResult<GWTJahiaNode>>(proxy);
userSearchField = new SearchField(Messages.get("label.search", "Search: "), false) {
@Override
public void onFieldValidation(String value) {
loader.load();
}
@Override
public void onSaveButtonClicked(String value) {
}
};
userSearchField.setWidth(490);
loader.setLimit(10);
loader.load();
HorizontalPanel panel = new HorizontalPanel();
panel.add(userSearchField);
ListStore<GWTJahiaNode> store = new ListStore<GWTJahiaNode>(loader);
List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
columns.add(new ColumnConfig("displayName", Messages.get("label.username", "User name"), 150));
columns.add(new ColumnConfig("j:lastName", Messages.get("label.lastName", "Last name"), 130));
columns.add(new ColumnConfig("j:firstName", Messages.get("label.firstName", "First name"), 130));
// columns.add(new ColumnConfig("siteName", "Site name", 80));
columns.add(new ColumnConfig("providerKey", Messages.get("column.provider.label", "Provider"), 75));
// columns.add(new ColumnConfig("email", "Email", 100));
ColumnModel cm = new ColumnModel(columns);
final PagingToolBar toolBar = new PagingToolBar(10);
toolBar.bind(loader);
toolBar.setBorders(false);
toolBar.setWidth(480);
userGrid = new Grid<GWTJahiaNode>(store, cm);
userGrid.getSelectionModel().setSelectionMode(Style.SelectionMode.SINGLE);
userGrid.setLoadMask(true);
userGrid.setBorders(false);
userGrid.setHeight(250);
userGrid.setWidth(490);
VerticalPanel verticalPanel = new VerticalPanel();
verticalPanel.add(userGrid);
verticalPanel.add(toolBar);
window.setTopComponent(panel);
panel = new HorizontalPanel();
panel.setTableHeight("30px");
panel.setVerticalAlign(Style.VerticalAlignment.BOTTOM);
Label label = new Label(" " + Messages.get("label.preview.window.date", "Pick a date for the preview") + " ");
label.setWidth(200);
label.setLabelFor("previewDate");
final Date date = new Date();
final CalendarField calendarField = new CalendarField("yyyy-MM-dd HH:mm", true, false, "previewDate", false, date);
panel.add(label);
panel.add(calendarField);
verticalPanel.add(panel);
window.add(verticalPanel);
// Channel selector
panel = new HorizontalPanel();
panel.setTableHeight("30px");
panel.setVerticalAlign(Style.VerticalAlignment.BOTTOM);
label = new Label(" " + Messages.get("label.preview.window.channel", "Channel") + " ");
label.setLabelFor("previewChannel");
// we will setup the right elements now because we will need to reference them in the event listener
final Label orientationLabel = new Label(" " + Messages.get("label.preview.window.channelOrientation", "Orientation") + " ");
orientationLabel.setLabelFor("previewChannelOrientation");
orientationLabel.hide();
final ListStore<GWTJahiaBasicDataBean> orientations = new ListStore<GWTJahiaBasicDataBean>();
final ComboBox<GWTJahiaBasicDataBean> orientationCombo = new ComboBox<GWTJahiaBasicDataBean>();
orientationCombo.setDisplayField("displayName");
orientationCombo.setName("previewChannelOrientation");
orientationCombo.setStore(orientations);
orientationCombo.setTypeAhead(true);
orientationCombo.setTriggerAction(TriggerAction.ALL);
orientationCombo.hide();
// now we can setup the channel selection combo box
final ListStore<GWTJahiaChannel> states = new ListStore<GWTJahiaChannel>();
final ComboBox<GWTJahiaChannel> combo = new ComboBox<GWTJahiaChannel>();
JahiaContentManagementServiceAsync contentService = JahiaContentManagementService.App.getInstance();
contentService.getChannels(new BaseAsyncCallback<List<GWTJahiaChannel>>() {
public void onSuccess(List<GWTJahiaChannel> result) {
states.add(result);
combo.setStore(states);
}
});
combo.setDisplayField("display");
combo.setName("previewChannel");
combo.setStore(states);
combo.setTypeAhead(true);
combo.setTriggerAction(TriggerAction.ALL);
combo.addSelectionChangedListener(new SelectionChangedListener<GWTJahiaChannel>() {
@Override
public void selectionChanged(SelectionChangedEvent<GWTJahiaChannel> event) {
GWTJahiaChannel selectedChannel = event.getSelectedItem();
Map<String, String> capabilities = selectedChannel.getCapabilities();
if (capabilities != null && capabilities.containsKey("variants")) {
String[] variants = capabilities.get("variants").split(",");
String[] displayNames = null;
if (capabilities.containsKey("variants-displayNames")) {
displayNames = capabilities.get("variants-displayNames").split(",");
}
ListStore<GWTJahiaBasicDataBean> orientations = orientationCombo.getStore();
orientations.removeAll();
for (int i = 0; i < variants.length; i++) {
String displayName = (displayNames == null ? variants[i] : displayNames[i]);
orientations.add(new GWTJahiaBasicDataBean(variants[i], displayName));
}
orientationCombo.setValue(orientations.getAt(0));
orientationLabel.show();
orientationCombo.show();
} else {
orientationLabel.hide();
orientationCombo.hide();
}
}
});
panel.add(label);
panel.add(combo);
panel.add(orientationLabel);
panel.add(orientationCombo);
verticalPanel.add(panel);
window.add(verticalPanel);
Button ok = new Button(Messages.get("label.preview.window.confirm", "Show customized preview"));
ok.addStyleName("button-preview");
ok.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent buttonEvent) {
final GWTJahiaNode node = linker.getSelectionContext().getMainNode();
if (node != null) {
String path = node.getPath();
String locale = JahiaGWTParameters.getLanguage();
JahiaContentManagementService.App.getInstance().getNodeURL(null, path, null, null, "default", locale, false, new BaseAsyncCallback<String>() {
@Override
public void onSuccess(String url) {
GWTJahiaNode selectedItem = userGrid.getSelectionModel().getSelectedItem();
String alias = null;
List<String> urlParameters = new ArrayList<String>();
if (selectedItem != null) {
alias = "alias=" + selectedItem.getName();
urlParameters.add(alias);
}
String previewDate = null;
if (calendarField.getValue().after(date)) {
previewDate = "prevdate=" + calendarField.getValue().getTime();
urlParameters.add(previewDate);
}
GWTJahiaChannel channel = combo.getValue();
String windowFeatures = null;
if ((channel != null) && (!"default".equals(channel.getValue()))) {
urlParameters.add("channel=" + channel.getValue());
Map<String, String> capabilities = channel.getCapabilities();
if (capabilities != null && capabilities.containsKey("variants")) {
int variantIndex = 0;
String[] variants = capabilities.get("variants").split(",");
String variant = orientationCombo.getValue().getValue();
urlParameters.add("variant=" + variant);
for (int i = 0; i < variants.length; i++) {
if (variants[i].equals(variant)) {
variantIndex = i;
break;
}
}
int[] imageSize = channel.getVariantDecoratorImageSize(variantIndex);
windowFeatures = "resizable=no,status=no,menubar=no,toolbar=no,width=" + imageSize[0] + ",height=" + imageSize[1];
}
}
StringBuilder urlParams = new StringBuilder();
for (int i = 0; i < urlParameters.size(); i++) {
if (i == 0) {
urlParams.append("?");
}
urlParams.append(urlParameters.get(i));
if (i < urlParameters.size() - 1) {
urlParams.append("&");
}
}
String url1 = url + urlParams.toString();
openWindow(url1, "customizedpreview", windowFeatures != null ? windowFeatures : defaultWindowOptions);
}
});
}
}
});
window.setBottomComponent(ok);
window.show();
}
use of com.extjs.gxt.ui.client.widget.form.ComboBox in project jahia by Jahia.
the class SaveAsReferencesMenuActionItem method onComponentSelection.
@Override
public void onComponentSelection() {
JahiaContentManagementService.App.getInstance().getPortalNodes(targetName.getValue(), new BaseAsyncCallback<List<GWTJahiaNode>>() {
@Override
public void onSuccess(List<GWTJahiaNode> result) {
if (result == null || result.size() == 0) {
MessageBox.alert(Messages.get("label.saveAsPortalComponent"), Messages.get("label.saveAsPortalComponent.portalComponents.nonedeclared", "There is no Portal Components folder declared. The component can not be saved"), null);
} else if (result.size() == 1) {
saveInPortalNode(result.get(0));
} else {
final Window popup = new Window();
popup.addStyleName("save-as-reference-modal");
popup.setHeadingHtml(Messages.get("label.saveAsPortalComponent.portalComponents.select", "Select a Portal Components folder"));
popup.setWidth(500);
popup.setAutoHeight(true);
popup.setModal(true);
FormPanel f = new FormPanel();
f.setHeaderVisible(false);
final ComboBox<GWTJahiaNode> portalNodesCombo = new ComboBox<GWTJahiaNode>();
portalNodesCombo.setStore(new ListStore<GWTJahiaNode>());
portalNodesCombo.setDisplayField(GWTJahiaNode.PATH);
portalNodesCombo.setTriggerAction(ComboBox.TriggerAction.ALL);
portalNodesCombo.setForceSelection(true);
portalNodesCombo.getStore().add(result);
ContentPanel p = new ContentPanel();
p.setLayout(new FitLayout());
p.setCollapsible(false);
p.setFrame(false);
p.setAnimCollapse(false);
p.setBorders(false);
p.setBodyBorder(false);
p.setHeaderVisible(false);
p.add(portalNodesCombo);
f.add(p);
Button b = new Button(Messages.get("label.save", "Save"));
f.addButton(b);
b.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent buttonEvent) {
GWTJahiaNode portalNode = portalNodesCombo.getValue();
if (portalNode != null) {
saveInPortalNode(portalNode);
}
popup.hide();
}
});
b.addStyleName("button-save");
Button c = new Button(Messages.get("label.cancel", "Cancel"));
c.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent buttonEvent) {
popup.hide();
}
});
c.addStyleName("button-cancel");
f.addButton(c);
f.setButtonAlign(Style.HorizontalAlignment.CENTER);
FormButtonBinding binding = new FormButtonBinding(f);
binding.addButton(b);
popup.add(f);
popup.show();
}
}
@Override
public void onApplicationFailure(Throwable caught) {
Info.display(Messages.get("label.saveAsPortalComponent"), Messages.get("label.saveAsPortalComponent.cannotGetPortalNodes"));
}
});
}
use of com.extjs.gxt.ui.client.widget.form.ComboBox 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.widget.form.ComboBox in project jahia by Jahia.
the class WorkflowTabItem method init.
@Override
public void init(final NodeHolder engine, final AsyncTabItem tab, String locale) {
if (engine.getNode() == null) {
return;
}
if (container != null) {
container.removeFromParent();
container.removeAll();
}
if (container == null) {
container = new LayoutContainer(new BorderLayout());
}
tab.add(container);
tab.setProcessed(true);
final LayoutContainer layoutContainer = new LayoutContainer(new BorderLayout());
container.add(layoutContainer, new BorderLayoutData(Style.LayoutRegion.NORTH, 150));
WorkflowHistoryPanel next = getPanel(locale, engine);
if (activePanel != null) {
if (activePanel != next) {
activePanel.removeFromParent();
}
}
container.add(next, new BorderLayoutData(Style.LayoutRegion.CENTER));
activePanel = next;
JahiaContentManagementService.App.getInstance().getWorkflowRules(engine.getNode().getPath(), new BaseAsyncCallback<Map<GWTJahiaWorkflowType, List<GWTJahiaWorkflowDefinition>>>() {
public void onSuccess(final Map<GWTJahiaWorkflowType, List<GWTJahiaWorkflowDefinition>> result) {
workflowRules = result;
for (List<GWTJahiaWorkflowDefinition> list : workflowRules.values()) {
for (GWTJahiaWorkflowDefinition definition : list) {
if (Boolean.TRUE.equals(definition.get("active")) && engine.getNode().getPath().equals(definition.get("workflowRootPath"))) {
definition.set("set", Boolean.TRUE);
}
}
}
final ListStore<GWTJahiaWorkflowType> types = new ListStore<GWTJahiaWorkflowType>();
types.add(new ArrayList<GWTJahiaWorkflowType>(workflowRules.keySet()));
types.sort("displayName", Style.SortDir.ASC);
ColumnModel header = new ColumnModel(Arrays.asList(new ColumnConfig("displayName", "displayName", 300)));
final Grid<GWTJahiaWorkflowType> grid = new Grid<GWTJahiaWorkflowType>(types, header);
grid.setWidth(250);
grid.setHideHeaders(true);
grid.setHeight(150);
grid.setAutoExpandColumn("displayName");
grid.setAutoExpandMax(1200);
BorderLayoutData data = new BorderLayoutData(Style.LayoutRegion.WEST, 250);
layoutContainer.add(grid, data);
FormPanel form = new FormPanel();
form.setHeaderVisible(false);
form.setLabelWidth(200);
form.setFieldWidth(300);
final CheckBox box = new CheckBox();
box.setFieldLabel(Messages.get("label.workflow.inherited", "Same workflow as parent"));
form.add(box);
final ListStore<GWTJahiaWorkflowDefinition> states = new ListStore<GWTJahiaWorkflowDefinition>();
final ComboBox<GWTJahiaWorkflowDefinition> combo = new ComboBox<GWTJahiaWorkflowDefinition>();
combo.setFieldLabel(Messages.get("label.workflow", "Workflow"));
combo.setForceSelection(true);
combo.setDisplayField("displayName");
combo.setWidth(400);
combo.setStore(states);
combo.setTypeAhead(true);
combo.setTriggerAction(ComboBox.TriggerAction.ALL);
form.add(combo);
data = new BorderLayoutData(Style.LayoutRegion.CENTER);
layoutContainer.add(form, data);
grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GWTJahiaWorkflowType>() {
@Override
public void selectionChanged(SelectionChangedEvent<GWTJahiaWorkflowType> se) {
previousSelection = null;
combo.setValue(null);
combo.clearSelections();
states.removeAll();
final List<GWTJahiaWorkflowDefinition> list = workflowRules.get(se.getSelectedItem());
states.add(list);
states.sort("displayName", Style.SortDir.ASC);
for (GWTJahiaWorkflowDefinition definition : list) {
if (Boolean.TRUE.equals(definition.get("active"))) {
box.setValue(!Boolean.TRUE.equals(definition.get("set")));
combo.setValue(definition);
return;
}
}
box.setValue(true);
}
});
box.addListener(Events.Change, new Listener<FieldEvent>() {
public void handleEvent(FieldEvent be) {
combo.setEnabled(!box.getValue());
if (combo.getSelection().size() == 1) {
combo.getSelection().get(0).set("set", !box.getValue());
if (!box.getValue()) {
combo.getSelection().get(0).set("active", Boolean.TRUE);
}
}
}
});
combo.addSelectionChangedListener(new SelectionChangedListener<GWTJahiaWorkflowDefinition>() {
@Override
public void selectionChanged(SelectionChangedEvent<GWTJahiaWorkflowDefinition> event) {
if (previousSelection != null) {
previousSelection.set("set", Boolean.FALSE);
previousSelection.set("active", Boolean.FALSE);
}
if (event.getSelectedItem() != null) {
event.getSelectedItem().set("set", !box.getValue());
if (!box.getValue()) {
event.getSelectedItem().set("active", Boolean.TRUE);
}
}
previousSelection = event.getSelectedItem();
tab.layout();
}
});
// todo : use specific permission to manage workflows ?
if (!PermissionsUtils.isPermitted("jcr:write", engine.getNode()) || engine.getNode().isLocked()) {
box.setReadOnly(true);
combo.setReadOnly(true);
}
grid.getSelectionModel().select(0, false);
tab.layout();
}
});
}
use of com.extjs.gxt.ui.client.widget.form.ComboBox in project jahia by Jahia.
the class ResourceBundleEditor method populateNewLanguageTab.
private void populateNewLanguageTab() {
if (newLanguageTab.isProcessed()) {
return;
}
FormPanel formPanel = new FormPanel();
formPanel.setHeight(150);
formPanel.setWidth(500);
formPanel.setLabelWidth(150);
formPanel.setFrame(true);
formPanel.setBorders(true);
formPanel.setButtonAlign(HorizontalAlignment.CENTER);
formPanel.setHeadingHtml(Messages.get("label.resourceBundle.addLanguage", "Add new language to the resource bundle") + ":");
final ComboBox<GWTJahiaValueDisplayBean> languageSelector = new ComboBox<GWTJahiaValueDisplayBean>();
languageSelector.setFieldLabel(Messages.get("label.resourceBundle.addLanguage.choose", "Choose"));
languageSelector.setStore(new ListStore<GWTJahiaValueDisplayBean>());
languageSelector.getStore().add(new GWTJahiaValueDisplayBean(GWTResourceBundle.DEFAULT_LANG, "[" + Messages.get("label.default", "Default") + "]"));
languageSelector.getStore().add(availableLanguages);
languageSelector.setDisplayField("display");
languageSelector.setTypeAhead(true);
languageSelector.setTriggerAction(ComboBox.TriggerAction.ALL);
languageSelector.setForceSelection(true);
formPanel.add(languageSelector);
final TextField<String> langField = new TextField<String>();
langField.setName("newLanguage");
langField.setFieldLabel(Messages.get("label.resourceBundle.addLanguage.type", "or type the locale"));
formPanel.add(langField);
languageSelector.addSelectionChangedListener(new SelectionChangedListener<GWTJahiaValueDisplayBean>() {
@Override
public void selectionChanged(SelectionChangedEvent<GWTJahiaValueDisplayBean> se) {
if (se == null) {
return;
}
langField.setValue(!GWTResourceBundle.DEFAULT_LANG.equals(se.getSelectedItem().getValue()) ? se.getSelectedItem().getValue() : "");
}
});
Button btn = new Button(Messages.get("label.add", "Add"), new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent event) {
String newLang = langField.getValue();
if (languages.contains(newLang)) {
return;
}
if (!newLang.matches("[a-z]{2,3}(_[A-Z]{2})?")) {
MessageBox.alert(Messages.get("label.error"), Messages.get("label.resourceBundle.addLanguage.invalidLang"), null).getDialog().addStyleName("engine-save-error");
return;
}
languages.add(newLang);
for (GWTResourceBundleEntry e : bundleView.getStore().getModels()) {
e.setValue(newLang, null);
}
populateForm();
tabPanel.setSelection(tabPanel.getItem(0));
}
});
btn.addStyleName("button-add");
btn.setEnabled(writable);
formPanel.addButton(btn);
newLanguageTab.add(formPanel);
newLanguageTab.setProcessed(true);
newLanguageTab.layout();
}
Aggregations