diff options
author | Stephan Leicht | 2012-07-02 15:29:15 +0000 |
---|---|---|
committer | Stephan Leicht | 2012-07-02 15:29:15 +0000 |
commit | 17efe99dd77c33e96f8bea61ee8a0cdaecc06dc9 (patch) | |
tree | 5f66631d8037997959b2d6cf1df6337a41fe48ce | |
parent | d2969643ec0548a88b77c20cf383894d4e341f3e (diff) | |
download | org.eclipse.scout.rt-17efe99dd77c33e96f8bea61ee8a0cdaecc06dc9.tar.gz org.eclipse.scout.rt-17efe99dd77c33e96f8bea61ee8a0cdaecc06dc9.tar.xz org.eclipse.scout.rt-17efe99dd77c33e96f8bea61ee8a0cdaecc06dc9.zip |
RESOLVED - bug 383803: [RAP] TreeBoxes don't render HTML
https://bugs.eclipse.org/bugs/show_bug.cgi?id=383803
6 files changed, 177 insertions, 57 deletions
diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/tree/AbstractTree.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/tree/AbstractTree.java index d6d6dc8b07..b5edd129e0 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/tree/AbstractTree.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/tree/AbstractTree.java @@ -130,6 +130,13 @@ public abstract class AbstractTree extends AbstractPropertyObserver implements I return false;
}
+ @ConfigProperty(ConfigProperty.INTEGER)
+ @Order(46)
+ @ConfigPropertyValue("-1")
+ protected int getConfiguredNodeHeightHint() {
+ return -1;
+ }
+
@ConfigProperty(ConfigProperty.BOOLEAN)
@Order(50)
@ConfigPropertyValue("false")
@@ -301,6 +308,7 @@ public abstract class AbstractTree extends AbstractPropertyObserver implements I setIconId(getConfiguredIconId());
setAutoTitle(getConfiguredAutoTitle());
setCheckable(getConfiguredCheckable());
+ setNodeHeightHint(getConfiguredNodeHeightHint());
setMultiCheck(getConfiguredMultiCheck());
setMultiSelect(getConfiguredMultiSelect());
setAutoDiscardOnDelete(getConfiguredAutoDiscardOnDelete());
@@ -578,6 +586,16 @@ public abstract class AbstractTree extends AbstractPropertyObserver implements I }
@Override
+ public int getNodeHeightHint() {
+ return propertySupport.getPropertyInt(PROP_NODE_HEIGHT_HINT);
+ }
+
+ @Override
+ public void setNodeHeightHint(int h) {
+ propertySupport.setPropertyInt(PROP_NODE_HEIGHT_HINT, h);
+ }
+
+ @Override
public boolean isDragEnabled() {
return propertySupport.getPropertyBool(PROP_DRAG_ENABLED);
}
diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/tree/ITree.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/tree/ITree.java index f58c15d933..311e9a3315 100644 --- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/tree/ITree.java +++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/tree/ITree.java @@ -34,6 +34,10 @@ public interface ITree extends IPropertyObserver, IDNDSupport { String PROP_MULTI_SELECT = "multiSelect";
String PROP_MULTI_CHECK = "multiCheck";
String PROP_CHECKABLE = "checkable";
+ /**
+ * Integer default -1
+ */
+ String PROP_NODE_HEIGHT_HINT = "propNodeHeightHint";
String PROP_ROOT_NODE_VISIBLE = "rootNodeVisible";
String PROP_ROOT_HANDLES_VISIBLE = "rootHandlesVisible";
String PROP_KEY_STROKES = "keyStroks";
@@ -281,6 +285,21 @@ public interface ITree extends IPropertyObserver, IDNDSupport { void setCheckable(boolean b);
+ /**
+ * This is a hint for the UI if it is not capable of having variable node height based on node contents
+ * (such as rap/rwt).
+ * <p>
+ * This hint defines the node height in pixels being used as the fixed node height for all nodes of this tree.
+ *
+ * @return the hint in pixels, default is -1
+ */
+ int getNodeHeightHint();
+
+ /**
+ * see {@link #getNodeHeightHint()}
+ */
+ void setNodeHeightHint(int h);
+
boolean isAutoDiscardOnDelete();
void setAutoDiscardOnDelete(boolean on);
diff --git a/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/basic/table/RwtScoutColumnModel.java b/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/basic/table/RwtScoutColumnModel.java index b923aeef22..0293662274 100644 --- a/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/basic/table/RwtScoutColumnModel.java +++ b/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/basic/table/RwtScoutColumnModel.java @@ -29,7 +29,7 @@ public class RwtScoutColumnModel extends ColumnLabelProvider { private transient ListenerList listenerList = null; private final ITable m_scoutTable; private HashMap<ITableRow, HashMap<IColumn<?>, ICell>> m_cachedCells; - private final IRwtScoutTableForPatch m_uiTable_; + private final IRwtScoutTableForPatch m_uiTable; private final TableColumnManager m_columnManager; private Image m_imgCheckboxFalse; private Image m_imgCheckboxTrue; @@ -41,15 +41,23 @@ public class RwtScoutColumnModel extends ColumnLabelProvider { public RwtScoutColumnModel(ITable scoutTable, IRwtScoutTableForPatch uiTable, TableColumnManager columnManager) { m_scoutTable = scoutTable; - m_uiTable_ = uiTable; + m_uiTable = uiTable; m_columnManager = columnManager; - m_imgCheckboxTrue = getRwtScoutTable().getUiEnvironment().getIcon(RwtIcons.CheckboxYes); - m_imgCheckboxFalse = getRwtScoutTable().getUiEnvironment().getIcon(RwtIcons.CheckboxNo); - m_disabledForegroundColor = getRwtScoutTable().getUiEnvironment().getColor(UiDecorationExtensionPoint.getLookAndFeel().getColorForegroundDisabled()); + m_imgCheckboxTrue = getUiTable().getUiEnvironment().getIcon(RwtIcons.CheckboxYes); + m_imgCheckboxFalse = getUiTable().getUiEnvironment().getIcon(RwtIcons.CheckboxNo); + m_disabledForegroundColor = getUiTable().getUiEnvironment().getColor(UiDecorationExtensionPoint.getLookAndFeel().getColorForegroundDisabled()); m_defaultRowHeight = UiDecorationExtensionPoint.getLookAndFeel().getTableRowHeight(); rebuildCache(); } + protected ITable getScoutTable() { + return m_scoutTable; + } + + public IRwtScoutTableForPatch getUiTable() { + return m_uiTable; + } + @Override public void update(ViewerCell cell) { ITableRow element = (ITableRow) cell.getElement(); @@ -71,23 +79,23 @@ public class RwtScoutColumnModel extends ColumnLabelProvider { text = ""; } if (HtmlTextUtility.isTextWithHtmlMarkup(cell.getText())) { - text = getRwtScoutTable().getUiEnvironment().adaptHtmlCell(getRwtScoutTable(), text); - text = getRwtScoutTable().getUiEnvironment().convertLinksWithLocalUrlsInHtmlCell(getRwtScoutTable(), text); + text = getUiTable().getUiEnvironment().adaptHtmlCell(getUiTable(), text); + text = getUiTable().getUiEnvironment().convertLinksWithLocalUrlsInHtmlCell(getUiTable(), text); } else if (text.indexOf("\n") >= 0) { - if (m_scoutTable.isMultilineText()) { + if (getScoutTable().isMultilineText()) { //transform to html text = "<html>" + HtmlTextUtility.transformPlainTextToHtml(text) + "</html>"; - text = getRwtScoutTable().getUiEnvironment().adaptHtmlCell(getRwtScoutTable(), text); + text = getUiTable().getUiEnvironment().adaptHtmlCell(getUiTable(), text); } else { text = StringUtility.replace(text, "\n", " "); } } - TableEx table = getRwtScoutTable().getUiField(); + TableEx table = getUiTable().getUiField(); if (HtmlTextUtility.isTextWithHtmlMarkup(cell.getText())) { - if (m_htmlTableRows == null || m_htmlTableRows.length != m_scoutTable.getRowCount()) { - double[] tempArray = new double[m_scoutTable.getRowCount()]; + if (m_htmlTableRows == null || m_htmlTableRows.length != getScoutTable().getRowCount()) { + double[] tempArray = new double[getScoutTable().getRowCount()]; for (int i = 0; i < tempArray.length; i++) { tempArray[i] = 1; } @@ -95,10 +103,10 @@ public class RwtScoutColumnModel extends ColumnLabelProvider { m_htmlTableRows = tempArray; } else { - getRwtScoutTable().getUiEnvironment().getDisplay().asyncExec(new Runnable() { + getUiTable().getUiEnvironment().getDisplay().asyncExec(new Runnable() { @Override public void run() { - getRwtScoutTable().getUiTableViewer().refresh(); + getUiTable().getUiTableViewer().refresh(); } }); m_htmlTableRows = tempArray; @@ -113,8 +121,8 @@ public class RwtScoutColumnModel extends ColumnLabelProvider { } } else { - if (m_newlines == null || m_newlines.length != m_scoutTable.getRowCount()) { - double[] tempArray = new double[m_scoutTable.getRowCount()]; + if (m_newlines == null || m_newlines.length != getScoutTable().getRowCount()) { + double[] tempArray = new double[getScoutTable().getRowCount()]; for (int i = 0; i < tempArray.length; i++) { tempArray[i] = 1; } @@ -122,10 +130,10 @@ public class RwtScoutColumnModel extends ColumnLabelProvider { m_newlines = tempArray; } else { - getRwtScoutTable().getUiEnvironment().getDisplay().asyncExec(new Runnable() { + getUiTable().getUiEnvironment().getDisplay().asyncExec(new Runnable() { @Override public void run() { - getRwtScoutTable().getUiTableViewer().refresh(); + getUiTable().getUiTableViewer().refresh(); } }); m_newlines = tempArray; @@ -149,7 +157,7 @@ public class RwtScoutColumnModel extends ColumnLabelProvider { } public Image getColumnImage(ITableRow element, int columnIndex) { - int[] columnOrder = getRwtScoutTable().getUiField().getColumnOrder(); + int[] columnOrder = getUiTable().getUiField().getColumnOrder(); if (columnOrder.length <= 1) { return null; } @@ -157,7 +165,7 @@ public class RwtScoutColumnModel extends ColumnLabelProvider { ICell cell = getCell(element, columnIndex); //checkbox Image checkBoxImage = null; - if (columnOrder[1] == columnIndex && getRwtScoutTable().getScoutObject() != null && getRwtScoutTable().getScoutObject().isCheckable()) { + if (columnOrder[1] == columnIndex && getUiTable().getScoutObject() != null && getUiTable().getScoutObject().isCheckable()) { if (element.isChecked()) { checkBoxImage = m_imgCheckboxTrue; } @@ -182,7 +190,7 @@ public class RwtScoutColumnModel extends ColumnLabelProvider { else if (columnOrder[1] == columnIndex) { iconId = element.getIconId(); } - Image decoImage = getRwtScoutTable().getUiEnvironment().getIcon(iconId); + Image decoImage = getUiTable().getUiEnvironment().getIcon(iconId); //merge if (checkBoxImage != null && decoImage != null) { //TODO rap/rwt: new GC(Image) is not possible since in rwt an image does not implement Drawable. @@ -201,7 +209,7 @@ public class RwtScoutColumnModel extends ColumnLabelProvider { if (columnIndex > 0) { ICell cell = getCell(element, columnIndex); if (cell != null) { - return getRwtScoutTable().getUiEnvironment().getColor(cell.getBackgroundColor()); + return getUiTable().getUiEnvironment().getColor(cell.getBackgroundColor()); } } return null; @@ -211,7 +219,7 @@ public class RwtScoutColumnModel extends ColumnLabelProvider { if (columnIndex > 0) { ICell cell = getCell(element, columnIndex); if (cell != null) { - Color col = getRwtScoutTable().getUiEnvironment().getColor(cell.getForegroundColor()); + Color col = getUiTable().getUiEnvironment().getColor(cell.getForegroundColor()); if (col == null) { if (!element.isEnabled() || !cell.isEnabled()) { col = m_disabledForegroundColor; @@ -227,7 +235,7 @@ public class RwtScoutColumnModel extends ColumnLabelProvider { if (columnIndex > 0) { ICell cell = getCell(element, columnIndex); if (cell != null) { - return getRwtScoutTable().getUiEnvironment().getFont(cell.getFont(), getRwtScoutTable().getUiField().getFont()); + return getUiTable().getUiEnvironment().getFont(cell.getFont(), getUiTable().getUiField().getFont()); } } return null; @@ -235,9 +243,9 @@ public class RwtScoutColumnModel extends ColumnLabelProvider { @Override public String getToolTipText(Object element) { - Display display = getRwtScoutTable().getUiEnvironment().getDisplay(); - Point cursorOnTable = display.map(null, getRwtScoutTable().getUiField(), display.getCursorLocation()); - ViewerCell uiCell = getRwtScoutTable().getUiTableViewer().getCell(cursorOnTable); + Display display = getUiTable().getUiEnvironment().getDisplay(); + Point cursorOnTable = display.map(null, getUiTable().getUiField(), display.getCursorLocation()); + ViewerCell uiCell = getUiTable().getUiTableViewer().getCell(cursorOnTable); String text = ""; if (uiCell != null) { int columnIndex = uiCell.getColumnIndex(); @@ -276,18 +284,14 @@ public class RwtScoutColumnModel extends ColumnLabelProvider { private void rebuildCache() { m_cachedCells = new HashMap<ITableRow, HashMap<IColumn<?>, ICell>>(); - if (m_scoutTable != null) { - for (ITableRow scoutRow : m_scoutTable.getRows()) { + if (getScoutTable() != null) { + for (ITableRow scoutRow : getScoutTable().getRows()) { HashMap<IColumn<?>, ICell> cells = new HashMap<IColumn<?>, ICell>(); - for (IColumn<?> col : m_scoutTable.getColumnSet().getVisibleColumns()) { - cells.put(col, m_scoutTable.getCell(scoutRow, col)); + for (IColumn<?> col : getScoutTable().getColumnSet().getVisibleColumns()) { + cells.put(col, getScoutTable().getCell(scoutRow, col)); } m_cachedCells.put(scoutRow, cells); } } } - - public IRwtScoutTableForPatch getRwtScoutTable() { - return m_uiTable_; - } } diff --git a/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/basic/tree/IRwtScoutTree.java b/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/basic/tree/IRwtScoutTree.java index 7b88182460..b20c559f64 100644 --- a/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/basic/tree/IRwtScoutTree.java +++ b/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/basic/tree/IRwtScoutTree.java @@ -10,6 +10,7 @@ *******************************************************************************/
package org.eclipse.scout.rt.ui.rap.basic.tree;
+import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.scout.rt.client.ui.basic.tree.ITree;
import org.eclipse.scout.rt.ui.rap.basic.IRwtScoutComposite;
import org.eclipse.swt.widgets.Tree;
@@ -20,4 +21,6 @@ public interface IRwtScoutTree extends IRwtScoutComposite<ITree> { @Override
Tree getUiField();
+
+ TreeViewer getUiTreeViewer();
}
diff --git a/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/basic/tree/RwtScoutTree.java b/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/basic/tree/RwtScoutTree.java index 497ae9d434..85393a42ad 100644 --- a/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/basic/tree/RwtScoutTree.java +++ b/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/basic/tree/RwtScoutTree.java @@ -57,6 +57,7 @@ import org.eclipse.swt.dnd.DropTargetEvent; import org.eclipse.swt.events.MenuAdapter;
import org.eclipse.swt.events.MenuEvent;
import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.internal.widgets.MarkupValidator;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
@@ -68,6 +69,7 @@ import org.eclipse.swt.widgets.Menu; *
* @since 3.7.0 June 2011
*/
+@SuppressWarnings("restriction")
public class RwtScoutTree extends RwtScoutComposite<ITree> implements IRwtScoutTree {
private static final IScoutLogger LOG = ScoutLogManager.getLogger(RwtScoutTree.class);
@@ -93,9 +95,13 @@ public class RwtScoutTree extends RwtScoutComposite<ITree> implements IRwtScoutT protected void initializeUi(Composite parent) {
TreeViewer viewer = createTreeModel(parent);
setUiTreeViewer(viewer);
+ setUiField(viewer.getTree());
+ initNodeHeight();
initializeTreeModel();
- setUiField(viewer.getTree());
+
+ viewer.getTree().setData(RWT.MARKUP_ENABLED, Boolean.TRUE);
+ viewer.getTree().setData(MarkupValidator.MARKUP_VALIDATION_DISABLED, Boolean.TRUE);
// listeners
viewer.addSelectionChangedListener(new P_RwtSelectionListener());
viewer.addTreeListener(new P_RwtExpansionListener());
@@ -112,7 +118,6 @@ public class RwtScoutTree extends RwtScoutComposite<ITree> implements IRwtScoutT m_contextMenu = new Menu(viewer.getTree().getShell(), SWT.POP_UP);
m_contextMenu.addMenuListener(new P_ContextMenuListener());
viewer.getTree().setMenu(m_contextMenu);
- initNodeHeight();
}
protected TreeViewer createTreeModel(Composite parent) {
@@ -148,7 +153,7 @@ public class RwtScoutTree extends RwtScoutComposite<ITree> implements IRwtScoutT }
protected RwtScoutTreeModel createTreeModel() {
- return new RwtScoutTreeModel(getScoutObject(), getUiEnvironment(), getUiTreeViewer());
+ return new RwtScoutTreeModel(getScoutObject(), this, getUiTreeViewer());
}
protected boolean isMultiSelect() {
@@ -164,6 +169,7 @@ public class RwtScoutTree extends RwtScoutComposite<ITree> implements IRwtScoutT m_treeViewer = viewer;
}
+ @Override
public TreeViewer getUiTreeViewer() {
return m_treeViewer;
}
@@ -176,7 +182,7 @@ public class RwtScoutTree extends RwtScoutComposite<ITree> implements IRwtScoutT public TreeEx getUiField() {
return (TreeEx) super.getUiField();
}
-
+
protected void initNodeHeight() {
int height = UiDecorationExtensionPoint.getLookAndFeel().getTreeNodeHeight();
if (height >= 0) {
@@ -204,6 +210,7 @@ public class RwtScoutTree extends RwtScoutComposite<ITree> implements IRwtScoutT }
setSelectionFromScout(getScoutObject().getSelectedNodes());
setKeyStrokeFormScout();
+ setNodeHeightFromScout();
attachDndSupport();
handleEventsFromRecentHistory();
}
@@ -312,6 +319,16 @@ public class RwtScoutTree extends RwtScoutComposite<ITree> implements IRwtScoutT m_keyStrokes = newKeyStrokes.toArray(new IRwtKeyStroke[newKeyStrokes.size()]);
}
+ protected void setNodeHeightFromScout() {
+ int h = getScoutObject().getNodeHeightHint();
+ if (h >= 0) {
+ getUiField().setData(RWT.CUSTOM_ITEM_HEIGHT, h);
+ }
+ if (isCreated()) {
+ getUiTreeViewer().refresh();
+ }
+ }
+
/**
* bsi ticket 95090: avoid multiple and excessive tree structure updates
*/
@@ -423,6 +440,9 @@ public class RwtScoutTree extends RwtScoutComposite<ITree> implements IRwtScoutT else if (name.equals(ITree.PROP_SCROLL_TO_SELECTION)) {
updateScrollToSelectionFromScout();
}
+ else if (name.equals(ITree.PROP_NODE_HEIGHT_HINT)) {
+ setNodeHeightFromScout();
+ }
super.handleScoutPropertyChange(name, newValue);
}
diff --git a/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/basic/tree/RwtScoutTreeModel.java b/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/basic/tree/RwtScoutTreeModel.java index de4133ba27..ada5ac56d0 100644 --- a/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/basic/tree/RwtScoutTreeModel.java +++ b/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/basic/tree/RwtScoutTreeModel.java @@ -16,45 +16,52 @@ import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.rwt.RWT;
+import org.eclipse.scout.commons.NumberUtility;
+import org.eclipse.scout.commons.StringUtility;
import org.eclipse.scout.commons.logger.IScoutLogger;
import org.eclipse.scout.commons.logger.ScoutLogManager;
import org.eclipse.scout.rt.client.ui.basic.cell.ICell;
import org.eclipse.scout.rt.client.ui.basic.tree.ITree;
import org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode;
-import org.eclipse.scout.rt.ui.rap.IRwtEnvironment;
import org.eclipse.scout.rt.ui.rap.RwtIcons;
import org.eclipse.scout.rt.ui.rap.extension.UiDecorationExtensionPoint;
+import org.eclipse.scout.rt.ui.rap.util.HtmlTextUtility;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Tree;
public class RwtScoutTreeModel extends LabelProvider implements ITreeContentProvider, IFontProvider, IColorProvider {
private static final long serialVersionUID = 1L;
private static final IScoutLogger LOG = ScoutLogManager.getLogger(RwtScoutTreeModel.class);
- private final ITree m_tree;
- private final IRwtEnvironment m_uiEnvironment;
+ private final ITree m_scoutTree;
+ private final IRwtScoutTree m_uiTree;
private final TreeViewer m_treeViewer;
private Image m_imgCheckboxTrue;
private Image m_imgCheckboxFalse;
private Color m_disabledForegroundColor;
+ private final int m_defaultNodeHeight;
+ private double[] m_htmlTableNodes = null;
- public RwtScoutTreeModel(ITree tree, IRwtEnvironment uiEnvironment, TreeViewer treeViewer) {
- m_tree = tree;
- m_uiEnvironment = uiEnvironment;
+ public RwtScoutTreeModel(ITree tree, IRwtScoutTree uiTree, TreeViewer treeViewer) {
+ m_scoutTree = tree;
+ m_uiTree = uiTree;
m_treeViewer = treeViewer;
- m_imgCheckboxTrue = getUiEnvironment().getIcon(RwtIcons.CheckboxYes);
- m_imgCheckboxFalse = getUiEnvironment().getIcon(RwtIcons.CheckboxNo);
- m_disabledForegroundColor = getUiEnvironment().getColor(UiDecorationExtensionPoint.getLookAndFeel().getColorForegroundDisabled());
+ m_imgCheckboxTrue = getUiTree().getUiEnvironment().getIcon(RwtIcons.CheckboxYes);
+ m_imgCheckboxFalse = getUiTree().getUiEnvironment().getIcon(RwtIcons.CheckboxNo);
+ m_disabledForegroundColor = getUiTree().getUiEnvironment().getColor(UiDecorationExtensionPoint.getLookAndFeel().getColorForegroundDisabled());
+ m_defaultNodeHeight = UiDecorationExtensionPoint.getLookAndFeel().getTreeNodeHeight();
}
- private IRwtEnvironment getUiEnvironment() {
- return m_uiEnvironment;
+ protected ITree getScoutTree() {
+ return m_scoutTree;
}
- protected ITree getScoutTree() {
- return m_tree;
+ private IRwtScoutTree getUiTree() {
+ return m_uiTree;
}
@Override
@@ -109,7 +116,7 @@ public class RwtScoutTreeModel extends LabelProvider implements ITreeContentProv //deco
String iconId = scoutNode.getCell().getIconId();
Image decoImage = null;
- decoImage = getUiEnvironment().getIcon(iconId);
+ decoImage = getUiTree().getUiEnvironment().getIcon(iconId);
//merge
if (checkBoxImage != null && decoImage != null) {
//TODO rap/rwt: new GC(Image) is not possible since in rwt an image does not implement Drawable.
@@ -127,14 +134,63 @@ public class RwtScoutTreeModel extends LabelProvider implements ITreeContentProv @Override
public String getText(Object element) {
ITreeNode scoutNode = (ITreeNode) element;
- return scoutNode.getCell().getText();
+ if (scoutNode != null && scoutNode.getCell() != null) {
+ ICell cell = scoutNode.getCell();
+ String text = cell.getText();
+ if (text == null) {
+ text = "";
+ }
+
+ if (HtmlTextUtility.isTextWithHtmlMarkup(cell.getText())) {
+ text = getUiTree().getUiEnvironment().adaptHtmlCell(getUiTree(), text);
+ text = getUiTree().getUiEnvironment().convertLinksWithLocalUrlsInHtmlCell(getUiTree(), text);
+
+ Tree tree = getUiTree().getUiField();
+ if (HtmlTextUtility.isTextWithHtmlMarkup(cell.getText())) {
+ if (m_htmlTableNodes == null || m_htmlTableNodes.length != getScoutTree().getRootNode().getChildNodeCount()) {
+ double[] tempArray = new double[getScoutTree().getRootNode().getChildNodeCount()];
+ for (int i = 0; i < tempArray.length; i++) {
+ tempArray[i] = 1;
+ }
+ if (m_htmlTableNodes == null) {
+ m_htmlTableNodes = tempArray;
+ }
+ else {
+ getUiTree().getUiEnvironment().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ getUiTree().getUiTreeViewer().refresh();
+ }
+ });
+ m_htmlTableNodes = tempArray;
+ }
+ }
+ m_htmlTableNodes[((ITreeNode) element).getChildNodeIndex()] = HtmlTextUtility.countHtmlTableRows(text);
+ double medianHtmlTableRows = NumberUtility.median(m_htmlTableNodes);
+ int htmlTreeNodeHeight = NumberUtility.toDouble(NumberUtility.round(medianHtmlTableRows, 1.0)).intValue() * 20;
+ if (tree.getData(RWT.CUSTOM_ITEM_HEIGHT) == null
+ || ((Integer) tree.getData(RWT.CUSTOM_ITEM_HEIGHT)).compareTo(htmlTreeNodeHeight) < 0) {
+ tree.setData(RWT.CUSTOM_ITEM_HEIGHT, Double.valueOf(NumberUtility.max(getDefaultNodeHeight(), htmlTreeNodeHeight)).intValue());
+ }
+ }
+ }
+ else if (text.indexOf("\n") >= 0) {
+ text = StringUtility.replace(text, "\n", " ");
+ }
+ return text;
+ }
+ return "";
+ }
+
+ protected int getDefaultNodeHeight() {
+ return m_defaultNodeHeight;
}
@Override
public Font getFont(Object element) {
ITreeNode scoutNode = (ITreeNode) element;
if (scoutNode.getCell().getFont() != null) {
- return getUiEnvironment().getFont(scoutNode.getCell().getFont(), m_treeViewer.getTree().getFont());
+ return getUiTree().getUiEnvironment().getFont(scoutNode.getCell().getFont(), m_treeViewer.getTree().getFont());
}
return null;
}
@@ -143,7 +199,7 @@ public class RwtScoutTreeModel extends LabelProvider implements ITreeContentProv public Color getForeground(Object element) {
ITreeNode scoutNode = (ITreeNode) element;
ICell scoutCell = scoutNode.getCell();
- Color col = getUiEnvironment().getColor(scoutCell.getForegroundColor());
+ Color col = getUiTree().getUiEnvironment().getColor(scoutCell.getForegroundColor());
if (col == null) {
if (!scoutCell.isEnabled()) {
col = m_disabledForegroundColor;
@@ -156,7 +212,7 @@ public class RwtScoutTreeModel extends LabelProvider implements ITreeContentProv public Color getBackground(Object element) {
ITreeNode scoutNode = (ITreeNode) element;
if (scoutNode.getCell().getBackgroundColor() != null) {
- return getUiEnvironment().getColor(scoutNode.getCell().getBackgroundColor());
+ return getUiTree().getUiEnvironment().getColor(scoutNode.getCell().getBackgroundColor());
}
return null;
}
|