View | Details | Raw Unified | Return to bug 201125 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/datatools/connectivity/internal/ui/ProfileUIManager.java (-62 / +6 lines)
Lines 15-41 Link Here
15
15
16
package org.eclipse.datatools.connectivity.internal.ui;
16
package org.eclipse.datatools.connectivity.internal.ui;
17
17
18
import java.util.Collection;
19
import java.util.List;
20
21
import org.eclipse.core.runtime.IAdaptable;
18
import org.eclipse.core.runtime.IAdaptable;
22
import org.eclipse.datatools.connectivity.IConnectionProfile;
19
import org.eclipse.datatools.connectivity.IConnectionProfile;
23
import org.eclipse.datatools.connectivity.ui.wizards.ProfilePropertyPage;
20
import org.eclipse.datatools.connectivity.ui.wizards.ProfilePropertyPage;
24
import org.eclipse.jface.preference.IPreferenceNode;
21
import org.eclipse.jface.preference.IPreferenceNode;
25
import org.eclipse.jface.preference.IPreferencePage;
22
import org.eclipse.jface.preference.IPreferencePage;
26
import org.eclipse.jface.preference.PreferenceDialog;
23
import org.eclipse.jface.preference.PreferenceDialog;
27
import org.eclipse.jface.preference.PreferenceManager;
28
import org.eclipse.swt.widgets.Shell;
24
import org.eclipse.swt.widgets.Shell;
29
import org.eclipse.ui.dialogs.PreferencesUtil;
25
import org.eclipse.ui.dialogs.PreferencesUtil;
30
import org.eclipse.ui.internal.dialogs.PropertyPageContributorManager;
31
import org.eclipse.ui.internal.dialogs.PropertyPageManager;
32
26
33
/**
27
/**
34
 *  An internal utility class of the Connection Profile UI Manager.
28
 *  An internal utility class of the Connection Profile UI Manager.
35
 *  This currently uses internal Platform UI packages to get at property page details.
29
 *  This has now switched from using internal Platform UI packages 
36
 *  It is pending switch to use Platform UI patch (Bugzilla 208830) in 3.4,
30
 *  to Platform UI API methods added in 3.4 (Bugzilla 208830), 
37
 *  when DTP no longer needs to provide backward compatibility to Platform version 3.3.  
31
 *  as backward compatibility to Platform version 3.3 is no longer supported from DTP 1.7 on.
38
 *  See TODO tags below.
39
 *  @since DTP 1.6
32
 *  @since DTP 1.6
40
 */
33
 */
41
public class ProfileUIManager
34
public class ProfileUIManager
Lines 47-54 Link Here
47
     */
40
     */
48
    public static boolean hasContributors( Object element ) 
41
    public static boolean hasContributors( Object element ) 
49
    {
42
    {
50
        // TODO replace with call to method in org.eclipse.ui.dialogs.PreferencesUtil
43
        return PreferencesUtil.hasPropertiesContributors( element );
51
        return hasPropertiesContributors( element );
52
    }
44
    }
53
45
54
    /**
46
    /**
Lines 64-71 Link Here
64
        if ( element == null || !(element instanceof IAdaptable) )
56
        if ( element == null || !(element instanceof IAdaptable) )
65
            return null;
57
            return null;
66
58
67
        // TODO replace with call to method in org.eclipse.ui.dialogs.PreferencesUtil
59
        IPreferenceNode[] nodes = PreferencesUtil.propertiesContributorsFor( element ); 
68
        IPreferenceNode[] nodes = propertiesContributorsFor( element ); 
69
        
60
        
70
        String[] displayedIds = new String[nodes.length]; 
61
        String[] displayedIds = new String[nodes.length]; 
71
        for ( int i = 0; i < nodes.length; i++ ) 
62
        for ( int i = 0; i < nodes.length; i++ ) 
Lines 85-92 Link Here
85
     */
76
     */
86
    public static ProfilePropertyPage createPropertyPage( IConnectionProfile profile )
77
    public static ProfilePropertyPage createPropertyPage( IConnectionProfile profile )
87
    {
78
    {
88
        // TODO replace with call to method in org.eclipse.ui.dialogs.PreferencesUtil
79
        IPreferenceNode[] nodes = PreferencesUtil.propertiesContributorsFor( profile );
89
        IPreferenceNode[] nodes = propertiesContributorsFor( profile );
90
        
80
        
91
        for( int i=0; i < nodes.length; i++ )
81
        for( int i=0; i < nodes.length; i++ )
92
        {
82
        {
Lines 110-160 Link Here
110
100
111
        return null;
101
        return null;
112
    }
102
    }
113
114
    /*
115
     * TODO Below utility methods are a copy of new utility API methods added to 
116
     * org.eclipse.ui.dialogs.PreferencesUtil in 3.4 M6 (Bugzilla 208830 patch 89658).
117
     * Need to remove these methods when DTP no longer needs to provide 
118
     * backward compatibility to Eclipse platform version 3.3.
119
     */
120
121
    /**
122
     * Indicates whether the specified element has at least one property page
123
     * contributor.
124
     * 
125
     * @param element
126
     *            an adapter element of a property page
127
     * @return true for having at least one contributor; false otherwise
128
     * @since 3.4
129
     */
130
    public static boolean hasPropertiesContributors(Object element) {
131
        if (element == null || !(element instanceof IAdaptable))
132
            return false;
133
        Collection contributors = PropertyPageContributorManager.getManager()
134
                .getApplicableContributors(element);
135
        return contributors != null && contributors.size() > 0;
136
    }
137
138
    /**
139
     * Return all of the properties page contributors for an element.
140
     * @param element
141
     * @return {@link IPreferenceNode}[]
142
     * @since 3.4
143
     */
144
    public static IPreferenceNode[] propertiesContributorsFor(Object element) {
145
        PropertyPageManager pageManager = new PropertyPageManager();
146
            if (element == null) {
147
            return null;
148
        }
149
        // load pages for the selection
150
        // fill the manager with contributions from the matching contributors
151
        PropertyPageContributorManager.getManager().contribute(pageManager,
152
                element);
153
        // testing if there are pages in the manager
154
        List pages =  pageManager.getElements(PreferenceManager.PRE_ORDER);
155
        IPreferenceNode[] nodes = new IPreferenceNode[pages.size()];
156
        pages.toArray(nodes);
157
        return nodes;
158
    }
159
    
103
    
160
}
104
}
(-)META-INF/MANIFEST.MF (-2 / +2 lines)
Lines 9-17 Link Here
9
Bundle-RequiredExecutionEnvironment: J2SE-1.4
9
Bundle-RequiredExecutionEnvironment: J2SE-1.4
10
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
10
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
11
 org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
11
 org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
12
 org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
12
 org.eclipse.ui;bundle-version="[3.4.0,4.0.0)",
13
 org.eclipse.ui.views;bundle-version="[3.2.0,4.0.0)",
13
 org.eclipse.ui.views;bundle-version="[3.2.0,4.0.0)",
14
 org.eclipse.datatools.connectivity;bundle-version="[0.9.1,1.5.0)",
14
 org.eclipse.datatools.connectivity;bundle-version="[1.1.0,1.5.0)",
15
 org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)",
15
 org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)",
16
 org.eclipse.core.expressions;bundle-version="[3.2.0,4.0.0)",
16
 org.eclipse.core.expressions;bundle-version="[3.2.0,4.0.0)",
17
 com.ibm.icu;bundle-version="[3.4.0,4.0.0)",
17
 com.ibm.icu;bundle-version="[3.4.0,4.0.0)",

Return to bug 201125