use of com.vaadin.v7.data.Property.ValueChangeListener in project opencms-core by alkacon.
the class CmsLocaleComparePanel method initialize.
/**
* Initializes the locale comparison view.<p>
*
* @param id the structure id of the currrent sitemap root entry
* @param initialComparisonLocale if not null, the initially selected ccomparison locale
*
* @throws CmsException if something goes wrong
*/
public void initialize(CmsUUID id, Locale initialComparisonLocale) throws CmsException {
removeAllComponents();
CmsObject cms = A_CmsUI.getCmsObject();
CmsResource res = cms.readResource(id);
m_currentRoot = res;
CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(res.getRootPath());
Locale rootLocale = OpenCms.getLocaleManager().getDefaultLocale(cms, res);
m_rootLocale = rootLocale;
Locale mainLocale = site.getMainTranslationLocale(null);
List<Locale> secondaryLocales = site.getSecondaryTranslationLocales();
List<Locale> possibleLocaleSelections = getMainLocaleSelectOptions(cms, res, mainLocale, secondaryLocales);
m_rootLocaleSelector = new ComboBox();
m_rootLocaleSelector.addStyleName("o-sitemap-localeselect");
m_rootLocaleSelector.setNullSelectionAllowed(false);
for (Locale selectableLocale : possibleLocaleSelections) {
m_rootLocaleSelector.addItem(selectableLocale);
m_rootLocaleSelector.setItemIcon(selectableLocale, FontOpenCms.SPACE);
m_rootLocaleSelector.setItemCaption(selectableLocale, selectableLocale.getDisplayName(A_CmsUI.get().getLocale()));
}
m_rootLocaleSelector.setItemIcon(mainLocale, MAIN_LOCALE_ICON);
m_rootLocaleSelector.setValue(m_rootLocale);
m_rootLocaleSelector.addValueChangeListener(new ValueChangeListener() {
private static final long serialVersionUID = 1L;
@SuppressWarnings("synthetic-access")
public void valueChange(ValueChangeEvent event) {
if (!m_handlingLocaleChange) {
m_handlingLocaleChange = true;
try {
Locale newLocale = (Locale) (event.getProperty().getValue());
switchToLocale(newLocale);
} catch (Exception e) {
LOG.error(e.getLocalizedMessage(), e);
CmsErrorDialog.showErrorDialog(e);
} finally {
m_handlingLocaleChange = false;
}
}
}
});
m_comparisonLocaleSelector = new ComboBox();
m_comparisonLocaleSelector.addStyleName("o-sitemap-localeselect");
m_comparisonLocaleSelector.setNullSelectionAllowed(false);
List<Locale> comparisonLocales = getComparisonLocales();
Locale selectedComparisonLocale = null;
for (Locale comparisonLocale : comparisonLocales) {
m_comparisonLocaleSelector.addItem(comparisonLocale);
m_comparisonLocaleSelector.setItemIcon(comparisonLocale, FontOpenCms.SPACE);
m_comparisonLocaleSelector.setItemCaption(comparisonLocale, comparisonLocale.getDisplayName(A_CmsUI.get().getLocale()));
if ((selectedComparisonLocale == null) && !comparisonLocale.equals(m_rootLocale)) {
selectedComparisonLocale = comparisonLocale;
}
if ((initialComparisonLocale != null) && comparisonLocale.equals(initialComparisonLocale) && !comparisonLocale.equals(m_rootLocale)) {
// if an initial comparison locale is given, it should have priority over the first comparison locale
selectedComparisonLocale = comparisonLocale;
}
}
m_comparisonLocale = selectedComparisonLocale;
m_comparisonLocaleSelector.setValue(selectedComparisonLocale);
m_comparisonLocaleSelector.setItemIcon(mainLocale, MAIN_LOCALE_ICON);
m_comparisonLocaleSelector.addValueChangeListener(new ValueChangeListener() {
private static final long serialVersionUID = 1L;
@SuppressWarnings("synthetic-access")
public void valueChange(ValueChangeEvent event) {
if (!m_handlingLocaleChange) {
m_handlingLocaleChange = true;
try {
Locale locale = (Locale) (event.getProperty().getValue());
if (m_rootLocale.equals(locale)) {
Locale oldComparisonLocale = m_comparisonLocale;
if (getLocaleGroup().getResourcesByLocale().keySet().contains(oldComparisonLocale)) {
m_comparisonLocale = locale;
switchToLocale(oldComparisonLocale);
updateLocaleWidgets();
} else {
Notification.show(CmsVaadinUtils.getMessageText(Messages.GUI_LOCALECOMPARE_CANNOT_SWITCH_COMPARISON_LOCALE_0));
m_comparisonLocaleSelector.setValue(oldComparisonLocale);
}
} else {
m_comparisonLocale = locale;
updateLocaleWidgets();
initTree(m_currentRoot);
}
} catch (Exception e) {
LOG.error(e.getLocalizedMessage(), e);
CmsErrorDialog.showErrorDialog(e);
} finally {
m_handlingLocaleChange = false;
}
}
}
});
CssLayout localeSelectors = new CssLayout();
localeSelectors.addStyleName(OpenCmsTheme.SITEMAP_LOCALE_BAR);
m_rootLocaleSelector.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_LOCALECOMPARE_MAIN_LOCALE_0));
m_comparisonLocaleSelector.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_LOCALECOMPARE_COMPARISON_LOCALE_0));
localeSelectors.setWidth("100%");
localeSelectors.addComponent(m_rootLocaleSelector);
localeSelectors.addComponent(m_comparisonLocaleSelector);
// localeSelectors.setComponentAlignment(wrapper2, Alignment.MIDDLE_RIGHT);
setSpacing(true);
addComponent(localeSelectors);
addComponent(m_treeContainer);
m_treeContainer.setWidth("100%");
initTree(res);
}
use of com.vaadin.v7.data.Property.ValueChangeListener in project opencms-core by alkacon.
the class CmsLogicalCheckboxGroup method remove.
/**
* Removes a check box from the group.<p>
*
* @param checkBox the check box
*/
public void remove(CheckBox checkBox) {
m_checkboxes.remove(checkBox);
if (m_selected == checkBox) {
m_selected = null;
}
ValueChangeListener listener = m_listeners.get(checkBox);
if (listener != null) {
checkBox.removeValueChangeListener(m_listeners.get(checkBox));
}
}
use of com.vaadin.v7.data.Property.ValueChangeListener in project opencms-core by alkacon.
the class CmsLogicalCheckboxGroup method add.
/**
* Adds a check box to the group.<p>
*
* @param checkBox the check box to add
*/
public void add(final CheckBox checkBox) {
checkBox.setValue(Boolean.FALSE);
m_checkboxes.add(checkBox);
ValueChangeListener listener = new ValueChangeListener() {
private static final long serialVersionUID = 1L;
@SuppressWarnings("synthetic-access")
public void valueChange(ValueChangeEvent event) {
if (m_runningEvent) {
return;
} else {
try {
m_runningEvent = true;
if (((Boolean) event.getProperty().getValue()).booleanValue()) {
if ((m_selected != null) && (m_selected != checkBox)) {
m_selected.setValue(Boolean.FALSE);
}
setActiveCheckBox(checkBox);
} else {
setActiveCheckBox(null);
m_selected = null;
}
// TODO Auto-generated method stub
} finally {
m_runningEvent = false;
}
}
}
};
checkBox.addValueChangeListener(listener);
m_listeners.put(checkBox, listener);
}
use of com.vaadin.v7.data.Property.ValueChangeListener in project opencms-core by alkacon.
the class CmsSiteSelectDialog method initForm.
/**
* Initializes the form component.<p>
*
* @return the form component
*/
private FormLayout initForm() {
FormLayout form = new FormLayout();
form.setWidth("100%");
m_siteComboBox = prepareSiteSelector(org.opencms.workplace.Messages.GUI_LABEL_SITE_0);
m_siteComboBox.setValue(new CmsExtendedSiteSelector.SiteSelectorOption(A_CmsUI.getCmsObject().getRequestContext().getSiteRoot(), null, null));
form.addComponent(m_siteComboBox);
ValueChangeListener changeListener = new ValueChangeListener() {
private static final long serialVersionUID = 1L;
public void valueChange(ValueChangeEvent event) {
submit();
}
};
m_siteComboBox.addValueChangeListener(evt -> submit());
return form;
}
use of com.vaadin.v7.data.Property.ValueChangeListener in project opencms-core by alkacon.
the class CmsDataViewPanel method updateFilters.
/**
* Changes the displayed filters to a new set.<p>
*
* @param newFilters the new filters
*/
public void updateFilters(List<CmsDataViewFilter> newFilters) {
if (newFilters.isEmpty()) {
m_filterContainer.setVisible(false);
}
if (m_filters.equals(newFilters)) {
return;
}
m_filterContainer.removeAllComponents();
m_filters = newFilters;
m_filterMap.clear();
for (CmsDataViewFilter filter : newFilters) {
m_filterMap.put(filter.getId(), filter);
final CmsDataViewFilter finalFilter = filter;
ComboBox select = new ComboBox(filter.getNiceName());
select.setWidth("175px");
select.setNullSelectionAllowed(false);
select.setPageLength(0);
Map<String, String> options = filter.getOptions();
for (Map.Entry<String, String> entry : options.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
select.addItem(key);
select.setItemCaption(key, value);
}
select.setValue(filter.getValue());
if (filter.getHelpText() != null) {
select.setDescription(filter.getHelpText());
}
select.addValueChangeListener(new ValueChangeListener() {
private static final long serialVersionUID = 1L;
public void valueChange(ValueChangeEvent event) {
String newValue = (String) (event.getProperty().getValue());
updateFilter(finalFilter.getId(), newValue);
}
});
m_filterContainer.addComponent(select);
}
}
Aggregations