use of org.jahia.ajax.gwt.client.data.GWTJahiaChannel in project jahia by Jahia.
the class ChannelDisplayActionItem method initMainComponent.
/**
* init main component
*/
private void initMainComponent() {
final ComboBox<GWTJahiaChannel> comboBox = new ComboBox<GWTJahiaChannel>();
comboBox.setDisplayField("display");
comboBox.setTriggerAction(ComboBox.TriggerAction.ALL);
comboBox.setStore(new ListStore<GWTJahiaChannel>());
comboBox.getStore().add(JahiaGWTParameters.getChannels());
comboBox.setTemplate(getChannelTemplate());
comboBox.setItemSelector("div.thumb-wrap");
comboBox.addSelectionChangedListener(new SelectionChangedListener<GWTJahiaChannel>() {
@Override
public void selectionChanged(SelectionChangedEvent<GWTJahiaChannel> event) {
GWTJahiaChannel selectedChannel = event.getSelectedItem();
if (linker instanceof EditLinker) {
((EditLinker) linker).getMainModule().switchChannel(selectedChannel, null);
}
}
});
horizontalPanel = new HorizontalPanel();
horizontalPanel.add(comboBox);
horizontalPanel.addStyleName(getGwtToolbarItem().getClassName());
horizontalPanel.addStyleName("action-bar-menu-item");
setEnabled(true);
}
use of org.jahia.ajax.gwt.client.data.GWTJahiaChannel in project jahia by Jahia.
the class MainModule method setChannelFromUrl.
private void setChannelFromUrl(String url) {
if (config.isSupportChannelsDisplay()) {
activeChannel = editLinker.getActiveChannel();
activeChannelVariant = editLinker.getActiveChannelVariant();
Map<String, String> params = getParamsFromUrl(url);
if (params.containsKey("channel")) {
String channelName = params.get("channel");
for (GWTJahiaChannel gwtJahiaChannel : JahiaGWTParameters.getChannels()) {
if (gwtJahiaChannel.getValue().equals(channelName)) {
this.activeChannel = gwtJahiaChannel;
this.activeChannelVariant = null;
break;
}
}
if (params.containsKey("variant")) {
activeChannelVariant = params.get("variant");
}
}
} else {
activeChannel = null;
activeChannelVariant = null;
}
}
use of org.jahia.ajax.gwt.client.data.GWTJahiaChannel in project jahia by Jahia.
the class ChannelsTabItem method doRefresh.
@Override
public void doRefresh() {
GWTJahiaChannel activeChannel = editLinker.getActiveChannel();
int activeChannelIndex = 0;
deviceImage.setUrl("");
deviceNameLabel.setHtml(Messages.get("label.default", "Default"));
if (activeChannel != null) {
if (activeChannel.getCapability("device-image") != null) {
deviceImage.setUrl(JahiaGWTParameters.getContextPath() + activeChannel.getCapability("device-image"));
}
deviceNameLabel.setHtml(activeChannel.getDisplay());
}
orientationComponent.getStore().removeAll();
if (activeChannel != null && activeChannel.getCapability("variants") != null) {
String[] variantValueArray = activeChannel.getCapability("variants").split(",");
String[] variantDisplayNameArray = variantValueArray;
if (activeChannel.getCapability("variants-displayNames") != null) {
variantDisplayNameArray = activeChannel.getCapability("variants-displayNames").split(",");
}
activeChannelIndex = editLinker.getActiveChannelVariantIndex();
List<GWTJahiaBasicDataBean> selectedItems = new ArrayList<GWTJahiaBasicDataBean>();
int i = 0;
for (String variantValue : variantValueArray) {
String displayName = variantValue;
if (i < variantDisplayNameArray.length) {
displayName = variantDisplayNameArray[i];
}
GWTJahiaBasicDataBean currentVariant = new GWTJahiaBasicDataBean(variantValue, displayName);
if (activeChannelIndex == i) {
selectedItems.add(currentVariant);
}
orientationComponent.getStore().add(currentVariant);
i++;
}
orientationComponent.disableEvents(true);
orientationComponent.setSelection(selectedItems);
orientationComponent.disableEvents(false);
orientationComponent.enable();
} else {
orientationComponent.disableEvents(true);
orientationComponent.setValue(null);
orientationComponent.disableEvents(false);
orientationComponent.disable();
}
grid.getStore().removeAll();
if (activeChannel != null && activeChannel.getCapabilities() != null) {
for (Map.Entry<String, String> capabilityEntry : activeChannel.getCapabilities().entrySet()) {
grid.getStore().add(new GWTJahiaBasicDataBean(capabilityEntry.getValue(), capabilityEntry.getKey()));
}
}
tab.layout();
}
use of org.jahia.ajax.gwt.client.data.GWTJahiaChannel in project jahia by Jahia.
the class ChannelsTabItem method create.
@Override
public TabItem create(GWTSidePanelTab sidePanelTab) {
super.create(sidePanelTab);
tab.setScrollMode(Style.Scroll.AUTO);
tab.setId("JahiaGxtChannelsTab");
VBoxLayout verticalEastLayout = new VBoxLayout();
verticalEastLayout.setVBoxLayoutAlign(VBoxLayout.VBoxLayoutAlign.STRETCH);
tab.setLayout(verticalEastLayout);
VerticalPanel deviceDetailsPanel = new VerticalPanel();
deviceDetailsPanel.setTableWidth("100%");
deviceDetailsPanel.setHorizontalAlign(Style.HorizontalAlignment.CENTER);
deviceImage = new Image();
deviceDetailsPanel.add(deviceImage, new TableData("64px", "64px"));
deviceNameLabel = new Label(Messages.get("label.deviceName", "Device name"));
deviceDetailsPanel.add(deviceNameLabel);
FormPanel formPanel = new FormPanel();
formPanel.setPadding(2);
formPanel.setBorders(false);
formPanel.setBodyBorder(false);
formPanel.setHeaderVisible(false);
ListStore<GWTJahiaChannel> channelListStore = new ListStore<GWTJahiaChannel>();
channelListStore.add(JahiaGWTParameters.getChannels());
deviceCombo = new ComboBox<GWTJahiaChannel>();
deviceCombo.setEmptyText(Messages.get("label.selectDevice", "Select device..."));
deviceCombo.setDisplayField("display");
deviceCombo.setStore(channelListStore);
if (channelListStore.getCount() > 0) {
GWTJahiaChannel channel = channelListStore.getAt(0);
deviceCombo.setValue(channel);
deviceImage.setUrl(JahiaGWTParameters.getContextPath() + channel.getCapability("device-image"));
} else {
deviceCombo.setValue(null);
deviceCombo.disable();
}
deviceCombo.setTypeAhead(true);
deviceCombo.setWidth(100);
deviceCombo.setFieldLabel(Messages.get("label.device", "Device"));
deviceCombo.setTriggerAction(ComboBox.TriggerAction.ALL);
deviceCombo.setTemplate(getChannelTemplate());
deviceCombo.setItemSelector("div.thumb-wrap");
deviceCombo.addSelectionChangedListener(new SelectionChangedListener<GWTJahiaChannel>() {
@Override
public void selectionChanged(SelectionChangedEvent<GWTJahiaChannel> event) {
GWTJahiaChannel selectedChannel = event.getSelectedItem();
editLinker.getMainModule().switchChannel(selectedChannel, null);
doRefresh();
}
});
formPanel.add(deviceCombo);
// we will setup the right elements now because we will need to reference them in the event listener
final ListStore<GWTJahiaBasicDataBean> orientations = new ListStore<GWTJahiaBasicDataBean>();
orientationComponent = new ComboBox<GWTJahiaBasicDataBean>();
orientationComponent.setEmptyText(Messages.get("label.selectVariant", "Select variant..."));
orientationComponent.setDisplayField("displayName");
orientationComponent.setName("previewChannelOrientation");
orientationComponent.setStore(orientations);
if (orientations.getCount() > 0) {
orientationComponent.setValue(orientations.getAt(0));
} else {
orientationComponent.disable();
}
orientationComponent.setTypeAhead(true);
orientationComponent.setWidth(100);
orientationComponent.setFieldLabel(Messages.get("label.variant", "Variant"));
orientationComponent.setTriggerAction(ComboBox.TriggerAction.ALL);
orientationComponent.addSelectionChangedListener(new SelectionChangedListener<GWTJahiaBasicDataBean>() {
@Override
public void selectionChanged(SelectionChangedEvent<GWTJahiaBasicDataBean> se) {
editLinker.getMainModule().switchChannel(editLinker.getActiveChannel(), se.getSelectedItem().getValue());
}
});
formPanel.add(orientationComponent, new FormData("100%"));
deviceDetailsPanel.add(formPanel);
VBoxLayoutData firstBoxLayoutData = new VBoxLayoutData();
firstBoxLayoutData.setFlex(1);
tab.add(deviceDetailsPanel, firstBoxLayoutData);
ContentPanel gridContentPanel = new ContentPanel(new FitLayout());
gridContentPanel.setHeadingHtml(Messages.get("label.capabilities", "Capabilities"));
ListStore<GWTJahiaBasicDataBean> capabilitiesStore = new ListStore<GWTJahiaBasicDataBean>();
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig();
column.setId("displayName");
column.setHeaderHtml(Messages.get("label.name", "Name"));
column.setRowHeader(true);
column.setWidth(100);
configs.add(column);
column = new ColumnConfig();
column.setId("value");
column.setHeaderHtml(Messages.get("label.value", "Value"));
column.setWidth(100);
configs.add(column);
ColumnModel cm = new ColumnModel(configs);
grid = new Grid<GWTJahiaBasicDataBean>(capabilitiesStore, cm);
grid.setAutoExpandColumn("value");
gridContentPanel.add(grid);
// grid.setAutoExpandColumn(cm.getAutoExpand());
VBoxLayoutData contentVBoxData = new VBoxLayoutData();
contentVBoxData.setFlex(3);
tab.add(gridContentPanel, contentVBoxData);
BorderLayoutData eastData = new BorderLayoutData(Style.LayoutRegion.EAST);
eastData.setSplit(true);
eastData.setCollapsible(true);
eastData.setSize(200);
eastData.setHidden(true);
return tab;
}
use of org.jahia.ajax.gwt.client.data.GWTJahiaChannel 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();
}
Aggregations