reorganized the dialog model and code
diff --git a/org.eclipse.osbp.ecview.extension.editparts.emf/src/org/eclipse/osbp/ecview/extension/editparts/emf/SuspectLayoutingInfoEditpart.java b/org.eclipse.osbp.ecview.extension.editparts.emf/src/org/eclipse/osbp/ecview/extension/editparts/emf/SuspectLayoutingInfoEditpart.java
index ffb9ad9..e964644 100644
--- a/org.eclipse.osbp.ecview.extension.editparts.emf/src/org/eclipse/osbp/ecview/extension/editparts/emf/SuspectLayoutingInfoEditpart.java
+++ b/org.eclipse.osbp.ecview.extension.editparts.emf/src/org/eclipse/osbp/ecview/extension/editparts/emf/SuspectLayoutingInfoEditpart.java
@@ -338,6 +338,11 @@
try {
// hold a reference to the bindingSet
bindingSet = getView().getBindingSet();
+
+ if(getBindings().size() == 2){
+ // TODO for debug
+ LOGGER.debug("Size bindingset = 2");
+ }
for (IBindingEditpart<?> binding : getBindings()) {
// else add it
bindingSet.addTransientBinding(binding);
diff --git a/org.eclipse.osbp.ecview.extension.editparts.emf/src/org/eclipse/osbp/ecview/extension/editparts/emf/strategies/DefaultLayoutingStrategyEditpart.java b/org.eclipse.osbp.ecview.extension.editparts.emf/src/org/eclipse/osbp/ecview/extension/editparts/emf/strategies/DefaultLayoutingStrategyEditpart.java
index e6ad67c..02b2a5a 100644
--- a/org.eclipse.osbp.ecview.extension.editparts.emf/src/org/eclipse/osbp/ecview/extension/editparts/emf/strategies/DefaultLayoutingStrategyEditpart.java
+++ b/org.eclipse.osbp.ecview.extension.editparts.emf/src/org/eclipse/osbp/ecview/extension/editparts/emf/strategies/DefaultLayoutingStrategyEditpart.java
@@ -73,10 +73,7 @@
* Sets the default strategy.
*/
protected void setDefaultStrategy() {
-// IViewContext viewContext = getView().getContext();
ILayoutingStrategyProvider provider = findDefaultService();
-// ILayoutingStrategyProvider provider = viewContext
-// .getService(ILayoutingStrategyProvider.class.getName());
if (provider == null) {
LOGGER.error("IDefaultLayoutingStrategyProvider not available!");
return;
diff --git a/org.eclipse.osbp.ecview.extension.feature/feature.xml b/org.eclipse.osbp.ecview.extension.feature/feature.xml
index d52a950..a35f8c8 100644
--- a/org.eclipse.osbp.ecview.extension.feature/feature.xml
+++ b/org.eclipse.osbp.ecview.extension.feature/feature.xml
@@ -4,7 +4,8 @@
id="org.eclipse.osbp.ecview.extension.feature"
label="%featureName"
version="0.9.0.qualifier"
- provider-name="%providerName">
+ provider-name="%providerName"
+ plugin="org.eclipse.osbp.license">
<description>
%description
diff --git a/org.eclipse.osbp.ecview.extension.presentation.vaadin/src/org/eclipse/osbp/ecview/extension/presentation/vaadin/components/common/ECViewComponent.java b/org.eclipse.osbp.ecview.extension.presentation.vaadin/src/org/eclipse/osbp/ecview/extension/presentation/vaadin/components/common/ECViewComponent.java
index 7428a80..57df0b5 100644
--- a/org.eclipse.osbp.ecview.extension.presentation.vaadin/src/org/eclipse/osbp/ecview/extension/presentation/vaadin/components/common/ECViewComponent.java
+++ b/org.eclipse.osbp.ecview.extension.presentation.vaadin/src/org/eclipse/osbp/ecview/extension/presentation/vaadin/components/common/ECViewComponent.java
@@ -16,6 +16,7 @@
package org.eclipse.osbp.ecview.extension.presentation.vaadin.components.common;
import java.util.HashMap;
+import java.util.Locale;
import java.util.Map;
import org.eclipse.osbp.ecview.core.common.context.ContextException;
@@ -182,6 +183,9 @@
// else check the service for a proper view model
context = service.getViewContext(viewId);
}
+ if(properties.containsKey(IViewContext.PRESET_LOCALE)) {
+ context.setLocale((Locale)properties.get(IViewContext.PRESET_LOCALE));
+ }
if (context != null) {
cache.put(viewId, context);
}
diff --git a/org.eclipse.osbp.ecview.extension.presentation.vaadin/src/org/eclipse/osbp/ecview/extension/presentation/vaadin/converter/SimpleDecimalConverter.java b/org.eclipse.osbp.ecview.extension.presentation.vaadin/src/org/eclipse/osbp/ecview/extension/presentation/vaadin/converter/SimpleDecimalConverter.java
index c7535d1..4316c85 100644
--- a/org.eclipse.osbp.ecview.extension.presentation.vaadin/src/org/eclipse/osbp/ecview/extension/presentation/vaadin/converter/SimpleDecimalConverter.java
+++ b/org.eclipse.osbp.ecview.extension.presentation.vaadin/src/org/eclipse/osbp/ecview/extension/presentation/vaadin/converter/SimpleDecimalConverter.java
@@ -18,6 +18,8 @@
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
+import java.text.ParsePosition;
+import java.util.Currency;
import java.util.Locale;
import org.apache.commons.lang.StringEscapeUtils;
@@ -33,6 +35,8 @@
@SuppressWarnings("serial")
public class SimpleDecimalConverter extends DecimalConverter {
+ private static final String CURRENCY_MASKED = "¤";
+
/** The Constant LOGGER. */
private static final Logger LOGGER = LoggerFactory
.getLogger(SimpleDecimalConverter.class);
@@ -43,6 +47,14 @@
/** The y converter. */
private YSimpleDecimalConverter yConverter;
+ private boolean hasCurrencySymbol;
+
+ private String blankBefore = "";
+
+ private String blankAfter = "";
+
+ private int currencyIndex;
+
/**
* Instantiates a new simple decimal converter.
*
@@ -71,12 +83,24 @@
* #getFormat(java.util.Locale)
*/
@Override
- protected NumberFormat getFormat(Locale locale) {
+ protected DecimalFormat getFormat(Locale locale) {
+ blankBefore = "";
+ blankAfter = "";
if (locale == null) {
locale = Locale.getDefault();
}
DecimalFormat result;
try {
+ currencyIndex = yConverter.getNumberFormatPattern().indexOf(CURRENCY_MASKED);
+ if(currencyIndex > -1) {
+ hasCurrencySymbol = true;
+ if(currencyIndex > 1 && yConverter.getNumberFormatPattern().charAt(currencyIndex-1) == ' ') {
+ blankBefore = " ";
+ }
+ if(currencyIndex < yConverter.getNumberFormatPattern().length()-1 && yConverter.getNumberFormatPattern().charAt(currencyIndex+CURRENCY_MASKED.length()) == ' ') {
+ blankAfter = " ";
+ }
+ }
result = new DecimalFormat(StringEscapeUtils.unescapeHtml(yConverter.getNumberFormatPattern()),
DecimalFormatSymbols.getInstance(locale));
} catch (IllegalArgumentException e) {
@@ -87,4 +111,42 @@
}
return result;
}
+
+ @Override
+ protected Number convertToNumber(String value,
+ Class<? extends Number> targetType, Locale locale)
+ throws ConversionException {
+ if (value == null) {
+ return null;
+ }
+
+ // Remove leading and trailing white space
+ value = value.trim();
+
+ DecimalFormat format = getFormat(locale);
+ // add currency sign if not given to avoid parsing errors
+ if(hasCurrencySymbol && !value.contains(format.getCurrency().getSymbol(locale))) {
+ if(currencyIndex < yConverter.getNumberFormatPattern().length()-3) {
+ value = String.format("%s%s%s%s", format.getCurrency().getSymbol(locale), blankAfter, value, blankBefore);
+ } else {
+ value = String.format("%s%s%s%s", blankAfter, value, blankBefore, format.getCurrency().getSymbol(locale));
+ }
+ }
+
+ // Parse and detect errors. If the full string was not used, it is
+ // an error.
+ ParsePosition parsePosition = new ParsePosition(0);
+ Number parsedValue = format.parse(value, parsePosition);
+ if (parsePosition.getIndex() != value.length()) {
+ throw new ConversionException("Could not convert '" + value
+ + "' to " + getModelType().getName());
+ }
+
+ if (parsedValue == null) {
+ // Convert "" to null
+ return null;
+ }
+
+ return parsedValue;
+ }
}
diff --git a/org.eclipse.osbp.ecview.extension.strategy/META-INF/MANIFEST.MF b/org.eclipse.osbp.ecview.extension.strategy/META-INF/MANIFEST.MF
index a8f407f..3bc3e3a 100644
--- a/org.eclipse.osbp.ecview.extension.strategy/META-INF/MANIFEST.MF
+++ b/org.eclipse.osbp.ecview.extension.strategy/META-INF/MANIFEST.MF
@@ -36,5 +36,7 @@
org.apache.pdfbox;bundle-version="2.0.6",
org.eclipse.e4.core.contexts,
org.eclipse.osbp.dsl.dto.lib;bundle-version="[0.9.0,0.10.0)",
- javax.persistence;bundle-version="2.1.0"
+ javax.persistence;bundle-version="2.1.0",
+ org.eclipse.e4.ui.model.workbench;bundle-version="1.2.0",
+ org.eclipse.e4.core.di;bundle-version="1.6.1"
Service-Component: OSGI-INF/*.xml
diff --git a/org.eclipse.osbp.ecview.extension.strategy/OSGI-INF/org.eclipse.osbp.ecview.extension.strategy.DefaultFocusingEnhancer.xml b/org.eclipse.osbp.ecview.extension.strategy/OSGI-INF/org.eclipse.osbp.ecview.extension.strategy.DefaultFocusingEnhancer.xml
new file mode 100644
index 0000000..ec6a687
--- /dev/null
+++ b/org.eclipse.osbp.ecview.extension.strategy/OSGI-INF/org.eclipse.osbp.ecview.extension.strategy.DefaultFocusingEnhancer.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.osbp.ecview.extension.strategy.DefaultFocusingEnhancer">
+ <property name="ecview.focusing.enhancer.id" value="DefaultFocusingEnhancer"/>
+ <property name="ecview.focusing.enhancer.default" value="true"/>
+ <service>
+ <provide interface="org.eclipse.osbp.ecview.extension.api.IFocusingEnhancer"/>
+ </service>
+ <implementation class="org.eclipse.osbp.ecview.extension.strategy.DefaultFocusingEnhancer"/>
+</scr:component>
\ No newline at end of file
diff --git a/org.eclipse.osbp.ecview.extension.strategy/OSGI-INF/org.eclipse.osbp.ecview.extension.strategy.DefaultLayoutingStrategyProvider.xml b/org.eclipse.osbp.ecview.extension.strategy/OSGI-INF/org.eclipse.osbp.ecview.extension.strategy.DefaultLayoutingStrategyProvider.xml
new file mode 100644
index 0000000..21ec7f3
--- /dev/null
+++ b/org.eclipse.osbp.ecview.extension.strategy/OSGI-INF/org.eclipse.osbp.ecview.extension.strategy.DefaultLayoutingStrategyProvider.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.eclipse.osbp.ecview.extension.strategy.DefaultLayoutingStrategyProvider">
+ <property name="ecview.layouting.id" value="Default"/>
+ <service>
+ <provide interface="org.eclipse.osbp.ecview.extension.api.ILayoutingStrategyProvider"/>
+ </service>
+ <implementation class="org.eclipse.osbp.ecview.extension.strategy.DefaultLayoutingStrategyProvider"/>
+</scr:component>
\ No newline at end of file
diff --git a/org.eclipse.osbp.ecview.extension.strategy/OSGI-INF/org.eclipse.osbp.ecview.extension.strategy.FocusingStrategyContextFunction.xml b/org.eclipse.osbp.ecview.extension.strategy/OSGI-INF/org.eclipse.osbp.ecview.extension.strategy.FocusingStrategyContextFunction.xml
new file mode 100644
index 0000000..ed25417
--- /dev/null
+++ b/org.eclipse.osbp.ecview.extension.strategy/OSGI-INF/org.eclipse.osbp.ecview.extension.strategy.FocusingStrategyContextFunction.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.osbp.ecview.extension.strategy.FocusingStrategyContextFunction">
+ <property name="service.context.key" value="Focusing"/>
+ <service>
+ <provide interface="org.eclipse.e4.core.contexts.IContextFunction"/>
+ </service>
+ <implementation class="org.eclipse.osbp.ecview.extension.strategy.FocusingStrategyContextFunction"/>
+</scr:component>
\ No newline at end of file
diff --git a/org.eclipse.osbp.ecview.extension.strategy/OSGI-INF/org.eclipse.osbp.ecview.extension.strategy.ServiceListener.xml b/org.eclipse.osbp.ecview.extension.strategy/OSGI-INF/org.eclipse.osbp.ecview.extension.strategy.ServiceListener.xml
index dcbf1ee..bf73dc1 100644
--- a/org.eclipse.osbp.ecview.extension.strategy/OSGI-INF/org.eclipse.osbp.ecview.extension.strategy.ServiceListener.xml
+++ b/org.eclipse.osbp.ecview.extension.strategy/OSGI-INF/org.eclipse.osbp.ecview.extension.strategy.ServiceListener.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.osbp.ecview.extension.strategy.ServiceListener">
- <reference bind="bindOrganizationService" cardinality="0..1" interface="org.eclipse.osbp.ui.api.useraccess.IOrganizationService" name="OrganizationService" policy="dynamic" unbind="unbindOrganizationService"/>
+ <reference bind="bindOrganizationService" cardinality="0..n" interface="org.eclipse.osbp.ui.api.useraccess.IOrganizationService" name="OrganizationService" policy="dynamic" unbind="unbindOrganizationService"/>
<implementation class="org.eclipse.osbp.ecview.extension.strategy.ServiceListener"/>
</scr:component>
\ No newline at end of file
diff --git a/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/AbstractFocusingStrategy.java b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/AbstractFocusingStrategy.java
new file mode 100644
index 0000000..82039d7
--- /dev/null
+++ b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/AbstractFocusingStrategy.java
@@ -0,0 +1,111 @@
+package org.eclipse.osbp.ecview.extension.strategy;
+
+import org.eclipse.osbp.ecview.core.common.context.IViewContext;
+import org.eclipse.osbp.ecview.core.common.model.core.YElement;
+import org.eclipse.osbp.ecview.core.common.model.core.YEmbeddable;
+import org.eclipse.osbp.ecview.core.common.model.core.YField;
+import org.eclipse.osbp.ecview.core.common.model.core.YFocusable;
+import org.eclipse.osbp.ecview.core.common.model.core.YView;
+import org.eclipse.osbp.ecview.core.common.services.IWidgetAssocationsService;
+import org.eclipse.osbp.ecview.core.extension.model.extension.YTab;
+import org.eclipse.osbp.ecview.core.extension.model.extension.YTabSheet;
+import org.eclipse.osbp.ecview.core.util.emf.ModelUtil;
+import org.eclipse.osbp.ecview.extension.api.IFocusingStrategy;
+import org.eclipse.osbp.ecview.extension.model.YStrategyLayout;
+import org.eclipse.osbp.ui.api.e4.IE4Dialog;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.vaadin.ui.UI;
+
+public abstract class AbstractFocusingStrategy implements IFocusingStrategy {
+ /** The Constant LOGGER. */
+ private static final Logger LOGGER = LoggerFactory.getLogger(AbstractFocusingStrategy.class);
+
+ abstract int getDirection();
+
+ @Override
+ public void focus(final Object source, final Object target, final YStrategyLayout yLayout) {
+ YView yView = yLayout.getView();
+ IViewContext context = ModelUtil.getViewContext(yView);
+ IWidgetAssocationsService<Object, ? extends YElement> service = context
+ .getService(IWidgetAssocationsService.ID);
+ YEmbeddable yCurrentFocus = (YEmbeddable) service.getModelElement(target);
+ if(yCurrentFocus == null) {
+ LOGGER.debug("{}", "current focus not set");
+ }
+ YEmbeddable yNextFocus = findElementToFocus(yCurrentFocus, service, true);
+ if(yNextFocus != null) {
+ yView.setCurrentFocus((YFocusable) yNextFocus);
+ } else {
+ LOGGER.debug("{}", "next focus not found");
+ }
+ }
+
+ @Override
+ public void focusField(YView yView, String fieldId) {
+ IViewContext context = ModelUtil.getViewContext(yView);
+ IWidgetAssocationsService<Object, ? extends YElement> service = context.getService(IWidgetAssocationsService.ID);
+ YEmbeddable yEmbeddable = null;
+ if(fieldId != null) {
+ LOGGER.debug("current field id:{}", fieldId);
+ yEmbeddable = (YEmbeddable) service.getModelElement(fieldId);
+ } else {
+ LOGGER.debug("current field id is null");
+ yEmbeddable = findElementToFocus((YEmbeddable)service.getModelElement(0), service, false);
+ }
+ if(yEmbeddable instanceof YTabSheet) {
+ YTab tab = ((YTabSheet)yEmbeddable).getTabs().get(0);
+ focusField(tab.getView(), null);
+ }
+ if(yView != null && yEmbeddable instanceof YFocusable) {
+ yView.setCurrentFocus((YFocusable)yEmbeddable);
+ }
+ }
+
+ protected YEmbeddable findElementToFocus(YEmbeddable yElement, IWidgetAssocationsService<Object, ? extends YElement> service, boolean focusNext) {
+ YEmbeddable nextFocusElement = null;
+ int maxIdx = service.getModelElements().size()-1;
+ LOGGER.debug("max idx:{}", maxIdx);
+ int idx = 0;
+ if(getDirection() < 0) {
+ idx = maxIdx;
+ }
+ if (yElement instanceof YFocusable) {
+ idx = ((YFocusable) yElement).getLayoutIdx();
+ LOGGER.debug("current focus index:{}", idx);
+ if(focusNext) {
+ idx += getDirection();
+ }
+ }
+ int turnAround = 0;
+ boolean found = false;
+ do {
+ LOGGER.debug("next focus index:{}", idx);
+ if(idx < 0) {
+ turnAround ++;
+ idx = maxIdx;
+ LOGGER.debug("goto last index:{} turnaround:{}", idx, turnAround);
+ }
+ if(idx > maxIdx) {
+ turnAround ++;
+ idx = 0;
+ LOGGER.debug("goto first index:{} turnaround:{}", idx, turnAround);
+ }
+ nextFocusElement = (YEmbeddable) service.getModelElement(idx);
+ if(nextFocusElement != null && !(nextFocusElement instanceof YTabSheet)) {
+ LOGGER.debug("potential next focus element:{}", nextFocusElement.getId());
+ found = (nextFocusElement instanceof YFocusable);
+ LOGGER.debug("potential next focus element is focusable:{}", found);
+ if(found && nextFocusElement instanceof YField) {
+ found = ((YField) nextFocusElement).isEditable() && ((YField) nextFocusElement).isEnabled() && ((YField) nextFocusElement).isVisible();
+ LOGGER.debug("potential next focus element is field editable:{}", found);
+ } else {
+ LOGGER.debug("unknown type");
+ }
+ }
+ idx = idx + getDirection();
+ } while(turnAround < 3 && !found);
+ return nextFocusElement;
+ }
+}
diff --git a/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/AbstractLayoutingStrategy.java b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/AbstractLayoutingStrategy.java
index 653ead5..37c3781 100644
--- a/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/AbstractLayoutingStrategy.java
+++ b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/AbstractLayoutingStrategy.java
@@ -76,6 +76,7 @@
import org.eclipse.osbp.ecview.core.extension.model.datatypes.YDateTimeResolution;
import org.eclipse.osbp.ecview.core.extension.model.extension.ExtensionModelFactory;
import org.eclipse.osbp.ecview.core.extension.model.extension.YBeanReferenceField;
+import org.eclipse.osbp.ecview.core.extension.model.extension.YButton;
import org.eclipse.osbp.ecview.core.extension.model.extension.YColumn;
import org.eclipse.osbp.ecview.core.extension.model.extension.YComboBox;
import org.eclipse.osbp.ecview.core.extension.model.extension.YDateTime;
@@ -132,6 +133,8 @@
import org.eclipse.osbp.runtime.common.layouting.IPropertyConstants;
import org.eclipse.osbp.ui.api.metadata.IDSLMetadataService;
import org.eclipse.osbp.ui.api.themes.EnumCssClass;
+import org.eclipse.osbp.ui.api.themes.IThemeResourceService;
+import org.eclipse.osbp.ui.api.themes.IThemeResourceService.ThemeResourceType;
import org.eclipse.osbp.ui.api.user.IUser;
import org.eclipse.osbp.ui.api.useraccess.AbstractAuthorization.Action;
import org.eclipse.osbp.ui.api.useraccess.AbstractAuthorization.Group;
@@ -180,7 +183,7 @@
private int layoutingIndex;
private List<YLayout> layoutList = new ArrayList<>();
-
+
private int currentIndex = 0;
private YFormLayout beanLayout;
@@ -189,7 +192,9 @@
private IUser user;
- private static Map<String, Boolean> isSuspectEditable = new HashMap<>();
+ private IThemeResourceService themeResourceService;
+
+ private static Map<String, Boolean> isSuspectEditable = new HashMap<>();
/** The Constant LOGGER. */
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractLayoutingStrategy.class);
@@ -226,7 +231,7 @@
YStrategyLayout yLayout = layoutingInfo.getLayout();
layoutingInfo.getActiveSuspectInfos().clear();
YLayout layout = null;
- if(yLayout.getNumberColumns() > 0) {
+ if (yLayout.getNumberColumns() > 0) {
layout = createColumnedLayout(yLayout.getNumberColumns());
} else {
layout = createContentLayout();
@@ -238,15 +243,16 @@
viewContext = ModelUtil.getViewContext(yLayout);
userAccessService = viewContext.getService(IUserAccessService.class.getName());
dslMetadataService = viewContext.getService(IDSLMetadataService.class.getName());
+ themeResourceService = viewContext.getService(IThemeResourceService.class.getName());
user = viewContext.getService(IUser.class.getName());
-
+
// Identify if a TabSheet is necessary due to existing table or grid
if (isTabSheetNeeded(yLayout.getSuspects())) {
YTabSheet tabSheet;
tabSheet = ExtensionModelFactory.eINSTANCE.createYTabSheet();
YTab tab = ExtensionModelFactory.eINSTANCE.createYTab();
String[] tokens = yLayout.getView().getViewName().split("\\.");
- tab.setLabelI18nKey(tokens[tokens.length-1]);
+ tab.setLabelI18nKey(tokens[tokens.length - 1]);
tab.setEmbeddable(layout);
tabSheet.getTabs().add(tab);
content = tabSheet;
@@ -277,43 +283,40 @@
private YLayout createColumnedLayout(int numberColumns) {
LOGGER.trace("{}", "createColumnedLayout");
- YHorizontalLayout layout = ExtensionModelFactory.eINSTANCE.createYHorizontalLayout();
- for(int i=0; i < numberColumns; i++) {
- layoutList.add(ExtensionModelFactory.eINSTANCE.createYVerticalLayout());
- }
- for (YLayout layoutListItem : layoutList){
- layout.addElement(layoutListItem);
- }
- return layout;
+ YHorizontalLayout layout = ExtensionModelFactory.eINSTANCE.createYHorizontalLayout();
+ for (int i = 0; i < numberColumns; i++) {
+ layoutList.add(ExtensionModelFactory.eINSTANCE.createYVerticalLayout());
+ }
+ for (YLayout layoutListItem : layoutList) {
+ layout.addElement(layoutListItem);
+ }
+ return layout;
}
private void addColumnedElement(final YLayout layout, final YEmbeddable element, int numberColumns) {
- LOGGER.trace("{}", "addColunedElement");
+ LOGGER.trace("{}", "addColumnedElement");
int idx = currentIndex % numberColumns;
int lastAddedIdx = layoutList.get(idx).getElements().size();
YLayout subLayout = null;
- if(lastAddedIdx == 0) {
- if(element instanceof YPanel) {
+ if (lastAddedIdx == 0) {
+ if (element instanceof YPanel) {
subLayout = ExtensionModelFactory.eINSTANCE.createYVerticalLayout();
} else {
subLayout = ExtensionModelFactory.eINSTANCE.createYFormLayout();
}
} else {
- subLayout = (YLayout) layoutList.get(idx).getElement(lastAddedIdx-1);
- if(subLayout instanceof YVerticalLayout && !(element instanceof YPanel)) {
+ subLayout = (YLayout) layoutList.get(idx).getElement(lastAddedIdx - 1);
+ if (subLayout instanceof YVerticalLayout && !(element instanceof YPanel)) {
subLayout = ExtensionModelFactory.eINSTANCE.createYFormLayout();
}
- if(subLayout instanceof YFormLayout && element instanceof YPanel) {
+ if (subLayout instanceof YFormLayout && element instanceof YPanel) {
subLayout = ExtensionModelFactory.eINSTANCE.createYVerticalLayout();
}
}
subLayout.addElement(element);
subLayout.setCssClass("os-no-padding");
layoutList.get(idx).addElement(subLayout);
- currentIndex ++;
- if (element instanceof YFocusable) {
- applyNextLayoutingIndex((YFocusable) element);
- }
+ currentIndex++;
}
/**
@@ -349,7 +352,7 @@
if (ySuspect.getTags().contains(TAG__TABLE) || ySuspect.getTags().contains(TAG__GRID)) {
suspectCollectionList.add(ySuspect);
} else if (ySuspect instanceof YTypedCompoundSuspect && ySuspect.getTags().contains(TAG__BEANONTAB)) {
- for (YSuspect childSuspect : ((YTypedCompoundSuspect)ySuspect).getChildren()) {
+ for (YSuspect childSuspect : ((YTypedCompoundSuspect) ySuspect).getChildren()) {
childSuspect.getTags().add(TAG__BEAN);
childSuspect.setGroupName(ySuspect.getLabelI18nKey());
suspectCollectionList.add(childSuspect);
@@ -362,27 +365,27 @@
// sort by first appearance in entity
HashMap<String, List<YSuspect>> suspectMap = new HashMap<>();
List<String> suspectGroupList = new ArrayList<>();
- for(YSuspect suspect:suspectList) {
- if(suspect.getGroupName() == null) {
+ for (YSuspect suspect : suspectList) {
+ if (suspect.getGroupName() == null) {
String groupName = UNGROUPED;
- if(suspect instanceof YTypedCompoundSuspect && !suspect.getTags().contains(TAG__BEANONTAB)) {
+ if (suspect instanceof YTypedCompoundSuspect && !suspect.getTags().contains(TAG__BEANONTAB)) {
groupName = suspect.getLabelI18nKey();
}
suspectMap.put(groupName, new ArrayList<YSuspect>());
- if(!suspectGroupList.contains(groupName)) {
+ if (!suspectGroupList.contains(groupName)) {
suspectGroupList.add(groupName);
}
} else {
suspectMap.put(suspect.getGroupName(), new ArrayList<YSuspect>());
- if(!suspectGroupList.contains(suspect.getGroupName())) {
+ if (!suspectGroupList.contains(suspect.getGroupName())) {
suspectGroupList.add(suspect.getGroupName());
}
}
}
- for(YSuspect suspect:suspectList) {
- if(suspect.getGroupName() == null) {
+ for (YSuspect suspect : suspectList) {
+ if (suspect.getGroupName() == null) {
String groupName = UNGROUPED;
- if(suspect instanceof YTypedCompoundSuspect && !suspect.getTags().contains(TAG__BEANONTAB)) {
+ if (suspect instanceof YTypedCompoundSuspect && !suspect.getTags().contains(TAG__BEANONTAB)) {
groupName = suspect.getLabelI18nKey();
}
suspectMap.get(groupName).add(suspect);
@@ -391,7 +394,7 @@
}
}
suspectList.clear();
- for(String suspectGroup:suspectGroupList) {
+ for (String suspectGroup : suspectGroupList) {
suspectList.addAll(suspectMap.get(suspectGroup));
}
// add the collections for the following tabs
@@ -424,7 +427,7 @@
tab.setEmbeddable(layout);
tabs.add(tab);
} else if (suspectInfo.getSuspect().getTags().contains(TAG__BEAN)) {
- if(beanTabName == null || !suspectInfo.getSuspect().getGroupName().equals(beanTabName)) {
+ if (beanTabName == null || !suspectInfo.getSuspect().getGroupName().equals(beanTabName)) {
YTab tab = ExtensionModelFactory.eINSTANCE.createYTab();
tab.setLabelI18nKey(suspectInfo.getSuspect().getGroupName());
beanLayout = ExtensionModelFactory.eINSTANCE.createYFormLayout();
@@ -438,7 +441,7 @@
createGrouping(tabs.get(0).getEmbeddable(), element, suspectInfo, numberColumns);
} else {
// Gets the YLayout of the first tab to add the element
- if(numberColumns > 0) {
+ if (numberColumns > 0) {
addColumnedElement((YLayout) tabs.get(0).getEmbeddable(), element, numberColumns);
} else {
addElement((YLayout) tabs.get(0).getEmbeddable(), element);
@@ -449,7 +452,7 @@
if (suspectInfo.getSuspect().getTags().contains(TAG__GROUP)) {
createGrouping(content, element, suspectInfo, numberColumns);
} else {
- if(numberColumns > 0) {
+ if (numberColumns > 0) {
addColumnedElement((YLayout) content, element, numberColumns);
} else {
addElement((YLayout) content, element);
@@ -457,6 +460,9 @@
}
}
+ if (element instanceof YFocusable) {
+ applyNextLayoutingIndex((YFocusable) element);
+ }
}
private void createGrouping(YEmbeddable content, YEmbeddable element, YSuspectInfo suspectInfo, int numberColumns) {
@@ -470,7 +476,7 @@
groupLayout = ExtensionModelFactory.eINSTANCE.createYFormLayout();
panel.addElement(groupLayout);
currentGroup = new GroupInfo(group, groupLayout);
- if(numberColumns > 0) {
+ if (numberColumns > 0) {
addColumnedElement((YLayout) content, panel, numberColumns);
} else {
addElement((YLayout) content, panel);
@@ -500,10 +506,9 @@
* the element
*/
protected abstract void addElement(YLayout layout, YEmbeddable element);
-
-
- protected void applyNextLayoutingIndex(YFocusable focusable){
- if(focusable instanceof YPanel) {
+
+ protected void applyNextLayoutingIndex(YFocusable focusable) {
+ if (focusable instanceof YPanel) {
return;
}
focusable.setLayoutIdx(layoutingIndex);
@@ -552,11 +557,27 @@
// different endpoint
YRichTextArea richtText = (YRichTextArea) yEmbeddable;
yValueEP = richtText.createBlobValueEndpoint();
+ } else if (suspectInfo.getTags().contains(ILayoutingStrategy.TAG__SUGGEST_TEXT)) {
+ if (ep.getTags().contains("dtoBinding")) {
+ // if we need to bind the blob value, then we need to use a
+ // different endpoint
+ YSuggestTextField suggestText = (YSuggestTextField) yEmbeddable;
+ yValueEP = suggestText.createSelectionEndpoint();
+ } else {
+ yValueEP = yBindable.createValueEndpoint();
+ }
} else {
yValueEP = yBindable.createValueEndpoint();
}
YValueBinding yBinding = BindingFactory.eINSTANCE.createYValueBinding();
+
+ // copy all tags from original bindingEndpoint to targets
+ //
+ yBinding.getTags().addAll(epCopy.getTags());
+ epCopy.getTags().addAll(epCopy.getTags());
+ yValueEP.getTags().addAll(epCopy.getTags());
+
yBinding.setModelEndpoint((YValueBindingEndpoint) epCopy);
yBinding.setTargetEndpoint(yValueEP);
@@ -599,6 +620,7 @@
suspectInfo.getBindings().add(yBinding);
}
}
+
}
/**
@@ -624,9 +646,12 @@
yEmbeddable = ExtensionModelFactory.eINSTANCE.createYTextField();
} else if (ySuspect.getTags().contains(TAG__PASSWORD)) {
yEmbeddable = createPasswordField(ySuspect);
+ } else if (ySuspect.getTags().contains(TAG__SAVEANDNEW)) {
+ yEmbeddable = createSaveAndNew(ySuspect);
} else if (ySuspect.getTags().contains(TAG__SUGGEST_TEXT)) {
YTypedSuspect typedSuspect = (YTypedSuspect) ySuspect;
YSuggestTextField yField = ExtensionModelFactory.eINSTANCE.createYSuggestTextField();
+ suspectInfo.getTags().add(TAG__SUGGEST_TEXT);
// the type the field will query for matching entries
yField.setType(typedSuspect.getType());
yField.setTypeQualifiedName(typedSuspect.getTypeQualifiedName());
@@ -663,7 +688,7 @@
if (YDateTimeResolution.get(prop.getValue().toUpperCase()) != null) {
yDt.setResolution(YDateTimeResolution.get(prop.getValue().toUpperCase()));
}
- if(ySuspect.getProperties().containsKey(YDateTimeDatatype.SHOWWEEKNUMBERS)){
+ if (ySuspect.getProperties().containsKey(YDateTimeDatatype.SHOWWEEKNUMBERS)) {
yDt.setShowISOWeeknumbers(true);
}
((YDateTime) yEmbeddable).setDatatype(yDt);
@@ -719,7 +744,11 @@
yEmbeddable.setLabelI18nKey(ySuspect.getLabelI18nKey());
yEmbeddable.setLabel(ySuspect.getLabel());
yEmbeddable.setId(ySuspect.getId());
- yEmbeddable.setCssClass(EnumCssClass.BOX.styleName());
+ if (ySuspect.getTags().contains(TAG__EXTRASTYLE)) {
+ yEmbeddable.setCssClass(EnumCssClass.BOX.styleName()+" "+ySuspect.getStyleName());
+ } else {
+ yEmbeddable.setCssClass(EnumCssClass.BOX.styleName());
+ }
if (ySuspect.getTags().contains(TAG__READONLY)) {
yEmbeddable.setReadonly(true);
}
@@ -734,7 +763,8 @@
if (ySuspect.getTags().contains(TAG__CONSTRAINT)) {
if (yEmbeddable instanceof YField) {
YBeanValidationValidator validator = ValidationFactory.eINSTANCE.createYBeanValidationValidator();
- validator.setBvalClassFullyQualifiedName(ySuspect.getProperties().get(IPropertyConstants.PROPERTY_CLASS));
+ validator.setBvalClassFullyQualifiedName(
+ ySuspect.getProperties().get(IPropertyConstants.PROPERTY_CLASS));
validator.setBvalProperty(ySuspect.getProperties().get(IPropertyConstants.PROPERTY_NAME));
((YField) yEmbeddable).getValidators().add(validator);
yEmbeddable.setCssClass(yEmbeddable.getCssClass() + " os-constraint");
@@ -744,7 +774,8 @@
if (ySuspect.getTags().contains(TAG__UNIQUE)) {
if (yEmbeddable instanceof YField) {
YUniqueAttributeValidator validator = ValidationFactory.eINSTANCE.createYUniqueAttributeValidator();
- validator.setValTypeFullyQualifiedName(ySuspect.getProperties().get(IPropertyConstants.PROPERTY_CLASS));
+ validator.setValTypeFullyQualifiedName(
+ ySuspect.getProperties().get(IPropertyConstants.PROPERTY_CLASS));
validator.setPropertyPath(ySuspect.getProperties().get(IPropertyConstants.PROPERTY_NAME));
// this endpoint gains access to the bound bean
validator.setContainerValueBindingEndpoint(
@@ -922,8 +953,8 @@
YEmbeddable yEmbeddable = YECviewFactory.eINSTANCE.createYBlobUploadComponent();
if (existInProperties(ySuspect, IPropertyConstants.PROPERTY_BLOB)) {
try {
- ((YBlobUploadComponent) yEmbeddable)
- .setDisplayResolutionId(Integer.parseInt(ySuspect.getProperties().get(IPropertyConstants.PROPERTY_BLOB)));
+ ((YBlobUploadComponent) yEmbeddable).setDisplayResolutionId(
+ Integer.parseInt(ySuspect.getProperties().get(IPropertyConstants.PROPERTY_BLOB)));
} catch (NumberFormatException nfe) {
// TODO (JCD): ExceptionHandling
LOGGER.error("blob property is not from type int!");
@@ -1007,6 +1038,22 @@
}
/**
+ * Creates the save and new button.
+ *
+ * @param ySuspect the y suspect
+ * @return the y embeddable
+ */
+ private YEmbeddable createSaveAndNew(YSuspect ySuspect) {
+ LOGGER.trace("{}", "createSaveAndNew");
+ YButton yButton = ExtensionModelFactory.eINSTANCE.createYButton();
+ yButton.setLabel(ySuspect.getLabel());
+ yButton.setLabelI18nKey(ySuspect.getLabelI18nKey());
+ yButton.setImage(themeResourceService.getThemeResource("dssaveandnew", ThemeResourceType.ICON));
+ yButton.getTags().addAll(ySuspect.getTags());
+ return yButton;
+ }
+
+ /**
* Creates the y bean reference.
*
* @param ySuspect
@@ -1040,21 +1087,22 @@
if (!yFilterComponent.getFilterDescriptors().isEmpty()) {
beanReferenceField.setFilteringComponent(yFilterComponent);
}
-
- if(ySuspect.getTags().contains(TAG__SIDEKICK)) {
+
+ if (ySuspect.getTags().contains(TAG__SIDEKICK)) {
YDialogComponent yDialogComponent = ExtensionModelFactory.eINSTANCE.createYDialogComponent();
yDialogComponent.setType(type);
yDialogComponent.setViewContextCallback(new DialogViewContextCallback());
yDialogComponent.setUpdateCallback(new DtoServiceCallback());
beanReferenceField.setDialogComponent(yDialogComponent);
}
-
- if(ySuspect.getProperties().containsKey("TargetEnumRefClass")) {
- beanReferenceField.setReferenceSourceTypeQualifiedName(ySuspect.getProperties().get("TargetEnumRefClass"));
- beanReferenceField.setReferenceSourceTypeProperty(ySuspect.getProperties().get("TargetEnumRefField"));
+
+ if (ySuspect.getProperties().containsKey("TargetEnumRefClass")) {
+ beanReferenceField
+ .setReferenceSourceTypeQualifiedName(ySuspect.getProperties().get("TargetEnumRefClass"));
+ beanReferenceField
+ .setReferenceSourceTypeProperty(ySuspect.getProperties().get("TargetEnumRefField"));
}
-
-
+
}
// Alternative for non editable bean references is a non editable
@@ -1088,7 +1136,7 @@
protected String getBeanSlotName(Map<String, Object> properties) {
return (String) properties.get(IViewContext.PROP_SLOT);
}
-
+
public IViewContext getAutobindedDialogModel(Class<?> dtoType) {
LOGGER.trace("{}", "getAutobindedDialogModel");
IViewContext viewContext = null;
@@ -1101,7 +1149,7 @@
} else {
LOGGER.error("{}", "IECViewProviderService not found");
}
- if(viewContext != null) {
+ if (viewContext != null) {
return viewContext;
} else {
LOGGER.error("No view found for dto {}", dtoType.getCanonicalName());
@@ -1113,7 +1161,7 @@
@Override
public IViewContext getDialogViewContext(Class<?> type) {
IViewContext dialogViewContext = getAutobindedDialogModel(type);
- if(dialogViewContext != null) {
+ if (dialogViewContext != null) {
dialogViewContext.setLocale(user.getLocale());
dialogViewContext.setRenderingParams(viewContext.getRenderingParams());
try {
@@ -1126,13 +1174,13 @@
return dialogViewContext;
}
}
-
+
class DtoServiceCallback implements IDtoServiceCallback {
@Override
public void persist(IViewContext dialogViewContext) {
Object dto = dialogViewContext.getBean(getBeanSlotName(dialogViewContext.getRenderingParams()));
IDTOService<?> dtoService = DtoServiceAccess.getService(dto.getClass());
- if(dtoService != null) {
+ if (dtoService != null) {
dtoService.persist(dto);
}
}
@@ -1258,8 +1306,8 @@
Collection<String> positionNames = getOrganizationPositionNames(
ProductConfiguration.getAuthenticationOrganizationId());
if (positionNames.isEmpty()) {
- yCombo.getCollection().add(IUserAccessService.ADMINISTRATOR);
- yCombo.setSelection(IUserAccessService.ADMINISTRATOR);
+ yCombo.getCollection().add(IUserAccessService.NAME_ADMINISTRATOR);
+ yCombo.setSelection(IUserAccessService.NAME_ADMINISTRATOR);
yCombo.setEditable(false);
} else {
yCombo.getCollection()
@@ -1332,7 +1380,7 @@
yCombo.getCollection().addAll(PdfPrintService.reLookupPrintServiceNames());
return yEmbeddable;
}
-
+
/**
* Creates the print service combo box inclosing DSL grammar model parts.
*
@@ -1351,14 +1399,15 @@
yCombo.setModelSelectionType(String.class);
yCombo.setModelSelectionTypeQualifiedName(String.class.getCanonicalName());
if (existInProperties(ySuspect, IPropertyConstants.PROPERTY_MODEL)) {
- IPropertyConstants.DSLModelsEnum modelEnum = IPropertyConstants.DSLModelsEnum.valueOf(ySuspect.getProperties().get(IPropertyConstants.PROPERTY_MODEL));
+ IPropertyConstants.DSLModelsEnum modelEnum = IPropertyConstants.DSLModelsEnum
+ .valueOf(ySuspect.getProperties().get(IPropertyConstants.PROPERTY_MODEL));
EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(modelEnum.getNsUri());
for (EClassifier classifier : ePackage.getEClassifiers()) {
- if (classifier.getName().equalsIgnoreCase(modelEnum.getKey())){
+ if (classifier.getName().equalsIgnoreCase(modelEnum.getKey())) {
for (EObject eObject : dslMetadataService.getAll((EClass) classifier)) {
yCombo.getCollection().add(eObject);
}
- }
+ }
}
}
return yEmbeddable;
@@ -1383,20 +1432,16 @@
private Collection<String> getOrganizationPositionNames(String organizationName) {
LOGGER.trace("{}", "getOrganizationPositionNames");
- IOrganizationService organizationService = ServiceListener.getOrganizationService();
- // In case of the open source solution a organization service is not
- // available!
- if (organizationService != null) {
+ Collection<String> positionNames = new TreeSet<>();
+ for(IOrganizationService organizationService:ServiceListener.getOrganizationServices().values()) {
AbstractSubOrganization organization = organizationService.getOrganization(organizationName);
if (organization != null) {
- Collection<String> positionNames = new TreeSet<>();
for (IPosition position : organization.getPositions()) {
positionNames.add(position.getLinkAlias());
}
- return positionNames;
}
}
- return Collections.emptyList();
+ return positionNames;
}
@SuppressWarnings("rawtypes")
@@ -1437,7 +1482,7 @@
if (suspect.getTags().contains(TAG__TABLE) || suspect.getTags().contains(TAG__GRID)) {
return true;
}
- if(suspect instanceof YTypedCompoundSuspect && suspect.getTags().contains(TAG__BEANONTAB)) {
+ if (suspect instanceof YTypedCompoundSuspect && suspect.getTags().contains(TAG__BEANONTAB)) {
return true;
}
}
@@ -1486,25 +1531,28 @@
String dtoName = ySuspect.getAuthorizationGroup();
String dtoProperty = ySuspect.getAuthorizationId();
- Boolean result=false;
- String grantKey = dtoName + "." + dtoProperty + "###EDITABLE";
- if( isSuspectEditable.containsKey(grantKey)) {
- result=isSuspectEditable.get(grantKey);
- } else {
- if (userAccessService.isGranted(Group.DTO, Action.READABLE, dtoName)) {
- boolean invisible = userAccessService.isVetoed(Group.DTO, Action.INVISIBLE, dtoName, dtoProperty);
- boolean enabled = false;
- boolean editable = false;
- if (!invisible) {
- enabled = !userAccessService.isVetoed(Group.DTO, Action.DISABLED, dtoName, dtoProperty);
- if (enabled) {
- editable = !userAccessService.isVetoed(Group.DTO, Action.NONEDITABLE, dtoName, dtoProperty);
- }
- }
- result = !invisible && enabled && editable;
- }
- isSuspectEditable.put(grantKey,result);
- }
+ if(ySuspect.getTags().contains(TAG__READONLY)) {
+ return false;
+ }
+ Boolean result = false;
+ String grantKey = dtoName + "." + dtoProperty + "###EDITABLE";
+ if (isSuspectEditable.containsKey(grantKey)) {
+ result = isSuspectEditable.get(grantKey);
+ } else {
+ if (userAccessService.isGranted(Group.DTO, Action.READABLE, dtoName)) {
+ boolean invisible = userAccessService.isVetoed(Group.DTO, Action.INVISIBLE, dtoName, dtoProperty);
+ boolean enabled = false;
+ boolean editable = false;
+ if (!invisible) {
+ enabled = !userAccessService.isVetoed(Group.DTO, Action.DISABLED, dtoName, dtoProperty);
+ if (enabled) {
+ editable = !userAccessService.isVetoed(Group.DTO, Action.NONEDITABLE, dtoName, dtoProperty);
+ }
+ }
+ result = !invisible && enabled && editable;
+ }
+ isSuspectEditable.put(grantKey, result);
+ }
return result;
}
diff --git a/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/AltEnterForwardFocusingStrategy.java b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/AltEnterForwardFocusingStrategy.java
index 274539f..27412c4 100644
--- a/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/AltEnterForwardFocusingStrategy.java
+++ b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/AltEnterForwardFocusingStrategy.java
@@ -15,17 +15,6 @@
*/
package org.eclipse.osbp.ecview.extension.strategy;
-import org.eclipse.osbp.ecview.core.common.context.IViewContext;
-import org.eclipse.osbp.ecview.core.common.model.core.YEditable;
-import org.eclipse.osbp.ecview.core.common.model.core.YElement;
-import org.eclipse.osbp.ecview.core.common.model.core.YEmbeddable;
-import org.eclipse.osbp.ecview.core.common.model.core.YFocusable;
-import org.eclipse.osbp.ecview.core.common.model.core.YLayout;
-import org.eclipse.osbp.ecview.core.common.model.core.YView;
-import org.eclipse.osbp.ecview.core.common.services.IWidgetAssocationsService;
-import org.eclipse.osbp.ecview.core.util.emf.ModelUtil;
-import org.eclipse.osbp.ecview.extension.api.IFocusingStrategy;
-import org.eclipse.osbp.ecview.extension.model.YStrategyLayout;
import org.eclipse.osbp.runtime.common.keystroke.KeyStrokeDefinition;
import com.vaadin.event.ShortcutAction.KeyCode;
@@ -34,56 +23,10 @@
/**
* The Class AltEnterForwardFocusingStrategy.
*/
-public class AltEnterForwardFocusingStrategy implements IFocusingStrategy {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.osbp.ecview.extension.api.IFocusingStrategy#focus(java.lang.Object, java.lang.Object, org.eclipse.osbp.ecview.extension.model.YStrategyLayout)
- */
- @Override
- public void focus(Object source, Object target, YStrategyLayout yLayout) {
- YView yView = yLayout.getView();
- IViewContext context = ModelUtil.getViewContext(yView);
- IWidgetAssocationsService<Object, ? extends YElement> service = context.getService(IWidgetAssocationsService.ID);
-
- YEmbeddable yCurrentFocus = (YEmbeddable) service.getModelElement(target);
- YEmbeddable yNextFocus = findNextElementToFocus(yCurrentFocus);
- yView.setCurrentFocus((YFocusable) yNextFocus);
+public class AltEnterForwardFocusingStrategy extends AbstractFocusingStrategy {
+ public int getDirection() {
+ return -1;
}
-
- /**
- * Looks for the next element to be focused. Therefore it uses a round robin approach. If end of elements are reached, we start by index = 0 again.
- *
- * @param yElement
- * the y element
- * @return the y embeddable
- */
- protected YEmbeddable findNextElementToFocus(YEmbeddable yElement) {
- if (yElement == null) {
- return null;
- }
- YLayout yParent = (YLayout) yElement.eContainer();
- int index = yParent.getElements().indexOf(yElement);
- if (index == yParent.getElements().size() - 1) {
- // element is the last -> Start again
- index = 0;
- } else {
- // use the next element
- index = index + 1;
- }
-
- YEmbeddable nextFocusElement = yParent.getElements().get(index);
- if (nextFocusElement instanceof YEditable) {
- if (((YEditable) nextFocusElement).isEditable()) {
- return nextFocusElement;
- } else {
- return findNextElementToFocus(nextFocusElement);
- }
- }
- return nextFocusElement;
- }
-
/*
* (non-Javadoc)
*
diff --git a/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/DefaultFocusingEnhancer.java b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/DefaultFocusingEnhancer.java
new file mode 100644
index 0000000..d31aa93
--- /dev/null
+++ b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/DefaultFocusingEnhancer.java
@@ -0,0 +1,35 @@
+package org.eclipse.osbp.ecview.extension.strategy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.osbp.ecview.extension.api.IFocusingEnhancer;
+import org.eclipse.osbp.ecview.extension.model.YDelegatingFocusingStrategy;
+import org.eclipse.osbp.ecview.extension.model.YECviewFactory;
+import org.eclipse.osbp.ecview.extension.model.YStrategyLayout;
+import org.osgi.service.component.annotations.Component;
+
+@Component(property = { "ecview.focusing.enhancer.id=DefaultFocusingEnhancer",
+ "ecview.focusing.enhancer.default=true" })
+public class DefaultFocusingEnhancer implements IFocusingEnhancer {
+ @SuppressWarnings("serial")
+ private static final List<String> strategies = new ArrayList<String>() {
+ {
+ add("cx.enter.forward");
+ add("cx.enter.backward");
+ add("cx.altenter.forward");
+ add("cx.tab.forward");
+ add("cx.tab.backward");
+ }
+ };
+
+ @Override
+ public void enhanceFocusing(final YStrategyLayout yLayout) {
+ yLayout.getFocusingStrategies().clear();
+ for (String strategy : strategies) {
+ YDelegatingFocusingStrategy yStgy = YECviewFactory.eINSTANCE.createYDelegatingFocusingStrategy();
+ yStgy.setDelegateStrategyId(strategy);
+ yLayout.getFocusingStrategies().add(yStgy);
+ }
+ }
+}
diff --git a/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/DefaultLayoutingStrategyProvider.java b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/DefaultLayoutingStrategyProvider.java
index 9f5dc41..e86fd08 100644
--- a/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/DefaultLayoutingStrategyProvider.java
+++ b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/DefaultLayoutingStrategyProvider.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
+ * Copyright (c) 2011, 2019 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -17,31 +17,20 @@
import org.eclipse.osbp.ecview.extension.api.ILayoutingStrategy;
import org.eclipse.osbp.ecview.extension.api.ILayoutingStrategyProvider;
+import org.osgi.service.component.annotations.Component;
-/**
- * The Class DefaultLayoutingStrategyProvider.
- */
-public class DefaultLayoutingStrategyProvider implements
- ILayoutingStrategyProvider {
+@Component(immediate = true, service = ILayoutingStrategyProvider.class, property = "ecview.layouting.id=Default")
+public class DefaultLayoutingStrategyProvider implements ILayoutingStrategyProvider {
+ private static final String ID = "DefaultLayoutingStrategy";
- /** The strategy. */
- private final ILayoutingStrategy strategy;
-
- /**
- * Instantiates a new default layouting strategy provider.
- *
- * @param strategy
- * the strategy
- */
- public DefaultLayoutingStrategyProvider(ILayoutingStrategy strategy) {
- this.strategy = strategy;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.osbp.ecview.extension.api.ILayoutingStrategyProvider#getStrategy()
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.osbp.ecview.extension.api.ILayoutingStrategyProvider#
+ * getStrategy()
*/
@Override
public ILayoutingStrategy getStrategy() {
- return strategy;
+ return new FormLayoutLayoutingStrategy();
}
}
\ No newline at end of file
diff --git a/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/EnterBackwardFocusingStrategy.java b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/EnterBackwardFocusingStrategy.java
index f722a8f..194c385 100644
--- a/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/EnterBackwardFocusingStrategy.java
+++ b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/EnterBackwardFocusingStrategy.java
@@ -15,76 +15,20 @@
*/
package org.eclipse.osbp.ecview.extension.strategy;
-import java.util.Map;
-
-import org.eclipse.osbp.ecview.core.common.context.IViewContext;
-import org.eclipse.osbp.ecview.core.common.model.core.YEditable;
-import org.eclipse.osbp.ecview.core.common.model.core.YElement;
-import org.eclipse.osbp.ecview.core.common.model.core.YEmbeddable;
-import org.eclipse.osbp.ecview.core.common.model.core.YFocusable;
-import org.eclipse.osbp.ecview.core.common.model.core.YLayout;
-import org.eclipse.osbp.ecview.core.common.model.core.YView;
-import org.eclipse.osbp.ecview.core.common.services.IWidgetAssocationsService;
-import org.eclipse.osbp.ecview.core.util.emf.ModelUtil;
-import org.eclipse.osbp.ecview.extension.api.IFocusingStrategy;
-import org.eclipse.osbp.ecview.extension.model.YStrategyLayout;
import org.eclipse.osbp.runtime.common.keystroke.KeyStrokeDefinition;
+import org.eclipse.osbp.runtime.common.keystroke.ModifierKey;
import com.vaadin.event.ShortcutAction.KeyCode;
/**
* The Class EnterBackwardFocusingStrategy.
*/
-public class EnterBackwardFocusingStrategy implements IFocusingStrategy {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.osbp.ecview.extension.api.IFocusingStrategy#focus(java.lang.Object, java.lang.Object, org.eclipse.osbp.ecview.extension.model.YStrategyLayout)
- */
- @Override
- public void focus(Object source, Object target, YStrategyLayout yLayout) {
- YView yView = yLayout.getView();
- IViewContext context = ModelUtil.getViewContext(yView);
- IWidgetAssocationsService<Object, ? extends YElement> service = context.getService(IWidgetAssocationsService.ID);
-
- YEmbeddable yCurrentFocus = (YEmbeddable) service.getModelElement(target);
- YEmbeddable yNextFocus = findNextElementToFocus(yCurrentFocus);
- yView.setCurrentFocus((YFocusable) yNextFocus);
+public class EnterBackwardFocusingStrategy extends AbstractFocusingStrategy {
+ public int getDirection() {
+ return -1;
}
- /**
- * Looks for the next element to be focused. Therefore it uses a round robin approach. If the first element is reached, we start at the end again.
- *
- * @param yElement
- * the y element
- * @return the y embeddable
- */
- protected YEmbeddable findNextElementToFocus(YEmbeddable yElement) {
- if (yElement == null) {
- return null;
- }
- YLayout yParent = (YLayout) yElement.eContainer();
- int index = yParent.getElements().indexOf(yElement);
- if (index == 0) {
- // element is the first -> Start again
- index = yParent.getElements().size() - 1;
- } else {
- // use the previous element
- index = index - 1;
- }
-
- YEmbeddable nextFocusElement = yParent.getElements().get(index);
- if (nextFocusElement instanceof YEditable) {
- if (((YEditable) nextFocusElement).isEditable()) {
- return nextFocusElement;
- } else {
- return findNextElementToFocus(nextFocusElement);
- }
- }
- return nextFocusElement;
- }
-
+ protected int direction = -1;
/*
* (non-Javadoc)
*
@@ -92,7 +36,9 @@
*/
@Override
public KeyStrokeDefinition getKeyStrokeDefinition() {
- KeyStrokeDefinition def = new KeyStrokeDefinition("", KeyCode.ENTER, new int[0]);
+ int[] modifierKeys = new int[1];
+ modifierKeys[0] = ModifierKey.SHIFT;
+ KeyStrokeDefinition def = new KeyStrokeDefinition("", KeyCode.ENTER, modifierKeys);
return def;
}
diff --git a/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/EnterForwardFocusingStrategy.java b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/EnterForwardFocusingStrategy.java
index 7d4b556..eed5fe4 100644
--- a/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/EnterForwardFocusingStrategy.java
+++ b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/EnterForwardFocusingStrategy.java
@@ -15,19 +15,6 @@
*/
package org.eclipse.osbp.ecview.extension.strategy;
-import java.util.Map;
-
-import org.eclipse.osbp.ecview.core.common.context.IViewContext;
-import org.eclipse.osbp.ecview.core.common.model.core.YEditable;
-import org.eclipse.osbp.ecview.core.common.model.core.YElement;
-import org.eclipse.osbp.ecview.core.common.model.core.YEmbeddable;
-import org.eclipse.osbp.ecview.core.common.model.core.YFocusable;
-import org.eclipse.osbp.ecview.core.common.model.core.YLayout;
-import org.eclipse.osbp.ecview.core.common.model.core.YView;
-import org.eclipse.osbp.ecview.core.common.services.IWidgetAssocationsService;
-import org.eclipse.osbp.ecview.core.util.emf.ModelUtil;
-import org.eclipse.osbp.ecview.extension.api.IFocusingStrategy;
-import org.eclipse.osbp.ecview.extension.model.YStrategyLayout;
import org.eclipse.osbp.runtime.common.keystroke.KeyStrokeDefinition;
import com.vaadin.event.ShortcutAction.KeyCode;
@@ -35,60 +22,16 @@
/**
* The Class EnterForwardFocusingStrategy.
*/
-public class EnterForwardFocusingStrategy implements IFocusingStrategy {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.osbp.ecview.extension.api.IFocusingStrategy#focus(java.lang.Object, java.lang.Object, org.eclipse.osbp.ecview.extension.model.YStrategyLayout)
- */
- @Override
- public void focus(Object source, Object target, YStrategyLayout yLayout) {
- YView yView = yLayout.getView();
- IViewContext context = ModelUtil.getViewContext(yView);
- IWidgetAssocationsService<Object, ? extends YElement> service = context.getService(IWidgetAssocationsService.ID);
-
- YEmbeddable yCurrentFocus = (YEmbeddable) service.getModelElement(target);
- YEmbeddable yNextFocus = findNextElementToFocus(yCurrentFocus);
- yView.setCurrentFocus((YFocusable) yNextFocus);
- }
-
- /**
- * Looks for the next element to be focused. Therefore it uses a round robin approach. If end of elements are reached, we start by index = 0 again.
- *
- * @param yElement
- * the y element
- * @return the y embeddable
- */
- protected YEmbeddable findNextElementToFocus(YEmbeddable yElement) {
- if (yElement == null) {
- return null;
- }
- YLayout yParent = (YLayout) yElement.eContainer();
- int index = yParent.getElements().indexOf(yElement);
- if (index == yParent.getElements().size() - 1) {
- // element is the last -> Start again
- index = 0;
- } else {
- // use the next element
- index = index + 1;
- }
-
- YEmbeddable nextFocusElement = yParent.getElements().get(index);
- if (nextFocusElement instanceof YEditable) {
- if (((YEditable) nextFocusElement).isEditable()) {
- return nextFocusElement;
- } else {
- return findNextElementToFocus(nextFocusElement);
- }
- }
- return nextFocusElement;
+public class EnterForwardFocusingStrategy extends AbstractFocusingStrategy {
+ public int getDirection() {
+ return 1;
}
/*
* (non-Javadoc)
*
- * @see org.eclipse.osbp.ecview.extension.api.IFocusingStrategy#getKeyStrokeDefinition()
+ * @see org.eclipse.osbp.ecview.extension.api.IFocusingStrategy#
+ * getKeyStrokeDefinition()
*/
@Override
public KeyStrokeDefinition getKeyStrokeDefinition() {
diff --git a/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/FocusingStrategy.java b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/FocusingStrategy.java
new file mode 100644
index 0000000..63c1b85
--- /dev/null
+++ b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/FocusingStrategy.java
@@ -0,0 +1,17 @@
+package org.eclipse.osbp.ecview.extension.strategy;
+
+import org.eclipse.osbp.runtime.common.keystroke.KeyStrokeDefinition;
+
+public class FocusingStrategy extends AbstractFocusingStrategy {
+
+ @Override
+ public KeyStrokeDefinition getKeyStrokeDefinition() {
+ return null;
+ }
+
+ @Override
+ int getDirection() {
+ return 1;
+ }
+
+}
diff --git a/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/FocusingStrategyContextFunction.java b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/FocusingStrategyContextFunction.java
new file mode 100644
index 0000000..cb5ff60
--- /dev/null
+++ b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/FocusingStrategyContextFunction.java
@@ -0,0 +1,20 @@
+package org.eclipse.osbp.ecview.extension.strategy;
+
+import org.eclipse.e4.core.contexts.ContextInjectionFactory;
+import org.eclipse.e4.core.contexts.IContextFunction;
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.ui.model.application.MApplication;
+import org.eclipse.osbp.ecview.extension.api.IFocusingStrategy;
+import org.osgi.service.component.annotations.Component;
+
+@Component(service = IContextFunction.class, property = "service.context.key=Focusing")
+public class FocusingStrategyContextFunction implements IContextFunction {
+ @Override
+ public Object compute(final IEclipseContext context, final String contextKey) {
+ MApplication application = context.get(MApplication.class);
+ IEclipseContext appCtx = application.getContext();
+ IFocusingStrategy provider = ContextInjectionFactory.make(FocusingStrategy.class, appCtx);
+ appCtx.set(IFocusingStrategy.class, provider);
+ return provider;
+ }
+}
diff --git a/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/ServiceListener.java b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/ServiceListener.java
index 37495e0..3d96fc3 100644
--- a/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/ServiceListener.java
+++ b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/ServiceListener.java
@@ -14,6 +14,9 @@
*/
package org.eclipse.osbp.ecview.extension.strategy;
+import java.util.HashMap;
+import java.util.Map;
+
import org.eclipse.osbp.ui.api.useraccess.IOrganizationService;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
@@ -22,7 +25,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-// TODO: Auto-generated Javadoc
/**
* The listener interface for receiving service events. The class that is
* interested in processing a service event implements this interface, and the
@@ -31,12 +33,6 @@
* occurs, that object's appropriate method is invoked.
*
*/
-// TODO: check reference
-/*
- * reference not found
- *
- * @see ServiceEvent
- */
@Component
public class ServiceListener {
@@ -44,15 +40,15 @@
private static final Logger LOGGER = LoggerFactory.getLogger(ServiceListener.class);
/** The Constant sOrganizationServices. */
- private static IOrganizationService sOrganizationService;
+ private static final Map<String, IOrganizationService> sOrganizationServices = new HashMap<>();
/**
* Gets the organization services.
*
* @return the organization services
*/
- public static IOrganizationService getOrganizationService() {
- return sOrganizationService;
+ public static Map<String, IOrganizationService> getOrganizationServices() {
+ return sOrganizationServices;
}
/**
@@ -61,10 +57,10 @@
* @param organization
* the organization
*/
- @Reference(cardinality = ReferenceCardinality.OPTIONAL, policy = ReferencePolicy.DYNAMIC)
+ @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
public void bindOrganizationService(IOrganizationService organization) {
LOGGER.debug(ServiceListener.class.getCanonicalName() + ": " + organization.getClass().getCanonicalName() + " bound");
- sOrganizationService = organization;
+ sOrganizationServices.put(organization.getClass().getCanonicalName(), organization);
}
/**
@@ -75,6 +71,6 @@
*/
public void unbindOrganizationService(IOrganizationService organization) {
LOGGER.debug(ServiceListener.class.getCanonicalName() + ": " + organization.getClass().getCanonicalName() + " unbound");
- sOrganizationService = null;
+ sOrganizationServices.remove(organization.getClass().getCanonicalName());
}
}
diff --git a/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/TabBackwardFocusingStrategy.java b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/TabBackwardFocusingStrategy.java
index 1c634f4..db3d8f7 100644
--- a/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/TabBackwardFocusingStrategy.java
+++ b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/TabBackwardFocusingStrategy.java
@@ -15,91 +15,18 @@
*/
package org.eclipse.osbp.ecview.extension.strategy;
-import java.util.Map;
-
-import org.eclipse.osbp.ecview.core.common.context.IViewContext;
-import org.eclipse.osbp.ecview.core.common.model.core.YEditable;
-import org.eclipse.osbp.ecview.core.common.model.core.YElement;
-import org.eclipse.osbp.ecview.core.common.model.core.YEmbeddable;
-import org.eclipse.osbp.ecview.core.common.model.core.YFocusable;
-import org.eclipse.osbp.ecview.core.common.model.core.YLayout;
-import org.eclipse.osbp.ecview.core.common.model.core.YView;
-import org.eclipse.osbp.ecview.core.common.services.IWidgetAssocationsService;
-import org.eclipse.osbp.ecview.core.util.emf.ModelUtil;
-import org.eclipse.osbp.ecview.extension.api.IFocusingStrategy;
-import org.eclipse.osbp.ecview.extension.model.YStrategyLayout;
import org.eclipse.osbp.runtime.common.keystroke.KeyStrokeDefinition;
+import org.eclipse.osbp.runtime.common.keystroke.ModifierKey;
import com.vaadin.event.ShortcutAction.KeyCode;
/**
* The Class TabBackwardFocusingStrategy.
*/
-public class TabBackwardFocusingStrategy implements IFocusingStrategy {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.osbp.ecview.extension.api.IFocusingStrategy#focus(java.lang.Object, java.lang.Object, org.eclipse.osbp.ecview.extension.model.YStrategyLayout)
- */
- @Override
- public void focus(Object source, Object target, YStrategyLayout yLayout) {
- YView yView = yLayout.getView();
- IViewContext context = ModelUtil.getViewContext(yView);
- IWidgetAssocationsService<Object, ? extends YElement> service = context.getService(IWidgetAssocationsService.ID);
-
- YEmbeddable yCurrentFocus = (YEmbeddable) service.getModelElement(target);
- YEmbeddable yNextFocus = findNextElementToFocus(yLayout, yCurrentFocus);
- yView.setCurrentFocus((YFocusable) yNextFocus);
+public class TabBackwardFocusingStrategy extends AbstractFocusingStrategy {
+ public int getDirection() {
+ return -1;
}
-
- /**
- * Looks for the next element to be focused. Therefore it uses a round robin approach. If the first element is reached, we start at the end again.
- *
- * @param yLayout
- * the y layout
- * @param yElement
- * the y element
- * @return the y embeddable
- */
- protected YEmbeddable findNextElementToFocus(YStrategyLayout yLayout, YEmbeddable yElement) {
- if (yElement == null) {
- return null;
- }
- YLayout yParent = (YLayout) yElement.eContainer();
- int index = yParent.getElements().indexOf(yElement);
- if (index == 0) {
- // element is the first -> Start again
- index = yParent.getElements().size() - 1;
- } else {
- // use the previous element
- index = index - 1;
- }
-
- YEmbeddable nextFocusElement = yParent.getElements().get(index);
- if (nextFocusElement instanceof YEditable) {
- if (((YEditable) nextFocusElement).isEditable()) {
- return nextFocusElement;
- } else {
- return findNextElementToFocus(yLayout, nextFocusElement);
- }
- }
- return nextFocusElement;
-
- // YSuspectInfo info = yLayout.findInfoFor(yElement);
- // YSuspectInfo previous = info != null ? info.getPreviousFocus() :
- // null;
- // YEmbeddable target = previous != null ? previous.getTarget() : null;
- //
- // // use the last element
- // if (target == null && yLayout.getLayoutingInfo() != null
- // && yLayout.findLastFocus() != null) {
- // target = yLayout.findLastFocus().getTarget();
- // }
- //
- // return target;
- }
-
/*
* (non-Javadoc)
*
@@ -107,7 +34,9 @@
*/
@Override
public KeyStrokeDefinition getKeyStrokeDefinition() {
- KeyStrokeDefinition def = new KeyStrokeDefinition("", KeyCode.TAB, new int[0]);
+ int[] modifierKeys = new int[1];
+ modifierKeys[0] = ModifierKey.SHIFT;
+ KeyStrokeDefinition def = new KeyStrokeDefinition("", KeyCode.TAB, modifierKeys);
return def;
}
diff --git a/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/TabForwardFocusingStrategy.java b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/TabForwardFocusingStrategy.java
index 9851c58..6f2e7d3 100644
--- a/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/TabForwardFocusingStrategy.java
+++ b/org.eclipse.osbp.ecview.extension.strategy/src/org/eclipse/osbp/ecview/extension/strategy/TabForwardFocusingStrategy.java
@@ -15,19 +15,6 @@
*/
package org.eclipse.osbp.ecview.extension.strategy;
-import java.util.Map;
-
-import org.eclipse.osbp.ecview.core.common.context.IViewContext;
-import org.eclipse.osbp.ecview.core.common.model.core.YEditable;
-import org.eclipse.osbp.ecview.core.common.model.core.YElement;
-import org.eclipse.osbp.ecview.core.common.model.core.YEmbeddable;
-import org.eclipse.osbp.ecview.core.common.model.core.YFocusable;
-import org.eclipse.osbp.ecview.core.common.model.core.YLayout;
-import org.eclipse.osbp.ecview.core.common.model.core.YView;
-import org.eclipse.osbp.ecview.core.common.services.IWidgetAssocationsService;
-import org.eclipse.osbp.ecview.core.util.emf.ModelUtil;
-import org.eclipse.osbp.ecview.extension.api.IFocusingStrategy;
-import org.eclipse.osbp.ecview.extension.model.YStrategyLayout;
import org.eclipse.osbp.runtime.common.keystroke.KeyStrokeDefinition;
import com.vaadin.event.ShortcutAction.KeyCode;
@@ -35,56 +22,10 @@
/**
* The Class TabForwardFocusingStrategy.
*/
-public class TabForwardFocusingStrategy implements IFocusingStrategy {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.osbp.ecview.extension.api.IFocusingStrategy#focus(java.lang.Object, java.lang.Object, org.eclipse.osbp.ecview.extension.model.YStrategyLayout)
- */
- @Override
- public void focus(Object source, Object target, YStrategyLayout yLayout) {
- YView yView = yLayout.getView();
- IViewContext context = ModelUtil.getViewContext(yView);
- IWidgetAssocationsService<Object, ? extends YElement> service = context.getService(IWidgetAssocationsService.ID);
-
- YEmbeddable yCurrentFocus = (YEmbeddable) service.getModelElement(target);
- YEmbeddable yNextFocus = findNextElementToFocus(yCurrentFocus);
- yView.setCurrentFocus((YFocusable) yNextFocus);
+public class TabForwardFocusingStrategy extends AbstractFocusingStrategy {
+ public int getDirection() {
+ return 1;
}
-
- /**
- * Looks for the next element to be focused. Therefore it uses a round robin approach. If end of elements are reached, we start by index = 0 again.
- *
- * @param yElement
- * the y element
- * @return the y embeddable
- */
- protected YEmbeddable findNextElementToFocus(YEmbeddable yElement) {
- if (yElement == null) {
- return null;
- }
- YLayout yParent = (YLayout) yElement.eContainer();
- int index = yParent.getElements().indexOf(yElement);
- if (index == yParent.getElements().size() - 1) {
- // element is the last -> Start again
- index = 0;
- } else {
- // use the next element
- index = index + 1;
- }
-
- YEmbeddable nextFocusElement = yParent.getElements().get(index);
- if (nextFocusElement instanceof YEditable) {
- if (((YEditable) nextFocusElement).isEditable()) {
- return nextFocusElement;
- } else {
- return findNextElementToFocus(nextFocusElement);
- }
- }
- return nextFocusElement;
- }
-
/*
* (non-Javadoc)
*