<artifactId>contextmenu</artifactId>
<version>4.5</version>
</dependency>
+ <dependency>
+ <groupId>org.vaadin.teemu</groupId>
+ <artifactId>switch</artifactId>
+ <version>3.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.vaadin.addon</groupId>
+ <artifactId>vaadin-onoffswitch</artifactId>
+ <version>0.0.1</version>
+ </dependency>
<!-- <dependency>
only in the edit repo
<groupId>org.vaadin.addons</groupId>
+
+ <inherits name="org.vaadin.teemu.switchui.SwitchComponentWidgetset" />
+
+ <inherits name="com.vaadin.addon.onoffswitch.WidgetSet" />
</module>
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
-package eu.etaxonomy.cdm.vaadin.component;
+package eu.etaxonomy.cdm.vaadin.component.common;
import java.util.HashSet;
import java.util.Set;
import eu.etaxonomy.cdm.model.common.TimePeriod;
import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser;
+import eu.etaxonomy.cdm.vaadin.component.PartialDateField;
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles;
import eu.etaxonomy.cdm.vaadin.util.formatter.DateTimeFormat;
import eu.etaxonomy.cdm.vaadin.util.formatter.TimePeriodFormatter;
}
//---------------------------------------------
- //private final String INITIAL_VIEW = "workflow/edit/100002";
+ // public static final String INITIAL_VIEW = "workflow/edit/10";
public static final String INITIAL_VIEW = DashBoardView.NAME;
+ static boolean debugMode = false;
/*
* this HACKY solution forces the bean to be instantiated, TODO do it properly
eventBus.publishEvent(new UIInitializedEvent());
- //navigate to initial view
- eventBus.publishEvent(new NavigationEvent(INITIAL_VIEW));
-
String brand = "phycobank";
//TODO create annotation:
// @Styles(files={""}, branding="brand")
// the 'vaadin://' protocol refers to the VAADIN folder
Resource registryCssFile = new ExternalResource("vaadin://branding/" + brand + "/css/branding.css");
Page.getCurrent().getStyles().add(registryCssFile);
+
+ //navigate to initial view
+ String state = pageFragmentAsState();
+
+ if(debugMode && state != null){
+ eventBus.publishEvent(new NavigationEvent(state));
+ } else {
+ eventBus.publishEvent(new NavigationEvent(INITIAL_VIEW));
+ }
+ }
+
+ /**
+ * @return
+ */
+ private String pageFragmentAsState() {
+ Page page = Page.getCurrent();
+ String fragment = page.getUriFragment();
+ String state = null;
+ if(fragment.startsWith("!")){
+ state = fragment.substring(1, fragment.length());
+ }
+ return state;
}
}
import eu.etaxonomy.cdm.model.reference.Reference;
import eu.etaxonomy.cdm.model.reference.ReferenceType;
-import eu.etaxonomy.cdm.vaadin.component.TimePeriodField;
+import eu.etaxonomy.cdm.vaadin.component.common.TimePeriodField;
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView;
import eu.etaxonomy.vaadin.mvp.AbstractCdmPopupEditor;
typeSelect.setRows(1);
addField(typeSelect, "type", 3, row);
row++;
- addTextField("Reference cache", "titleCache", 0, row, GRID_COLS-1, row).setWidth(100, Unit.PERCENTAGE);
+ addSwitchableTextField("Reference cache", "titleCache", "protectedTitleCache", 0, row, GRID_COLS-1, row).setWidth(100, Unit.PERCENTAGE);
row++;
- addTextField("Abbrev. cache", "abbrevTitleCache", 0, row, GRID_COLS-1, row).setWidth(100, Unit.PERCENTAGE);
+ addSwitchableTextField("Abbrev. cache", "abbrevTitleCache", "protectedAbbrevTitleCache", 0, row, GRID_COLS-1, row).setWidth(100, Unit.PERCENTAGE);
row++;
titleField = addTextField("Title", "title", 0, row, GRID_COLS-1, row);
titleField.setRequired(true);
--- /dev/null
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.vaadin.component;
+
+import org.vaadin.teemu.switchui.Switch;
+
+import com.vaadin.data.fieldgroup.FieldGroup;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.CustomField;
+import com.vaadin.ui.TextField;
+
+
+/**
+ * @author a.kohlbecker
+ * @since May 11, 2017
+ *
+ */
+public class SwitchableTextField extends CustomField<String> {
+
+ private static final long serialVersionUID = -4760153886584883137L;
+
+ private static final String PRIMARY_STYLE = "v-switchable-textfield";
+
+ CssLayout root = new CssLayout();
+ private TextField textField = new TextField();
+ private SwitchButton unlockSwitch = new SwitchButton();
+
+ /**
+ * @param caption
+ */
+ public SwitchableTextField(String caption) {
+ super();
+ textField.setCaption(caption);
+ unlockSwitch.addValueChangeListener(e -> {
+ textField.setEnabled(unlockSwitch.getValue());
+ });
+ unlockSwitch.setValueSetLister(e -> {
+ textField.setEnabled(unlockSwitch.getValue());
+ });
+ }
+
+ /**
+ * {@inheritDoc}textField
+ */
+ @Override
+ protected Component initContent() {
+ root = new CssLayout();
+ root.addComponent(textField);
+ root.setWidth(getWidth(), getWidthUnits());
+ textField.setWidth(getWidth(), getWidthUnits());
+ root.addComponent(unlockSwitch);
+ setPrimaryStyleName(PRIMARY_STYLE);
+ return root;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Class<? extends String> getType() {
+ return String.class;
+ }
+
+ /**
+ * @return the serialversionuid
+ */
+ public static long getSerialversionuid() {
+ return serialVersionUID;
+ }
+
+ /**
+ * @return the textField
+ */
+ public TextField getTextField() {
+ return textField;
+ }
+
+ /**
+ * @return the unlockSwitch
+ */
+ public Switch getUnlockSwitch() {
+ return unlockSwitch;
+ }
+
+ public void bindTo(FieldGroup fieldGroup, Object textPropertyId, Object switchPropertyId){
+ fieldGroup.bind(textField, textPropertyId);
+ fieldGroup.bind(unlockSwitch, switchPropertyId);
+ textField.setEnabled(unlockSwitch.getValue());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setWidthUndefined() {
+ super.setWidthUndefined();
+ root.setWidthUndefined();
+ textField.setWidthUndefined();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setWidth(String width) {
+ super.setWidth(width);
+ root.setWidth(width);
+ textField.setWidth(width);
+ }
+
+ @Override
+ public void setWidth(float width, Unit unit){
+ super.setWidth(width, unit);
+ if(root != null){
+ root.setWidth(width, unit);
+ textField.setWidth(width, unit);
+ }
+ }
+
+ @Override
+ public void setStyleName(String style) {
+ super.setStyleName(style);
+ textField.setStyleName(style);
+ unlockSwitch.setStyleName(style);
+ }
+
+ @Override
+ public void addStyleName(String style) {
+ super.addStyleName(style);
+ textField.addStyleName(style);
+ unlockSwitch.addStyleName(style);
+ }
+
+ private class SwitchButton extends Switch {
+
+ private static final long serialVersionUID = 2557108593729214773L;
+
+ private ValueChangeListener valueSetListener = null;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void setInternalValue(Boolean newValue) {
+ super.setInternalValue(newValue);
+ if(valueSetListener != null){
+ valueSetListener.valueChange(new ValueChangeEvent(this));
+ }
+ }
+
+ public void setValueSetLister(ValueChangeListener valueSetListener){
+ this.valueSetListener = valueSetListener;
+ }
+
+
+
+ }
+}
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.ValoTheme;
+import eu.etaxonomy.vaadin.component.SwitchableTextField;
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent;
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent.Reason;
return addField(new TextField(caption), propertyId, column, row);
}
+ protected SwitchableTextField addSwitchableTextField(String caption, String textPropertyId, String switchPropertyId, int column1, int row1,
+ int column2, int row2)
+ throws OverlapsException, OutOfBoundsException {
+
+ SwitchableTextField field = new SwitchableTextField(caption);
+ field.bindTo(fieldGroup, textPropertyId, switchPropertyId);
+ addComponent(field, column1, row1, column2, row2);
+ return field;
+ }
+
+ protected SwitchableTextField addSwitchableTextField(String caption, String textPropertyId, String switchPropertyId, int column, int row)
+ throws OverlapsException, OutOfBoundsException {
+
+ SwitchableTextField field = new SwitchableTextField(caption);
+ field.bindTo(fieldGroup, textPropertyId, switchPropertyId);
+ addComponent(field, column, row);
+ return field;
+ }
+
protected PopupDateField addDateField(String caption, String propertyId) {
return addField(new PopupDateField(caption), propertyId);
}
+
+ <inherits name="org.vaadin.teemu.switchui.SwitchComponentWidgetset" />
+
+ <inherits name="com.vaadin.addon.onoffswitch.WidgetSet" />
</module>
color: $helper-color;
background-color: valo-font-color($helper-color);
border-radius: $v-border-radius;
- }
+ }
+
+ // v-switchable-textfield
+ .v-switchable-textfield {
+ height: $v-line-height * 2;
+ .v-caption {
+ display: block;
+ }
+ .v-textfield {
+ padding-right: $v-unit-size;
+ }
+ .v-switch {
+ z-index: 10;
+ width: $v-unit-size;
+ position: absolute;
+ right: 1px;
+ bottom: 1px;
+ }
+ }
}
\ No newline at end of file