use of com.vaadin.v7.ui.Field in project opencms-core by alkacon.
the class CmsEditModuleForm method updateModule.
/**
* Writes the form data back to the module.<p>
*/
public void updateModule() {
try {
m_fieldGroup.commit();
// validate 'dynamic' tabs here
TreeMap<String, String> params = Maps.newTreeMap();
for (I_CmsEditableGroupRow row : m_parameterGroup.getRows()) {
TextField paramField = (TextField) (row.getComponent());
String paramStr = paramField.getValue();
int eqPos = paramStr.indexOf("=");
if (eqPos >= 0) {
String key = paramStr.substring(0, eqPos);
key = key.trim();
String value = paramStr.substring(eqPos + 1);
value = value.trim();
if (!CmsStringUtil.isEmpty(key)) {
params.put(key, value);
}
}
}
m_module.setParameters(params);
List<CmsExportPoint> exportPoints = Lists.newArrayList();
for (I_CmsEditableGroupRow row : m_exportPointGroup.getRows()) {
CmsExportPointWidget widget = (CmsExportPointWidget) (row.getComponent());
String source = widget.getUri().trim();
String target = widget.getDestination().trim();
if (CmsStringUtil.isEmpty(source) || CmsStringUtil.isEmpty(target)) {
continue;
}
CmsExportPoint point = new CmsExportPoint(source, target);
exportPoints.add(point);
}
m_module.setExportPoints(exportPoints);
List<CmsModuleDependency> dependencies = Lists.newArrayList();
for (CmsModuleDependencyWidget widget : getFormRowChildren(m_dependencies, CmsModuleDependencyWidget.class)) {
String moduleName = widget.getModuleName();
String moduleVersion = widget.getModuleVersion();
try {
CmsModuleDependency dep = new CmsModuleDependency(moduleName, new CmsModuleVersion(moduleVersion));
dependencies.add(dep);
} catch (Exception e) {
LOG.debug(e.getLocalizedMessage(), e);
}
}
m_module.setDependencies(dependencies);
List<String> moduleResources = Lists.newArrayList();
for (I_CmsEditableGroupRow row : m_moduleResourcesGroup.getRows()) {
CmsModuleResourceSelectField field = (CmsModuleResourceSelectField) (row.getComponent());
String moduleResource = field.getValue().trim();
if (!moduleResource.isEmpty()) {
moduleResources.add(moduleResource);
}
}
m_module.setResources(moduleResources);
List<String> excludedResources = Lists.newArrayList();
for (I_CmsEditableGroupRow row : m_excludedResourcesGroup.getRows()) {
CmsModuleResourceSelectField field = (CmsModuleResourceSelectField) (row.getComponent());
String moduleResource = field.getValue().trim();
if (!moduleResource.isEmpty()) {
excludedResources.add(moduleResource);
}
}
m_module.setExcludeResources(excludedResources);
if (!m_oldModuleInstance.isAutoIncrement() && m_module.isAutoIncrement()) {
m_module.setCheckpointTime(System.currentTimeMillis());
}
CmsObject cms = A_CmsUI.getCmsObject();
if (m_new) {
createModuleFolders(cms, m_module);
OpenCms.getModuleManager().addModule(cms, m_module);
} else {
OpenCms.getModuleManager().updateModule(cms, m_module);
}
CmsVaadinUtils.getWindow(this).close();
m_updateCallback.run();
} catch (CommitException e) {
if (e.getCause() instanceof FieldGroup.FieldGroupInvalidValueException) {
int minTabIdx = 999;
for (Field<?> field : e.getInvalidFields().keySet()) {
int tabIdx = getTabIndex(field);
if (tabIdx != -1) {
minTabIdx = Math.min(tabIdx, minTabIdx);
}
}
m_tabs.setSelectedTab(minTabIdx);
} else {
CmsErrorDialog.showErrorDialog(e);
}
return;
} catch (Exception e) {
CmsErrorDialog.showErrorDialog(e);
}
}
use of com.vaadin.v7.ui.Field in project opencms-core by alkacon.
the class CmsMessageBundleEditorOptions method initAddKeyInput.
/**
* Initializes the input field for new keys {@link #m_addKeyInput}.
*/
private void initAddKeyInput() {
// the input field for the key
m_addKeyInput = new TextField();
m_addKeyInput.setWidth("100%");
m_addKeyInput.setInputPrompt(m_messages.key(Messages.GUI_INPUT_PROMPT_ADD_KEY_0));
final ShortcutListener shortCutListener = new ShortcutListener("Add key via ENTER", KeyCode.ENTER, null) {
private static final long serialVersionUID = 1L;
@Override
public void handleAction(Object sender, Object target) {
handleAddKey();
}
};
m_addKeyInput.addFocusListener(new FocusListener() {
private static final long serialVersionUID = 1L;
public void focus(FocusEvent event) {
m_addKeyInput.addShortcutListener(shortCutListener);
}
});
m_addKeyInput.addBlurListener(new BlurListener() {
private static final long serialVersionUID = 1L;
public void blur(BlurEvent event) {
m_addKeyInput.removeShortcutListener(shortCutListener);
}
});
}
use of com.vaadin.v7.ui.Field in project opencms-core by alkacon.
the class CmsMessageBundleEditorOptions method initLowerRightComponent.
/**
* Initializes the lower right component {@link #m_lowerRightComponent}, with all its components, i.e.,
* the "Add key" input field {@link #m_addKeyInput} and the "Add key" button.
*/
private void initLowerRightComponent() {
initAddKeyInput();
Component addKeyButton = createAddKeyButton();
HorizontalLayout addKeyWrapper = new HorizontalLayout(addKeyButton);
addKeyWrapper.setComponentAlignment(addKeyButton, Alignment.MIDDLE_CENTER);
addKeyWrapper.setHeight("100%");
addKeyWrapper.setWidth(CmsMessageBundleEditorTypes.OPTION_COLUMN_WIDTH_PX);
FormLayout inputForm = new FormLayout(m_addKeyInput);
inputForm.setWidth("100%");
HorizontalLayout lowerRight = new HorizontalLayout();
lowerRight.setWidth("100%");
lowerRight.addComponent(inputForm);
lowerRight.addComponent(addKeyWrapper);
lowerRight.setExpandRatio(inputForm, 1f);
m_lowerRightComponent = lowerRight;
}
use of com.vaadin.v7.ui.Field in project opencms-core by alkacon.
the class CmsDbSynchronizationView method addResource.
/**
* Adds a resource to form.<p>
*
* @param path of resource to add
*/
protected void addResource(String path) {
CmsPathSelectField field = new CmsPathSelectField();
field.setCmsObject(m_cms);
field.setUseRootPaths(true);
field.setValue(path);
field.addValueChangeListener(new ValueChangeListener() {
private static final long serialVersionUID = 8646438704383992571L;
public void valueChange(ValueChangeEvent event) {
setOkButtonEnabled(true);
}
});
m_componentsToValidate.add(field);
CmsRemovableFormRow<CmsPathSelectField> row = new CmsRemovableFormRow<CmsPathSelectField>(field, CmsVaadinUtils.getMessageText(Messages.GUI_DATABASEAPP_SYNC_REMOVE_RESOURCE_0));
row.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_DATABASEAPP_SYNC_RESOURCE_0));
row.setRemoveRunnable(new Runnable() {
public void run() {
setOkButtonEnabled(true);
}
});
m_resources.addComponent(row);
}
use of com.vaadin.v7.ui.Field in project opencms-core by alkacon.
the class CmsEditSiteForm method isValidAliase.
/**
* Are the aliase valid?<p>
*
* @return true if ok
*/
boolean isValidAliase() {
boolean ret = true;
for (I_CmsEditableGroupRow row : m_aliasGroup.getRows()) {
FormLayout layout = (FormLayout) (row.getComponent());
TextField field = (TextField) layout.getComponent(0);
ret = ret & field.isValid();
}
return ret;
}
Aggregations