Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
af3
kernel
Commits
66412ffa
Commit
66412ffa
authored
9 years ago
by
Simon Barner
Browse files
Options
Downloads
Patches
Plain Diff
Support line breaks in string contents.
refs 2450
parent
570b1c0a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/generic/GenericAnnotationView.java
+79
-1
79 additions, 1 deletion
...ase/ui/annotation/view/generic/GenericAnnotationView.java
with
79 additions
and
1 deletion
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/generic/GenericAnnotationView.java
+
79
−
1
View file @
66412ffa
...
...
@@ -20,6 +20,7 @@ package org.fortiss.tooling.base.ui.annotation.view.generic;
import
static
org
.
fortiss
.
tooling
.
base
.
ui
.
annotation
.
editingsupport
.
EditingSupportFactory
.
createEditingSupport
;
import
static
org
.
fortiss
.
tooling
.
base
.
ui
.
annotation
.
labelprovider
.
LabelProviderFactory
.
createLabelProvider
;
import
java.lang.reflect.Method
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -36,12 +37,16 @@ import org.eclipse.jface.viewers.TableViewer;
import
org.eclipse.jface.viewers.TableViewerColumn
;
import
org.eclipse.jface.window.ToolTip
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.graphics.Point
;
import
org.eclipse.swt.layout.FillLayout
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.layout.GridLayout
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Event
;
import
org.eclipse.swt.widgets.Listener
;
import
org.eclipse.swt.widgets.Table
;
import
org.eclipse.swt.widgets.TableColumn
;
import
org.eclipse.swt.widgets.TableItem
;
import
org.fortiss.tooling.base.annotation.AnnotationEntry
;
import
org.fortiss.tooling.base.annotation.IAnnotationValueService
;
import
org.fortiss.tooling.base.annotation.valueprovider.IAnnotationValueProvider
;
...
...
@@ -69,7 +74,7 @@ import org.fortiss.tooling.base.ui.annotation.view.generic.filter.AnnotationFilt
* @author eder, diewald, barner
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: B
F52B9E58D2D44E769E05ADCC62499CD
* @ConQAT.Rating YELLOW Hash: B
BED92F55537563D7EF594EF27F36870
*/
public
class
GenericAnnotationView
extends
AnnotationViewPartBase
{
/** Root composite of {@link GenericAnnotationView}. */
...
...
@@ -101,6 +106,9 @@ public class GenericAnnotationView extends AnnotationViewPartBase {
/** Default width of columns. */
static
final
int
COLUMN_DEFAULT_WIDTH
=
125
;
/** Default height of rows. */
private
int
defaultRowHeight
;
/**
* Sets a fixed {@link AnnotationFilter}.
* <ul>
...
...
@@ -233,6 +241,11 @@ public class GenericAnnotationView extends AnnotationViewPartBase {
}
tableViewer
.
getTable
().
setRedraw
(
true
);
// After contents change, restore row height. It will be adjusted to the new content
// using the TableViewer's SWT.{MeasureItem, PaintItem, EraseItem} listeners installed
// in addRowHeightListener()
setTableItemHeight
(
tableViewer
.
getTable
(),
defaultRowHeight
);
}
// Update the view
...
...
@@ -258,6 +271,64 @@ public class GenericAnnotationView extends AnnotationViewPartBase {
annotationFilterWidget
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
CENTER
,
true
,
false
,
1
,
1
));
}
/**
* Sets the item height of the given {@link Table} to the specified value.
*
* <b>The underlying method {@code Table#setItemHeight} is not exposed. This wrapper method
* should only called during a full {@link #update(Collection)} of the table's contents.</b>>
*/
private
void
setTableItemHeight
(
Table
table
,
int
height
)
{
try
{
Method
method
=
table
.
getClass
().
getDeclaredMethod
(
"setItemHeight"
,
int
.
class
);
if
(
method
!=
null
)
{
boolean
accessible
=
method
.
isAccessible
();
method
.
setAccessible
(
true
);
method
.
invoke
(
table
,
height
);
method
.
setAccessible
(
accessible
);
}
}
catch
(
Exception
e
)
{
// ignore
}
}
/**
* Installs a listener to the given {@link Table} that adjust the row height to to the current
* contents.
*/
private
void
addRowHeightListener
(
Table
table
)
{
Listener
rowHeightListener
=
new
Listener
()
{
@Override
public
void
handleEvent
(
Event
event
)
{
switch
(
event
.
type
)
{
case
SWT
.
MeasureItem
:
{
TableItem
item
=
(
TableItem
)
event
.
item
;
String
text
=
item
.
getText
(
event
.
index
);
Point
size
=
event
.
gc
.
textExtent
(
text
);
event
.
width
=
size
.
x
;
event
.
height
=
Math
.
max
(
event
.
height
,
size
.
y
);
break
;
}
case
SWT
.
PaintItem
:
{
TableItem
item
=
(
TableItem
)
event
.
item
;
String
text
=
item
.
getText
(
event
.
index
);
Point
size
=
event
.
gc
.
textExtent
(
text
);
int
offset
=
event
.
index
==
0
?
Math
.
max
(
0
,
(
event
.
height
-
size
.
y
)
/
2
)
:
0
;
event
.
gc
.
drawText
(
text
,
event
.
x
,
event
.
y
+
offset
,
true
);
break
;
}
case
SWT
.
EraseItem
:
{
event
.
detail
&=
~
SWT
.
FOREGROUND
;
break
;
}
}
}
};
table
.
addListener
(
SWT
.
MeasureItem
,
rowHeightListener
);
table
.
addListener
(
SWT
.
PaintItem
,
rowHeightListener
);
table
.
addListener
(
SWT
.
EraseItem
,
rowHeightListener
);
}
/** {@inheritDoc} */
@Override
public
void
createPartControl
(
Composite
parent
)
{
...
...
@@ -271,6 +342,13 @@ public class GenericAnnotationView extends AnnotationViewPartBase {
table
.
setLinesVisible
(
true
);
table
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
true
,
true
,
1
,
1
));
// Listener to adjust row height to contents
addRowHeightListener
(
table
);
// Preserve default row-height (used to restore it during contents updates in
// update(Collection<AnnotationEntry>)).
defaultRowHeight
=
table
.
getItemHeight
();
ColumnViewerToolTipSupport
.
enableFor
(
tableViewer
,
ToolTip
.
NO_RECREATE
);
// Install layout for Table in order to ensure that it claims all available vertical space
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment