Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
ikus-soft
swt
Compare revisions
8120afebf15326818a42c89216ee12d200dfba9c to 9b361db8e3ecbfc42b63e06c5d1095551fed96d7
Commits on Source (2)
WIP
· 4b29a8a1
Patrik Dufresne
authored
Feb 20, 2019
4b29a8a1
WIP
· 9b361db8
Patrik Dufresne
authored
Feb 20, 2019
9b361db8
Hide whitespace changes
Inline
Side-by-side
jface/src/main/java/com/patrikdufresne/jface/databinding/viewers/ColumnSupport.java
View file @
9b361db8
...
...
@@ -448,6 +448,8 @@ public class ColumnSupport {
// Add default label provider
this
.
column
.
setLabelProvider
(
new
ObservableMapCellLabelProvider
(
property
.
observeDetail
(
knownElements
)));
this
.
property
=
property
;
this
.
addPropertySorting
();
}
...
...
managers-databinding/src/main/java/com/patrikdufresne/managers/databinding/ManagedObjectComputedSet.java
View file @
9b361db8
...
...
@@ -36,10 +36,13 @@ import org.eclipse.core.databinding.observable.set.AbstractObservableSet;
import
org.eclipse.core.databinding.observable.set.ComputedSet
;
import
org.eclipse.core.databinding.observable.set.ISetChangeListener
;
import
org.eclipse.core.databinding.observable.set.SetDiff
;
import
org.eclipse.core.databinding.property.value.IValueProperty
;
import
org.eclipse.core.databinding.util.Policy
;
import
org.eclipse.core.runtime.IStatus
;
import
org.eclipse.core.runtime.Status
;
import
org.eclipse.jface.viewers.TableViewer
;
import
com.patrikdufresne.jface.databinding.viewers.ColumnSupport
;
import
com.patrikdufresne.managers.IManager
;
import
com.patrikdufresne.managers.IManagerObserver
;
import
com.patrikdufresne.managers.ManagedObject
;
...
...
@@ -144,7 +147,9 @@ public class ManagedObjectComputedSet extends AbstractObservableSet implements I
* the managers
* @param elementType
* the element type
* @deprecated please use {@link ManagedObjectComputedSet(IManager)} instead.
*/
@Deprecated
public
ManagedObjectComputedSet
(
Managers
managers
,
Class
<?
extends
ManagedObject
>
elementType
)
{
this
(
managers
,
elementType
,
defaultEvents
(
elementType
),
null
);
}
...
...
@@ -159,8 +164,9 @@ public class ManagedObjectComputedSet extends AbstractObservableSet implements I
* the element type
* @param dependencies
* list of observable dependencies or null
*
*
@deprecated please use {@link ManagedObjectComputedSet(IManager, IObservable[])} instead.
*/
@Deprecated
public
ManagedObjectComputedSet
(
Managers
managers
,
Class
<?
extends
ManagedObject
>
elementType
,
IObservable
[]
dependencies
)
{
this
(
managers
,
elementType
,
defaultEvents
(
elementType
),
dependencies
);
}
...
...
@@ -176,8 +182,9 @@ public class ManagedObjectComputedSet extends AbstractObservableSet implements I
* the element type
* @param events
* the list of manager event to listen to
*
*
@deprecated please use {@link ManagedObjectComputedSet(IManager, Map)} instead.
*/
@Deprecated
public
ManagedObjectComputedSet
(
Managers
managers
,
Class
<?
extends
ManagedObject
>
elementType
,
Map
<
Class
,
Integer
>
events
)
{
this
(
managers
,
elementType
,
events
,
null
);
}
...
...
@@ -193,7 +200,9 @@ public class ManagedObjectComputedSet extends AbstractObservableSet implements I
* the list of manager event to listen to
* @param dependencies
* the list of observable dependencies.
* @deprecated please use {@link ManagedObjectComputedSet(IManager, Map, IObservable[])} instead.
*/
@Deprecated
public
ManagedObjectComputedSet
(
Managers
managers
,
Class
<?
extends
ManagedObject
>
elementType
,
Map
<
Class
,
Integer
>
events
,
IObservable
[]
dependencies
)
{
this
(
Realm
.
getDefault
(),
managers
,
elementType
,
events
,
dependencies
);
}
...
...
@@ -211,7 +220,9 @@ public class ManagedObjectComputedSet extends AbstractObservableSet implements I
* the list of manager event to listen to
* @param dependencies
* the list of observable dependencies.
* @deprecated please use {@link ManagedObjectComputedSet(Realm, IManager, Map, IObservable[])} instead.
*/
@Deprecated
public
ManagedObjectComputedSet
(
Realm
realm
,
Managers
managers
,
...
...
managers-databinding/src/main/java/com/patrikdufresne/managers/databinding/ManagerContentProvider.java
0 → 100644
View file @
9b361db8
/**
* Copyright (C) 2019 Patrik Dufresne Service Logiciel <info@patrikdufresne.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package
com.patrikdufresne.managers.databinding
;
import
java.util.Set
;
import
org.eclipse.core.databinding.observable.IObservableCollection
;
import
org.eclipse.core.databinding.observable.set.IObservableSet
;
import
org.eclipse.core.databinding.observable.set.ISetChangeListener
;
import
org.eclipse.core.databinding.observable.set.SetChangeEvent
;
import
org.eclipse.core.runtime.Assert
;
import
org.eclipse.jface.databinding.viewers.IViewerUpdater
;
import
org.eclipse.jface.internal.databinding.viewers.ObservableCollectionContentProvider
;
import
org.eclipse.jface.viewers.IStructuredContentProvider
;
import
org.eclipse.jface.viewers.Viewer
;
import
com.patrikdufresne.managers.IManager
;
import
com.patrikdufresne.managers.ManagerException
;
public
class
ManagerContentProvider
implements
IStructuredContentProvider
{
private
ObservableCollectionContentProvider
impl
;
private
static
class
Impl
extends
ObservableCollectionContentProvider
implements
ISetChangeListener
{
protected
Impl
(
IViewerUpdater
explicitViewerUpdater
)
{
super
(
explicitViewerUpdater
);
}
@Override
protected
void
checkInput
(
Object
input
)
{
Assert
.
isTrue
(
input
instanceof
IObservableSet
,
"This content provider only works with input of type IObservableSet"
);
//$NON-NLS-1$
}
@Override
protected
void
addCollectionChangeListener
(
IObservableCollection
collection
)
{
((
IObservableSet
)
collection
).
addSetChangeListener
(
this
);
}
@Override
protected
void
removeCollectionChangeListener
(
IObservableCollection
collection
)
{
((
IObservableSet
)
collection
).
removeSetChangeListener
(
this
);
}
@Override
public
void
handleSetChange
(
SetChangeEvent
event
)
{
if
(
isViewerDisposed
())
return
;
Set
removals
=
event
.
diff
.
getRemovals
();
Set
additions
=
event
.
diff
.
getAdditions
();
knownElements
.
addAll
(
additions
);
if
(
realizedElements
!=
null
)
realizedElements
.
removeAll
(
removals
);
viewerUpdater
.
remove
(
removals
.
toArray
());
viewerUpdater
.
add
(
additions
.
toArray
());
if
(
realizedElements
!=
null
)
realizedElements
.
addAll
(
additions
);
knownElements
.
removeAll
(
removals
);
}
}
/**
* Constructs an ObservableSetContentProvider. Must be called from the display thread.
*/
public
ManagerContentProvider
()
{
this
(
null
);
}
/**
* Constructs an ObservableSetContentProvider with the given viewer updater. Must be called from the display thread.
*
* @param viewerUpdater
* the viewer updater to use when elements are added or removed from the input observable set.
* @since 1.3
*/
public
ManagerContentProvider
(
IViewerUpdater
viewerUpdater
)
{
impl
=
new
Impl
(
viewerUpdater
);
}
@Override
public
void
inputChanged
(
Viewer
viewer
,
Object
oldInput
,
Object
newInput
)
{
Assert
.
isTrue
(
newInput
instanceof
IManager
,
"This content provider only works with input of type IManager"
);
//$NON-NLS-1$
impl
.
inputChanged
(
viewer
,
null
,
new
ManagedObjectComputedSet
((
IManager
)
newInput
));
}
@Override
public
Object
[]
getElements
(
Object
inputElement
)
{
return
impl
.
getElements
(
inputElement
);
}
/**
* Disposes of this content provider. This is called by the viewer when a content provider is replaced, or when the
* viewer itself is disposed.
* <p>
* The viewer should not be updated during this call, as it is in the process of being disposed.
* </p>
* <p>
* <em>Note:</em> Data binding content providers become unusable on disposal.
* </p>
*/
@Override
public
void
dispose
()
{
impl
.
dispose
();
}
/**
* Returns the set of elements known to this content provider. Label providers may track this set if they need to be
* notified about additions before the viewer sees the added element, and notified about removals after the element
* was removed from the viewer. This is intended for use by label providers, as it will always return the items that
* need labels.
*
* @return unmodifiable set of items that will need labels
*/
public
IObservableSet
getKnownElements
()
{
return
impl
.
getKnownElements
();
}
/**
* Returns the set of known elements which have been realized in the viewer. Clients may track this set in order to
* perform custom actions on elements while they are known to be present in the viewer.
*
* @return the set of known elements which have been realized in the viewer.
* @since 1.3
*/
public
IObservableSet
getRealizedElements
()
{
return
impl
.
getRealizedElements
();
}
}
managers-databinding/src/main/java/com/patrikdufresne/managers/databinding/ManagerDataBindingContext.java
0 → 100644
View file @
9b361db8
/**
* Copyright (C) 2019 Patrik Dufresne Service Logiciel <info@patrikdufresne.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package
com.patrikdufresne.managers.databinding
;
import
org.eclipse.core.databinding.DataBindingContext
;
import
org.eclipse.core.databinding.UpdateListStrategy
;
import
org.eclipse.core.databinding.UpdateSetStrategy
;
import
org.eclipse.core.databinding.UpdateValueStrategy
;
import
org.eclipse.core.databinding.observable.list.IObservableList
;
import
org.eclipse.core.databinding.observable.set.IObservableSet
;
import
org.eclipse.core.databinding.observable.value.IObservableValue
;
import
com.patrikdufresne.managers.Managers
;
/**
* Specialised data binding context for managers.
*
* @author Patrik Dufresne
*
*/
public
class
ManagerDataBindingContext
extends
DataBindingContext
{
private
Managers
managers
;
/**
* Create a data binding context for the given managers.
*
* @param managers
* the managers used for persistance.
*/
public
ManagerDataBindingContext
(
Managers
managers
)
{
this
.
managers
=
managers
;
}
/**
* Returns an update value strategy to be used for copying values from the from value to the to value. Clients may
* override.
*
* @param fromValue
* @param toValue
* @return a update value strategy
*/
@Override
protected
<
T
,
M
>
UpdateValueStrategy
<
T
,
M
>
createTargetToModelUpdateValueStrategy
(
IObservableValue
<
T
>
fromValue
,
IObservableValue
<
M
>
toValue
)
{
return
new
ManagerUpdateValueStrategy
(
managers
,
UpdateValueStrategy
.
POLICY_CONVERT
);
}
/**
* @param targetObservableList
* @param modelObservableList
* @return an update list strategy
*/
@Override
protected
<
T
,
M
>
UpdateListStrategy
<
T
,
M
>
createTargetToModelUpdateListStrategy
(
IObservableList
<
T
>
targetObservableList
,
IObservableList
<
M
>
modelObservableList
)
{
return
new
ManagerUpdateListStrategy
(
managers
,
UpdateValueStrategy
.
POLICY_CONVERT
);
}
/**
* @param targetObservableSet
* @param modelObservableSet
* @return a default set update strategy
*/
@Override
protected
<
T
,
M
>
UpdateSetStrategy
<
T
,
M
>
createTargetToModelUpdateSetStrategy
(
IObservableSet
<
T
>
targetObservableSet
,
IObservableSet
<
M
>
modelObservableSet
)
{
return
new
ManagerUpdateSetStrategy
(
managers
,
UpdateValueStrategy
.
POLICY_CONVERT
);
}
}