0
|
1 |
/*
|
|
2 |
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
package com.nokia.s60tools.appdep.ui.wizards;
|
|
20 |
|
|
21 |
|
|
22 |
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
|
23 |
import org.eclipse.jface.viewers.Viewer;
|
|
24 |
|
|
25 |
import com.nokia.s60tools.appdep.util.AppDepConsole;
|
|
26 |
import com.nokia.s60tools.sdk.SdkEnvInfomationResolveFailureException;
|
|
27 |
import com.nokia.s60tools.sdk.SdkInformation;
|
|
28 |
import com.nokia.s60tools.sdk.SdkManager;
|
|
29 |
import com.nokia.s60tools.util.console.IConsolePrintUtility;
|
|
30 |
|
|
31 |
/**
|
|
32 |
* The content provider class is responsible for
|
|
33 |
* providing objects to the SDK Selection Wizard.
|
|
34 |
*/
|
|
35 |
class SelectSDKWizardPageContentProvider implements IStructuredContentProvider{
|
|
36 |
/**
|
|
37 |
* Invisible root object.
|
|
38 |
*/
|
|
39 |
private InvisibleRootNode invisibleRoot;
|
|
40 |
|
|
41 |
/**
|
|
42 |
* Empty object array returned whenever there is no content.
|
|
43 |
*/
|
|
44 |
static Object[] EMPTY_ARRAY = new Object[0];
|
|
45 |
|
|
46 |
/**
|
|
47 |
* Content provider's constructor
|
|
48 |
*/
|
|
49 |
public SelectSDKWizardPageContentProvider(){
|
|
50 |
}
|
|
51 |
|
|
52 |
/* (non-Javadoc)
|
|
53 |
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
|
54 |
*/
|
|
55 |
public void inputChanged(Viewer v, Object oldInput, Object newInput) {
|
|
56 |
}
|
|
57 |
|
|
58 |
/* (non-Javadoc)
|
|
59 |
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
|
|
60 |
*/
|
|
61 |
public void dispose() {
|
|
62 |
}
|
|
63 |
|
|
64 |
/* (non-Javadoc)
|
|
65 |
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
|
|
66 |
*/
|
|
67 |
public Object[] getElements(Object parent) {
|
|
68 |
if (parent.equals(this)) {
|
|
69 |
if (invisibleRoot==null){
|
|
70 |
invisibleRoot = new InvisibleRootNode();
|
|
71 |
SdkInformation[] sdkInfoColl = null;
|
|
72 |
try {
|
|
73 |
sdkInfoColl = SdkManager.getSdkInformation();
|
|
74 |
for (int i = 0; i < sdkInfoColl.length; i++) {
|
|
75 |
SdkInformation info = sdkInfoColl[i];
|
|
76 |
invisibleRoot.addSdkNode(new SdkTreeViewNode(info, invisibleRoot));
|
|
77 |
}
|
|
78 |
} catch (SdkEnvInfomationResolveFailureException e) {
|
|
79 |
e.printStackTrace();
|
|
80 |
AppDepConsole.getInstance().println(e.getMessage(),
|
|
81 |
IConsolePrintUtility.MSG_ERROR);
|
|
82 |
}
|
|
83 |
}
|
|
84 |
}
|
|
85 |
return invisibleRoot.getChildren();
|
|
86 |
}
|
|
87 |
|
|
88 |
/**
|
|
89 |
* Tries to find tree viewer node that matches
|
|
90 |
* with the given parameters.
|
|
91 |
* @param sdkIdString Id string of the SDK.
|
|
92 |
* @return Returns the matching object if it was found,
|
|
93 |
* otherwise return <code>null</code>.
|
|
94 |
*/
|
|
95 |
public Object find(String sdkIdString){
|
|
96 |
return invisibleRoot.find(sdkIdString);
|
|
97 |
}
|
|
98 |
|
|
99 |
}
|