Subversion Repository Public Repository

litesoft

Diff Revisions 949 vs 950 for /trunk/Java/GWT/OldClient/src/org/litesoft/GWT/client/iconservice/FavoritesManager.java

Diff revisions: vs.
  @@ -1,94 +1,94 @@
1 - // This Source Code is in the Public Domain per: http://unlicense.org
2 - package org.litesoft.GWT.client.iconservice;
3 -
4 - import org.litesoft.GWT.client.taskbar.*;
5 -
6 - import java.util.*;
7 -
8 - public class FavoritesManager {
9 - public static final FavoritesManager INSTANCE = new FavoritesManager();
10 -
11 - private List mFavorites = new ArrayList();
12 - public static final TaskbarFavoriteEntry[] EMPTY_ARRAY = new TaskbarFavoriteEntry[0];
13 - private TaskbarHelper mTaskbarHelper;
14 -
15 - private FavoritesManager() {
16 - }
17 -
18 - public void addToFavorites( PersistentTaskbarFavoritePackage pFavorite ) {
19 - if ( mTaskbarHelper != null ) {
20 - mFavorites.add( new TaskbarFavoriteEntry( pFavorite.getFactoryRef() ) );
21 -
22 - mTaskbarHelper.updateFavoritesDisplay( mFavorites );
23 - }
24 - }
25 -
26 - public void removeFavorite( TaskbarItem pItem ) {
27 - TaskbarEntry taskbarEntry = pItem.getEntry();
28 -
29 - int indx = mFavorites.indexOf( taskbarEntry );
30 -
31 - if ( indx >= 0 ) {
32 - mFavorites.remove( indx );
33 - mTaskbarHelper.updateFavoritesDisplay( mFavorites );
34 - }
35 - }
36 -
37 - public void moveFavoriteUp( TaskbarItem pItem ) {
38 - TaskbarEntry taskbarEntry = pItem.getEntry();
39 -
40 - if ( taskbarEntry != null ) {
41 - int currentIndex = mFavorites.indexOf( taskbarEntry );
42 -
43 - Object o = mFavorites.remove( currentIndex );
44 -
45 - if ( (currentIndex - 1) < 0 ) {
46 - currentIndex = 0;
47 - } else {
48 - currentIndex--;
49 - }
50 -
51 - mFavorites.add( currentIndex, o );
52 - mTaskbarHelper.updateFavoritesDisplay( mFavorites );
53 - }
54 - }
55 -
56 - public void moveFavoriteDown( TaskbarItem pItem ) {
57 - TaskbarEntry taskbarEntry = pItem.getEntry();
58 -
59 - if ( taskbarEntry != null ) {
60 -
61 - int currentIndex = mFavorites.indexOf( taskbarEntry );
62 - int totalFavorites = mFavorites.size();
63 - Object o = mFavorites.remove( currentIndex );
64 -
65 - if ( (currentIndex + 1) >= totalFavorites ) {
66 - currentIndex = totalFavorites - 1;
67 - } else {
68 - currentIndex++;
69 - }
70 -
71 - mFavorites.add( currentIndex, o );
72 - mTaskbarHelper.updateFavoritesDisplay( mFavorites );
73 - }
74 - }
75 -
76 - public TaskbarFavoriteEntry[] getFavoritesForDisplay() {
77 - return toArray( mFavorites );
78 - }
79 -
80 - private TaskbarFavoriteEntry[] toArray( List pFavorites ) {
81 - if ( pFavorites.isEmpty() ) {
82 - return FavoritesManager.EMPTY_ARRAY;
83 - }
84 - TaskbarFavoriteEntry[] rv = new TaskbarFavoriteEntry[pFavorites.size()];
85 - for ( int i = 0; i < pFavorites.size(); i++ ) {
86 - rv[i] = (TaskbarFavoriteEntry) pFavorites.get( i );
87 - }
88 - return rv;
89 - }
90 -
91 - public void setTaskbarHelper( TaskbarHelper pTaskbarHelper ) {
92 - mTaskbarHelper = pTaskbarHelper;
93 - }
94 - }
1 + // This Source Code is in the Public Domain per: http://unlicense.org
2 + package org.litesoft.GWT.client.iconservice;
3 +
4 + import org.litesoft.GWT.client.taskbar.*;
5 +
6 + import java.util.*;
7 +
8 + public class FavoritesManager {
9 + public static final FavoritesManager INSTANCE = new FavoritesManager();
10 +
11 + private List mFavorites = new ArrayList();
12 + public static final TaskbarFavoriteEntry[] EMPTY_ARRAY = new TaskbarFavoriteEntry[0];
13 + private TaskbarHelper mTaskbarHelper;
14 +
15 + private FavoritesManager() {
16 + }
17 +
18 + public void addToFavorites( PersistentTaskbarFavoritePackage pFavorite ) {
19 + if ( mTaskbarHelper != null ) {
20 + mFavorites.add( new TaskbarFavoriteEntry( pFavorite.getFactoryRef() ) );
21 +
22 + mTaskbarHelper.updateFavoritesDisplay( mFavorites );
23 + }
24 + }
25 +
26 + public void removeFavorite( TaskbarItem pItem ) {
27 + TaskbarEntry taskbarEntry = pItem.getEntry();
28 +
29 + int indx = mFavorites.indexOf( taskbarEntry );
30 +
31 + if ( indx >= 0 ) {
32 + mFavorites.remove( indx );
33 + mTaskbarHelper.updateFavoritesDisplay( mFavorites );
34 + }
35 + }
36 +
37 + public void moveFavoriteUp( TaskbarItem pItem ) {
38 + TaskbarEntry taskbarEntry = pItem.getEntry();
39 +
40 + if ( taskbarEntry != null ) {
41 + int currentIndex = mFavorites.indexOf( taskbarEntry );
42 +
43 + Object o = mFavorites.remove( currentIndex );
44 +
45 + if ( (currentIndex - 1) < 0 ) {
46 + currentIndex = 0;
47 + } else {
48 + currentIndex--;
49 + }
50 +
51 + mFavorites.add( currentIndex, o );
52 + mTaskbarHelper.updateFavoritesDisplay( mFavorites );
53 + }
54 + }
55 +
56 + public void moveFavoriteDown( TaskbarItem pItem ) {
57 + TaskbarEntry taskbarEntry = pItem.getEntry();
58 +
59 + if ( taskbarEntry != null ) {
60 +
61 + int currentIndex = mFavorites.indexOf( taskbarEntry );
62 + int totalFavorites = mFavorites.size();
63 + Object o = mFavorites.remove( currentIndex );
64 +
65 + if ( (currentIndex + 1) >= totalFavorites ) {
66 + currentIndex = totalFavorites - 1;
67 + } else {
68 + currentIndex++;
69 + }
70 +
71 + mFavorites.add( currentIndex, o );
72 + mTaskbarHelper.updateFavoritesDisplay( mFavorites );
73 + }
74 + }
75 +
76 + public TaskbarFavoriteEntry[] getFavoritesForDisplay() {
77 + return toArray( mFavorites );
78 + }
79 +
80 + private TaskbarFavoriteEntry[] toArray( List pFavorites ) {
81 + if ( pFavorites.isEmpty() ) {
82 + return FavoritesManager.EMPTY_ARRAY;
83 + }
84 + TaskbarFavoriteEntry[] rv = new TaskbarFavoriteEntry[pFavorites.size()];
85 + for ( int i = 0; i < pFavorites.size(); i++ ) {
86 + rv[i] = (TaskbarFavoriteEntry) pFavorites.get( i );
87 + }
88 + return rv;
89 + }
90 +
91 + public void setTaskbarHelper( TaskbarHelper pTaskbarHelper ) {
92 + mTaskbarHelper = pTaskbarHelper;
93 + }
94 + }