Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Docking
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Software Control System
Libraries
java
Docking
Commits
308cb80c
Commit
308cb80c
authored
11 years ago
by
GIRARDOT Raphael
Committed by
MADELA Patrick
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Use Map instead of Collection for IView storage
parent
1377d9f8
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
dockingcore/src/main/java/fr/soleil/docking/view/ViewFactory.java
+48
-22
48 additions, 22 deletions
...ore/src/main/java/fr/soleil/docking/view/ViewFactory.java
with
48 additions
and
22 deletions
dockingcore/src/main/java/fr/soleil/docking/view/ViewFactory.java
+
48
−
22
View file @
308cb80c
...
...
@@ -8,35 +8,36 @@ import java.io.ObjectInputStream;
import
java.io.ObjectOutputStream
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.prefs.Preferences
;
import
javax.swing.Action
;
import
fr.soleil.docking.action.ViewAction
;
import
fr.soleil.lib.project.ObjectUtils
;
/**
* Basic implementation of {@link IViewFactory}
*
* @author girardot
*/
public
class
ViewFactory
implements
IViewFactory
{
protected
final
Collection
<
IView
>
views
;
protected
final
Map
<
Object
,
IView
>
views
;
protected
final
PropertyChangeSupport
support
;
public
ViewFactory
()
{
super
();
views
=
Collections
.
newSetFromMap
(
new
ConcurrentHashMap
<
IView
,
Boolean
>()
)
;
views
=
new
ConcurrentHashMap
<
Object
,
IView
>();
support
=
new
PropertyChangeSupport
(
this
);
}
@Override
public
IView
getView
(
Object
id
)
{
IView
result
=
null
;
for
(
IView
view
:
views
)
{
if
(
ObjectUtils
.
sameObject
(
id
,
view
.
getId
()))
{
result
=
view
;
break
;
}
if
(
id
!=
null
)
{
result
=
views
.
get
(
id
);
}
return
result
;
}
...
...
@@ -74,19 +75,38 @@ public class ViewFactory implements IViewFactory {
@Override
public
IView
addView
(
IView
view
)
{
if
(
views
.
add
(
view
))
{
support
.
firePropertyChange
(
VIEWS
,
null
,
view
);
}
else
{
view
=
null
;
IView
added
=
null
;
if
(
view
!=
null
)
{
Object
id
=
view
.
getId
();
if
(
id
!=
null
)
{
if
(!
views
.
containsKey
(
id
))
{
views
.
put
(
id
,
view
);
if
(
views
.
get
(
id
)
==
view
)
{
added
=
view
;
}
}
}
}
return
view
;
if
(
added
!=
null
)
{
synchronized
(
support
)
{
support
.
firePropertyChange
(
VIEWS
,
null
,
view
);
}
}
return
added
;
}
@Override
public
IView
removeView
(
Object
id
)
{
IView
toRemove
=
getView
(
id
)
;
if
(
!
removeView
(
toRemove
)
)
{
IView
toRemove
;
if
(
id
==
null
)
{
toRemove
=
null
;
}
else
{
toRemove
=
views
.
remove
(
id
);
if
(
toRemove
!=
null
)
{
synchronized
(
support
)
{
support
.
firePropertyChange
(
VIEWS
,
toRemove
,
null
);
}
}
}
return
toRemove
;
}
...
...
@@ -97,9 +117,13 @@ public class ViewFactory implements IViewFactory {
if
(
view
==
null
)
{
result
=
false
;
}
else
{
result
=
views
.
remove
(
view
);
if
(
result
)
{
support
.
firePropertyChange
(
VIEWS
,
view
,
null
);
Object
id
=
view
.
getId
();
IView
temp
=
getView
(
id
);
if
(
temp
==
view
)
{
result
=
true
;
removeView
(
id
);
}
else
{
result
=
false
;
}
}
return
result
;
...
...
@@ -108,8 +132,10 @@ public class ViewFactory implements IViewFactory {
@Override
public
List
<
Action
>
getActionList
()
{
List
<
Action
>
result
=
new
ArrayList
<
Action
>(
views
.
size
());
for
(
IView
view
:
views
)
{
result
.
add
(
new
ViewAction
(
view
));
for
(
IView
view
:
views
.
values
())
{
if
(
view
!=
null
)
{
result
.
add
(
new
ViewAction
(
view
));
}
}
return
result
;
}
...
...
@@ -121,7 +147,7 @@ public class ViewFactory implements IViewFactory {
@Override
public
Collection
<
IView
>
getViews
()
{
return
views
;
return
views
.
values
()
;
}
@Override
...
...
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