Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2013-07-29 09:40:43 +0000
committerCamille Letavernier2013-07-29 09:40:43 +0000
commite03e83b41c3b36b37ffe02707ef1011763a443b4 (patch)
tree4ecfbe9321f31814bbce44ee4083faad9f15bee6 /extraplugins
parentb1eedccdd5696687bb7e52a5ecb714d4a3fb2009 (diff)
parent77421b2d73993e25c3d7a50174df6b052bf60b7a (diff)
downloadorg.eclipse.papyrus-e03e83b41c3b36b37ffe02707ef1011763a443b4.tar.gz
org.eclipse.papyrus-e03e83b41c3b36b37ffe02707ef1011763a443b4.tar.xz
org.eclipse.papyrus-e03e83b41c3b36b37ffe02707ef1011763a443b4.zip
Merge branch 'master' of ssh://cletavernie@git.eclipse.org/gitroot/papyrus/org.eclipse.papyrus.git
Diffstat (limited to 'extraplugins')
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/BodyLayerStack.java4
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/ColumnHeaderLayerStack.java3
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/DefaultSizeUtils.java91
3 files changed, 95 insertions, 3 deletions
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/BodyLayerStack.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/BodyLayerStack.java
index 06848ae064b..44f381a8067 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/BodyLayerStack.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/BodyLayerStack.java
@@ -29,6 +29,7 @@ import org.eclipse.papyrus.infra.nattable.configuration.StyleConfiguration;
import org.eclipse.papyrus.infra.nattable.layer.PapyrusSelectionLayer;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.reorder.CustomDefaultColumnReorderBindings;
+import org.eclipse.papyrus.infra.nattable.utils.DefaultSizeUtils;
import org.eclipse.swt.SWT;
@@ -48,9 +49,8 @@ public class BodyLayerStack extends AbstractLayerTransform {
// private final RowReorderLayer rowReoderLayer;
public BodyLayerStack(final IDataProvider dataProvider, final INattableModelManager manager) {
- this.bodyDataLayer = new DataLayer(dataProvider);
+ this.bodyDataLayer = new DataLayer(dataProvider, DefaultSizeUtils.getDefaultCellWidth(), DefaultSizeUtils.getDefaultCellHeight());
this.bodyDataLayer.addConfiguration(new StyleConfiguration());
- this.bodyDataLayer.setDefaultColumnWidth(200);
this.columnReorderLayer = new ColumnReorderLayer(this.bodyDataLayer, false);
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/ColumnHeaderLayerStack.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/ColumnHeaderLayerStack.java
index dbed1ca9539..fb19416c80a 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/ColumnHeaderLayerStack.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/ColumnHeaderLayerStack.java
@@ -21,6 +21,7 @@ import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
import org.eclipse.papyrus.infra.nattable.configuration.PapyrusColumnHeaderStyleConfiguration;
import org.eclipse.papyrus.infra.nattable.configuration.PapyrusColumnResizeBindingsConfiguration;
import org.eclipse.papyrus.infra.nattable.dataprovider.BodyDataProvider;
+import org.eclipse.papyrus.infra.nattable.utils.DefaultSizeUtils;
public class ColumnHeaderLayerStack extends AbstractLayerTransform {
@@ -34,7 +35,7 @@ public class ColumnHeaderLayerStack extends AbstractLayerTransform {
* @param bodyDataProvider
*/
public ColumnHeaderLayerStack(final IDataProvider dataProvider, final BodyLayerStack bodyLayer, final BodyDataProvider bodyDataProvider) {
- DataLayer dataLayer = new DataLayer(dataProvider);
+ DataLayer dataLayer = new DataLayer(dataProvider, DefaultSizeUtils.getDefaultCellWidth(), DefaultSizeUtils.getDefaultCellHeight());
ColumnHeaderLayer colHeaderLayer = new ColumnHeaderLayer(dataLayer, bodyLayer.getViewportLayer(), bodyLayer.getSelectionLayer(), false);
colHeaderLayer.addConfiguration(new PapyrusColumnResizeBindingsConfiguration());
colHeaderLayer.addConfiguration(new PapyrusColumnHeaderStyleConfiguration());
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/DefaultSizeUtils.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/DefaultSizeUtils.java
new file mode 100644
index 00000000000..6dceb10e69b
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/DefaultSizeUtils.java
@@ -0,0 +1,91 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Adapted code from EMF-Facet Nattable integration
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.utils;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.widgets.Display;
+
+public final class DefaultSizeUtils {
+
+ private static final float MARGINE = 4;
+
+ private static final float FONT_CELL_RATIO = 2;
+
+ private static final float WIDTH_HEIGHT_RATIO = 8;
+
+ private static final float ROW_HEADER_RATIO = 2; //Row header width height ratio
+
+ private static final float DEFAULT_DPI = 96;
+
+ private DefaultSizeUtils() {
+ // Must not be used.
+ }
+
+ /**
+ * windows : 150%
+ * dipX=dpiY = 150
+ * fontName = Segoe UI
+ * fontHeight = 9
+ * value = 33
+ *
+ * windows 125% :
+ * dipX = dpiY = 120
+ * fontName = Segoe UI
+ * fontHeight = 9
+ * value = 27,5
+ *
+ * windows 100%
+ * dipX = dpiY = 96
+ * fontName = Segoe UI
+ * fontHeight = 9
+ * value = 22
+ *
+ * @return
+ * the default cell height to use, according to the dpi used by the system
+ */
+ public static int getDefaultCellHeight() {
+ float dpiY = Display.getDefault().getDPI().y;
+ FontData[] fd = Display.getDefault().getSystemFont().getFontData();
+ //fd[0].getName();
+ float height = (fd[0].getHeight() * DefaultSizeUtils.FONT_CELL_RATIO) + DefaultSizeUtils.MARGINE;
+ float value = height * (dpiY / DEFAULT_DPI);
+ return (int)Math.ceil(value);
+ }
+
+ /**
+ *
+ * @return
+ * the default cell width to use, according to the dpi used by the system
+ */
+ public static int getDefaultCellWidth() {
+ float width = DefaultSizeUtils.getDefaultCellHeight() * DefaultSizeUtils.WIDTH_HEIGHT_RATIO;
+ return (int)Math.ceil(width);
+ }
+
+ //not used
+ public static int getDefaultRowHeaderWidth() {
+ float width = DefaultSizeUtils.getDefaultCellHeight() * DefaultSizeUtils.ROW_HEADER_RATIO;
+ return (int)Math.ceil(width);
+ }
+
+ //not used
+ public static Font getHeaderFont() {
+ FontData[] fd = Display.getDefault().getSystemFont().getFontData().clone();
+ fd[0].setStyle(SWT.BOLD);
+ Font headerFont = new Font(Display.getDefault(), fd);
+ return headerFont;
+ }
+}

Back to the top