# HG changeset patch # User noe\swadi # Date 1263011651 -19800 # Node ID a02c979e8dfd8feb8c09ce7571b81273a7c9a10b 1. Copyrights changed to EPL 2. Feature updates mentioned in release notes. diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.carbide.extensions.apiquery/.project --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.carbide.extensions.apiquery/.project Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,17 @@ + + + com.nokia.carbide.extensions.apiquery + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.carbide.extensions.apiquery/build.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.carbide.extensions.apiquery/build.properties Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,2 @@ +bin.includes = feature.xml,\ + license.txt diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.carbide.extensions.apiquery/feature.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.carbide.extensions.apiquery/feature.xml Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,67 @@ + + + + + API Query is tool to search for information about the APIs used in S60 projects. + + + + Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +All rights reserved. License:http://www.eclipse.org/legal/epl-v10.html. + + + + Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + All rights reserved. + + This component and the accompanying materials are made available + under the terms of "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.carbide.extensions.apiquery/license.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.carbide.extensions.apiquery/license.txt Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,8 @@ + + Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + All rights reserved. + + This component and the accompanying materials are made available + under the terms of "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/.project --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/.project Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,28 @@ + + + com.nokia.s60tools.apiquery.cache.help + + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + com.nokia.carbide.extension.pclint.pclintAuditor + + + + + + org.eclipse.pde.PluginNature + com.nokia.carbide.extension.pclint.pclintNature + + \ No newline at end of file diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/META-INF/MANIFEST.MF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/META-INF/MANIFEST.MF Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,7 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Carbice.c++ Extensions - API Query Metadata information from the SDK Help Plug-in +Bundle-SymbolicName: com.nokia.s60tools.apiquery.cache.help;singleton:=true +Bundle-Version: 1.2.6 +Bundle-Vendor: Nokia + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/book.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/book.css Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,191 @@ +/* + + Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + All rights reserved. + + This component and the accompanying materials are made available + under the terms of "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". +*/ + +/* Add whitespace around entire display to avoid crowding edges of view */ +/* 20070523-Removed top margin size to close gap between location breadcrumbs and page title */ +html { + margin: 0px 10px 10px 10px; + } + +/* Set default font to serif style, 12-pt and plain */ +body, p, table { + font-family: Georgia, "Times New Roman", Times, serif; + font-size: 12px; + font-weight: normal; +} + +/* Use sans-serif fonts for all title styles */ +h1, h2, h3, h4, h5, h6, strong, em { + font-family: Helvetica, sans-serif; + color: #000000; + } + +h1 { font-size:20px } +h2 { font-size:18px } +h3 { font-size:16px } +h4 { font-size:14px } +h5 { font-size:12px } +h6 { font-size:10px } + +/* For headlines at the top of a view, add space */ +/* 20070522-added gradiant to background to update visual style of docs */ +h1, h2, h3 { + background-image: url(html/images/green_fade_left_68_165_28.png); + background-repeat: no-repeat; + padding:10px 0px 10px 12px; + } + +li { + margin-bottom:8px; + margin-top:8px; + } + +/* Footer includes space and a gray line above the company logo */ +#footer { + padding-top:10px; + margin-top:20px; + border-top:1px solid #999; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; + color: #03C; + } + +.listing { + font-family: "Courier New", Courier, mono; + color: #009; + background-color: #EEE; + padding: 10px 0px; + margin: 10px 0px; + } + +.code, pre { + font-family: "Courier New", Courier, mono; + font-size: 11px; + color: #333; + } + +.step { + /* background-color: #EEE; */ + /* margin: 10px 0px; */ + color: #333; + border-bottom:2px solid #EEE; + } + +.substep { + background-color: #EEE; + } + + +/* Figure/Listing/Table titles are centered and gray */ +p.table { + color: #999; + font-weight: bold; + padding-top: 5px; + } + +table { + border: solid #999 1px; + table-layout: auto; + font-size: 12px; + } + +td, th { + border: solid #999 1px; + padding: 5px; + vertical-align:top; + } + +/* 20070522-replaced gray with green background to match gradiant color for title */ +th { + background-color:#ACD79B; + /* background-color:#999; + color:#FFF; */ + } + +div.ol.p { + margin-left: 3em; + } + +/* Make all ordered/unordered list items appear in bold gray */ +div ol > li, div ul > li { + font-weight:bold; + color: #333; + } + +div ol > p, div ul > p, div li > p { + font-weight:normal; + } + +/* Make all H4 and H5 items appear in bold gray against a light green background */ +div h5, div h4 { + padding:5px 0px 5px 12px; + background-color:#ECFBEA; + /* background-color: #EEE; */ + font-weight:bold; + color: #333; + } + + +/* Notes stand out using a light top & bottom borders with dark gray text */ +p.note { + /* color: #03C; */ + /* background-color: #FFFF99; */ + color: #333; + padding: 5px; + margin-left: 1em; + margin-right: 1em; + border-top: solid #BBB thin; + border-bottom: solid #BBB thin; + } + + +/* Figure/Listing/Table titles are centered and gray */ +p.figure { + color: #333; + text-align: center; + font-weight: bold; + } + +/* highly visible red background and white text for things that need fixing before release */ +/* SHOULD NOT BE PRESENT IN RELEASED PRODUCTS */ +.fix { + background-color: red; + font-weight: bold; + color: white; + } + +.question { + font-style:italic; + font-weight:bold; + color: #555; + } + +.titleSmall { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; + } + + +.plain { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 12px; + font-style: normal; + line-height: normal; + font-weight: normal; + font-variant: normal; + color: #000000; + text-decoration: none; + } + +a:link { color: #0033CC } +a:visited { color: #555555 } +a:hover { color: #0033CC } + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/build.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/build.properties Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,7 @@ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + html/,\ + book.css +bin.excludes = html/nokia.css diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/html/contexts.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/html/contexts.xml Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,12 @@ + + + + + + + Properties tab + + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/html/images/green_fade_left_68_165_28.png Binary file srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/html/images/green_fade_left_68_165_28.png has changed diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/html/index.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/html/index.xml Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/html/nokia.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/html/nokia.css Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,170 @@ +/* + Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + All rights reserved. + + This component and the accompanying materials are made available + under the terms of "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". +*/ + +/* Add whitespace around entire display to avoid crowding edges of view */ +html { + margin: 10px; + /* fixes gray backgrounds when displayed in external browsers */ + background-color:#FFFFFF; + } + +/* Set default font to serif style, 12-pt and plain */ +body { + font-family: Georgia, "Times New Roman", Times, serif; + font-size: 12px; + font-weight: plain; +} + +/* Use sans-serif fonts for all title styles and Nokia blue */ +h1, h2, h3, h4, h5, h6, strong, em { + font-family: Arial, Helvetica, sans-serif; + color: #333; + } + +strong{ + color: #333; + } + +/* For headlines at the top of a view, add space and a gray line underneath */ +h2, h3 { + padding:10px 0px; + border-bottom:1px solid #BBB; + } + +li { + margin-bottom:8px; + margin-top:8px; + } + + +/* Footer includes space and a gray line above the company logo */ +#footer { + padding-top:10px; + margin-top:20px; + border-top:1px solid #999; + font-family: Arial, Helvetica, sans-serif; + font-size: 11px; + color: #333; + } + +.listing { + font-family: "Courier New", Courier, mono; + color: #009; + background-color: #EEE; + padding: 10px 0px; + margin: 10px 0px; + } + +.code, pre { + font-family: "Courier New", Courier, mono; + font-size: 12px; + color: #333; + } + +.step { + /* background-color: #EEE; */ + /* margin: 10px 0px; */ + color: #333; + border-bottom:2px solid #EEE; + } + +.substep { + background-color: #EEE; + } + + +/* Figure/Listing/Table titles are centered and gray */ +p.table { + color: #999; + font-weight: bold; + padding-top: 5px; + } + +table { + border: 1px solid #999; + table-layout: auto; + } + +td, th { + border: 1px solid #999; + padding: 5px; + vertical-align:top; + } + +th { + background-color:#999; + color:#FFF; + } + +div.ol.p { + margin-left: 3em; + } + +/* Make all ordered/unordered list items appear in bold gray */ +div ol > li, div ul > li { + font-weight:bold; + color: #333; + } + +/* Make all H4 and H5 items appear in bold gray against a light gray background */ +div h5, div h4 { + padding: 5px; + background-color: #EEE; + font-weight:bold; + color: #333; + } + + +/* Notes stand out using a light top & bottom borders with dark gray text */ +p.note { + /* color: #03C; */ + /* background-color: #FFFF99; */ + color: #333; + padding: 5px; + margin-left: 1em; + margin-right: 1em; + border-top:1px solid #BBB; + border-bottom:1px solid #BBB; +} + + +/* Figure/Listing/Table titles are centered and gray */ +p.figure { + color: #333; + text-align: center; + font-weight: bold; +} + +/* red background and white text for things that need fixing before release */ +.fix { + background-color: red; + font-weight: bold; + color: white; + } + +.question { + font-style:italic; + font-weight:bold; + color: #333; + } + +.titleSmall { + font-family: Arial, Helvetica, sans-serif; + font-size: 10px; + } + +.copyrightStatement { + font-size: 11px; + color: #006699; /* Symbian blue */ + } + +div.Footer table, div.Footer td, div.Footer th { + border: 0px none #000; + } diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/html/propertiesTab.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/html/propertiesTab.htm Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,51 @@ + + + + +Configuring the API metadata file data source properties + + + + +

Configuring the API metadata file data source properties

+

Using the API metadata file data source from an SDK is a good option, for example, for cases when you have network restrictions for using the Web data source option. This data source only requires a suitable SDK to be present.

+

To configure the API metadata file data source, do the following:

+
    +
  1. On the Properties tab, select API Metadata files from the SDK from the Data Source drop-down list. +

  2. +
  3. +From the listbox, select an SDK from your local workstation.To aid selection ,cached/uncached information is displayed against each sdk. +

    With applicable SDKs, API Query starts seeking for the existing .metaxml files from the SDK.

    +

    If you have problems with the SDK, see the Tips and hints below for more information.

    + +
  4. +
+

Next, you can start an API query either from the Search tab or from the context menu of your project. For instructions, see the Tasks section in the Table of Contents in API Query Help.

+ +

Tips and hints for API metadata file data source

+ + + + + + + + + + + + + + + + + + + + +
SituationSolution

The selected SDK does not contain any API metadata .metaxml files.

The SDK cannot be used in API queries. Select another SDK and try again.

Some of the data sources cannot be loaded.

The SDK contains API metadata files that are not formally valid XML. These files are excluded from API queries.

(If possible, to fix the issue, notify the API's responsible person about the problem.)

The SDK contents have changed since it was first loaded.

You can refresh the local cache of the specified SDK by clicking Refresh cache.

Refreshing the SDK data is useful in cases when the metadata files have been updated or errors detected earlier have been corrected.

+ + + + \ No newline at end of file diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/html/screenshots/sdk_data_source_properties.png Binary file srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/html/screenshots/sdk_data_source_properties.png has changed diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/html/toc.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/html/toc.htm Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,18 @@ + + + + +API metadata file data source + + + + +

API metadata file data source

+

The API metadata file data source enables the query of API information from a local software development kit (SDK) installed on your workstation.

+

Queries can be made only in SDKs that contain API metadata (.metaxml) files. In addition, only files that are valid XML are included in queries.

+

The used SDK is specified on the Properties tab. For instructions, see Configuring the SDK metadata data source properties.

+ + + + \ No newline at end of file diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/html/toc.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/html/toc.xml Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + \ No newline at end of file diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/plugin.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache.help/plugin.xml Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/.classpath --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/.classpath Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,7 @@ + + + + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/.cvsignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/.cvsignore Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,1 @@ +bin diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/.project --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/.project Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,28 @@ + + + com.nokia.s60tools.apiquery.cache + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/.settings/org.eclipse.jdt.core.prefs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/.settings/org.eclipse.jdt.core.prefs Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,12 @@ +#Wed Feb 28 15:29:47 EET 2007 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/.settings/org.eclipse.jdt.ui.prefs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/.settings/org.eclipse.jdt.ui.prefs Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,3 @@ +#Wed Feb 28 15:29:47 EET 2007 +eclipse.preferences.version=1 +internal.default.compliance=default diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/META-INF/MANIFEST.MF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/META-INF/MANIFEST.MF Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,20 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Carbice.c++ Extensions - API Query Metadata information from the SDK Plug-in +Bundle-SymbolicName: com.nokia.s60tools.apiquery.cache; singleton:=true +Bundle-Version: 1.2.6 +Bundle-Activator: com.nokia.s60tools.apiquery.cache.plugin.CachePlugin +Bundle-Vendor: Nokia +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + com.nokia.s60tools.util;bundle-version="1.1.11", + com.nokia.s60tools.apiquery, + com.nokia.s60tools.sdk;bundle-version="1.1.6", + com.nokia.carbide.cpp.sdk.core, + org.eclipse.ui.workbench.texteditor, + org.eclipse.ui.ide +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Export-Package: com.nokia.s60tools.apiquery.cache.configuration, + com.nokia.s60tools.apiquery.cache.util, + com.nokia.s60tools.apiquery.cache.xml diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/about.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/about.html Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,21 @@ + + + +About + + + +

About This Content

+ +

Dec 2, 2009

+ +

Copyright

+ +

+ +Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). + +

+ + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/build.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/build.properties Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,8 @@ +javacSource=1.5 +javacTarget=1.5 +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + about.html diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/plugin.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/plugin.xml Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,12 @@ + + + + + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/CacheHelpContextIDs.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/CacheHelpContextIDs.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.cache; + + +/** + * IDs for context sensitive help. + * @see contexts.xml -file IDs links to + */ +public class CacheHelpContextIDs { + /** + * The plug-in ID. Copy from APIQueryHelpActivator.PLUGIN_ID + * to here to avoid runtime dependency to help project + */ + private static final String CACHE_HELP_PROJECT_PLUGIN_ID = "com.nokia.s60tools.apiquery.cache.help"; //$NON-NLS-1$ + + + /** + * ID for Excel Interface Sheets properties -tab. + */ + public static final String CACHE_HELP_PROPERTIES_TAB = + CACHE_HELP_PROJECT_PLUGIN_ID +".CACHE_HELP_PROPERTIES_TAB"; //$NON-NLS-1$ +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/common/Product.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/common/Product.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.cache.common; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + + +/** + * Class for getting properties from product.properties file, located in same package. + */ +public class Product { + private static final String BUNDLE_NAME = "com.nokia.s60tools.apiquery.cache.common.Product"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + private Product() { + } + + /** + * @param key to product.properties -file + * @return a String from product.properties -file + */ + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/common/Product.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/common/Product.properties Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,19 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# +ProductInfoRegistry.Product_Name=API Metadata files from the SDK +ProductInfoRegistry.Console_Window_Name=Console +ProductInfoRegistry.Images_Directory=icons diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/common/ProductInfoRegistry.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/common/ProductInfoRegistry.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.cache.common; + +/** + * This class stores product information such as product name, + * version, console view name etc. + * The idea is to have the product information defined + * in one place and used via single access point. + */ +public class ProductInfoRegistry { + + private static final String PRODUCT_NAME = Product.getString("ProductInfoRegistry.Product_Name"); //$NON-NLS-1$ + private static final String CONSOLE_WINDOW_NAME = PRODUCT_NAME + " " + Product.getString("ProductInfoRegistry.Console_Window_Name"); //$NON-NLS-1$ //$NON-NLS-2$ + private static final String IMAGES_DIRECTORY = Product.getString("ProductInfoRegistry.Images_Directory"); //$NON-NLS-1$ + + /** + * @return Returns the CONSOLE_WINDOW_NAME. + */ + public static String getConsoleWindowName() { + return CONSOLE_WINDOW_NAME; + } + /** + * @return Returns the PRODUCT_NAME. + */ + public static String getProductName() { + return PRODUCT_NAME; + } + + /** + * @return Returns the IMAGES_DIRECTORY. + */ + public static String getImagesDirectoryName() { + return IMAGES_DIRECTORY; + } + + + + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/configuration/CacheEntry.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/configuration/CacheEntry.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,216 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.cache.configuration; + + +import java.io.FileNotFoundException; +import java.io.IOException; + +import com.nokia.s60tools.apiquery.cache.resources.Messages; +import com.nokia.s60tools.apiquery.cache.xml.MetadataXMLToUIMappingRules; +import com.nokia.s60tools.apiquery.shared.datatypes.APIDetails; +import com.nokia.s60tools.apiquery.shared.datatypes.config.AbstractEntry; +import com.nokia.s60tools.apiquery.shared.exceptions.XMLNotValidException; +import com.nokia.s60tools.apiquery.shared.util.xml.XMLUtils; +import com.nokia.s60tools.sdk.SdkInformation; +import com.nokia.s60tools.util.resource.FileUtils; + +/** + * Stores information for a single API Metadata information from the SDK entry. + */ +public class CacheEntry extends AbstractEntry { + + // + // Column sorting indices for table column sorter + // + public static final int NAME_COLUMN_INDEX = 0; + public static final int FOLDER_COLUMN_INDEX = 1; + + /** + * file size + */ + private long size; + /** + * File name + */ + private String name; + + /** + * Date of file creation + */ + private long date = 0; + + /** + * SDK Id as given by {@link SdkInformation#getSdkId()} + */ + private String sdkid; + + private String apiName; + + + /** + * API Details (XML data file contents readed to memory) + */ + private APIDetails APIDetails = null; + + + /** + * Constructor. + * @param id Entry id that is unique per search method. + * @param name If Sheet entry name. + * @param size Folder path name. + * @param isSelected Is this server entry used for queries. + */ + public CacheEntry(String id, String name, String SDKID, boolean isSelected, long size, long date,String apiName){ + super(id, isSelected);//There are no not selected entries in Metadata data source + sdkid = SDKID; + this.date = date; + validateArguments(id, name); + this.name = name; + this.size = size; + this.apiName =apiName; + } + + + /** + * Validates that all the datafiles are valid + * i.e. currently checking that they all contain values. + * @param id file name with absolutely path + * @param name entry (file) name. + * @param size File size on disk. + * @throws IllegalArgumentException + */ + private void validateArguments(String id, String name) throws IllegalArgumentException{ + if( ( id == null || name == null ) + || + ( id.length() == 0 || name.length() == 0 )){ + throw new IllegalArgumentException(new String(Messages.getString("CacheEntry.Cannot_Contain_Empty_Field_ErrMsg"))); //$NON-NLS-1$ + } + } + + + + /** + * @return the folder in file system + */ + public long getSize() { + return size; + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.web.configuration.AbstractEntry#updateEntryTypeSpecificDataFields(com.nokia.s60tools.apiquery.web.configuration.AbstractEntry) + */ + public void updateEntryTypeSpecificDataFields(AbstractEntry entryWithUpdatedData) { + CacheEntry entry = (CacheEntry) entryWithUpdatedData; + this.size = entry.getSize(); + this.name = entry.getName(); + this.date = entry.getDate(); + this.sdkid = entry.getSDKID(); + this.isSelected = entry.isSelected; + } + + + /** + * Get ID for SDK where entry belongs to + * @return SDK Id as given by {@link SdkInformation#getSdkId()} + */ + public String getSDKID() { + return sdkid; + } + + /** + * return the file name + * @return + */ + public String getName() { + return name; + } + + /** + * return the file creation date + * @return date + */ + public long getDate() { + return date; + } + + /** + * Set API details + * @param APIDetails + */ + public void setAPIDetails(APIDetails APIDetails) { + this.APIDetails = APIDetails; + } + + /** + * get API details + * @return API Details + */ + public APIDetails getAPIDetails() { + //If details is null, it must not be loaded now, because of lot of time taken + //and UpdateSDKSelectionJob gets API Details when saving current situation to ram + //for user cancel situation data restore. + return APIDetails; + } + + /** + * Load file contents for this entry. + * + * if load() fails for some reason, this entry will be set as not selected. + * @see CacheEntry#setSelected(false) + * + * @throws FileNotFoundException + * @throws IOException + */ + public void load() throws XMLNotValidException{ + + try { + StringBuffer buf = FileUtils.loadDataFromFile(getId()); + + APIDetails details = XMLUtils.extractAPIDetailsData(buf.toString(), new MetadataXMLToUIMappingRules()); + + MetadataHeadersFinder headerFinder = new MetadataHeadersFinder(); + details.addOrUpdateField(MetadataXMLToUIMappingRules.HEADERS, headerFinder.getHeadersForEntry(this)); + setAPIDetails(details); + } catch (FileNotFoundException e) { + setSelected(false, true);//Because load was failed, this cannot be selected as data source, if is, search will fail + throw new XMLNotValidException(e.getMessage(), getId()); + } catch (IOException e) { + setSelected(false, true);//Because load was failed, this cannot be selected as data source, if is, search will fail + throw new XMLNotValidException(e.getMessage(), getId()); + }catch (Exception e) { + setSelected(false, true);//Because load was failed, this cannot be selected as data source, if is, search will fail + e.printStackTrace(); + throw new XMLNotValidException(e.getMessage(), getId()); + } + + } + + /** + * Release API details from memory by setting API Details to null. + */ + public void unload() { + setAPIDetails(null); + } + + public String getAPIName() + { + return apiName; + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/configuration/CacheEntryStorage.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/configuration/CacheEntryStorage.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,744 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.cache.configuration; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; +import java.util.Vector; + +import org.eclipse.core.runtime.IProgressMonitor; + +import com.nokia.s60tools.apiquery.cache.plugin.CachePlugin; +import com.nokia.s60tools.apiquery.cache.resources.Messages; +import com.nokia.s60tools.apiquery.shared.datatypes.APIDetailField; +import com.nokia.s60tools.apiquery.shared.datatypes.APIDetails; +import com.nokia.s60tools.apiquery.shared.datatypes.config.AbstractEntry; +import com.nokia.s60tools.apiquery.shared.datatypes.config.AbstractEntryStorage; +import com.nokia.s60tools.apiquery.shared.datatypes.config.DuplicateEntryException; +import com.nokia.s60tools.apiquery.shared.datatypes.config.EntryNotFoundException; +import com.nokia.s60tools.apiquery.shared.datatypes.config.IConfigurationChangedListener; +import com.nokia.s60tools.apiquery.shared.exceptions.XMLNotValidException; +import com.nokia.s60tools.apiquery.shared.job.JobCancelledByUserException; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.apiquery.shared.util.xml.XMLElementData; +import com.nokia.s60tools.apiquery.shared.util.xml.XMLUtils; +import com.nokia.s60tools.sdk.SdkInformation; +import com.nokia.s60tools.util.debug.DbgUtility; +import com.nokia.s60tools.util.resource.FileUtils; + +/** + * Singleton class that is created on plugin startup, and is kept active as long + * as plugin is active. + * + * The purpose of this class is to store If Sheet entries configured by user. + * + * The format of used XML: + * + * + * + * + */ +public class CacheEntryStorage extends AbstractEntryStorage { + + /** + * Singleton instance. + */ + static private CacheEntryStorage instance = null; + + /** + * Public Singleton instance accessor. + * + * @return Returns instance of this singleton class- + */ + public static CacheEntryStorage getInstance() { + if (instance == null) { + instance = new CacheEntryStorage(); + } + return instance; + } + + // + // Variables for creating XML file from server entry data. + // + private static final String XML_HEADER = "";//$NON-NLS-1$ + + private static final String XML_ROOT_START_ELEMENT = "";//$NON-NLS-1$ + + private static final String XML_ROOT_END_ELEMENT = "";//$NON-NLS-1$ + + private static final String XML_ATTRIBUTE_ASSIGNMENT_WITH_QUOTE_START = "=\"";//$NON-NLS-1$ + + private static final String CARRIAGE_RETURN_AND_NEWLINE = "\r\n";//$NON-NLS-1$ + + private static final String SINGLE_SPACE = " ";//$NON-NLS-1$ + + private static final String QUOTE_AND_SINGLE_SPACE = "\" ";//$NON-NLS-1$ + + private static final String ELEMENT_START_STR = "<";//$NON-NLS-1$ + + private static final String ELEMENT_END_STR = "/>"; //$NON-NLS-1$ + + // + // XML element and attribute names used for storing configuration + // + private static final String METADATA_ELEMENT = "metadata";//$NON-NLS-1$ + + private static final String ID_ATTRIBUTE = "id";//$NON-NLS-1$ + + private static final String SDK_ID_ATTRIBUTE = "sdkid";//$NON-NLS-1$ + + private static final String SIZE_ATTRIBUTE = "size";//$NON-NLS-1$ + + private static final String SELECTION_ATTRIBUTE = "selected";//$NON-NLS-1$ + + private static final String DATE_ATTRIBUTE = "last_modified";//$NON-NLS-1$ + + private static final String API_NAME = "api_name";//$NON-NLS-1$ + + private Vector loadErrors = null; + + private boolean isLoaded = false; + + /** + * Private default constructor. + */ + private CacheEntryStorage() { + super(); + DbgUtility.println(DbgUtility.PRIORITY_CLASS, + "-- <> --> " + getClass().getName()); //$NON-NLS-1$ + } + + /* + * (non-Javadoc) + * + * @see com.nokia.s60tools.apiquery.shared.datatypes.config.AbstractEntryStorage#save(java.lang.String) + */ + public void save(String destinationFileAbsolutePathName) throws IOException { + // System.out.println("save" + destinationFileAbsolutePathName); + + StringBuffer xmlDataBuf = new StringBuffer(); + + File f = new File(destinationFileAbsolutePathName); + // Deleting possibly old + if (f.exists()) { + if (!f.canWrite()) { + String cannotWriteToFileErrMsg = Messages + .getString("CacheEntry.Destination_File_Is_Write_Protected_ErrMsg") //$NON-NLS-1$ + + destinationFileAbsolutePathName; + APIQueryConsole.getInstance().println(cannotWriteToFileErrMsg, + APIQueryConsole.MSG_ERROR); + throw new RuntimeException(cannotWriteToFileErrMsg); + } + if (!f.delete()) { + String cannotWriteToFileErrMsg = Messages + .getString("CacheEntry.Destination_File_Is_In_Use_ErrMsg") //$NON-NLS-1$ + + destinationFileAbsolutePathName; + APIQueryConsole.getInstance().println(cannotWriteToFileErrMsg, + APIQueryConsole.MSG_ERROR); + throw new RuntimeException(cannotWriteToFileErrMsg); + } + } + + FileOutputStream fos = new FileOutputStream(f); + + BufferedOutputStream bos = new BufferedOutputStream(fos); + + xmlDataBuf.append(XML_HEADER); + xmlDataBuf.append(CARRIAGE_RETURN_AND_NEWLINE); + xmlDataBuf.append(XML_ROOT_START_ELEMENT); + xmlDataBuf.append(CARRIAGE_RETURN_AND_NEWLINE); + Collection entriesColl = getEntries(); + // Create ... XML -elements from entries + for (AbstractEntry entryBeforeCast : entriesColl) { + CacheEntry entry = (CacheEntry) entryBeforeCast; + xmlDataBuf.append(ELEMENT_START_STR + METADATA_ELEMENT + + SINGLE_SPACE); + xmlDataBuf.append(ID_ATTRIBUTE + + XML_ATTRIBUTE_ASSIGNMENT_WITH_QUOTE_START + entry.getId() + + QUOTE_AND_SINGLE_SPACE); + xmlDataBuf.append(SELECTION_ATTRIBUTE + + XML_ATTRIBUTE_ASSIGNMENT_WITH_QUOTE_START + + Boolean.toString(entry.isSelected()) + + QUOTE_AND_SINGLE_SPACE); + xmlDataBuf.append(SDK_ID_ATTRIBUTE + + XML_ATTRIBUTE_ASSIGNMENT_WITH_QUOTE_START + + entry.getSDKID() + QUOTE_AND_SINGLE_SPACE); + xmlDataBuf.append(SIZE_ATTRIBUTE + + XML_ATTRIBUTE_ASSIGNMENT_WITH_QUOTE_START + + entry.getSize() + QUOTE_AND_SINGLE_SPACE); + xmlDataBuf.append(DATE_ATTRIBUTE + + XML_ATTRIBUTE_ASSIGNMENT_WITH_QUOTE_START + + entry.getDate() + QUOTE_AND_SINGLE_SPACE); + xmlDataBuf.append(API_NAME + + XML_ATTRIBUTE_ASSIGNMENT_WITH_QUOTE_START + + entry.getAPIName() + QUOTE_AND_SINGLE_SPACE); + //System.out.println("apiname" +entry.getAPIName()); + xmlDataBuf.append(ELEMENT_END_STR); + xmlDataBuf.append(CARRIAGE_RETURN_AND_NEWLINE); + } + xmlDataBuf.append(XML_ROOT_END_ELEMENT); + xmlDataBuf.append(CARRIAGE_RETURN_AND_NEWLINE); + + // Writing data to file + byte[] writeData = xmlDataBuf.toString().getBytes(); + bos.write(writeData, 0, writeData.length); + bos.flush(); + bos.close(); + fos.close(); + + } + + /* + * (non-Javadoc) + * + * @see com.nokia.s60tools.apiquery.shared.datatypes.config.AbstractEntryStorage#load(java.lang.String) + */ + public void load(String storageFilePathName) throws IOException { + //System.out.println("storage file path" + storageFilePathName); + + // Setting elements to be parsed + Set elemNameSet = new LinkedHashSet(); + elemNameSet.add(METADATA_ELEMENT); // server element + // Setting attributes to be parsed for server element + Map attrNameSet = new LinkedHashMap(); + attrNameSet.put(ID_ATTRIBUTE, ID_ATTRIBUTE); + attrNameSet.put(SELECTION_ATTRIBUTE, SELECTION_ATTRIBUTE); + attrNameSet.put(SDK_ID_ATTRIBUTE, SDK_ID_ATTRIBUTE); + attrNameSet.put(SIZE_ATTRIBUTE, SIZE_ATTRIBUTE); + attrNameSet.put(DATE_ATTRIBUTE, DATE_ATTRIBUTE); + attrNameSet.put(API_NAME, API_NAME); + Map> attributeMap = new LinkedHashMap>(); + attributeMap.put(METADATA_ELEMENT, attrNameSet); + + try { + // Loading XML data into memory + StringBuffer xmlData = FileUtils + .loadDataFromFile(storageFilePathName); + // Parsing elements from the XML data and adding found server + // entries to storage + XMLElementData[] elementArr = XMLUtils.parseXML(xmlData.toString(), + elemNameSet, attributeMap); + ArrayList foundEntries = convertElementDataToEntryList(elementArr); + // Removing the old server entries and adding new ones + // When we are really sure that the whole load opearation was + // successful. + entriesMap.clear(); + for (AbstractEntry entry : foundEntries) { + // CacheEntry ent = (CacheEntry) entry; + + entriesMap.put(entry.getId(), entry); + } + + } catch (Exception e) { + e.printStackTrace(); + String msg = Messages + .getString("CacheEntry.LoadFailed_Part_1_ErrMsg") + e.getMessage() //$NON-NLS-1$ + + ". " + Messages.getString("CacheEntry.LoadFailed_Part_2_ErrMsg"); //$NON-NLS-1$ //$NON-NLS-2$ + APIQueryConsole.getInstance().println(msg, + APIQueryConsole.MSG_ERROR); + File f = new File(storageFilePathName); + if (f.exists()) { + f.delete(); + } + } + } + + /** + * Converts element data into server entry list. + * + * @param elementArr + * XML Element data to be converted. + * @return Server entry list. + */ + private ArrayList convertElementDataToEntryList( + XMLElementData[] elementArr) { + ArrayList foundEntries = new ArrayList(); + + // Temporary data used during attribute fetching + String id = null; + String sdkid = null; + boolean isSelected = false; + String apiName = null; + long size = -1; + long date = -1; + + for (int i = 0; i < elementArr.length; i++) { + XMLElementData data = elementArr[i]; + Map params = data.getAttributes(); + + try { + + id = params.get(ID_ATTRIBUTE); + isSelected = Boolean.parseBoolean(params + .get(SELECTION_ATTRIBUTE)); + sdkid = params.get(SDK_ID_ATTRIBUTE); + size = Long.parseLong(params.get(SIZE_ATTRIBUTE)); + date = Long.parseLong(params.get(DATE_ATTRIBUTE)); + apiName = params.get(API_NAME); + //System.out.println("api name" + apiName); + } catch (Exception e) { + throw new RuntimeException( + Messages + .getString("CacheEntry.Unexpected_Attribute_ErrMsg") + data.getElementName()); //$NON-NLS-1$ + } + + File file = new File(id); + if (file.exists()) { + String fileName = file.getName(); + // Adding an entry + foundEntries.add(new CacheEntry(id, fileName, sdkid, + isSelected, size, date, apiName)); + } + } + return foundEntries; + } + + /** + * Get currentry selected SDK ID + * + * @return SDK ID or null if not found. + */ + public String getCurrentlySelectedSDKID() { + for (AbstractEntry entry : getEntries()) { + CacheEntry cacheEntry = (CacheEntry) entry; + if (cacheEntry.getSDKID() != null && cacheEntry.isSelected()) { + return cacheEntry.getSDKID(); + } + } + return null; + } + + /** + * Updates an entry to the storage. Additional not recommended possibility + * to update entry without notifying listeners. It's not recommended to use + * this, but if used, make sure that listeners is notified afterwards by + * using + * {@link AbstractEntryStorage#notifyConfigurationChangeListeners(int)}. + * + * @param entryWithNewData + * Entry object containing new data. + * @throws EntryNotFoundException + * @param dontNotifyListeners + * if true listeners will not be notified. + */ + public void updateEntry(AbstractEntry entryWithNewData, + boolean dontNotifyListeners) throws EntryNotFoundException { + + if (dontNotifyListeners) { + AbstractEntry entryWithOldData = (AbstractEntry) entriesMap + .get(entryWithNewData.getId()); + if (entryWithOldData == null) { + String nonExistingEntryMsg = Messages + .getString("AbstractEntryStorage.NonExistingEntry_ErrMsg") + entryWithNewData.getId(); //$NON-NLS-1$ + throw new EntryNotFoundException(nonExistingEntryMsg); + } + // Updating data fields (which triggers notification to + // configuration change listeners) + entryWithOldData + .updateEntryTypeSpecificDataFields(entryWithNewData); + } else { + updateEntry(entryWithNewData); + } + this.isLoaded = false; + + } + + /* + * (non-Javadoc) + * + * @see com.nokia.s60tools.apiquery.shared.datatypes.config.AbstractEntryStorage#updateEntry(com.nokia.s60tools.apiquery.shared.datatypes.config.AbstractEntry) + */ + public void updateEntry(AbstractEntry entryWithNewData) + throws EntryNotFoundException { + super.updateEntry(entryWithNewData); + this.isLoaded = false; + + } + + /** + * Adds an entry to the storage. Additional not recommended possibility to + * add entry without notifying listeners. It's not recommended to use this, + * but if used, make sure that listeners is notified afterwards by using + * {@link AbstractEntryStorage#notifyConfigurationChangeListeners(int)}. + * + * @param entry + * Entry to be added. + * @param dontNotifyListeners + * if true listeners will not be notified. + * @throws DuplicateEntryException + */ + public void addEntry(AbstractEntry entry, boolean dontNotifyListeners) + throws DuplicateEntryException { + + if (!dontNotifyListeners) { + super.addEntry(entry); + } else { + if (entriesMap.get(entry.getId()) != null) { + String duplicateEntriesErrMsg = Messages + .getString("AbstractEntryStorage.Duplicate_ErrMsg"); //$NON-NLS-1$ + throw new DuplicateEntryException(duplicateEntriesErrMsg); + } + entriesMap.put(entry.getId(), entry); + } + this.isLoaded = false; + } + + /* + * (non-Javadoc) + * + * @see com.nokia.s60tools.apiquery.shared.datatypes.config.AbstractEntryStorage#addEntry(com.nokia.s60tools.apiquery.shared.datatypes.config.AbstractEntry) + */ + public void addEntry(AbstractEntry entry) throws DuplicateEntryException { + super.addEntry(entry); + this.isLoaded = false; + } + + /** + * Load all selected entrys to storage. Parsing XML:s for all items, by + * calling {@link CacheEntry#load()}. + * + * Also {@link CacheEntry#unload()} for entry if not selected. + * + * If want to know if there was some errors, ask it by + * {@link CacheEntryStorage#isLoadErros()}. If there was errors, ask them + * by {@link CacheEntryStorage#getLoadErrors()}. + * + * @param monitor + * to check for cancellations + * @param newSelectedSDKInfo + * SDK info to be selected + * @throws JobCancelledByUserException + * if canceled by user + * + */ + + public void selectSDKAndLoadAllSelectedDatasToMemory( + IProgressMonitor monitor, SdkInformation newSelectedSDKInfo) + throws JobCancelledByUserException { + selectSDKAndLoadAllSelectedDatasToMemory(monitor, newSelectedSDKInfo, + true); + } + + /** + * Load all selected entrys to storage. Parsing XML:s for all items, by + * calling {@link CacheEntry#load()}. + * + * Also {@link CacheEntry#unload()} for entry if not selected. + * + * If want to know if there was some errors, ask it by + * {@link CacheEntryStorage#isLoadErros()}. If there was errors, ask them + * by {@link CacheEntryStorage#getLoadErrors()}. + * + * @param monitor + * to check for cancellations + * @param newSelectedSDKInfo + * SDK info to be selected + * @param selectSDK + * if newSelectedSDKInfo is to be selected as new selected SDK + * @throws JobCancelledByUserException + * if canceled by user + * + */ + private void selectSDKAndLoadAllSelectedDatasToMemory( + IProgressMonitor monitor, SdkInformation newSelectedSDKInfo, + boolean selectSDK) throws JobCancelledByUserException { + + // set to data store that all are deselected + Collection entrys = getEntries(); + + // Store current situation for restoring it in cases of cancel + Set keys = entriesMap.keySet(); + Map storedEntriesMap = new LinkedHashMap( + entriesMap.size()); + for (String key : keys) { + CacheEntry ent = (CacheEntry) entriesMap.get(key); + APIDetails det = ent.getAPIDetails();// If details is null, it + // must not be loaded now, + // because of lot of time + // taken + CacheEntry ent_ = new CacheEntry(ent.getId(), ent.getName(), ent + .getSDKID(), ent.isSelected(), ent.getSize(), + ent.getDate(), ent.getAPIName()); + ent_.setAPIDetails(det); + storedEntriesMap.put(new String(key), ent_); + } + + try { + + // select new SDK + if (selectSDK) { + selectNewSDK(monitor, newSelectedSDKInfo, entrys); + } + + // For XML validity errors + loadErrors = null; + Vector entrysToBeUnloaded = new Vector(); + // Loading all selected entrys to to memory by using entry.load() + for (AbstractEntry entry : entrys) { + // If canceled, throwing exception and catch will handle data + // restore + if (monitor.isCanceled()) { + throw new JobCancelledByUserException( + Messages + .getString("CacheEntryStorage.JobCanceledByUserMsg")); + } + CacheEntry ce = (CacheEntry) entry; + if (ce.isSelected()) { + try { + ce.load(); + } catch (XMLNotValidException e) { + addLoadError(e); + } + } + // If entry is not selected, unloading it from memory. + else { + entrysToBeUnloaded.add(ce); + } + } + // If canceled during operation, we unload entrys just when all is + // loaded, unload does not really take any time. + // So for here cancel wont occur anymore + for (CacheEntry ce : entrysToBeUnloaded) { + ce.unload(); + } + + this.isLoaded = true; + + } catch (JobCancelledByUserException e) { + entriesMap = storedEntriesMap; + throw e; + } + } + + /** + * Sets selected sdk as true and un selects not selected SDK + * + * @param monitor + * @param newSelectedSDKInfo + * @param entrys + * @throws JobCancelledByUserException + */ + private void selectNewSDK(IProgressMonitor monitor, + SdkInformation newSelectedSDKInfo, Collection entrys) + throws JobCancelledByUserException { + for (AbstractEntry entry : entrys) { + if (monitor.isCanceled()) { + // If canceled, throwing exception and catch will handle data + // restore + throw new JobCancelledByUserException(Messages + .getString("CacheEntryStorage.JobCanceledByUserMsg")); + } + CacheEntry ce = (CacheEntry) entry; + if (ce.getSDKID().equalsIgnoreCase(newSelectedSDKInfo.getSdkId())) { + entry.setSelected(true, true); + } else { + ce.setSelected(false, true); + } + } + } + + /** + * Load all selected entrys to storage. Parsing XML:s for all items, by + * calling {@link CacheEntry#load()}. + * + * Also {@link CacheEntry#unload()} for entry if not selected. + * + * If want to know if there was some errors, ask it by + * {@link CacheEntryStorage#isLoadErros()}. If there was errors, ask them + * by {@link CacheEntryStorage#getLoadErrors()}. + * + * @param monitor + * to check for cancellations + * @throws JobCancelledByUserException + * if canceled by user + */ + public void loadAllSelectedDatasToMemory(IProgressMonitor monitor) + throws JobCancelledByUserException { + + selectSDKAndLoadAllSelectedDatasToMemory(monitor, null, false); + + } + + /** + * Check if there was load errors. + * + * @return true if there was load errors false + * otherwise. + */ + public boolean isLoadErros() { + return loadErrors != null; + } + + /** + * Get load errors + * + * @return load errors or null if there was no errors on + * CacheEntryStorage#loadAllSelectedDatasToMemory(). + */ + public Vector getLoadErrors() { + return loadErrors; + } + + /** + * Adds load error to errors + * + * @param e + */ + private void addLoadError(XMLNotValidException e) { + + if (loadErrors == null) { + loadErrors = new Vector(); + } + loadErrors.add(e); + + } + + /** + * Removes all selected entrys. + */ + public void removeSelectedEntrys(String currentlySelectedSDKID) { + + Collection entrys = getEntries(); + Vector ids = new Vector(); + for (AbstractEntry aEntry : entrys) { + CacheEntry entry = (CacheEntry) aEntry; + if (entry.isSelected() + || entry.getSDKID().equals(currentlySelectedSDKID)) { + ids.add(entry.getId()); + } + + } + for (String id : ids) { + entriesMap.remove(id); + } + + notifyConfigurationChangeListeners(IConfigurationChangedListener.ALL_SELECTED_ENTRYS_REMOVED); + } + + /** + * Unloads all entrys + */ + public void unload() { + Collection entrys = getEntries(); + // For XML validity errors + loadErrors = null;// Now there are no loads -> no load Errors eather + // Unload all items + for (AbstractEntry entry : entrys) { + CacheEntry ce = (CacheEntry) entry; + ce.unload(); + } + this.isLoaded = false; + } + + /** + * Check if source is loaded. + * + * @return true if is loaded, false otherwise + */ + public boolean isLoaded() { + return isLoaded; + } + + /** + * Return the path to xml file. + * @param sdkID : SDK name as given in metadata_cache_entries.xml file + * @param APIName : API Name + * @param headerFile : header file name + * @return + */ + + public String getID(String sdkID, String APIName, String headerFile) { + // System.out.println("SDK ID" +sdkID + "apiame " + APIName + " + // headerfile : " + headerFile); + try { + //CacheEntryStorage instance = getInstance(); + //instance.load(CachePlugin.getconfigFilePath()); + + Set elemNameSet = new LinkedHashSet(); + elemNameSet.add(METADATA_ELEMENT); // server element + // Setting attributes to be parsed for server element + Map attrNameSet = new LinkedHashMap(); + attrNameSet.put(ID_ATTRIBUTE, ID_ATTRIBUTE); + attrNameSet.put(SELECTION_ATTRIBUTE, SELECTION_ATTRIBUTE); + attrNameSet.put(SDK_ID_ATTRIBUTE, SDK_ID_ATTRIBUTE); + attrNameSet.put(SIZE_ATTRIBUTE, SIZE_ATTRIBUTE); + attrNameSet.put(DATE_ATTRIBUTE, DATE_ATTRIBUTE); + attrNameSet.put(API_NAME, API_NAME); + Map> attributeMap = new LinkedHashMap>(); + attributeMap.put(METADATA_ELEMENT, attrNameSet); + + // Loading XML data into memory + StringBuffer xmlData = FileUtils.loadDataFromFile(CachePlugin + .getconfigFilePath()); + // Parsing elements from the XML data and adding found server + // entries to storage + XMLElementData[] elementArr = XMLUtils.parseXML(xmlData.toString(), + elemNameSet, attributeMap); + for (int i = 0; i < elementArr.length; i++) { + XMLElementData data = elementArr[i]; + Map params = data.getAttributes(); + + if (params.get(API_NAME).equalsIgnoreCase(APIName) + && params.get(SDK_ID_ATTRIBUTE).equalsIgnoreCase(sdkID)) { + //System.out.println("found"); + // serach in the list of avaliable folders + String id = params.get(ID_ATTRIBUTE); + // c:\.....\xyz.xml + + String folder = id.substring(0, id.lastIndexOf("\\")) + + "\\inc"; + //System.out.println( "Folder" + folder); + + File directory = new File(folder); + + if (directory.isDirectory()) { // check to make sure it + // is a directory + String filenames[] = directory.list(); // make array of + // filenames. + + for (int j = 0; j < filenames.length; j++) { + if (filenames[j].equalsIgnoreCase(headerFile)) + return id; + } + + } // is directory + + } + } //forloop + } catch (Exception e) { + e.printStackTrace(); + } + + + + + return null; + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/configuration/MetadataHeadersFinder.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/configuration/MetadataHeadersFinder.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,122 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.cache.configuration; + +import java.io.File; +import java.io.FilenameFilter; + +import com.nokia.s60tools.apiquery.cache.resources.Messages; +import com.nokia.s60tools.apiquery.shared.datatypes.APIDetailField; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.util.console.IConsolePrintUtility; + +/** + * Helper class for seeking header files from where .metaxml file was found. + */ +public class MetadataHeadersFinder { + + private IConsolePrintUtility printUtility; + + /** + * Constructor with IConsolePrintUtility + * @param printUtility + */ + public MetadataHeadersFinder(IConsolePrintUtility printUtility){ + this.printUtility = printUtility; + + } + public MetadataHeadersFinder(){ + this.printUtility = APIQueryConsole.getInstance(); + } + + public static final String INC_FOLDER = "inc"; //$NON-NLS-1$ + public static final String HEADER_FILE_H_SUFFIX = ".h"; //$NON-NLS-1$ + public static final String HEADER_FILE_HPP_SUFFIX = ".hpp"; //$NON-NLS-1$ + public static final String HEADER_FILE_HRH_SUFFIX = ".hrh"; //$NON-NLS-1$ + public static final String HEADER_FILE_DISTRIBUTION_POLICY_PREFIX = "distribution.policy"; //$NON-NLS-1$ + + /** + * Get headers as comma separated String + * @param entry + * @return headers belongs to API + */ + public String getHeadersForEntry(CacheEntry entry){ + + try { + String metaXMLSourcePath = entry.getId(); + String metaPath = metaXMLSourcePath.substring(0, metaXMLSourcePath.lastIndexOf(File.separator)); + String incPath = metaPath + File.separatorChar + INC_FOLDER; + File incPathFile = new File(incPath); + //We did not found inc folder, just returning with no results + if(!incPathFile.exists() || !incPathFile.isDirectory()){ + //It's probably error if there is no ../inc folder at all, when metadata file is existing, but its no major error, just printing console message for that + printUtility.println(Messages.getString("MetadataHeadersFinder.IncFolderNotFound_WarnMsg_Part1") +incPath +Messages.getString("MetadataHeadersFinder.IncFolderNotFound_WarnMsg_Part2") +entry.getId() +Messages.getString("MetadataHeadersFinder.IncFolderNotFound_WarnMsg_Part3")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + return ""; //$NON-NLS-1$ + } + File [] headers = incPathFile.listFiles(new HeaderFilter()); + if(headers.length > 0){ + StringBuffer b = new StringBuffer(); + for (int i = 0; i < headers.length; i++) { + File header = headers[i]; + //Skipping folders, only files is added + if(header.isDirectory()){ + continue; + } + String headerName = header.getName(); + b.append(headerName); + b.append(APIDetailField.VALUE_FIELD_SEPARATOR); + } + //If there was no files, only folders, there is no ", ":s eather, then just returning empty string + int commaIndex = b.lastIndexOf(APIDetailField.VALUE_FIELD_SEPARATOR); + if(commaIndex == -1){ + return ""; + } + //Cut last ", " of, and then return header names. + return b.substring(0, commaIndex); + } + //Else it's not an error if there are none header files in folder, + //so no operations when there are no headers found. + } catch (Exception e) { + e.printStackTrace(); + printUtility.println(Messages.getString("MetadataHeadersFinder.HeadersSeekError_Msg") +e, IConsolePrintUtility.MSG_ERROR); //$NON-NLS-1$ + } + + return ""; //$NON-NLS-1$ + } + + /** + * Checks that file is header file. Every other files will be accepted, + * but {@link MetadataHeadersFinder#HEADER_FILE_DISTRIBUTION_POLICY_PREFIX} + * will be excluded. + */ + private class HeaderFilter implements FilenameFilter{ + + + public boolean accept(File f, String name) { + + String name_ = name.toLowerCase(); + if( name_.startsWith(HEADER_FILE_DISTRIBUTION_POLICY_PREFIX) ){ + return false; + }else{ + return true; + } + } + + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/core/job/JobMessageUtils.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/core/job/JobMessageUtils.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.cache.core.job; + +import java.util.Vector; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; + +import com.nokia.s60tools.apiquery.cache.configuration.CacheEntryStorage; +import com.nokia.s60tools.apiquery.cache.resources.Messages; +import com.nokia.s60tools.apiquery.shared.exceptions.XMLNotValidException; +import com.nokia.s60tools.apiquery.shared.ui.dialogs.APIQueryMessageBox; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; + +/** + * Class for show and print Messages + */ +public class JobMessageUtils { + + /** + * Show error dialog for load errors. Also prints message to console. + */ + public static void showLoadErrorDialog() { + + Runnable showMsg = new Runnable(){ + + public void run() { + String msg = getLoadErrorMessage(); + printErrorMessage(msg); + new APIQueryMessageBox(msg, SWT.OK| SWT.ICON_ERROR ).open(); + + } + + }; + Display.getDefault().asyncExec(showMsg); + + } + /** + * Get load errors as message + * @return error message + */ + private static String getLoadErrorMessage() { + CacheEntryStorage storage = CacheEntryStorage.getInstance(); + Vector errors = storage.getLoadErrors(); + StringBuffer msg = new StringBuffer(); + msg.append(Messages.getString("JobMessageUtils.DataSourceLoadErrorMsg_Part1")); //$NON-NLS-1$ + for (XMLNotValidException e : errors) { + msg.append(e.getFileName()); + msg.append(": "); //$NON-NLS-1$ + msg.append(e.getMessage()); + msg.append("\n"); //$NON-NLS-1$ + } + msg.append(Messages.getString("JobMessageUtils.DataSourceLoadErrorMsg_Part2")); //$NON-NLS-1$ + return msg.toString(); + } + + /** + * Print error message to console + */ + public static void printLoadErrorMessage(){ + printErrorMessage(getLoadErrorMessage()); + } + /** + * Print error message to console + */ + private static void printErrorMessage(String msg){ + APIQueryConsole.getInstance().println(msg,APIQueryConsole.MSG_ERROR); + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/core/job/SeekMetaXMLFilesJob.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/core/job/SeekMetaXMLFilesJob.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,359 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.cache.core.job; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Collection; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; + +import com.nokia.s60tools.apiquery.cache.configuration.CacheEntry; +import com.nokia.s60tools.apiquery.cache.configuration.CacheEntryStorage; +import com.nokia.s60tools.apiquery.cache.resources.Messages; +import com.nokia.s60tools.apiquery.shared.datatypes.config.DuplicateEntryException; +import com.nokia.s60tools.apiquery.shared.datatypes.config.EntryNotFoundException; +import com.nokia.s60tools.apiquery.shared.datatypes.config.IConfigurationChangedListener; +import com.nokia.s60tools.apiquery.shared.job.AbstractJob; +import com.nokia.s60tools.apiquery.shared.job.JobCancelledByUserException; +import com.nokia.s60tools.apiquery.shared.ui.dialogs.APIQueryMessageBox; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.apiquery.ui.views.main.MainView; +import com.nokia.s60tools.sdk.SdkInformation; +import com.nokia.s60tools.util.resource.FileFinder; +import com.nokia.s60tools.util.resource.FileUtils; +import com.nokia.s60tools.util.resource.IFileFinderObserver; + +/** + * Job for seeking .metaxml files from under SDK ({@link SdkInformation}) given. + */ +public class SeekMetaXMLFilesJob extends AbstractJob implements IFileFinderObserver { + + /** + * Metaxml file type + */ + private static final String METAXML_FILE_SUFFIX = ".metaxml"; //$NON-NLS-1$ + + /** + * s60 folder name in R&D SDK + */ + private static final String S60 = "s60"; //$NON-NLS-1$ + + /*** + * SF folder + * + */ + private static final String SF = "sf"; //$NON-NLS-1$ + + /** + * Information about selected SDK + */ + private final SdkInformation sdkInformation; + + /** + * Total steps as double, to be able to count percentages. + */ + double stepsAsDouble = 1; + + /** + * Folders where to seek .metaxml files under selected SDK + */ + private static final String [] FOLDERS_TO_SEEK_META_FILES = new String [] { + "osext", //$NON-NLS-1$ + "mw", //$NON-NLS-1$ + "app", + "os" }; //$NON-NLS-1$ + + + /** + * Create a Job to seek .metaxml files under selected SDK. + * @param name + * @param sdkInformation + */ + public SeekMetaXMLFilesJob(String name, SdkInformation sdkInformation) { + super(name); + this.sdkInformation = sdkInformation; + setUser(true); + } + + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) + */ + protected IStatus run(IProgressMonitor monitor) { + + + + setMonitor(monitor); + + reportStartTime(); + try { + MainView.enablePropTabcontents(false); + FileFinder finder = new FileFinder(APIQueryConsole.getInstance()); + + String epocRoot = sdkInformation.getEpocRootDir(); + + //System.out.println("epoc 32 " + epocRoot); + + String message = Messages.getString("SeekMetaXMLFilesJob.StartJobMsg_Part1") //$NON-NLS-1$ + +METAXML_FILE_SUFFIX +Messages.getString("SeekMetaXMLFilesJob.StartJobMsg_Part2") +sdkInformation.getSdkId() //$NON-NLS-1$ + +Messages.getString("SeekMetaXMLFilesJob.StartJobMsg_Part3") +epocRoot +"'."; //$NON-NLS-1$ //$NON-NLS-2$ + APIQueryConsole.getInstance().println(message); + + String [] folders = new String[FOLDERS_TO_SEEK_META_FILES.length]; + + boolean isS60 = true; + //try to check if s60 is present + File directoryOfPdfs = new File(epocRoot ); + + if(directoryOfPdfs.isDirectory()) { // check to make sure it is a directory + String filenames[] = directoryOfPdfs.list(); //make array of filenames. + for(int i =0 ;i files) { + + try { + + if(isCanceled() || exitValue == IStatus.CANCEL){ + interrupted(Messages.getString("SeekMetaXMLFilesJob.CancelledByUser")); //$NON-NLS-1$ + } + else if(exitValue == IStatus.OK){ + handleSeekCompleatedOK(files); + } + else{ + handleSeekCompleatedError(exitValue); + } + reportEndTime(); + } catch (Exception e) { + //Handle file not found e.g. errors. + e.printStackTrace(); + handleSeekCompleatedError(e); + } + finally{ + MainView.enablePropTabcontents(true); + + + } + } + + /** + * Handle Error situations after getting data + * @param e + */ + private void handleSeekCompleatedError(Exception e) { + String message = Messages.getString("SeekMetaXMLFilesJob.SeekCompleatedErrorMsg") +sdkInformation.getSdkId(); //$NON-NLS-1$ + APIQueryConsole.getInstance().println(message, APIQueryConsole.MSG_ERROR); + IStatus status = new Status( + Status.ERROR,Platform.PI_RUNTIME, + Status.ERROR,message, e); + + done(status); + } + + /** + * Handle error return values + * @param exitValue + */ + private void handleSeekCompleatedError(int exitValue) { + String message = Messages.getString("SeekMetaXMLFilesJob.SeekCompleatedErrorMsg") +sdkInformation.getSdkId() +Messages.getString("SeekMetaXMLFilesJob.SeekCompleatedExitValueErrorMsg") +exitValue; //$NON-NLS-1$ //$NON-NLS-2$ + APIQueryConsole.getInstance().println(message, APIQueryConsole.MSG_ERROR); + IStatus status = new Status( + Status.ERROR,Platform.PI_RUNTIME, + Status.ERROR,message, null); + + done(status); + } + + /** + * If status was OK, handling completed situation + * @param files + * @throws FileNotFoundException + * @throws IOException + */ + private void handleSeekCompleatedOK(Collection files) throws FileNotFoundException, IOException { + + //We are pretty much done, so marking that we are in 100% of progress, updating storage does not really take any time + progress(steps, Messages.getString("SeekMetaXMLFilesJob.UpdatingDB_ProgressMsg")); //$NON-NLS-1$ + + CacheEntryStorage storage = CacheEntryStorage.getInstance(); + + try { + + + + //set to data store that all are deselected + storage.deselectAll(true);//When SDK is changed, all entries is deselected + + for (File file : files) { + //Read the File , get the API Name + //System.out.println("file path" + file.getAbsolutePath()); + StringBuffer buf = FileUtils.loadDataFromFile(file.getAbsolutePath()); + int startIndex = buf.indexOf(""); + String apiName = buf.substring(startIndex+6, buf.indexOf("",startIndex )); + System.out.println("api name while seeking" + apiName); + + CacheEntry entry = new CacheEntry( + file.getAbsolutePath(), file.getName(), sdkInformation.getSdkId(), + true, file.length(), file.lastModified(),apiName.trim()); + try { + + if(isCanceled()){ + interrupted(Messages.getString("SeekMetaXMLFilesJob.CancelledByUser")); //$NON-NLS-1$ + return; + } + if(storage.contains(entry)){ + storage.updateEntry(entry, true); + }else{ + storage.addEntry(entry, true); + } + } catch (DuplicateEntryException e) { + // Should not be able to occur, because if(storage.contains(entry)) check before adding + e.printStackTrace(); + } + catch (EntryNotFoundException e) { + // Should not be able to occur, because if(storage.contains(entry)) check before update + e.printStackTrace(); + } + + } + + reportStartTime(); + storage.loadAllSelectedDatasToMemory(getMonitor());//There can be parsing errors, so listeners must be notified afterwards + + //Notifying listeners, only one notifying should be enaugh. + storage.notifyConfigurationChangeListeners(IConfigurationChangedListener.ALL_ENTRYS_UPDATED); + + //If there was some load errors. + if(storage.isLoadErros()){ + JobMessageUtils.showLoadErrorDialog(); + } + reportEndTime(); + + + if(files == null || files.size()==0){ + showNoMetadatasWarning(); + } + + done(Status.OK_STATUS); + + } catch (JobCancelledByUserException e) { + e.printStackTrace(); + //return original map + done(Status.CANCEL_STATUS); + } + } + + /** + * Show warning dialog when no metadata found from selected sdk + */ + private void showNoMetadatasWarning() { + Runnable showWarning = new Runnable(){ + + public void run() { + APIQueryMessageBox msg = new APIQueryMessageBox( + Messages.getString("SeekMetaXMLFilesJob.MetadataNotFoundWarningMsg_Part1") //$NON-NLS-1$ + +sdkInformation.getSdkId() + +Messages.getString("SeekMetaXMLFilesJob.MetadataNotFoundWarningMsg_Part2") , //$NON-NLS-1$ + SWT.OK| SWT.ICON_WARNING ); + msg.open(); + } + }; + Display.getDefault().asyncExec(showWarning); + } + + public void interrupted(String reasonMsg) { + done(Status.CANCEL_STATUS); + super.cancel(); + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.util.resource.IFileFinderObserver#isCancelled() + */ + public boolean isCanceled(){ + return getMonitor().isCanceled(); + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.util.resource.IFileFinderObserver#beginTask(java.lang.String, int) + */ + public void beginTask(String name, int steps) { + + //Its not allowed to dived with "0" + if(steps < 1){ + steps = 1; + } + this.steps = steps; + stepsAsDouble = new Double(steps).doubleValue(); + + getMonitor().beginTask(name, PROGRESS_COMPLETED_PERCENTAGE); + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.shared.job.AbstractJob#progress(int, java.lang.String) + */ + public void progress(int stepsCompleated, String prosessing) { + + try { + int persentage = (new Double( stepsCompleated / stepsAsDouble * 100)).intValue(); + + super.progress(persentage, prosessing); + } catch (JobCancelledByUserException e) { + e.printStackTrace(); + done(Status.CANCEL_STATUS); + } + } + + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/core/job/UpdateSDKSelectionJob.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/core/job/UpdateSDKSelectionJob.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,178 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.cache.core.job; + +import java.io.FileNotFoundException; +import java.io.IOException; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; + +import com.nokia.s60tools.apiquery.cache.configuration.CacheEntryStorage; +import com.nokia.s60tools.apiquery.cache.resources.Messages; +import com.nokia.s60tools.apiquery.cache.searchmethod.ui.LocalCacheUIComposite; +import com.nokia.s60tools.apiquery.shared.datatypes.config.IConfigurationChangedListener; +import com.nokia.s60tools.apiquery.shared.job.AbstractJob; +import com.nokia.s60tools.apiquery.shared.job.JobCancelledByUserException; +import com.nokia.s60tools.apiquery.ui.views.main.MainView; +import com.nokia.s60tools.sdk.SdkInformation; + +/** + * Job for loading already seeked SDK data to RAM + */ +public class UpdateSDKSelectionJob extends AbstractJob { + + private final SdkInformation info; + private boolean showErrorDialog = true; + + + /** + * Constructor + * @param name + * @param info + */ + public UpdateSDKSelectionJob(String name, SdkInformation info) { + super(name); + this.info = info; + setUser(true); + } + /** + * Constructor + * @param name + * @param info + * @param showErrorDialog set false if dont want to show error dialog when there was errors + * when updating cache. + */ + public UpdateSDKSelectionJob(String name, SdkInformation info, boolean showErrorDialog) { + super(name); + this.info = info; + setUser(true); + this.showErrorDialog = showErrorDialog; + } + + /** + * Check if job is allready running + * @return true if job with same name is allready running + */ + public boolean isAllreadyRunning(){ + + //Get and check all jobs + Job[] jobs = getJobManager().find(null); + for (int i = 0; i < jobs.length; i++) { + if(jobs[i] instanceof UpdateSDKSelectionJob){ + UpdateSDKSelectionJob job = (UpdateSDKSelectionJob)jobs[i]; + //If we found job what is not this job, and it runs for same SDK (same name) + //then there is job allready runnig to update this SDK + if(!job.equals(this) && job.getName().equals(this.getName())){ + return true; + } + } + } + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) + */ + protected IStatus run(IProgressMonitor monitor) { + + + MainView.enablePropTabcontents(false); + //Check if Update is already ongoing, returning warning if is. + if(isAllreadyRunning()){ + IStatus status = new Status( + Status.WARNING,Platform.PI_RUNTIME, + Status.WARNING, "Job: '" +getName() +"' already runnig.", null); + return status; + } + + setMonitor(monitor); + try{ + reportStartTime(); + updateDataStore(); + reportEndTime(); + return Status.OK_STATUS; + + }catch (JobCancelledByUserException e) { + return Status.CANCEL_STATUS; + }catch (Exception e) { + e.printStackTrace(); + return returnErrorStatus(e); + } + finally{ + + MainView.enablePropTabcontents(true); + + + } + + } + + /** + * Return error status + * @param e + * @return + */ + private IStatus returnErrorStatus(Exception e){ + String msg = Messages.getString("UpdateSDKSelectionJob.SDKReadError_Msg") +info.getSdkId() +"'"; //$NON-NLS-1$ //$NON-NLS-2$ + IStatus status = new Status( + Status.ERROR,Platform.PI_RUNTIME, + Status.ERROR,msg, e); + return status; + } + + /** + * When known that data source allready found (files seeked under SDK) just + * updating datastore selections so that selected SDK is selected. + * + * @throws IOException + * @throws FileNotFoundException + * @throws JobCancelledByUserException + */ + private void updateDataStore() throws FileNotFoundException, IOException, JobCancelledByUserException { + + getMonitor().beginTask( + Messages.getString("UpdateSDKSelectionJob.ReadingSDK_ProgressMsg") + info.getSdkId() + "'", //$NON-NLS-1$ //$NON-NLS-2$ + IProgressMonitor.UNKNOWN); + + CacheEntryStorage storage = CacheEntryStorage.getInstance(); + + getMonitor().subTask(Messages.getString("UpdateSDKSelectionJob.ParsingFiles_ProgressMsg")); //$NON-NLS-1$ + // Cancel situations will throw exception and restore old data + storage.selectSDKAndLoadAllSelectedDatasToMemory(getMonitor(), info); + + // Notifying listeners, only one notifying should be enough. + storage.notifyConfigurationChangeListeners(IConfigurationChangedListener.ALL_ENTRYS_UPDATED); + + // Show error message or write to log if there is some errors on load. + if (storage.isLoadErros()) { + if (showErrorDialog) { + JobMessageUtils.showLoadErrorDialog(); + } else { + JobMessageUtils.printLoadErrorMessage(); + } + } + + } + + + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/plugin/CachePlugin.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/plugin/CachePlugin.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,157 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.cache.plugin; + +import java.io.File; +import java.io.IOException; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.SWT; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +import com.nokia.s60tools.apiquery.cache.configuration.CacheEntryStorage; +import com.nokia.s60tools.apiquery.cache.resources.Messages; +import com.nokia.s60tools.apiquery.shared.datatypes.config.IConfigurationChangedListener; +import com.nokia.s60tools.apiquery.shared.ui.dialogs.APIQueryMessageBox; +import com.nokia.s60tools.util.debug.DbgUtility; + + +/** + * The extension plugin class for API Query Metadata information from the SDK Plug-in. + * This plug-in adds a data source to API Query Plug-in. + */ +public class CachePlugin extends AbstractUIPlugin implements IConfigurationChangedListener { + + //The shared instance. + private static CachePlugin plugin; + + /** + * Instantiating if sheet entry storage singleton class, and therefore + * making sure that it is available during the existence of the whole + * plug-in's lifetime. + */ + private static CacheEntryStorage entryStorage = CacheEntryStorage.getInstance(); + + /** + * Absolute path name for the plug-in specific configuration file. + */ + private static String configFilePath; + + /** + * Entrys file name + */ + private static final String CACHE_ENTRY_CONFIG_FILE_DEFAULT_NAME = "metadata_cache_entries.xml";//$NON-NLS-1$ + + + /** + * The constructor. + */ + public CachePlugin() { + plugin = this; + } + + /** + * This method is called upon plug-in activation + */ + public void start(BundleContext context) throws Exception { + super.start(context); + // Starting to listen for configuration change events + entryStorage.addConfigurationChangeListener(this); + // Loading server information stored by the user + String wsPath = getPluginWorkspacePath(); + configFilePath = wsPath + File.separator + CACHE_ENTRY_CONFIG_FILE_DEFAULT_NAME; + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "API Metadata information from the SDK method's config file: " + configFilePath);//$NON-NLS-1$ + File configFile = new File(configFilePath); + if(configFile.exists()){ + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "API Metadata information from the SDK method/loading configuration");//$NON-NLS-1$ + entryStorage.load(configFilePath); + } + else{ + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "API Metadata information from the SDK configuration file not found: " +configFilePath);//$NON-NLS-1$ + } + } + + /** + * This method is called when the plug-in is stopped + */ + public void stop(BundleContext context) throws Exception { + super.stop(context); + plugin = null; + } + + /** + * Returns the shared instance. + */ + public static CachePlugin getDefault() { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path. + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return AbstractUIPlugin.imageDescriptorFromPlugin("com.nokia.s60tools.apiquery.cache.plugin", path); //$NON-NLS-1$ + } + /** + * Returns runtime workspace directory path for the plugin, which + * can be used e.g. to store plugin/workspace-specific configuration data. + * + * @return Workspace directory path for the plugin. + */ + public static String getPluginWorkspacePath(){ + IPath runtimeWorkspacePath = plugin.getStateLocation(); + runtimeWorkspacePath.makeAbsolute(); + return runtimeWorkspacePath.toOSString(); + } + + /** + * Saves the configuration for an external file. + * @throws IOException + */ + private static void saveConfiguration() throws IOException{ + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "API Metadata information from the SDK/Storing configuration...");//$NON-NLS-1$ + entryStorage.save(configFilePath); + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "API Metadata information from the SDK/Configuration stored!");//$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.shared.datatypes.config.IConfigurationChangedListener#configurationChanged(int) + */ + public void configurationChanged(int eventType) { + try { + saveConfiguration(); + } catch (IOException e) { + String errMsg = Messages.getString("CacheEntry.Save_Configuration_ErrMsg") //$NON-NLS-1$ + + " ( " + e.getMessage() + ").";//$NON-NLS-1$ //$NON-NLS-2$ + APIQueryMessageBox msgBox = new APIQueryMessageBox(errMsg, SWT.OK | SWT.ICON_ERROR); + msgBox.open(); + } + } + +public static String getconfigFilePath() +{ + return configFilePath; +} + +} \ No newline at end of file diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/resources/Messages.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/resources/Messages.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.cache.resources; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * Class for getting externalized Strings. + */ +public class Messages { + private static final String BUNDLE_NAME = "com.nokia.s60tools.apiquery.cache.resources.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + private Messages() { + } + + /** + * Get String by key + * @param key + * @return a String + */ + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/resources/messages.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/resources/messages.properties Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,77 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# +AbstractEntryStorage.Duplicate_ErrMsg= +AbstractEntryStorage.NonExistingEntry_ErrMsg= +CacheEntry.Cannot_Contain_Empty_Field_ErrMsg=API Metadata information from the SDK entry cannot contain an empty field. +CacheEntry.Destination_File_Is_Write_Protected_ErrMsg=Error encountered, cannot save configuration. Destination file is write-protected: +CacheEntry.Destination_File_Is_In_Use_ErrMsg=Error encountered, failed to delete old configuration. Destination file is in use: +CacheEntry.LoadFailed_Part_1_ErrMsg=Failed to load API Metadata information from the SDK entry configuration: +CacheEntry.LoadFailed_Part_2_ErrMsg=Removing possibly corrupted configuration file. +CacheEntry.Unexpected_Attribute_ErrMsg=Unexpected attribute in configuration file element: +CacheEntry.Save_Configuration_ErrMsg=Failed to save configuration +JobMessageUtils.DataSourceLoadErrorMsg_Part1=There were errors loading the following data sources:\n\n +JobMessageUtils.DataSourceLoadErrorMsg_Part2=\nThese files were not selected as data sources. +LocalCacheSearchMethodExtension.No_Server_Entries_ErrMsg=No server entries configured or selected in Properties-tab. +LocalCacheSearchMethodExtension.UnexpectedEntryErrMsg=Unexpected null data source found, entry id was: +LocalCacheSearchMethodExtension.UnexpectedException_ErrMsg=Unexpected exception +LocalCacheSearchMethodExtension.UpdatingDataSourceMsg_Part1=Updating ' +LocalCacheSearchMethodExtension.UpdatingDataSourceMsg_Part2=' data sources. +LocalCacheSearchMethodExtension.IOException_ErrMsg=I/O Exception +LocalCacheSearchMethodExtension.InvalidXML_ErrMsg=Invalid XML +LocalCacheSearchMethodExtension.Failed_To_Start_Query_ErrMsg=Failed to start API query from context menu: +LocalCacheUIComposite.RefreshCache=Refresh cache +LocalCacheUIComposite.SDKDoesNotExistErrMsg_Part1=Selected SDK: ' +LocalCacheUIComposite.SDKDoesNotExistErrMsg_Part2=' does not exist, please check your devices configuration. +LocalCacheUIComposite.SDKSelectionErrMsg_Part1=Selected SDK: ' +LocalCacheUIComposite.SDKSelectionErrMsg_Part2=' cannot be refreshed, see log for more information. +LocalCacheUIComposite.SDKSelectionErrMsg_Part3=\ Error was: +LocalCacheUIComposite.SeekingMetadataFilesMsg=Seeking metadatas from SDK: +LocalCacheUIComposite.SelectSDK=Select SDK: +LocalCacheUIComposite.UpdatingDataSourceMsg_Part1=Updating ' +LocalCacheUIComposite.UpdatingDataSourceMsg_Part2=' data sources. +MetadataHeadersFinder.HeadersSeekError_Msg=Error seeking header files, Exception was: +MetadataHeadersFinder.IncFolderNotFound_WarnMsg_Part1=Inc folder: ' +MetadataHeadersFinder.IncFolderNotFound_WarnMsg_Part2=' for entry: ' +MetadataHeadersFinder.IncFolderNotFound_WarnMsg_Part3=' does not exist. Headers was not added for API. +MetadataXMLToUIMappingRules.Adaptiotion=Adaptation +MetadataXMLToUIMappingRules.Collection=Collection +MetadataXMLToUIMappingRules.Description=Description +MetadataXMLToUIMappingRules.ExtendedSDK=Extended SDK +MetadataXMLToUIMappingRules.Headers=Headers +MetadataXMLToUIMappingRules.HtmlDocProvided=Html doc provided +MetadataXMLToUIMappingRules.Libs=Libs +MetadataXMLToUIMappingRules.Name=Name +MetadataXMLToUIMappingRules.Release=Release +MetadataXMLToUIMappingRules.ReleaseCategory=Release category +MetadataXMLToUIMappingRules.Subsystem=Subsystem +MetadataXMLToUIMappingRules.Type=Type +MetadataXMLToUIMappingRules.ReleaseSince=Release since version +MetadataXMLToUIMappingRules.DeprecatedSince=Release deprecated since version +SeekMetaXMLFilesJob.CancelledByUser=Cancelled by User. +SeekMetaXMLFilesJob.MetadataNotFoundWarningMsg_Part1=No metadata found from SDK: ' +SeekMetaXMLFilesJob.MetadataNotFoundWarningMsg_Part2='. An SDK with no metadata cannot be used as a data source. Please select another SDK. +SeekMetaXMLFilesJob.SeekCompleatedErrorMsg=Error when seeking Metadata files from SDK: +SeekMetaXMLFilesJob.SeekCompleatedExitValueErrorMsg=. Exit value was: +SeekMetaXMLFilesJob.SeekErrorMsg=Error starting to seek Metadata files from SDK: +SeekMetaXMLFilesJob.StartJobMsg_Part1=Starting to seek ' +SeekMetaXMLFilesJob.StartJobMsg_Part2=' files from selected SDK: ' +SeekMetaXMLFilesJob.StartJobMsg_Part3=' under EPOCROOT: ' +SeekMetaXMLFilesJob.UpdatingDB_ProgressMsg=Updating metadata data source data base. +UpdateSDKSelectionJob.ParsingFiles_ProgressMsg=Parsing .metaxml files... +UpdateSDKSelectionJob.ReadingSDK_ProgressMsg=Reading .metaxml files from SDK: ' +UpdateSDKSelectionJob.SDKReadError_Msg=Error on reading .metaxml files from SDK: ' +CacheEntryStorage.JobCanceledByUserMsg=Job canceled by user \ No newline at end of file diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/searchmethod/LocalCacheSearchMethodExtension.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/searchmethod/LocalCacheSearchMethodExtension.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,859 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.cache.searchmethod; + +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Hashtable; +import java.util.Set; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExecutableExtension; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.IJobChangeListener; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.browser.IWebBrowser; + + + +import com.nokia.s60tools.apiquery.cache.configuration.CacheEntry; +import com.nokia.s60tools.apiquery.cache.configuration.CacheEntryStorage; +import com.nokia.s60tools.apiquery.cache.core.job.UpdateSDKSelectionJob; +import com.nokia.s60tools.apiquery.cache.resources.Messages; +import com.nokia.s60tools.apiquery.cache.searchmethod.ui.LocalCacheUIComposite; +import com.nokia.s60tools.apiquery.cache.util.SDKFinder; +import com.nokia.s60tools.apiquery.cache.util.SDKUtil; +import com.nokia.s60tools.apiquery.cache.xml.MetadataXMLToUIMappingRules; +import com.nokia.s60tools.apiquery.popup.actions.OpenFileAction; +import com.nokia.s60tools.apiquery.shared.datatypes.APIDetailField; +import com.nokia.s60tools.apiquery.shared.datatypes.APIDetails; +import com.nokia.s60tools.apiquery.shared.datatypes.APIQueryParameters; +import com.nokia.s60tools.apiquery.shared.datatypes.APIShortDescription; +import com.nokia.s60tools.apiquery.shared.datatypes.APIShortDescriptionSearchResults; +import com.nokia.s60tools.apiquery.shared.datatypes.config.AbstractEntry; +import com.nokia.s60tools.apiquery.shared.datatypes.config.AbstractEntryStorage; +import com.nokia.s60tools.apiquery.shared.exceptions.QueryOperationFailedException; +import com.nokia.s60tools.apiquery.shared.exceptions.XMLNotValidException; +import com.nokia.s60tools.apiquery.shared.searchmethod.AbstractSearchMethodExtension; +import com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension; +import com.nokia.s60tools.apiquery.shared.searchmethod.SearchMethodExtensionInfo; +import com.nokia.s60tools.apiquery.shared.searchmethod.ui.AbstractUiFractionComposite; +import com.nokia.s60tools.apiquery.shared.services.QueryServices; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.apiquery.shared.util.xml.XMLUtils; +import com.nokia.s60tools.sdk.SdkInformation; +import com.nokia.s60tools.util.debug.DbgUtility; + +/** + * Search Method extension allowing to create local caches from the web server + * entries, and used the cached information instead of the online information. + */ +public class LocalCacheSearchMethodExtension implements ISearchMethodExtension, IExecutableExtension, IJobChangeListener +{ + + /** + * This class is created by using createExecutableExtension + * method from IConfigurationElement class, and therefore the + * constructor cannot have any parameters. + * + * @see org.eclipse.core.runtime.IConfigurationElement#createExecutableExtension + */ + public LocalCacheSearchMethodExtension(){ + extensionInfo = new SearchMethodExtensionInfo(); + } + + private SearchMethodExtensionInfo extensionInfo; + private APIQueryParameters apiQueryParameters = null; + + + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, + * java.lang.String, java.lang.Object) + */ + public void setInitializationData(IConfigurationElement configElem, String classPropertyName, Object data) throws CoreException { + extensionInfo.setId(configElem.getAttribute(AbstractSearchMethodExtension.ID_ATTRIBUTE)); + extensionInfo.setDescription(configElem.getAttribute(AbstractSearchMethodExtension.DESCRIPTION_ATTRIBUTE)); + extensionInfo.setDefault(Boolean.parseBoolean(configElem.getAttribute(AbstractSearchMethodExtension.IS_DEFAULT_ATTRIBUTE))); + } + + /* + * (non-Javadoc) + * + * @see com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension#getExtensionInfo() + */ + public SearchMethodExtensionInfo getExtensionInfo() { + return extensionInfo; + } + + /* + * (non-Javadoc) + * + * @see com.nokia.s60tools.apiquery.searchmethodregistry.ISearchMethodExtension#notifyExtensionShutdown() + */ + public void notifyExtensionShutdown() { + // Currently nothing to do + } + + /* + * (non-Javadoc) + * + * @see com.nokia.s60tools.apiquery.searchmethodregistry.ISearchMethodExtension#createExtensionConfigurationUi(org.eclipse.swt.widgets.Composite) + */ + public AbstractUiFractionComposite createExtensionConfigurationUi(Composite parent) { + return new LocalCacheUIComposite(parent); + } + + /* + * (non-Javadoc) + * + * @see com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension#isSupportedQueryType(int) + */ + public boolean isSupportedQueryType(int queryType) { + // By default the query type is not supported. + boolean isSupported = false; + + switch (queryType) { + + // Flow through (supported types) + case APIQueryParameters.QUERY_BY_API_NAME: + case APIQueryParameters.QUERY_BY_SUBSYSTEM_NAME: + case APIQueryParameters.QUERY_BY_LIB_NAME: + case APIQueryParameters.QUERY_BY_HEADER_NAME: + isSupported = true; + break; + + default: + break; + } + + return isSupported; + } + + /* + * (non-Javadoc) + * + * @see com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension#getAPIDetails(com.nokia.s60tools.apiquery.shared.datatypes.APIShortDescription) + */ + public APIDetails getAPIDetails(APIShortDescription summary) throws QueryOperationFailedException { + + CacheEntryStorage storage = CacheEntryStorage.getInstance(); + if(!storage.isLoaded()){ + startUpdateJobAndWaitUntilFinished(storage); + } + + APIDetails details = null; + + CacheEntry entry = (CacheEntry) storage.getByEntryId(summary.getSource()); + details = entry.getAPIDetails(); + return details; + } + + + + /* + * (non-Javadoc) + * + * @see com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension#getEntryStorageInstance() + */ + public AbstractEntryStorage getEntryStorageInstance() { + return CacheEntryStorage.getInstance(); + } + + + + /** + * Handles (run) query for one entry + * + * @param parameters + * @param runSynchronous + * @return APIs matching search criteria + * @throws QueryOperationFailedException + */ + private Collection handleSingleEntryQuery(APIQueryParameters parameters, boolean runSynchronous) throws QueryOperationFailedException { + + ArrayList summary = null; + // Create a job to convert needed Excel If sheets to XML format + try { + summary = getSummarys(parameters, runSynchronous); + } catch (Exception e1) { + examineAndHandleQueryFailureException(e1); + } + + return summary; + + } + + + /* + * (non-Javadoc) + * + * @see com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension#runAPIQuery(com.nokia.s60tools.apiquery.shared.datatypes.APIQueryParameters) + */ + public APIShortDescriptionSearchResults runAPIQuery(APIQueryParameters parameters) { + + this.apiQueryParameters = parameters; + // Owerwriting query for if sheets, because of usually there is multiple + // (>100) data sources + APIShortDescriptionSearchResults results = new APIShortDescriptionSearchResults(); + + try { + // Making query for each configured and selected server entry. + AbstractEntry[] selEntryArr = getEntryStorageInstance().getSelectedEntries(); + + // Were any entries configured or selected? + if(selEntryArr.length == 0){ + throw new QueryOperationFailedException(Messages.getString("LocalCacheSearchMethodExtension.No_Server_Entries_ErrMsg")); //$NON-NLS-1$ + } + + boolean runSynchronous = !parameters.isQueryFromUI();// If query + // comes + // from UI, + // running + // async, if + // not, + // running + // sync + + // If there was semi-comma separated search items or not + if (parameters.getSearchString().contains( + APIQueryParameters.SEARCH_ITEM_SEPARATOR_CHAR)) { + results.addSearchResults(handleMultiEntryQuery(parameters, runSynchronous)); + } else { + results.addSearchResults(handleSingleEntryQuery(parameters, runSynchronous)); + } + }catch(QueryOperationFailedException e){ + results.addSearchError(e); + } + catch (Exception e) { + e.printStackTrace(); + results.addSearchError( new QueryOperationFailedException(e.getMessage())); + } + + return results; + } + + /** + * Get APIShortDescriptions from XML Excel If Sheet XML files. + * + * @return + * @throws QueryOperationFailedException + */ + private ArrayList getSummarys( APIQueryParameters parameters, boolean runSynchronous) throws QueryOperationFailedException { + ArrayList summary = new ArrayList(); + String curId = "";//$NON-NLS-1$ + try { + CacheEntryStorage storage = CacheEntryStorage.getInstance(); + Collection selectedAPIs = storage.getSelectedEntriesCollection(); + + // if storage is not loaded, e.g. this is first time of searching + // after Carbide is started up, must load data first + if(!storage.isLoaded() && !runSynchronous){ + startUpdateJobAndRunQueryWhenFinished(storage); + } + else{ + if(!storage.isLoaded()){ + startUpdateJobAndWaitUntilFinished(storage); + } + + String [] searchStrings = new String []{parameters.getSearchString()}; + + + // Try to found search string from selected search method + // (selected field from XML data) + for (AbstractEntry abstractEntry : selectedAPIs) { + + CacheEntry entry = (CacheEntry)abstractEntry; + + APIDetails det = entry.getAPIDetails(); + if(det == null){ + APIQueryConsole.getInstance().println(Messages.getString("LocalCacheSearchMethodExtension.UnexpectedEntryErrMsg") +entry.getId()); //$NON-NLS-1$ + continue;// Should not be able to occur, because load + // deselects source if load fails + } + curId = entry.getId(); + String curSourceDesc = entry.getName() ; + // Select Field from APIDetail, by selected search type, to + // found if that field contais the search string + APIDetailField fieldToSearchFor = getSelectedSearchField(det, parameters.getQueryType()); + String fieldValueToSearch = fieldToSearchFor.getValue(); + String apiName = det.getDetail(MetadataXMLToUIMappingRules.NAME).getValue(); + + DbgUtility.println(DbgUtility.PRIORITY_LOOP, "From API: " +//$NON-NLS-1$ + apiName + +", file: " + curId //$NON-NLS-1$ + +", querytype: " +parameters.getQueryType()//$NON-NLS-1$ + + ", foundig values to search for: " +fieldValueToSearch);//$NON-NLS-1$ + + // Looking for all search strings if there was semi-comma + // separated strings to search for + for (int i = 0; i < searchStrings.length; i++) { + boolean matchs; + if(apiQueryParameters.isExactMatchInUse()){ + // If exact match is in use, using equals as match + matchs = fieldValueToSearch.equalsIgnoreCase(searchStrings[i]); + } + else{ + // If exact match is not in use, and if result + // contains search string (case insensitive) + matchs = fieldValueToSearch.toLowerCase().contains(searchStrings[i].toLowerCase()); + } + // If result matches to search string, creating new API + // Summary object and add it to result + + if(matchs){ + APIShortDescription sum = new APIShortDescription( + apiName + ,curId, + curSourceDesc); + // If API Details should be added to description + // then adding it + if(parameters.isDetailsMentToAddToDescriptions()){ + sum.setAPIDetails(det); + } + summary.add(sum); + } + } + } + } + + } catch (Exception e) { + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "Error when handling file: " + curId);//$NON-NLS-1$ + e.printStackTrace(); + examineAndHandleQueryFailureException(e); + } + return summary; + } + + /** + * Update (load) data sources if not loaded yet, after done, launch real + * query + * + * @param storage + * @throws QueryOperationFailedException + */ + private void startUpdateJobAndRunQueryWhenFinished(CacheEntryStorage storage) + throws QueryOperationFailedException { + + try { + + SdkInformation info = SDKFinder.getSDKInformation(storage.getCurrentlySelectedSDKID()); + UpdateSDKSelectionJob job = new UpdateSDKSelectionJob(Messages.getString("LocalCacheSearchMethodExtension.UpdatingDataSourceMsg_Part1") +info.getSdkId() +Messages.getString("LocalCacheSearchMethodExtension.UpdatingDataSourceMsg_Part2"), info, false); //$NON-NLS-1$ //$NON-NLS-2$ + if(job.isAllreadyRunning()){ + return; + } + job.setPriority(Job.DECORATE); + job.addJobChangeListener(this); + job.schedule(); + + } catch (Exception e) { + e.printStackTrace(); + examineAndHandleQueryFailureException(e); + } + } + + /** + * Update (load) data sources if not loaded yet, after done, launch real + * query + * + * @param storage + * @throws QueryOperationFailedException + */ + private void startUpdateJobAndWaitUntilFinished(CacheEntryStorage storage) + throws QueryOperationFailedException { + + try { + + SdkInformation info = SDKFinder.getSDKInformation(storage.getCurrentlySelectedSDKID()); + UpdateSDKSelectionJob job = new UpdateSDKSelectionJob(Messages.getString("LocalCacheSearchMethodExtension.UpdatingDataSourceMsg_Part1") +info.getSdkId() +Messages.getString("LocalCacheSearchMethodExtension.UpdatingDataSourceMsg_Part2"), info, false); //$NON-NLS-1$ //$NON-NLS-2$ + if(job.isAllreadyRunning()){ + return; + } + job.setPriority(Job.DECORATE); + job.schedule(); + job.join(); + + } catch (Exception e) { + e.printStackTrace(); + examineAndHandleQueryFailureException(e); + } + } + + + /** + * get search field by query type + * + * @param det + * @param queryType + * @return + */ + private APIDetailField getSelectedSearchField(APIDetails det, int queryType) { + + APIDetailField field; + switch (queryType) { + case APIQueryParameters.QUERY_BY_API_NAME: + field = det.getDetail(MetadataXMLToUIMappingRules.NAME); + break; + case APIQueryParameters.QUERY_BY_SUBSYSTEM_NAME: + field = det.getDetail(MetadataXMLToUIMappingRules.SUBSYSTEM); + break; + case APIQueryParameters.QUERY_BY_LIB_NAME: + field = det.getDetail(MetadataXMLToUIMappingRules.LIBS); + break; + case APIQueryParameters.QUERY_BY_HEADER_NAME: + field = det.getDetail(MetadataXMLToUIMappingRules.HEADERS); + break; + default: + field = det.getDetail(MetadataXMLToUIMappingRules.NAME); + break; + } + return field; + } + + + /** + * Handles (run) query for several search strings + * + * @param parameters + * @param runSynchronous + * @return APIs matching search criteria + * @throws QueryOperationFailedException + */ + private Collection handleMultiEntryQuery(APIQueryParameters parameters, boolean runSynchronous) throws QueryOperationFailedException { + + // Using table to make sure that same API:s does not exist more than + // once + Hashtable summary = new Hashtable(); + String [] searchStrings = parameters.getSearchString().split(APIQueryParameters.SEARCH_ITEM_SEPARATOR_CHAR); + + APIQueryParameters param ; + Collection temp; + // Adding all APIDetails to collection one by one + for (int i = 0; i < searchStrings.length; i++) { + param = new APIQueryParameters(parameters.getQueryType(), searchStrings[i]); + + temp = handleSingleEntryQuery(param, runSynchronous); + for (APIShortDescription api : temp) { + summary.put(api.getName(), api);// One API can contain in + // results only once. HashTable + // does not allow multiple + // occurances as keys. + } + + } + return summary.values(); + } + + /* + * (non-Javadoc) + * + * @see com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension#getAPIDetails(java.util.Collection) + */ + public Hashtable getAPIDetails(Collection apis) throws QueryOperationFailedException { + + CacheEntryStorage storage = CacheEntryStorage.getInstance(); + if(!storage.isLoaded()){ + startUpdateJobAndWaitUntilFinished(storage); + } + + Hashtable apiDetails = new Hashtable(apis.size()); + for (APIShortDescription summary : apis) { + apiDetails.put(summary.getName(), getAPIDetails(summary)); + } + return apiDetails; + } + + /** + * Examines the type of throwable parameter, and adds appropriate error + * message or default message, and forwards the information for further + * processing. + * + * @param throwable + * Throwable to be examined. + * @throws QueryOperationFailedException + */ + private void examineAndHandleQueryFailureException(Throwable throwable) throws QueryOperationFailedException{ + + String errMsg = Messages.getString("LocalCacheSearchMethodExtension.UnexpectedException_ErrMsg"); //$NON-NLS-1$ + + if(throwable instanceof IOException) { + errMsg = Messages.getString("LocalCacheSearchMethodExtension.IOException_ErrMsg"); //$NON-NLS-1$ + } + else if(throwable instanceof XMLNotValidException) { + errMsg = Messages.getString("LocalCacheSearchMethodExtension.InvalidXML_ErrMsg"); //$NON-NLS-1$ + } + + queryFailed(errMsg, throwable.getMessage()); + } + /** + * Throws an exception for user with the given message. + * + * @param errorMsg + * Main error message for the user. + * @param detailedMsg + * More detailed message shown in parenthesis. + * @throws QueryOperationFailedException + */ + private void queryFailed(String errorMsg, String detailedMsg) throws QueryOperationFailedException { + APIQueryConsole.getInstance().println(errorMsg, APIQueryConsole.MSG_ERROR); + String combinedMsg = errorMsg + " (" + detailedMsg + ")."; //$NON-NLS-1$ //$NON-NLS-2$ + throw new QueryOperationFailedException(combinedMsg); + } + + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#done(org.eclipse.core.runtime.jobs.IJobChangeEvent) + * When data sources (metadata) is loaded, running real query + * @see com.nokia.s60tools.apiquery.ui.views.main.MainView#runAPIQueryFromExternalClass(int, + * java.lang.String) + */ + public void done(IJobChangeEvent event) { + + Job job = event.getJob(); + UpdateSDKSelectionJob ifsJob = (UpdateSDKSelectionJob)job; + ifsJob.reportEndTime(); + IStatus status = ifsJob.getResult(); + + // Chekc that job status was ok before launching query + if( status != null && status.getSeverity() == IStatus.OK) { + + // Launching the the real query when XML:s was generated + Runnable runQueryRunnable = new Runnable(){ + public void run(){ + try { + QueryServices.runAPIQuery(apiQueryParameters.getQueryType(), + apiQueryParameters.getSearchString()); + } catch (QueryOperationFailedException e) { + APIQueryConsole.getInstance().println(Messages.getString("LocalCacheSearchMethodExtension.Failed_To_Start_Query_ErrMsg") //$NON-NLS-1$ + +e.getMessage(), APIQueryConsole.MSG_ERROR); + e.printStackTrace(); + } + } + }; + + // Showing a visible message has to be done in its own thread + // in order not to cause invalid thread access + Display.getDefault().asyncExec(runQueryRunnable); + } + + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#aboutToRun(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void aboutToRun(IJobChangeEvent event) { + // Not needed + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#awake(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void awake(IJobChangeEvent event) { + // Not needed + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#running(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void running(IJobChangeEvent event) { + // Not needed + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#scheduled(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void scheduled(IJobChangeEvent event) { + // Not needed + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#sleeping(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void sleeping(IJobChangeEvent event) { + // Not needed + } + + /* + * (non-Javadoc) + * + * @see com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension#getAPIDetailsToReport() + */ + public String[] getAPIDetailsToReport(Set usedAPIs, Hashtable projectUsingAPIDetails) { + + boolean containsCollection = false; + boolean containsSubsystem = false; + for (String api : usedAPIs) { + APIDetails det = projectUsingAPIDetails.get(api); + if(det == null || det.getKeys() == null){ + continue; + } + if(det.getKeys().contains(MetadataXMLToUIMappingRules.COLLECTION)){ + containsCollection = true; + } + if(det.getKeys().contains(MetadataXMLToUIMappingRules.SUBSYSTEM)){ + containsSubsystem = true; + } + // If we found occurrence of both subsystems version (sybsystem in + // data version 1.0 collection in data version 2.0) + // we can continue because then both headers will occur in report + // anyway + if(containsCollection && containsSubsystem){ + break; + } + } + + String [] apiDetailsToReport; + + // If both subsystem versions is found + if(containsCollection && containsSubsystem){ + apiDetailsToReport= new String []{ + MetadataXMLToUIMappingRules.COLLECTION, + MetadataXMLToUIMappingRules.SUBSYSTEM, + MetadataXMLToUIMappingRules.RELEASE_CATEGORY, + MetadataXMLToUIMappingRules.RELEASE_SINCE_VERSION, + MetadataXMLToUIMappingRules.RELEASE_DEPRECATED_SINCE_VERSION, + MetadataXMLToUIMappingRules.LIBS + }; + } + // if we found only collections, not subsystems + else if(containsCollection && !containsSubsystem){ + apiDetailsToReport= new String []{ + MetadataXMLToUIMappingRules.COLLECTION, + MetadataXMLToUIMappingRules.RELEASE_CATEGORY, + MetadataXMLToUIMappingRules.RELEASE_SINCE_VERSION, + MetadataXMLToUIMappingRules.RELEASE_DEPRECATED_SINCE_VERSION, + MetadataXMLToUIMappingRules.LIBS + }; + } + // else if we dont found collections or we did not found anything, using + // subsystem as default value + else {// if(!containsCollection){ + apiDetailsToReport= new String []{ + MetadataXMLToUIMappingRules.SUBSYSTEM, + MetadataXMLToUIMappingRules.RELEASE_CATEGORY, + MetadataXMLToUIMappingRules.RELEASE_SINCE_VERSION, + MetadataXMLToUIMappingRules.RELEASE_DEPRECATED_SINCE_VERSION, + MetadataXMLToUIMappingRules.LIBS + }; + } + return apiDetailsToReport; + } + + /** + * Maps query type to API Detail topic in API Details. + * + * @param queryType + * Query type constant. + * @return Name of the API Detail. + */ + public String getAPIDetailNameInDetailsByQueryType(int queryType){ + + String apiDetail = null; + + switch (queryType) { + + case APIQueryParameters.QUERY_BY_API_NAME: + apiDetail = MetadataXMLToUIMappingRules.NAME; + break; + + case APIQueryParameters.QUERY_BY_SUBSYSTEM_NAME: + apiDetail = MetadataXMLToUIMappingRules.SUBSYSTEM; + break; + + case APIQueryParameters.QUERY_BY_DLL_NAME: + apiDetail = XMLUtils.DESCRIPTION_DLLS; + break; + + case APIQueryParameters.QUERY_BY_LIB_NAME: + apiDetail = MetadataXMLToUIMappingRules.LIBS; + break; + + case APIQueryParameters.QUERY_BY_HEADER_NAME: + apiDetail = MetadataXMLToUIMappingRules.HEADERS; + break; + + case APIQueryParameters.QUERY_BY_CRPS_KEY_NAME: + apiDetail = XMLUtils.DESCRIPTION_KEY_NAME; + break; + + default: + throw new IllegalArgumentException(Messages.getString("APIQueryParameters.QueryTypePart1_ErrMsg") //$NON-NLS-1$ + + queryType + + Messages.getString("APIQueryParameters.QueryTypePart2_ErrMsg") //$NON-NLS-1$ + ); + } + + return apiDetail; + } + + /* + * (non-Javadoc) + * + * @see com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension#getQueryTypeByAPIDetailNameInDetails(java.lang.String) + */ + public int getQueryTypeByAPIDetailNameInDetails(String queryType) { + int queryInt = -1; + + if(queryType == null){ + return queryInt; + } + + if(queryType.equals(MetadataXMLToUIMappingRules.NAME)){ + queryInt = APIQueryParameters.QUERY_BY_API_NAME; + } + else if(queryType.equals( MetadataXMLToUIMappingRules.SUBSYSTEM)){ + queryInt = APIQueryParameters.QUERY_BY_SUBSYSTEM_NAME; + } + else if(queryType.equals(XMLUtils.DESCRIPTION_DLLS)){ + queryInt = APIQueryParameters.QUERY_BY_DLL_NAME; + } + else if(queryType.equals(MetadataXMLToUIMappingRules.LIBS)){ + queryInt = APIQueryParameters.QUERY_BY_LIB_NAME; + } + else if(queryType.equals(MetadataXMLToUIMappingRules.HEADERS)){ + queryInt = APIQueryParameters.QUERY_BY_HEADER_NAME; + } + else if(queryType.equals(XMLUtils.DESCRIPTION_KEY_NAME)){ + queryInt = APIQueryParameters.QUERY_BY_CRPS_KEY_NAME; + } + + return queryInt; + } + + public boolean isAsyncQueryPreferred() { + return false; + } + + +/** + * opens the header file in the workbench + */ + /* + public int openHeaderFile(String headerName,String source) { + try{ + + String temp =source.replace( + "\\", "/"); + System.out.println(temp); + + temp = temp.substring(0, temp.lastIndexOf("/")) + + "/inc/" + headerName; + temp = "file://" + temp; + System.out.print("temp" + temp); + + + + OpenFileAction action = new OpenFileAction(); + action.openFile(new URI(temp), headerName); + }catch (Exception e) { + return 1; + } + + return 0; + } + */ + + + + public boolean serachHeaderLinkEnable() { + + return true; + } + + public String[] getHeaderSourceList() { + return new String[] + {"http://s60lxr", "http://developer.symbian.org/xref/oss", "3.2RnDSDK", "pf_5250robot"}; + + } + + + + public int openHeaderFile(String headerName, String APIName) { + try{ + System.out.println("header" + headerName + "APINAME " +APIName); + + // get the source + String source = LocalCacheUIComposite.headerSource; + String url = " "; + boolean isweb = false; + if(source.equalsIgnoreCase("http://s60lxr")){ + url = "http://s60lxr/search?filestring=%2F"+headerName+"%24&advanced=1&string="; + isweb = true; + } + else if(source.equalsIgnoreCase("http://developer.symbian.org/xref/oss")) + {url="http://developer.symbian.org/xref/epl/search?q=&defs=&refs=&path="+headerName+"&hist=&project=%2FMCL"; + isweb = true; + } + + + + if(isweb) + { //open from the browser + IWorkbench workbench = PlatformUI.getWorkbench(); + IWebBrowser browser; + + browser = workbench.getBrowserSupport() + .createBrowser(null); + + browser + .openURL(new java.net.URL(url)); + } + else + { //open from the sdk + SDKUtil.headerOpen(source, APIName, headerName); + } + }catch (Exception e) { + e.printStackTrace(); + } + + return 0 ; + + } + + + + + + + + + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/searchmethod/ui/LocalCacheUIComposite.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/searchmethod/ui/LocalCacheUIComposite.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,470 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.cache.searchmethod.ui; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Collection; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.IJobChangeListener; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CCombo; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Layout; +import org.eclipse.ui.PlatformUI; + +import com.nokia.s60tools.apiquery.cache.CacheHelpContextIDs; +import com.nokia.s60tools.apiquery.cache.configuration.CacheEntry; +import com.nokia.s60tools.apiquery.cache.configuration.CacheEntryStorage; +import com.nokia.s60tools.apiquery.cache.core.job.SeekMetaXMLFilesJob; +import com.nokia.s60tools.apiquery.cache.core.job.UpdateSDKSelectionJob; +import com.nokia.s60tools.apiquery.cache.resources.Messages; +import com.nokia.s60tools.apiquery.cache.util.SDKFinder; +import com.nokia.s60tools.apiquery.cache.util.SDKUtil; +import com.nokia.s60tools.apiquery.shared.datatypes.config.AbstractEntry; +import com.nokia.s60tools.apiquery.shared.searchmethod.ui.AbstractUiFractionComposite; +import com.nokia.s60tools.apiquery.shared.settings.UserSettingListenerNotificator; +import com.nokia.s60tools.apiquery.shared.ui.dialogs.APIQueryMessageBox; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.sdk.SdkEnvInfomationResolveFailureException; +import com.nokia.s60tools.sdk.SdkInformation; +import com.nokia.s60tools.sdk.SdkManager; +import com.nokia.s60tools.util.console.IConsolePrintUtility; +import com.nokia.s60tools.util.debug.DbgUtility; + +public class LocalCacheUIComposite extends AbstractUiFractionComposite + implements IJobChangeListener { + + /** + * Amount of columns in the used grid layout. + */ + private final int COLUMN_COUNT = 1; + + public static CCombo SDKCombo; + + private Button refreshBtn; + + static final String CACHED = " |SDK CACHED"; + + static final String UNCACHED = " |SDK UNCACHED"; + + private Combo headerfileSource; + + public static String headerSource; + + /** + * Constructor. + * @param parentComposite Parent composite for the created composite. + */ + public LocalCacheUIComposite(Composite parentComposite) { + super(parentComposite); + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.ui.views.main.AbstractTabComposite#createLayout() + */ + protected Layout createLayout() { + return new GridLayout(COLUMN_COUNT, false); + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.ui.views.main.AbstractTabComposite#createLayoutData() + */ + protected Object createLayoutData() { + return new GridData(GridData.FILL_HORIZONTAL); + } + + /** + * Set context sensitive help ids to components that can have focus + * @param tbl + */ + private void setContextSensitiveHelpIDs() { + //When all links point to same direction, we only need set context sensitive link id to composite. + PlatformUI.getWorkbench().getHelpSystem().setHelp(this, + CacheHelpContextIDs.CACHE_HELP_PROPERTIES_TAB); + } + + public static void updateSDKCacheInfoList() { + + Display.getDefault().asyncExec(new Runnable() { + public void run() { + SDKCombo.setItems(getSDKs()); + + } + }); + + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.ui.views.main.AbstractTabComposite#createControls() + */ + protected void createControls() { + + RGB rgbWhite = new RGB(255, 255, 255); + Color white = new Color(null, rgbWhite); + + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, + "-- createControls() --> " + getClass().getName()); //$NON-NLS-1$ + Label label = new Label(this, SWT.HORIZONTAL | SWT.LEFT); + label.setText(Messages.getString("LocalCacheUIComposite.SelectSDK")); //$NON-NLS-1$ + SDKCombo = new CCombo(this, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.BORDER); + + SDKCombo.setBackground(white); + SDKCombo.setItems(getSDKs()); + + String comboSelection = getSDKComboSelection(); + System.out.println("combo selection" + comboSelection); + SDKCombo.setText(comboSelection); + SDKCombo.addSelectionListener(new SDKComboSelectionListener()); + + refreshBtn = new Button(this, SWT.PUSH); + refreshBtn.setText(Messages + .getString("LocalCacheUIComposite.RefreshCache")); //$NON-NLS-1$ + refreshBtn.addSelectionListener(new RefreshBtnSelectionListener()); + + //Setting context sensitive help IDs + setContextSensitiveHelpIDs(); + + (new Label(this, SWT.LEFT)).setText(" "); + Label comboTitleLabel1 = new Label(this, SWT.LEFT); + // Creating controls + + comboTitleLabel1.setText("Select Source For Headers"); //$NON-NLS-1$ + + headerfileSource = new Combo(this, SWT.READ_ONLY); + final Combo myCombo = headerfileSource; + String[] cached = SDKUtil.getCachedSDKs(); + String[] webSources = { "http://s60lxr", "http://developer.symbian.org/xref/oss"}; + String[] headersources = new String[cached.length+webSources.length]; + System.arraycopy(webSources, 0, headersources,0 , webSources.length); + System.arraycopy(cached, 0, headersources,2 , cached.length); + + myCombo.setItems(headersources); + + +String defaultSource = "http://s60lxr"; +if(headersources.length!=0) defaultSource = comboSelection; + + headerfileSource.setText(defaultSource); + + headerSource = myCombo.getText(); + myCombo.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + headerSource = myCombo.getText(); + //System.out.println("you selected me: " + myCombo.getText()); + } + }); + + } + + /** + * Refresh SDK + */ + private class RefreshBtnSelectionListener implements SelectionListener { + + public void widgetDefaultSelected(SelectionEvent arg0) { + //not needed + } + + /** + * Refrenshing selected SDK... + */ + public void widgetSelected(SelectionEvent arg0) { + String selectedSDK = SDKCombo.getText(); + int index = selectedSDK.indexOf(CACHED); + + if (index == -1) + index = selectedSDK.indexOf(UNCACHED); + selectedSDK = selectedSDK.substring(0, index).trim(); + + try { + DbgUtility.println(DbgUtility.PRIORITY_LOOP, + " Refreshing SDK: " + selectedSDK); //$NON-NLS-1$ + SdkInformation info = SDKFinder.getSDKInformation(selectedSDK); + CacheEntryStorage storage = CacheEntryStorage.getInstance(); + //removing selected entrys + storage.removeSelectedEntrys(selectedSDK); + + //update (seek and load) selected SDK + selectSDKAndSeekFilesIfNeeded(info); + } catch (Exception e) { + + e.printStackTrace(); + String message = Messages + .getString("LocalCacheUIComposite.SDKSelectionErrMsg_Part1") + selectedSDK //$NON-NLS-1$ + + Messages + .getString("LocalCacheUIComposite.SDKSelectionErrMsg_Part2"); //$NON-NLS-1$ + APIQueryConsole + .getInstance() + .println( + message + + Messages + .getString("LocalCacheUIComposite.SDKSelectionErrMsg_Part3") + e, APIQueryConsole.MSG_ERROR); //$NON-NLS-1$ + APIQueryMessageBox box = new APIQueryMessageBox(message, + SWT.ICON_ERROR | SWT.OK); + box.open(); + } + } + + } + + /** + * Get selection for SDK combo + * @return SDK ID or null + */ + private String getSDKComboSelection() { + String currentlySelectedSDKID = CacheEntryStorage.getInstance() + .getCurrentlySelectedSDKID(); + if (currentlySelectedSDKID == null) { + currentlySelectedSDKID = ""; //$NON-NLS-1$ + } + return currentlySelectedSDKID; + } + + /** + * Select SDK + */ + private class SDKComboSelectionListener implements SelectionListener, + ActionListener { + + public void widgetDefaultSelected(SelectionEvent arg0) { + //Not needed + + } + + /** + * selecting new SDK + */ + public void widgetSelected(SelectionEvent arg0) { + + String selectedSDK = SDKCombo.getText(); + + //update the headersource + + int index = selectedSDK.indexOf(CACHED); + if(index!=-1){ + //update header source selection list + String headersrc=selectedSDK.substring(0,selectedSDK.indexOf(CACHED)).trim(); + headerfileSource.setText(headersrc); + } + + if (index == -1) + index = selectedSDK.indexOf(UNCACHED); + selectedSDK = selectedSDK.substring(0, index).trim(); + + DbgUtility.println(DbgUtility.PRIORITY_LOOP, + " Selecting SDK: " + selectedSDK); //$NON-NLS-1$ + SdkInformation info = SDKFinder.getSDKInformation(selectedSDK); + if (info != null) { + selectSDKAndSeekFilesIfNeeded(info); + + } else { + String message = Messages + .getString("LocalCacheUIComposite.SDKDoesNotExistErrMsg_Part1") + selectedSDK //$NON-NLS-1$ + + Messages + .getString("LocalCacheUIComposite.SDKDoesNotExistErrMsg_Part2"); //$NON-NLS-1$ + APIQueryConsole.getInstance().println(message, + APIQueryConsole.MSG_ERROR); + APIQueryMessageBox box = new APIQueryMessageBox(message, + SWT.ICON_ERROR | SWT.OK); + box.open(); + } + } + + public void actionPerformed(ActionEvent arg0) { + + } + + } + + /** + * Selecting dataSource and seeking file from SDK if not seeked allready + * @param info + */ + private void selectSDKAndSeekFilesIfNeeded(SdkInformation info) { + + //If selected SDK allready added, just updating data stor + if (isSDKAllreadySeeked(info)) { + updateDataStore(info); + } + //else we need to seek files under SDK and then update storage (job will do that) + else { + DbgUtility.println(DbgUtility.PRIORITY_LOOP, + " Starting to seek files from SDK: " + info.getSdkId()); //$NON-NLS-1$ + SeekMetaXMLFilesJob job = new SeekMetaXMLFilesJob( + Messages + .getString("LocalCacheUIComposite.SeekingMetadataFilesMsg") + info.getSdkId(), info); //$NON-NLS-1$ + job.setPriority(Job.DECORATE); + job.addJobChangeListener(this); + job.schedule(); + } + + //When SDK is changed, it really means that data source is changed, and we want to clear existing search results + UserSettingListenerNotificator.notifyListeners(); + } + + /** + * Returning previous selection to SDK if cancelled. + */ + private void doCancel() { + Runnable doCancel = new Runnable() { + public void run() { + SDKCombo.setText(getSDKComboSelection()); + } + }; + Display.getDefault().asyncExec(doCancel); + } + + /** + * Check if selected SDK is allready added to data store + * @param info + * @return true if found, false otherwise. + */ +public static boolean isSDKAllreadySeeked(SdkInformation info) { + CacheEntryStorage storage = CacheEntryStorage.getInstance(); + Collection entrys = storage.getEntries(); + for (AbstractEntry entry : entrys) { + CacheEntry ce = (CacheEntry) entry; + if (ce.getSDKID().equalsIgnoreCase(info.getSdkId())) { + return true; + } + } + return false; + } + + /** + * When known that data source allready found (files seeked under SDK) + * just updating datastore selections so that selected SDK is selected. + * @param info + */ + private void updateDataStore(SdkInformation info) { + + UpdateSDKSelectionJob job = new UpdateSDKSelectionJob( + Messages + .getString("LocalCacheUIComposite.UpdatingDataSourceMsg_Part1") + info.getSdkId() + Messages.getString("LocalCacheUIComposite.UpdatingDataSourceMsg_Part2"), info); //$NON-NLS-1$ //$NON-NLS-2$ + if (job.isAllreadyRunning()) { + return; + } + job.setPriority(Job.DECORATE); + job.addJobChangeListener(this); + job.schedule(); + + } + + /** + * Get SDK:s + * @return sdk:s + */ +public static String[] getSDKs() { + + try { + SdkInformation[] sdkInfoColl = SdkManager.getSdkInformation(); + String[] sdks = new String[sdkInfoColl.length]; + + for (int i = 0; i < sdkInfoColl.length; i++) { + + sdks[i] = sdkInfoColl[i].getSdkId() + + ((isSDKAllreadySeeked(SDKFinder + .getSDKInformation(sdkInfoColl[i].getSdkId()))) ? CACHED + : UNCACHED); + + } + + return sdks; + + } catch (SdkEnvInfomationResolveFailureException e) { + e.printStackTrace(); + APIQueryConsole.getInstance().println(e.getMessage(), + IConsolePrintUtility.MSG_ERROR); + return null; + } + } + + + /* (non-Javadoc) + * @see org.eclipse.swt.widgets.Widget#dispose() + */ + public void dispose() { + super.dispose(); + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, + "-- Dispose() --> " + getClass().getName()); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#aboutToRun(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void aboutToRun(IJobChangeEvent event) { + // not needed + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#awake(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void awake(IJobChangeEvent event) { + // not needed + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#done(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void done(IJobChangeEvent event) { + //If cancelled, select selection was before started! + IStatus status = event.getResult(); + if (status.getCode() != IStatus.OK) { + doCancel(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#running(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void running(IJobChangeEvent event) { + // not needed + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#scheduled(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void scheduled(IJobChangeEvent event) { + // not needed + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#sleeping(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void sleeping(IJobChangeEvent event) { + // not needed + } + + + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/util/SDKFinder.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/util/SDKFinder.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.cache.util; + +import org.osgi.framework.Version; + +import com.nokia.carbide.cpp.sdk.core.ISDKManager; +import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.sdk.SdkEnvInfomationResolveFailureException; +import com.nokia.s60tools.sdk.SdkInformation; +import com.nokia.s60tools.sdk.SdkManager; +import com.nokia.s60tools.util.console.IConsolePrintUtility; + + +/** + * Helper Class for finding SDK information. + */ +public class SDKFinder { + + /** + * Get SDK information by SDK ID + * @param sdkID + * @return information about SDK + */ + public static SdkInformation getSDKInformation(String sdkID){ + try{ + + SdkInformation[] sdkInfoColl = SdkManager.getSdkInformation(); + + for (int i = 0; i < sdkInfoColl.length; i++) { + SdkInformation info = sdkInfoColl[i]; + + + + if(info.getSdkId().equalsIgnoreCase(sdkID)){ + return info; + } + } + return null;//Should not be able to occur + } catch (SdkEnvInfomationResolveFailureException e) { + e.printStackTrace(); + APIQueryConsole.getInstance().println(e.getMessage(), + IConsolePrintUtility.MSG_ERROR); + return null; + } + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/util/SDKUtil.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/util/SDKUtil.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +package com.nokia.s60tools.apiquery.cache.util; + +import java.net.URI; +import java.util.ArrayList; + +import com.nokia.s60tools.apiquery.cache.configuration.CacheEntryStorage; + +import com.nokia.s60tools.apiquery.cache.searchmethod.ui.LocalCacheUIComposite; +import com.nokia.s60tools.apiquery.popup.actions.OpenFileAction; + +import com.nokia.s60tools.sdk.SdkInformation; +import com.nokia.s60tools.sdk.SdkManager; + +public class SDKUtil { + + public static void headerOpen(String sdkName, String apiName, + String headerName) { + try { + + CacheEntryStorage cacheEntryStorage = CacheEntryStorage + .getInstance(); + String source = cacheEntryStorage.getID(sdkName, apiName, + headerName); + System.out.println("source " + source); + String temp = source.replace("\\", "/"); + System.out.println(temp); + + temp = temp.substring(0, temp.lastIndexOf("/")) + "/inc/" + + headerName; + temp = "file://" + temp; + System.out.print("temp" + temp); + + OpenFileAction action = new OpenFileAction(); + action.openFile(new URI(temp), headerName); + + } catch (Exception e) { + + } + + } + + /* + * return cachedarray + */ + public static String[] getCachedSDKs() { + String[] cachedsdks = new String[0]; + + try { + ArrayList sdks = new ArrayList(); + SdkInformation[] sdkInfoColl = SdkManager.getSdkInformation(); + //String[] sdks = new String[sdkInfoColl.length]; + + for (int i = 0; i < sdkInfoColl.length; i++) { + String sdkid = sdkInfoColl[i].getSdkId(); + if (LocalCacheUIComposite.isSDKAllreadySeeked(SDKFinder + .getSDKInformation(sdkid))) { + sdks.add(sdkid); + System.out.println("cached" + sdkid); + + } + } + + cachedsdks = new String[sdks.size()]; + sdks.toArray(cachedsdks); + + } catch (Exception e) { + e.printStackTrace(); + } + + return cachedsdks; + + } + + + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/xml/MetadataXMLToUIMappingRules.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.cache/src/com/nokia/s60tools/apiquery/cache/xml/MetadataXMLToUIMappingRules.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,139 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.cache.xml; + + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.nokia.s60tools.apiquery.cache.resources.Messages; +import com.nokia.s60tools.apiquery.shared.datatypes.XMLToUIMappingRules; + + +/** + * XML to UI Mapping rules for .metaxml files. + */ +public class MetadataXMLToUIMappingRules extends XMLToUIMappingRules { + + private static final String NAME_PARAM = "name"; //$NON-NLS-1$ + + // + // UI Texts + // + public static final String RELEASE_DEPRECATED_SINCE_VERSION = Messages.getString("MetadataXMLToUIMappingRules.DeprecatedSince"); //$NON-NLS-1$ + public static final String RELEASE_SINCE_VERSION = Messages.getString("MetadataXMLToUIMappingRules.ReleaseSince"); //$NON-NLS-1$ + public static final String RELEASE_CATEGORY = Messages.getString("MetadataXMLToUIMappingRules.ReleaseCategory"); //$NON-NLS-1$ + public static final String ADAPTATION = Messages.getString("MetadataXMLToUIMappingRules.Adaptiotion"); //$NON-NLS-1$ + public static final String HTML_DOC_PROVIDED = Messages.getString("MetadataXMLToUIMappingRules.HtmlDocProvided"); //$NON-NLS-1$ + public static final String SUBSYSTEM = Messages.getString("MetadataXMLToUIMappingRules.Subsystem"); //$NON-NLS-1$ + public static final String TYPE = Messages.getString("MetadataXMLToUIMappingRules.Type"); //$NON-NLS-1$ + public static final String DESCRIPTION = Messages.getString("MetadataXMLToUIMappingRules.Description"); //$NON-NLS-1$ + public static final String NAME = Messages.getString("MetadataXMLToUIMappingRules.Name"); //$NON-NLS-1$ + public static final String LIBS = Messages.getString("MetadataXMLToUIMappingRules.Libs"); //$NON-NLS-1$ + public static final String HEADERS = Messages.getString("MetadataXMLToUIMappingRules.Headers"); //$NON-NLS-1$ + + //Extended SDK is removed in metadata version 2.0. + public static final String EXTENDED_SDK = Messages.getString("MetadataXMLToUIMappingRules.ExtendedSDK"); //$NON-NLS-1$ + + + /** + * Collection replaces {@link MetadataXMLToUIMappingRules#SUBSYSTEM} in metadata version 2.0. + */ + public static final String COLLECTION = Messages.getString("MetadataXMLToUIMappingRules.Collection"); //$NON-NLS-1$ + + public MetadataXMLToUIMappingRules(){ + init(); + } + + /** + * Set rules for mapping .metaxml file to UI. + * + */ + private void init() { + + /* + * 1.0 version of XML: + * + * + * + * temp + * temp + * c++ + * temp + * + * + * + * + * yes + * yes + * + * + * + * + * 2.0 version of XML + * + * + * + * temp + * temp + * c++ + * temp + * + * + * + * + * yes + * yes + * + * + */ + + addRule(NAME_PARAM, NAME); + addRule("description", DESCRIPTION);//$NON-NLS-1$ + addRule("type", TYPE);//$NON-NLS-1$ + addRule("subsystem", SUBSYSTEM);//$NON-NLS-1$ + addRule("collection", COLLECTION);//$NON-NLS-1$ //Collection replaces subsystem in version 2.0 + + //Libs parameters + Map libAttributes = new LinkedHashMap (); + libAttributes.put(NAME_PARAM, NAME_PARAM); //$NON-NLS-1$ + addRule("lib", LIBS, "libs", libAttributes);//$NON-NLS-1$ //$NON-NLS-2$ + + //release parameters + //@see e.g. Z:\s60\mw\cameraengines\cameraengines_dom\custom_onboard_camera_api\custom_onboard_camera_api.metaxml for release attributes + Map releasAttributes = new LinkedHashMap (); + releasAttributes.put("category", RELEASE_CATEGORY); //$NON-NLS-1$ //$NON-NLS-2$ + releasAttributes.put("sinceversion", RELEASE_SINCE_VERSION); //$NON-NLS-1$ //$NON-NLS-2$ + releasAttributes.put("deprecatedsince", RELEASE_DEPRECATED_SINCE_VERSION); //$NON-NLS-1$ //$NON-NLS-2$ + addRule("release", Messages.getString("MetadataXMLToUIMappingRules.Release"), releasAttributes); //$NON-NLS-1$ //$NON-NLS-2$ + + addRule("htmldocprovided", HTML_DOC_PROVIDED);//$NON-NLS-1$ + addRule("adaptation", ADAPTATION);//$NON-NLS-1$ + + //Extended SDK parameters + //Extended SDK is removed in metadata version 2.0. + //Developer edited by hand file: Z:\s60\mw\ahle\ahle_dom\adaptive_history_list_api\adaptive_history_list_api.metaxml Where is extended SDK params to tests - This comment can be removed. + Map extendedAttributes = new LinkedHashMap (); + extendedAttributes.put("sinceversion", "Extended SDK since version"); //$NON-NLS-1$ //$NON-NLS-2$ + extendedAttributes.put("deprecatedsince", "Extended SDK deprecated since version"); //$NON-NLS-1$ //$NON-NLS-2$ + addRule("extendedsdk", EXTENDED_SDK, extendedAttributes);//$NON-NLS-1$ + + + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/.classpath --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/.classpath Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,6 @@ + + + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/.project --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/.project Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,34 @@ + + + com.nokia.s60tools.apiquery.help + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + com.nokia.carbide.extension.pclint.pclintAuditor + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + com.nokia.carbide.extension.pclint.pclintNature + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/.settings/org.eclipse.jdt.core.prefs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/.settings/org.eclipse.jdt.core.prefs Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,7 @@ +#Thu Oct 09 15:30:10 EEST 2008 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/META-INF/MANIFEST.MF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/META-INF/MANIFEST.MF Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,10 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Carbide.c++ Extensions - APIQuery Help Plug-in +Bundle-SymbolicName: com.nokia.s60tools.apiquery.help;singleton:=true +Bundle-Version: 1.2.6 +Bundle-Vendor: Nokia +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.help +Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/book.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/book.css Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,191 @@ +/* + + Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + All rights reserved. + + This component and the accompanying materials are made available + under the terms of "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". +*/ + +/* Add whitespace around entire display to avoid crowding edges of view */ +/* 20070523-Removed top margin size to close gap between location breadcrumbs and page title */ +html { + margin: 0px 10px 10px 10px; + } + +/* Set default font to serif style, 12-pt and plain */ +body, p, table { + font-family: Georgia, "Times New Roman", Times, serif; + font-size: 12px; + font-weight: normal; +} + +/* Use sans-serif fonts for all title styles */ +h1, h2, h3, h4, h5, h6, strong, em { + font-family: Helvetica, sans-serif; + color: #000000; + } + +h1 { font-size:20px } +h2 { font-size:18px } +h3 { font-size:16px } +h4 { font-size:14px } +h5 { font-size:12px } +h6 { font-size:10px } + +/* For headlines at the top of a view, add space */ +/* 20070522-added gradiant to background to update visual style of docs */ +h1, h2, h3 { + background-image: url(html/images/green_fade_left_68_165_28.png); + background-repeat: no-repeat; + padding:10px 0px 10px 12px; + } + +li { + margin-bottom:8px; + margin-top:8px; + } + +/* Footer includes space and a gray line above the company logo */ +#footer { + padding-top:10px; + margin-top:20px; + border-top:1px solid #999; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; + color: #03C; + } + +.listing { + font-family: "Courier New", Courier, mono; + color: #009; + background-color: #EEE; + padding: 10px 0px; + margin: 10px 0px; + } + +.code, pre { + font-family: "Courier New", Courier, mono; + font-size: 11px; + color: #333; + } + +.step { + /* background-color: #EEE; */ + /* margin: 10px 0px; */ + color: #333; + border-bottom:2px solid #EEE; + } + +.substep { + background-color: #EEE; + } + + +/* Figure/Listing/Table titles are centered and gray */ +p.table { + color: #999; + font-weight: bold; + padding-top: 5px; + } + +table { + border: solid #999 1px; + table-layout: auto; + font-size: 12px; + } + +td, th { + border: solid #999 1px; + padding: 5px; + vertical-align:top; + } + +/* 20070522-replaced gray with green background to match gradiant color for title */ +th { + background-color:#ACD79B; + /* background-color:#999; + color:#FFF; */ + } + +div.ol.p { + margin-left: 3em; + } + +/* Make all ordered/unordered list items appear in bold gray */ +div ol > li, div ul > li { + font-weight:bold; + color: #333; + } + +div ol > p, div ul > p, div li > p { + font-weight:normal; + } + +/* Make all H4 and H5 items appear in bold gray against a light green background */ +div h5, div h4 { + padding:5px 0px 5px 12px; + background-color:#ECFBEA; + /* background-color: #EEE; */ + font-weight:bold; + color: #333; + } + + +/* Notes stand out using a light top & bottom borders with dark gray text */ +p.note { + /* color: #03C; */ + /* background-color: #FFFF99; */ + color: #333; + padding: 5px; + margin-left: 1em; + margin-right: 1em; + border-top: solid #BBB thin; + border-bottom: solid #BBB thin; + } + + +/* Figure/Listing/Table titles are centered and gray */ +p.figure { + color: #333; + text-align: center; + font-weight: bold; + } + +/* highly visible red background and white text for things that need fixing before release */ +/* SHOULD NOT BE PRESENT IN RELEASED PRODUCTS */ +.fix { + background-color: red; + font-weight: bold; + color: white; + } + +.question { + font-style:italic; + font-weight:bold; + color: #555; + } + +.titleSmall { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; + } + + +.plain { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 12px; + font-style: normal; + line-height: normal; + font-weight: normal; + font-variant: normal; + color: #000000; + text-decoration: none; + } + +a:link { color: #0033CC } +a:visited { color: #555555 } +a:hover { color: #0033CC } + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/build.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/build.properties Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,7 @@ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + html/,\ + book.css +bin.excludes = html/nokia.css diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/concepts/concepts.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/concepts/concepts.htm Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,21 @@ + + + + + +Concepts + + + +

Concepts

+

The following concepts provide information on relevant concepts for the API Query tool:

+ + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/concepts/data_source.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/concepts/data_source.htm Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,32 @@ + + + + +Data source + + + + +

Data source

+

A data source is an external repository that stores information about Application Programming Interfaces (APIs).

+

The repository can be, for example:

+ +

API information identifies, for example, the header files, DLL files, subsystems, SDKs, and the contact persons for an API. However, different data sources contain different levels of detail. To check which data source suits your needs the best and how to take it into use, see the topics under Data source configurations.

+ +
Related concepts
+ + +
Related tasks
+ + + + + \ No newline at end of file diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/concepts/metadata_file.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/concepts/metadata_file.htm Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,35 @@ + + + + +API metadata file + + + + +

API metadata file

+

A metadata file is used to provide information about an Application Programming Interface (API). Metadata files contain the following information of an API, as shown in the example below:

+

+<?xml version="1.0" ?>
+<api id="16bdb6fdf38e8ced9e907a4eea1f68c5" dataversion="1.0">
+  <name>Phone Parser API</name>
+  <description>This API is used to parse and validate phone numbers.</description>
+  <type>c++</type>
+  <subsystem>commonservices</subsystem>
+  <libs>
+    <lib name="CommonEngine.lib" />
+  </libs>
+  <release category="sdk" sinceversion="2.0"/>
+  <attributes>
+     <htmldocprovided>yes</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api> +

+

Metadata files are identified by the extension .metaxml. The name of the file comes from the API name and should be the same as the API directory name. For example, if the API directory is phone_parser_api, the corresponding metadata file name should be phone_parser_api.metaxml. The file is located directly under the API's own directory.

+

Tip: These files can be created and edited in the Carbide.c++ development environment with the Metadata Editor tool. You can start the tool from the Carbide > Metadata Editor menu.

+ + + + \ No newline at end of file diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/concepts/software_development_kit.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/concepts/software_development_kit.htm Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,28 @@ + + + + +Software Development Kit (SDK) + + + + +

Software Development Kit (SDK)

+

A Software Development Kit (SDK) contains the tools, documentation and code examples that support the development of applications. It also contains Application Programming Interface (API) metadata files (.metaxml) that you can specify as one data source type for your queries.

+

You can use both Public SDKs and RnD SDKs in queries. Public SDKs can be downloaded from the Internet (for example, from Forum Nokia pages), whereas RnD SDKs are more restricted but contain all system-level components.

+

To install SDKs to Carbide.c++, go to Windows > Preferences > Carbide.c++ > SDK Preferences > Add New SDK, and select the SDK to be added.

+

For more information, see SDK Support under the general Carbide.c++ help.

+ +
Related concepts
+ + +
Related tasks
+ + + + \ No newline at end of file diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/contexts.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/contexts.xml Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,20 @@ + + + + + + Search tab + + + + + + + + Properties tab + + + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/datasources/datasources.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/datasources/datasources.htm Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,17 @@ + + + + + +Data source configurations + + + + +

Data source configurations

+

This section of the help shows the documentation for currently installed data sources. Each data source implementation can be installed as a separate plug-in, and each plug-in provides its help under this category. Follow the topic links on the help's table of contents for more information.

+ + + + \ No newline at end of file diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/gettingstarted/GS_index.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/gettingstarted/GS_index.htm Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,24 @@ + + + + + Getting Started + + + + +

Getting started

+ +

The information in this section will help you get started quickly using the basic + features of the API Query extension for Carbide.c++.

+ +

Topics in this section include:

+ + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/gettingstarted/overview.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/gettingstarted/overview.htm Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,40 @@ + + + + +Overview + + + + +

Overview

+

API Query is a tool for querying Application Programming Interface (API) information. With this tool, you can quickly found out which headers belong to a specific API, who is the owner of a particular API, and whether the API has been published in an SDK.

+

API data is accessed via a data source, such as an online database service. For more information, see Data source.

+

You can use the following criteria when querying for API information (some of these may not be available with all data source types):

+ +

In the API Query tool, you can run a query either from the Search tab or directly from your code. In the code, you can either search for specific identifiers or generate a report about the usage of APIs in your entire project.

+ +
Related concepts
+ + +
Related tasks
+ + + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/gettingstarted/walk_through.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/gettingstarted/walk_through.htm Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,22 @@ + + + + +Basic walk-through + + + + +

Basic walk-through

+

To launch the API Query extension, do either of the following:

+ +

Before you can run queries, configure the data sources you want to use. The currently installed data sources are listed on the Properties tab.

+

After this, you can run an API query from the Search tab or from the context menu of your project.

+ + + + \ No newline at end of file diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/images/green_fade_left_68_165_28.png Binary file srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/images/green_fade_left_68_165_28.png has changed diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/index.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/index.xml Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/legal.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/legal.htm Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,20 @@ + + + + +License Information + + + + +

License Information

+ +
COPYRIGHT
+

Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. This component and the accompanying materials are made available under the terms of the License "Symbian Foundation License v1.0" which accompanies this distribution, and is available at the URL "http://www.eclipse.org/legal/epl-v10.html".

+

Initial Contributors:
+Nokia Corporation - initial contribution

+ + + + \ No newline at end of file diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/nokia.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/nokia.css Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,165 @@ +/* + Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. + License: http://www.eclipse.org/legal/epl-v10.html. +*/ + +/* Add whitespace around entire display to avoid crowding edges of view */ +html { + margin: 10px; + /* fixes gray backgrounds when displayed in external browsers */ + background-color:#FFFFFF; + } + +/* Set default font to serif style, 12-pt and plain */ +body { + font-family: Georgia, "Times New Roman", Times, serif; + font-size: 12px; + font-weight: plain; +} + +/* Use sans-serif fonts for all title styles and Nokia blue */ +h1, h2, h3, h4, h5, h6, strong, em { + font-family: Arial, Helvetica, sans-serif; + color: #333; + } + +strong{ + color: #333; + } + +/* For headlines at the top of a view, add space and a gray line underneath */ +h2, h3 { + padding:10px 0px; + border-bottom:1px solid #BBB; + } + +li { + margin-bottom:8px; + margin-top:8px; + } + + +/* Footer includes space and a gray line above the company logo */ +#footer { + padding-top:10px; + margin-top:20px; + border-top:1px solid #999; + font-family: Arial, Helvetica, sans-serif; + font-size: 11px; + color: #333; + } + +.listing { + font-family: "Courier New", Courier, mono; + color: #009; + background-color: #EEE; + padding: 10px 0px; + margin: 10px 0px; + } + +.code, pre { + font-family: "Courier New", Courier, mono; + font-size: 12px; + color: #333; + } + +.step { + /* background-color: #EEE; */ + /* margin: 10px 0px; */ + color: #333; + border-bottom:2px solid #EEE; + } + +.substep { + background-color: #EEE; + } + + +/* Figure/Listing/Table titles are centered and gray */ +p.table { + color: #999; + font-weight: bold; + padding-top: 5px; + } + +table { + border: 1px solid #999; + table-layout: auto; + } + +td, th { + border: 1px solid #999; + padding: 5px; + vertical-align:top; + } + +th { + background-color:#999; + color:#FFF; + } + +div.ol.p { + margin-left: 3em; + } + +/* Make all ordered/unordered list items appear in bold gray */ +div ol > li, div ul > li { + font-weight:bold; + color: #333; + } + +/* Make all H4 and H5 items appear in bold gray against a light gray background */ +div h5, div h4 { + padding: 5px; + background-color: #EEE; + font-weight:bold; + color: #333; + } + + +/* Notes stand out using a light top & bottom borders with dark gray text */ +p.note { + /* color: #03C; */ + /* background-color: #FFFF99; */ + color: #333; + padding: 5px; + margin-left: 1em; + margin-right: 1em; + border-top:1px solid #BBB; + border-bottom:1px solid #BBB; +} + + +/* Figure/Listing/Table titles are centered and gray */ +p.figure { + color: #333; + text-align: center; + font-weight: bold; +} + +/* red background and white text for things that need fixing before release */ +.fix { + background-color: red; + font-weight: bold; + color: white; + } + +.question { + font-style:italic; + font-weight:bold; + color: #333; + } + +.titleSmall { + font-family: Arial, Helvetica, sans-serif; + font-size: 10px; + } + +.copyrightStatement { + font-size: 11px; + color: #006699; /* Symbian blue */ + } + +div.Footer table, div.Footer td, div.Footer th { + border: 0px none #000; + } diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/release_notes.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/release_notes.htm Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,80 @@ + + + + +Release Notes + + + + +

Release Notes

+ +

API Query 1.2.6

+ + +

Product description

+

API Query is a tool for querying Application Programming Interface (API) information.

+

You can start the API Query tool either by selecting the Carbide > API Query menu item or via Window > Show View > Other... under Carbide Extensions category.

+ +

Features

+ + +

Enhancements/Fixed

+ + +

New Features

+ + +

System requirements

+

Basic Requirements:

+ +

Additional Requirements:

+ +

+ +

Compatibility issues

+ + +

Known issues

+ + + + + + \ No newline at end of file diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/configure_data_sources.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/configure_data_sources.htm Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,30 @@ + + + + +Configuring data sources + + + + +

Configuring data sources

+

Data sources are configured on the Properties Tab in the API Query tool. The currently used data source is selected from the list box. The contents of the configuration UI vary based on which data source is selected. There is no common rule for configuration UI, but it is normally divided into several data source entries that can be either taken into or omitted from an API search.

+ +

For data source specific configuration steps, see Data source configurations in this help.

+ +
Related tasks
+ + +
Related concepts
+ + + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/query_for_project.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/query_for_project.htm Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,39 @@ + + + + +Running an API query for a project + + + + +

Running an API query for a project

+

You can generate a report of the usage of APIs throughout your active project from the context menu. +You can access the context menu either by right-clicking any .cpp or .h file or any folder in the C/C++ Projects view, or by right-clicking your code anywhere in the editor.

+ +

The report is a table in HTML format and is named as [name]-project_is_using_APIs.html by default. You can view it in Carbide's internal browser or in any Web browser.

+

To run a query for a project, do the following:

+
    +
  1. Right-click the item of your choice and from the pop-up menu, select API Query > for Active Project.
  2. +
  3. In the Save As dialog, select the location for saving the query report within your project and click OK.
  4. +
  5. When the report has been generated, click OK in the confirmation dialog to view it right away.

    The report is opened to Carbide's internal browser. See the following figure for an example:

    +

    +

    You can perform operations by clicking the underlined links in the report:

    + +

    Note: You can only open links from the report when the API Query Carbide.c++ Extension is running.

    +
  6. +
+ +
Related tasks
+ + + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/query_for_source_code_identifier.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/query_for_source_code_identifier.htm Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,35 @@ + + + + +Running an API query based on the source code identifier + + + + +

Running an API query based on the source code identifier

+

A convenient way to run an API query is to start it directly from your source code. You can use any of the following identifier types as criteria:

+ +

To run a query using an identifier, do the following:

+
    +
  1. Select the identifier name or part of the name from the code.

    Tip: with the Header Name type, it is enough to place the cursor on a line that has a valid #include directive, or select multiple lines.

  2. +
  3. Right-click the selection and from the pop-up menu, select API Query followed by the identifier type. +

    +

    The API Query view is opened, if not already activated, and the selected identifier is copied into the Search string field. The query is carried out automatically and the found matches are displayed in the Search results list.

  4. +
  5. Select the API of your choice from the list to view its details.

    The information is retrieved into the API details table.

  6. +
+ +
Related tasks
+ + + + + \ No newline at end of file diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/query_from_context_menu.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/query_from_context_menu.htm Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,24 @@ + + + + +Running an API query from the context menu + + + + +

Running an API query from the context menu

+

API Query provides a context menu that is visible for Carbide projects both in the C/C++ Projects view, and for header and source files of those projects opened in the editor.

+

From the context menu, you can either run a query based on a specific identifier in the source code (for example, a header name), or you can generate a report of API usage throughout your project. The report is in HTML format, and it summarizes the API names and header files that your project uses.

+

For instructions, see Running an API Query based on the source code identifier and Running an API Query for a project.

+ +
Related tasks
+ + + + + \ No newline at end of file diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/query_from_search_tab.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/query_from_search_tab.htm Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,43 @@ + + + + +Running an API query from the Search tab + + + + +

Running an API query from the Search tab

+ +
Before you start
+

Make sure you have configured the data source you want to use. For instructions, see Configuring data sources.

+

To run API queries, do the following:

+
    +
  1. Select the query type from the Query by group.

    Note: a different set of query types may be enabled depending on the configured data source.

  2. +
  3. In the Search string field, enter the string you want to search for.

    For example, avkon for an API name or akna for a header name, and so on. For multi search seperate the keyword with "; " character. Wildcard characters (*,?) are not supported.

  4. +
  5. To run the query, click Search.

    The list of found APIs are shown in the Search results list, as shown in the example below.

    +

    Single keyword search

    + +

    Multi Keyword search

    + + +

    The ID of the data source is shown in the brackets after the API name. If there are multiple data source entries configured, the same API may be listed once for each data source entry.

    +

    To view only the API names in the Search results list, check the option Show only API names.

  6. +
  7. Select the API of your choice from the list to view its details.

    The information is fetched into the API details table and the value that fulfils the search criteria is highlighted with red, as shown in the example below.

    +

    +

    Headers can be opened by clicking on the link provided in the api details tab.Header is opened in editor/web browser based on the selected data source.If the data source is sdk then it will be opened in editor.If the data source is webserver then it will be opened in s60lxr.

    +

    Note: the data fields shown in the API details table can vary based on the current data source selection and headerlink will be enabled only when the serach is for header file.

    +
  8. +
+ +
Related tasks
+ + + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/context_menu.png Binary file srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/context_menu.png has changed diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/data_source_config.png Binary file srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/data_source_config.png has changed diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/generate_api_report.png Binary file srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/generate_api_report.png has changed diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/identifier_from_code.png Binary file srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/identifier_from_code.png has changed diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/multiserach.PNG Binary file srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/multiserach.PNG has changed diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/results.PNG Binary file srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/results.PNG has changed diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/sample_api_report.png Binary file srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/sample_api_report.png has changed diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/search_tab.png Binary file srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/search_tab.png has changed diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/singlesearch.PNG Binary file srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/singlesearch.PNG has changed diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/web_sample_details.png Binary file srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/web_sample_details.png has changed diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/web_sample_found_entries.png Binary file srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/screenshots/web_sample_found_entries.png has changed diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/tasks.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tasks/tasks.htm Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,22 @@ + + + + + +Tasks + + + + +

Tasks

+

The following tasks are available for this tool:

+ + + + + \ No newline at end of file diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/toc.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/toc.htm Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,40 @@ + + + + + Table of Contents + + + + +

API Query Online Help

+

Release Notes

+ +

Getting started

+ + +

Concepts

+ + +

Tasks

+ + +

Data source configurations + +

Legal

+ + + + \ No newline at end of file diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tocConcepts.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tocConcepts.xml Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tocGettingStarted.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tocGettingStarted.xml Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,9 @@ + + + + + + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tocReference.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tocReference.xml Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,11 @@ + + + + + + + + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tocTasks.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/tocTasks.xml Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/toolTOC.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/html/toolTOC.xml Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/plugin.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/plugin.xml Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/ppt/APIQueryMainPluginHelpFigures.ppt Binary file srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/ppt/APIQueryMainPluginHelpFigures.ppt has changed diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/ppt/README.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery.help/ppt/README.txt Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,4 @@ + +APIQueryMainPluginHelpFigures.ppt stores the figures that +are edited in Powerpoint before they are stored under the +screenshots directory under the corresponding help directory. diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/.classpath --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/.classpath Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,7 @@ + + + + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/.cvsignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/.cvsignore Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,1 @@ +bin diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/.project --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/.project Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,28 @@ + + + com.nokia.s60tools.apiquery + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/.settings/org.eclipse.core.resources.prefs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/.settings/org.eclipse.core.resources.prefs Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,4 @@ +#Thu Sep 06 17:13:39 EEST 2007 +eclipse.preferences.version=1 +encoding//src/com/nokia/s60tools/apiquery/shared/common/product.properties=8859_1 +encoding//src/com/nokia/s60tools/apiquery/shared/resources/messages.properties=8859_1 diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/.settings/org.eclipse.jdt.core.prefs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/.settings/org.eclipse.jdt.core.prefs Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,12 @@ +#Mon Feb 26 15:24:00 EET 2007 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/.settings/org.eclipse.jdt.ui.prefs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/.settings/org.eclipse.jdt.ui.prefs Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,3 @@ +#Mon Feb 26 15:24:00 EET 2007 +eclipse.preferences.version=1 +internal.default.compliance=default diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/META-INF/MANIFEST.MF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/META-INF/MANIFEST.MF Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,47 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Carbide.c++ Extensions - API Query Tool +Bundle-SymbolicName: com.nokia.s60tools.apiquery; singleton:=true +Bundle-Version: 1.2.6 +Bundle-Activator: com.nokia.s60tools.apiquery.shared.plugin.APIQueryPlugin +Bundle-Vendor: Nokia +Bundle-Localization: plugin +Require-Bundle: org.eclipse.ui.editors, + org.eclipse.ui.workbench.texteditor, + org.eclipse.ui, + org.eclipse.core.runtime, + com.nokia.s60tools.sdk, + com.nokia.s60tools.ui, + com.nokia.s60tools.util, + org.eclipse.core.resources, + org.eclipse.jface.text, + org.eclipse.ui.ide, + org.eclipse.help, + org.eclipse.ui.forms, + javax.servlet;bundle-version="2.4.0", + org.eclipse.equinox.http.jetty;bundle-version="1.1.0", + com.nokia.carbide.cpp.sdk.core;bundle-version="2.0.0", + com.nokia.carbide.cdt.builder;bundle-version="2.0.0" +Bundle-ActivationPolicy: lazy +Export-Package: com.nokia.s60tools.apiquery.popup.actions;x-friends:="com.nokia.s60tools.apiquery.cache", + com.nokia.s60tools.apiquery.shared.common, + com.nokia.s60tools.apiquery.shared.datatypes, + com.nokia.s60tools.apiquery.shared.datatypes.config, + com.nokia.s60tools.apiquery.shared.exceptions, + com.nokia.s60tools.apiquery.shared.job, + com.nokia.s60tools.apiquery.shared.plugin, + com.nokia.s60tools.apiquery.shared.preferences, + com.nokia.s60tools.apiquery.shared.resources, + com.nokia.s60tools.apiquery.shared.searchmethod, + com.nokia.s60tools.apiquery.shared.searchmethod.ui, + com.nokia.s60tools.apiquery.shared.searchmethodregistry, + com.nokia.s60tools.apiquery.shared.services, + com.nokia.s60tools.apiquery.shared.settings, + com.nokia.s60tools.apiquery.shared.ui, + com.nokia.s60tools.apiquery.shared.ui.dialogs, + com.nokia.s60tools.apiquery.shared.util, + com.nokia.s60tools.apiquery.shared.util.console, + com.nokia.s60tools.apiquery.shared.util.xml, + com.nokia.s60tools.apiquery.ui.views.main;x-friends:="com.nokia.s60tools.apiquery.cache" +Bundle-RequiredExecutionEnvironment: J2SE-1.5 + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/about.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/about.html Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,24 @@ + + + +About + + + +

About This Content

+ +

Dec 2, 2009

+ +

Copyright

+ +

+ +Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). + +This product includes software developed by Eclipse Project. +http://www.eclipse.org. + +

+ + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/about.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/about.ini Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,36 @@ +################################################################################ +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +################################################################################ + +# about.ini +# contains information about a feature +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# "%key" are externalized strings defined in about.properties +# This file does not need to be translated. + +# Property "aboutText" contains blurb for "About" dialog (translated) +# This text is shown in Feature Details -dialog when feature is selected. +aboutText=%productBlurb + +# Property "windowImage" contains path to window icon (16x16) +# needed for primary features only + +# Property "featureImage" contains path to feature image (32x32) +# Not using this in here because we do not want the icon to +# show on about dialog. Only using aboutText above. +#featureImage=icons/ + +# Property "aboutImage" contains path to product image (500x330 or 115x164) +# needed for primary features only + +# Property "appName" contains name of the application (translated) +# needed for primary features only + +# Property "welcomePerspective" contains the id of the perspective in which the +# welcome page is to be opened. +# optional diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/about.mappings --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/about.mappings Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,25 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# +# +# about.mappings +# contains fill-ins for about.properties +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# This file does not need to be translated. + +# The following should contain the build version. +# e.g. "0=20020612" +0=3 diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/about.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/about.properties Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,26 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# + +productBlurb=Carbide.c++ Extensions - API Query \n\ +\n\ +Version: 1.2.6\n\ +Build id: {0}\n\ +\n\ +\n\ +Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +License:http://www.eclipse.org/legal/epl-v10.html\n\ +\n\ diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/build.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/build.properties Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,31 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# +javacSource=1.5 +javacTarget=1.5 + +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + icons/,\ + about.ini,\ + about.mappings,\ + about.properties,\ + about.html,\ + plugin.properties,\ + resources/ diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/ccbuild.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/ccbuild.xml Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,490 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + basic + codesize + coupling + design + strictexception + strings + sunsecure + unusedcode + junit + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/docs/ReleaseNote.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/docs/ReleaseNote.txt Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,85 @@ +======================================================================== +RELEASE NOTE FOR APIQUERY 1.0 Build 1 (version 1.0.4) +SUPPORTING S60 1.x-3.x +======================================================================== + +Product Description: +==================== + +API Query is a tool for querying S60 Application Programming Interface (API) information. + +You can start the API Query tool either by selecting the Carbide > +API Query menu item or via Window > Show View > Other... under Carbide Extensions category. + + +Features: +========= + +- API Query using the following software asset database services: + - for S60 data: http://kevlar.nmp.nokia.com/kevlar/api/legacyquery/ + - for Core SW data: http://trwww017/cgi-bin/ifinfo/sheets.pl + - for SPP data: http://s60tools/cgi-bin/spp/ifinfo/sheets.pl +- API Query using local API Interface Sheets. +- API usage verification in an active project. + + +Fixed issues: +============= +- Search result for working sources can be seen, when there was some sources + unavailable or causing errors. If at least one source is giving results but not + errors, warning message for failed sources is given, if all sources is giving + errors, an error message is given to user. + This issue is fixed to plug-in version 1.0.3. +- API Query WWW Search Method plug-in search failed for 'API name' search + when 'Search string' field contained white space character(s). This issue + is fixed to plug-in version 1.0.2. + +Enhancements: +============= +- Added usage logging and update site url + + +New Features: +============= +- N/A (1st version) + + +System Requirements: +==================== +Basic Requirements: +- Windows 2000, Windows XP +- Carbide.c++ v2.0 (tested with build 7) +- Minimum Platform/SDK build PC. +- Normal Platform/SDK build PC. + +Additional Requirements: +- Carbide.c++ with all its prerequisites have to be installed prior to installation. + See readme\readme_sdks.html under Carbide.c++ installation directory for prerequisites + (ActivePerl-5.6.1.635 and at least one S60 3rd Edition SDK/Platform needs to be installed). + +How to upgrade from the older versions: +--------------------------------------- + +New version of the extension comes with updated versions of common utility plug-ins. +Once you have installed the new set of plug-ins, perform the following steps: + +1) Open up 'Command Prompt' +2) Go to the Carbide.c++ installation directory (e.g. C:\Program Files\Nokia\Carbide.c++ v2.0). +3) Start Carbide.c++ with the following command line: "Carbide.c++.exe" -clean + +The starting of Carbide.c++ with clean option makes sure that the latest versions +of the plug-ins are loaded. + +Compatibility Issues: +===================== +- N/A + +Known Issues: +============= +- Context sensitive help will not get focus when pressing F1 if API Query plug-in is + running in same tab with Help. Afterall, Context sensitive help will open to relative + item when pressing F1, and can be navigated by opening Help by clicking tab. + + +Copyright © 2007, 2008 Nokia Corporation. All rights reserved. +Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation. diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/docs/internal/testing/FunctionalityTestingNotes.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/docs/internal/testing/FunctionalityTestingNotes.txt Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,33 @@ + +------------------------------------------------------------------------ +Things that has been tested but might need official functionality tests: +------------------------------------------------------------------------ + +- Failed to start some search method extension. + * Prints error info into console + +- No extension plugins (that implement "com.nokia.s60tools.apiquery.searchMethods" extension point) + exists in the system. + * Show an error dialog to a user + * Prints error info into console + * Raises run-time exception that creates and error log entry. + +- + + +- + + +- + + +- + +--------------------------------------------------------------------------- +Things that has NOT been tested and might need official functionality tests: +---------------------------------------------------------------------------- + +- + +- + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/icons/.cvsignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/icons/.cvsignore Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,1 @@ +Thumbs.db diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/icons/apiquery_tsk.png Binary file srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/icons/apiquery_tsk.png has changed diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/icons/apiquery_wiz.png Binary file srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/icons/apiquery_wiz.png has changed diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/icons/not_yet_implemented_action_misc.png Binary file srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/icons/not_yet_implemented_action_misc.png has changed diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/plugin.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/plugin.properties Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,23 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# +view.Label=API Query +view.Tooltip=API Query +popups.ApiQueryMainMenu=API Query +popups.action.searchProject=for Active Project +popups.action.searchCRPSKey=for CR/P&S key name +popups.action.searchLIBName=for LIB Name +popups.action.searchHeaderName=for Header Name diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/plugin.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/plugin.xml Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/resources/htmlReportStyles.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/resources/htmlReportStyles.css Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,94 @@ + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/schema/searchMethods.exsd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/schema/searchMethods.exsd Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,134 @@ + + + + + + + + + It can be used to add another serachmethod to query api information. + + + + + + + + + + + + a fully qualified identifier of the target extension point + + + + + + + an optional identifier of the extension instance + + + + + + + an optional name of the extension instance + + + + + + + + + + + + + + + a fully qualified name of the class that implements com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension + or subclass com.nokia.s60tools.apiquery.shared.searchmethod.AbstractSearchMethodExtension + + + + + + + + + + Unique source name + + + + + + + unique Id + + + + + + + To use the current source as default source + + + + + + + + + + + + The following is an example of Web extension point: + + &lt;extension + point=&quot;com.nokia.s60tools.apiquery.searchMethods&quot;&gt; + &lt;searchMethod + class=&quot;com.nokia.s60tools.apiquery.web.searchmethod.WebServerSearchMethodExtension&quot; + description=&quot;Web Server&quot; + id=&quot;web&quot; + isDefault=&quot;true&quot;/&gt; + &lt;/extension&gt; + + + + + + + + + The value of the class attribute must be a fully qualified name of the class that implements com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension or subclass com.nokia.s60tools.apiquery.shared.searchmethod.AbstractSearchMethodExtension when developing a new serach method. + + + + + + + + + APIQuery is provided with 3 serach methods :cache,web and excel sheets which are the extension of this plugin. + + + + + + + + + + Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + All rights reserved. + + This component and the accompanying materials are made available + under the terms of "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + + + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/APIQueryHelpContextIDs.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/APIQueryHelpContextIDs.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery; + + +/** + * IDs for context sensitive help. + * @see contexts.xml -file IDs links to + */ +public class APIQueryHelpContextIDs { + + /** + * The plug-in ID. Copy from APIQueryHelpActivator.PLUGIN_ID + * to here to avoid runtime dependency to help project + */ + private static final String API_QUERY_HELP_PROJECT_PLUGIN_ID = "com.nokia.s60tools.apiquery.help";//$NON-NLS-1$ + + + /** + * Context sensitive help id to API Query search tab + */ + public static final String API_QUERY_HELP_SEARCH_TAB = + API_QUERY_HELP_PROJECT_PLUGIN_ID +".API_QUERY_HELP_SEARCH_TAB";//$NON-NLS-1$ + + + /** + * Context sensitive help id to API Query properties tab + */ + public static final String API_QUERY_HELP_PROPERTIES_TAB = + API_QUERY_HELP_PROJECT_PLUGIN_ID +".API_QUERY_HELP_PROPERTIES_TAB";//$NON-NLS-1$ + + + + + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/job/ActiveProjectQueryJob.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/job/ActiveProjectQueryJob.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,732 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.job; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Collection; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Set; +import java.util.SortedMap; +import java.util.TreeMap; +import java.util.Vector; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; + +import com.nokia.s60tools.apiquery.popup.actions.CheckProjectReport; +import com.nokia.s60tools.apiquery.settings.UserSettings; +import com.nokia.s60tools.apiquery.shared.datatypes.APIDetails; +import com.nokia.s60tools.apiquery.shared.datatypes.APIQueryParameters; +import com.nokia.s60tools.apiquery.shared.datatypes.APIShortDescription; +import com.nokia.s60tools.apiquery.shared.datatypes.APIShortDescriptionSearchResults; +import com.nokia.s60tools.apiquery.shared.exceptions.QueryOperationFailedException; +import com.nokia.s60tools.apiquery.shared.job.AbstractJob; +import com.nokia.s60tools.apiquery.shared.job.JobCancelledByUserException; +import com.nokia.s60tools.apiquery.shared.resources.Messages; +import com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension; +import com.nokia.s60tools.apiquery.shared.util.SourceCodeParsingUtilities; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.apiquery.shared.util.xml.XMLUtils; +import com.nokia.s60tools.apiquery.ui.views.main.MainView; +import com.nokia.s60tools.util.console.IConsolePrintUtility; +import com.nokia.s60tools.util.debug.DbgUtility; + +/** + * This class implements the Job for Active project query. + * + */ +public class ActiveProjectQueryJob extends AbstractJob { + + private static final String HEADERS_SEPARATOR = ","; //$NON-NLS-1$ + + // + //Researched values for indicating progress persentages in different steps + // + private static final int PROGRESS_STEP_1_PERCENTAGE = 5; + private static final int PROGRESS_STEP_2_PERCENTAGE = 10; + private static final int PROGRESS_STEP_3_PERCENTAGE = 70; + private static final int PROGRESS_STEP_4_PERCENTAGE = 95; + + /** + * File types count in for project search + */ + public static final String [] FILE_TYPES={"c", "cpp", "h", "hpp", "inl"};//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + /** + * File types count in for project search + */ + private Vector fileTypes; + /** + * File types count in for #include statements + */ + public static final String [] INCLUDE_TYPES={"h", "hpp"}; //$NON-NLS-1$ //$NON-NLS-2$ + /** + * File types count in for #include statements + */ + private Vector includeTypes; + /** + * Ingnoring folders named for project search + */ + public static final String [] IGNORE_FOLDERS={"tsrc", "internal"}; //$NON-NLS-1$ //$NON-NLS-2$ + /** + * Ingnoring folders named for project search + */ + private Vector ignoreFolders; + + /** + * + * HashMap containing information of used headers in this project + * as String (header name) and Vector (files including that header) + * containig information of what files is using that header () + */ + private HashMap>headersUsedInFiles; + + /** + * filenames in project in lover case + */ + private Vector projectFileNames; + + + /** + * Collection to store returned API names and headers in those APIs + * header name, API name + */ + Hashtable headerBelongsToAPI ; + + /** + * Path where exported file will be located + */ + private IPath exportFilePath; + + /** + * Exported file + */ + private IFile generatedReportFile; + + + /** + * Project for making the query for. + */ + private final IProject selectedProject; + + /** + * Semi-colon separated headers found in project files, search string + */ + private String searchString; + + /** + * + * @param name Jobs name + * @param selectedProject Project for making the query for. + * @param exportFilePath Path where exported file will be located + */ + public ActiveProjectQueryJob(String name, IProject selectedProject, IPath exportFilePath) { + super(name); + this.selectedProject = selectedProject; + this.exportFilePath = exportFilePath; + + //Init lists + init(); + } + + /** + * Initing headersUsedInFiles, projectFileNames, headerBelongsToAPI, + * fileTypes, includeTypes and ignoreFolders + * + */ + private void init() { + + headersUsedInFiles = new HashMap>(); + projectFileNames = new Vector(); + headerBelongsToAPI = new Hashtable(); + + fileTypes = new Vector(FILE_TYPES.length); + for (int i = 0; i < FILE_TYPES.length; i++) { + fileTypes.add(FILE_TYPES[i]); + } + + includeTypes = new Vector(INCLUDE_TYPES.length); + for (int i = 0; i < INCLUDE_TYPES.length; i++) { + includeTypes.add(INCLUDE_TYPES[i]); + } + + ignoreFolders = new Vector(IGNORE_FOLDERS.length); + for (int i = 0; i < IGNORE_FOLDERS.length; i++) { + ignoreFolders.add(IGNORE_FOLDERS[i]); + } + } + + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) + */ + protected IStatus run(IProgressMonitor monitor) { + + IStatus status; + + setMonitor(monitor); + ActiveProjectQueryJobManager.getInstance().registerJob(this); + APIQueryConsole.getInstance().println(Messages.getString("ActiveProjectQueryJob.StartingToRun_Msg") + super.getName(), //$NON-NLS-1$ + IConsolePrintUtility.MSG_NORMAL); + + try { + + //Start to do actual job + status = doQuery(); + + } catch (Exception e) { + e.printStackTrace(); + status = new Status(IStatus.ERROR, this.getName(), IStatus.ERROR, + Messages.getString("ActiveProjectQueryJob.ErrorsOnJob_ErrMsg") + this.getName(), e); //$NON-NLS-1$ + } + + return status; + + } + + + /** + * Doing actual API Query + * @return status how we succeeded + */ + private IStatus doQuery() { + +// disable datasouce selection + MainView.enablePropTabcontents(false); + + getMonitor().beginTask(Messages.getString("ActiveProjectQueryJob.TaskStarted_Msg") , steps); //$NON-NLS-1$ + APIQueryConsole.getInstance().println(Messages.getString("ActiveProjectQueryJob.APIQueryForProject_Msg") +getProjectName() +Messages.getString("ActiveProjectQueryJob.APIQueryForProject_OnProgress_Part2_Msg"), IConsolePrintUtility.MSG_NORMAL); //$NON-NLS-1$ //$NON-NLS-2$ + + IStatus status = null; + + try { + // Get files from p + IFile [] files = getProjectFiles(); + + progress(PROGRESS_STEP_1_PERCENTAGE, Messages.getString("ActiveProjectQueryJob.Progresbar_Step1_Msg")); //$NON-NLS-1$ + foundHeadersFromFiles(files); + + //Generate search string (header1.h;header2.h;...) + searchString = generateSearchString(); + + + progress(PROGRESS_STEP_2_PERCENTAGE, Messages.getString("ActiveProjectQueryJob.Progresbar_Step2_Msg")); //$NON-NLS-1$ + + + APIShortDescriptionSearchResults projectUsingAPIs = getAPIShortDescriptions(APIQueryParameters.QUERY_BY_HEADER_NAME); + + // Did we succeed? + if(projectUsingAPIs.getSearchResults() != null){ + + // Something failed, e.g. no servers configured. + if(projectUsingAPIs.hasErrors()){ + String errMsg = Messages.getString("ActiveProjectQueryJob.APIQueryFailed_ErrMsg") +"\n" + projectUsingAPIs.getErrorMessages(); //$NON-NLS-1$ //$NON-NLS-2$ + throw new QueryOperationFailedException(errMsg); + } + + progress(PROGRESS_STEP_3_PERCENTAGE, Messages.getString("ActiveProjectQueryJob.Progresbar_Step3_Msg")); //$NON-NLS-1$ + + //Getting details for all used APIs + /** + * Collection for APIDetails used in selected project. API Name as key. + */ + Hashtable projectUsingAPIDetails = getAPIDetails(projectUsingAPIs.getSearchResults()); + + progress(PROGRESS_STEP_4_PERCENTAGE, Messages.getString("ActiveProjectQueryJob.Progresbar_Step4_Msg")); //$NON-NLS-1$ + + //Get detailed information of apis + findHeadersFromAPIs(projectUsingAPIDetails); + String report = generateReport(projectUsingAPIDetails); + generatedReportFile = doSave(report); + + status = Status.OK_STATUS; + } + else{ + status = new Status(IStatus.ERROR, this.getName(), IStatus.ERROR, + Messages.getString("ActiveProjectQueryJob.ErrorsOnJob_ErrMsg") + Messages.getString("ActiveProjectQueryJob.CouldNotGetAPISUmmaries_ErrMsg"), null); //$NON-NLS-1$ //$NON-NLS-2$ + } + + progress(PROGRESS_COMPLETED_PERCENTAGE,Messages.getString("ActiveProjectQueryJob.Progresbar_Done_Msg")); //$NON-NLS-1$ + APIQueryConsole.getInstance().println(Messages.getString("ActiveProjectQueryJob.APIQueryForProject_Msg") +getProjectName() +Messages.getString("ActiveProjectQueryJob.APIQueryForProject_Compeleated_Msg"), IConsolePrintUtility.MSG_NORMAL); //$NON-NLS-1$ //$NON-NLS-2$ + + //If we get some results, but there was also some errors + if(projectUsingAPIs.hasErrors()){ + status = new Status(IStatus.WARNING, this.getName(), IStatus.ERROR, + projectUsingAPIs.getErrorMessages(), null); + } + + } catch (JobCancelledByUserException e) { + status = new Status(IStatus.CANCEL, this.getName(), IStatus.CANCEL, + e.getMessage(), e); + + } catch (CoreException e) { + status = new Status(IStatus.ERROR, this.getName(), IStatus.ERROR, + Messages.getString("ActiveProjectQueryJob.ErrorsOnJob_ErrMsg") + e.getMessage(), e); //$NON-NLS-1$ + e.printStackTrace(); + } catch (IOException e) { + status = new Status(IStatus.ERROR, this.getName(), IStatus.ERROR, + Messages.getString("ActiveProjectQueryJob.ErrorsOnJob_ErrMsg") + e.getMessage(), e); //$NON-NLS-1$ + e.printStackTrace(); + } + catch (Exception e) { + status = new Status(IStatus.ERROR, this.getName(), IStatus.ERROR, + Messages.getString("ActiveProjectQueryJob.ErrorsOnJob_ErrMsg") + e.getMessage(), e); //$NON-NLS-1$ + e.printStackTrace(); + } + finally{ + getMonitor().done(); + // enable data source selection + MainView.enablePropTabcontents(true); + } + + return status; + + } + + /** + * Searching headers from project files, using this.handleOneFile for each file + * @param files + * @throws JobCancelledByUserException + * @throws CoreException + * @throws IOException + */ + private void foundHeadersFromFiles(IFile[] files) throws JobCancelledByUserException, CoreException, IOException { + + for (int i = 0; i < files.length; i++) { + IFile file = files[i]; + InputStream in = file.getContents(); + String [] fileIncludeLines = getFileIncludeLines(in); + in.close(); + + handleOneFile(fileIncludeLines, file); + + } + + } + + /** + * Gets search String, semi colon (;) separated list of + * includes found in project + * @return + */ + private String generateSearchString() { + StringBuffer search = new StringBuffer(); + String incl; + for (Iterator it = headersUsedInFiles.keySet().iterator(); it.hasNext();) { + incl = it.next().trim(); + search.append(incl); + search.append(APIQueryParameters.SEARCH_ITEM_SEPARATOR_CHAR); + } + return search.toString(); + } + + /** + * Found all includes from file. Using this.addOneHeaderToIncludes to set includes. + * @param fileIncludeLines + */ + private void handleOneFile(String [] fileIncludeLines, IFile file) { + String line; + for (int i = 0; i < fileIncludeLines.length; i++) { + line = fileIncludeLines[i]; + //If it's a system include <> + if(line != null && line.trim().length() > 0){ + String include = SourceCodeParsingUtilities.parseIncludeFromLine(line); + if(include != null){ + addOneHeaderToIncludes(include, file); + } + + } + } + } + + /** + * Adds one header to this.includes + * if include filetype matches INCLUDE_TYPES (this.includeTypes) + * And header is not one of project files (this.projectFiles) + * @param header + * @param fileName + */ + private void addOneHeaderToIncludes(String header, IFile file) { + //if user using wrong way SYSTEMINCLUDE and USERINCLUDE + //a system header can be really a user include and vice versa + if(includeTypes.contains( + header.substring(header.indexOf(".") +1))//$NON-NLS-1$ + && !projectFileNames.contains(header.toLowerCase())) + { + //If a header is already found and added to includes + //get Vector where is files using this header and add + //this file to that file list + if(headersUsedInFiles.containsKey(header)){ + Vector usedInFiles = headersUsedInFiles.get(header); + usedInFiles.add(file); + headersUsedInFiles.put(header, usedInFiles); + } + //if this was first time founding this header, creating new + //Vector and add current file to it and add this set to includes + else{ + Vector usedInFiles = new Vector(); + usedInFiles.add(file); + headersUsedInFiles.put(header, usedInFiles); + } + } + } + + + + + /** + * Found all files (file type is one of this.FILE_TYPES) + * from project where this.selectedFile belongs + * @return + * @throws CoreException + */ + private IFile[] getProjectFiles() throws CoreException{ + + Vector projectFiles = new Vector(); + IResource [] resources = selectedProject.members(); + //Seek the project and found all files + searchFiles(projectFiles, resources); + IFile [] files = projectFiles.toArray(new IFile[0]); + return files; + + } + + /** + * Search recursively all files from resource. If a resource is + * a IFolder calls recursively it self to found all files under that + * folder. Ignoring this.IGNORE_FOLDERS (tsrc and internal) folders. + * + * Adds all files to Vector this.projectFiles if file type found from + * this.FILE_TYPES + * + * Saves fileNames to this.projectFileNames + * + * @param resources + * @throws CoreException + */ + private void searchFiles(Vector v, IResource[] resources) throws CoreException { + + for (int i = 0; i < resources.length; i++) { + if(resources[i] instanceof IFile){ + IFile file = (IFile)resources[i]; + if( fileTypes.contains( file.getFileExtension() ) ){ + v.add(file); + projectFileNames.add(file.getName().toLowerCase()); + } + } + else if(resources[i] instanceof IFolder){ + IFolder folder = (IFolder)resources[i]; + //Ignorin tsrc and internal folders, so headers from those + //folders is not included to search + if(!ignoreFolders.contains(folder.getName().toLowerCase())){ + searchFiles(v, folder.members()); + } + } + } + } + + /** + * Get lines from stream containing #include in the line, + * ingnoring all other lines. + * @param is + * @return String[] of lines, each of them contains #include + * @throws CoreException + * @throws IOException + */ + private String [] getFileIncludeLines(InputStream is) throws CoreException, + IOException { + + Vector lines = new Vector(); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader br = new BufferedReader(isr); + String line; + String include = "#include";//$NON-NLS-1$ + while ((line = br.readLine()) != null) { + if(line.contains(include)){ + lines.add(line); + } + } + // Closing buffers + br.close(); + isr.close(); + return lines.toArray(new String[0]); + } + + public String getSearchString() { + return this.searchString; + } + + + /** + * + * HashMap containing information of used headers in this project + * as String and Vector containig information + * of what files is using that header () + * + * @return HashMap> where String is header name + * and Vector contains file names what includes that header + */ + + public HashMap> getHeadersUsedInFiles() { + return headersUsedInFiles; + } + + /** + * Starts query for the current identifier selection with + * the given query type. + * @param queryType + * @throws JobCancelledByUserException + * @throws CoreException + * @throws IOException + */ + private APIShortDescriptionSearchResults getAPIShortDescriptions(final int queryType) throws JobCancelledByUserException, CoreException, IOException{ + + String msg = Messages.getString("ActiveProjectQueryJob.Starting_Part1_Msg") //$NON-NLS-1$ + + APIQueryParameters.getDescriptionForQueryType(queryType) + + Messages.getString("ActiveProjectQueryJob.Starting_Part2_Msg") //$NON-NLS-1$ + + selectedProject.getName()+ Messages.getString("ActiveProjectQueryJob.Starting_Part3_Msg") //$NON-NLS-1$ + +this.searchString + "'.";//$NON-NLS-1$ + DbgUtility.println(DbgUtility.PRIORITY_CLASS, msg); + APIQueryConsole.getInstance().println(msg, + IConsolePrintUtility.MSG_NORMAL); + + final APIQueryParameters params = new APIQueryParameters(queryType, searchString); + params.setQueryFromUI(false); + + ISearchMethodExtension currSelExt = UserSettings.getInstance().getCurrentlySelectedSearchMethod(); + + APIShortDescriptionSearchResults projectUsingAPIs = currSelExt.runAPIQuery(params); + return projectUsingAPIs; + + } + + + /** + * put headername - API name pairs to this.headerBelongsToAPI + * @param projectUsingAPIDetails Find headers from all APIs from table given + * @throws JobCancelledByUserException + */ + private void findHeadersFromAPIs(Hashtable projectUsingAPIDetails) throws JobCancelledByUserException { + String headersStr; + String [] headersTbl; + String headerName; + + Vector headers; + + Set keys = projectUsingAPIDetails.keySet(); + //Looping all received API Summarys + + for (Iterator iter = keys.iterator(); iter.hasNext();) { + String api = (String) iter.next(); + if(api == null){ + continue; + } + APIDetails details = projectUsingAPIDetails.get(api); + + + if(details != null){ + + //Splitting headers string eg. "header1.h, header2.h" to table {"header1.h", header2.h} + //And putting those values to Vector + headersStr = details.getDetail(XMLUtils.DESCRIPTION_HEADERS).getValue(); + headersTbl = headersStr.split(HEADERS_SEPARATOR); + headers = new Vector(headersTbl.length); + for (int i = 0; i < headersTbl.length; i++) { + headerName = headersTbl[i].trim(); + headers.add(headerName); + //Putting "header1.h", API Name" to used header and APIs, same API Name will be several time in map + headerBelongsToAPI.put(headerName.toLowerCase(), api); + } + //Putting API used with all headers API contais to table + + } + //When error occurs (there is no Details for API) just printing to console that there was no details + //This should not be happend so often (if never), but if occurs from time to time, checkin implementation + //and/or adding more error situation handling might needed. + else{ + DbgUtility.println(DbgUtility.PRIORITY_CLASS, "Can't found or parse details for API: " +api );//$NON-NLS-1$ + APIQueryConsole.getInstance().println(Messages.getString("ActiveProjectQueryJob.NoDetailsForAPI_Msg") +api, //$NON-NLS-1$ + IConsolePrintUtility.MSG_NORMAL); + + } + } + } + + /** + * Getting API Details from selected search method + * @param apis + * @return + * @throws QueryOperationFailedException + */ + private Hashtable getAPIDetails(Collection apis) throws QueryOperationFailedException { + ISearchMethodExtension currSelExt = UserSettings.getInstance().getCurrentlySelectedSearchMethod(); + Hashtable details = currSelExt.getAPIDetails(apis); + return details; + } + + + /** + * Putting pieces together. Collecting needed data from headersUsedInFiles and + * headerBelongsToAPI to send for CheckProjectReport + * @return + * @throws CoreException + * @throws IOException + */ + private String generateReport(Hashtable projectUsingAPIDetails) throws CoreException, IOException{ + + + //API Name and headers what is used for that API in searched project + SortedMap>usedHeaders = new TreeMap>(); + //API Name and files in searched project that is using that API + Hashtable>usingFiles = new Hashtable>(); + + + Set headersUsedInProject = headersUsedInFiles.keySet(); + Vector tmpUsedHeaders; + Vector tmpUsingFiles; + String tmpAPIName; + int unknownAPIIndex = 0; + + + for (String header : headersUsedInProject) { + //API where this header belongs, was found with selected search method + if(headerBelongsToAPI.containsKey(header.toLowerCase())){ + tmpAPIName = headerBelongsToAPI.get(header.toLowerCase()); + //If current API is allready added to usedHeaders, just adding one + //header that is using that API to collection + if(usedHeaders.containsKey(tmpAPIName)){ + + tmpUsedHeaders = usedHeaders.get(tmpAPIName); + if(!tmpUsedHeaders.contains(header.toLowerCase())){ + tmpUsedHeaders.add(header.toLowerCase()); + } + usedHeaders.put(tmpAPIName, tmpUsedHeaders); + + tmpUsingFiles = usingFiles.get(tmpAPIName); + tmpUsingFiles.addAll(headersUsedInFiles.get(header)); + usingFiles.put(tmpAPIName, tmpUsingFiles); + } + //Else this is first time for this API, so creating new Vectors to put in maps + else{ + tmpUsedHeaders = new Vector(); + if(!tmpUsedHeaders.contains(header.toLowerCase())){ + tmpUsedHeaders.add(header.toLowerCase()); + } + usedHeaders.put(tmpAPIName, tmpUsedHeaders); + + tmpUsingFiles = new Vector(); + tmpUsingFiles.addAll(headersUsedInFiles.get(header)); + usingFiles.put(tmpAPIName, tmpUsingFiles); + } + } + //Else API for this header cannot be found, setting it as "Unknown" API + else{ + tmpAPIName = CheckProjectReport.UNKNOWN_API_NAME + +CheckProjectReport.UNKNOWN_API_NAME_SEPARATOR + +unknownAPIIndex; + unknownAPIIndex ++; + tmpUsedHeaders = new Vector(); + tmpUsedHeaders.add(header); + usedHeaders.put(tmpAPIName, tmpUsedHeaders); + + tmpUsingFiles = new Vector(); + tmpUsingFiles.addAll(headersUsedInFiles.get(header)); + usingFiles.put(tmpAPIName, tmpUsingFiles); + } + } + + + ISearchMethodExtension searchMethod = UserSettings.getInstance().getCurrentlySelectedSearchMethod(); + //API Details to be added for report, parameters are given so it can be checked if Collection/Subsystem header topic are found to be added to report + String [] apiDetailsToReport = searchMethod.getAPIDetailsToReport(usedHeaders.keySet(), projectUsingAPIDetails); + CheckProjectReport report = new CheckProjectReport(usedHeaders, usingFiles, projectUsingAPIDetails, apiDetailsToReport, selectedProject); + + return report.toHTML(getTitle()); + + } + + /** + * Save the report + * @param html + * @return + * @throws CoreException + * @throws IOException + */ + private IFile doSave(String html) throws CoreException, IOException{ + String containerName = exportFilePath.removeLastSegments(1).toOSString(); + String fileName = exportFilePath.lastSegment(); + + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IResource resource = root.findMember(new Path(containerName)); + + IContainer container = (IContainer) resource; + final IFile file = container.getFile(new Path(fileName)); + //Creating temp file because given API name must be found + InputStream stream = new ByteArrayInputStream(html.getBytes()); + if (file.exists()) { + file.setContents(stream, true, true, null); + } else { + file.create(stream, true, null); + } + stream.close(); + return file; + + } + + /** + * get title to exported report header + * @return title + */ + private String getTitle(){ + String title = Messages.getString("ActiveProjectQueryJob.Title_Project_Msg") +getProjectName() +Messages.getString("ActiveProjectQueryJob.Title_IsUsingFollowingAPIs_Msg"); //$NON-NLS-1$ //$NON-NLS-2$ + return title; + } + + /** + * Get project name where report was saved + * @return project name + */ + private String getProjectName() { + return selectedProject.getName(); + } + + /** + * Get report file + * @return file generated + */ + public IFile getGeneratedReportFile() { + return generatedReportFile; + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/job/ActiveProjectQueryJobManager.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/job/ActiveProjectQueryJobManager.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,130 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.job; + +import java.util.ArrayList; +import java.util.Iterator; + +import org.eclipse.core.runtime.ListenerList; + +import com.nokia.s60tools.apiquery.shared.job.IJobCompletionListener; +import com.nokia.s60tools.apiquery.shared.job.IManageableJob; + + + +/** + * Singleton class that is created on plugin + * startup, and is kept active as long as plugin is active. + * + * The purpose of this class is to enable shutdown of all + * ongoing jobs on forced shutdown. All the jobs implementing + * IManageableJob should register itself to + * this class and deregister when completed. + */ +public class ActiveProjectQueryJobManager { + + /** + * Singleton instance. + */ + static private ActiveProjectQueryJobManager instance = null; + + /** + * List of registered jobs. + */ + private ArrayList registeredJobs = null; + + /** + * Listeners interested in job completions operations. + */ + private ListenerList listeners = null; + + /** + * Public Singleton instance accessor. + * @return Returns instance of this singleton class- + */ + public static ActiveProjectQueryJobManager getInstance(){ + if( instance == null ){ + instance = new ActiveProjectQueryJobManager(); + } + return instance; + } + + /** + * Private default constructor. + */ + private ActiveProjectQueryJobManager() { + registeredJobs = new ArrayList(); + listeners = new ListenerList(); + } + + /** + * Register job to manager + * @param job + */ + void registerJob(IManageableJob job){ + registeredJobs.add(job); + } + + /** + * Un register a job from manager + * @param job + */ + void unregisterJob(IManageableJob job){ + registeredJobs.remove(job); + Object[] listenerArray = listeners.getListeners(); + for (int i = 0; i < listenerArray.length; i++) { + IJobCompletionListener listenerObj + = (IJobCompletionListener) listenerArray[i]; + listenerObj.backgroundJobCompleted(job); + } + } + + /** + * Shutdown all jobs registerd + */ + public void shutdown(){ + for (Iterator iter = registeredJobs.iterator(); iter.hasNext();) { + IManageableJob job = (IManageableJob) iter.next(); + job.forcedShutdown(); + } + registeredJobs.clear(); + // Giving a moment for processes to really shutdwown + try { + Thread.sleep(500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + /** + * Add a listener + * @param listener + */ + public void addListener(IJobCompletionListener listener){ + listeners.add(listener); + } + + /** + * Remove a listener + * @param listener + */ + public void removeListener(IJobCompletionListener listener){ + listeners.remove(listener); + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/popup/actions/CheckIdentifierAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/popup/actions/CheckIdentifierAction.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,390 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.popup.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IRegion; +import org.eclipse.jface.text.TextSelection; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.swt.SWT; +import org.eclipse.ui.IActionDelegate; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.editors.text.TextEditor; +import org.eclipse.ui.editors.text.TextFileDocumentProvider; +import org.eclipse.ui.forms.editor.FormEditor; +import org.eclipse.ui.texteditor.ITextEditor; + +import com.nokia.s60tools.apiquery.shared.datatypes.APIQueryParameters; +import com.nokia.s60tools.apiquery.shared.exceptions.QueryOperationFailedException; +import com.nokia.s60tools.apiquery.shared.resources.Messages; +import com.nokia.s60tools.apiquery.shared.ui.dialogs.APIQueryMessageBox; +import com.nokia.s60tools.apiquery.shared.util.SourceCodeParsingUtilities; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.apiquery.ui.views.main.MainView; +import com.nokia.s60tools.util.console.IConsolePrintUtility; +import com.nokia.s60tools.util.debug.DbgUtility; + +/** + * Runs API query on the identifier that user has selected from an editor. + */ +public class CheckIdentifierAction implements IObjectActionDelegate{ + + // + // Static members + // + + /** + * Common ID path for the all identifier actions + */ + private static final String ACTION_ID_PATH = "com.nokia.s60tools.apiquery.popup.actions.CheckIdentifierAction."; //$NON-NLS-1$ + + /** + * Actions ID for + */ + private static final String FOR_CPRS_KEY_NAME_ID = ACTION_ID_PATH + "CRPSKey"; //$NON-NLS-1$ + + /** + * Actions ID for + */ + private static final String FOR_LIB_NAME_ID = ACTION_ID_PATH + "LIBName"; //$NON-NLS-1$ + + /** + * Actions ID for + */ + private static final String FOR_HEADER_NAME_ID = ACTION_ID_PATH + "HeaderName"; //$NON-NLS-1$ + + // + // Non-static members + // + + /** + * The identifier that user has selected for the query, or multiple + * identifiers separated with ; character. + */ + private String queryString; + + + + /** + * Constructor for Action1. + */ + public CheckIdentifierAction() { + super(); + } + + /** + * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) + */ + public void setActivePart(IAction action, IWorkbenchPart targetPart) { + } + + /** + * @see IActionDelegate#run(IAction) + */ + public void run(IAction action) { + // Resolving the correct query type + if (action.getId().equals(FOR_CPRS_KEY_NAME_ID)){ + startQuery(APIQueryParameters.QUERY_BY_CRPS_KEY_NAME); + } else if (action.getId().equals(FOR_LIB_NAME_ID)){ + startQuery(APIQueryParameters.QUERY_BY_LIB_NAME); + } else if (action.getId().equals(FOR_HEADER_NAME_ID)){ + startQuery(APIQueryParameters.QUERY_BY_HEADER_NAME); + } + else //if (action.getId().equals(FOR_HEADER_NAME_ID)) + { + startQuery(APIQueryParameters.QUERY_BY_API_NAME); + } + } + + + /** + * @see IActionDelegate#selectionChanged(IAction, ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + + // By default the action is disables + boolean isActionEnabled = false; + + try { + if(selection != null){ + + // Parameter 'selection' is actually File-object instance + // of the selected file, but we are interested instead if + // We have an open editor, and text selection in there. + + IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + IEditorPart activeEditor = activePage.getActiveEditor(); + //Active editor can be Text Editor or FormEditor, in case of FormEditor it's really + //com.nokia.carbide.cpp.mmpEditor.MMPEditor, but that Class cannot be used outside of that package. + if(activeEditor != null && (activeEditor instanceof TextEditor || activeEditor instanceof FormEditor)){ + + ISelectionProvider selectionProvider = activeEditor.getSite().getSelectionProvider(); + + ISelection textSel = selectionProvider.getSelection(); + if(textSel instanceof TextSelection){ + TextSelection currEditorTextSel = (TextSelection) textSel; + int endLine = currEditorTextSel.getEndLine(); + int startLine = currEditorTextSel.getStartLine(); + boolean isMultipleLinesSelection = ((endLine - startLine) > 0); + String currSelStr = currEditorTextSel.getText().toString().trim(); + + // Header name action is a special case among the other actions + if (action.getId().equals(FOR_HEADER_NAME_ID)){ + + IDocument doc = null; + if(activeEditor instanceof TextEditor){ + // This is actually an instance of 'org.eclipse.cdt.internal.ui.editor.CEditor' + // that extends org.eclipse.ui.editors.text.TextEditor + TextEditor cEditor = (TextEditor) activeEditor; + doc = getDocument(cEditor); + }else if(activeEditor instanceof FormEditor){ + // This is actually an instance of com.nokia.carbide.cpp.mmpEditor.MMPEditor, + // but that Class cannot be used outside of that package, and it extends FormEditor class. + FormEditor fEditor = (FormEditor)activeEditor; + doc = getDocument(fEditor); + } + isActionEnabled = handleHeaderNameActionStateCheck(doc, startLine, isMultipleLinesSelection, currSelStr); + } + // Other action types get same kind of treatment. + else{ + isActionEnabled = handleStateCheckForOtherActions(isMultipleLinesSelection, currSelStr); + } + + } // if a text selection intance + } // if activeEditor is not null + }// if selection is not null + + } catch (Exception e) { + // Just making easier to find out problems during dev. time. + e.printStackTrace(); + } + + // Enabling/disabling the action + action.setEnabled(isActionEnabled); + + } + + /** + * Checks the enable/disable state for other actions. + * @param isMultipleLinesSelection true in case of multiline selection, otherwise false. + * @param currSelStr User's text selection from the editor. + * @return Action's enablement state. + */ + private boolean handleStateCheckForOtherActions(boolean isMultipleLinesSelection, String currSelStr) { + + boolean isActionEnabled = false; + + // For other actions, the valid selection is not empty + // and not a selection of multiple lines. + if(currSelStr.length() > 0 + && + !isMultipleLinesSelection + ){ + // We have a valid selection => let's store it... + this.queryString = currSelStr; + // ... and enable the action. + isActionEnabled = true; + } + return isActionEnabled; + } + + /** + * Checks the enable/disable state for header name action. + * @param cEditor Text editor instance user for browsing editor contents, if needed. + * @param startLine Start line for the curren selection (=line for current cursor location). + * @param isMultipleLinesSelection true in case of multiline selection, otherwise false. + * @param currSelStr User's text selection from the editor. + * @return Action's enablement state. + */ + private boolean handleHeaderNameActionStateCheck(IDocument doc, int startLine, boolean isMultipleLinesSelection, String currSelStr) { + + boolean isActionEnabled = false; + + // Checking if we have a selection containing text + if( currSelStr.length() > 0){ + if(isMultipleLinesSelection){ + // Parsing multiline selection for directives + if(checkSelectionForIncludeDirectives(currSelStr)){ + isActionEnabled = true; + } + } + else{ + // Otherwise regarding the selection as an identifier. + queryString = currSelStr; + isActionEnabled = true; + } + } + else{ + // There is no selection made => parsing the current line + if(doc != null){ + // Does the line contain any include directives? + if(checkForIncludeDirectiveFromGivenLine(doc, startLine)){ + isActionEnabled = true; + } + } + } + return isActionEnabled; + } + + /** + * Checks if there is/are (an) include directive(s) in the given text selection + * and stores the header names as the selected identifier(s). + * @param selectedMultilineText Selected text to check for (may contain multiple lines) + * @return true if a valid include definitions were stored. + */ + private boolean checkSelectionForIncludeDirectives(String selectedMultilineText) { + + boolean hasIncludeDirectives = false; + + String[] lineArr = selectedMultilineText.split("\n"); //$NON-NLS-1$ + String headerFileName = null; + // Resettings the identifier storage string + queryString = ""; //$NON-NLS-1$ + + for (int i = 0; i < lineArr.length; i++) { + String line = lineArr[i]; + headerFileName = SourceCodeParsingUtilities.parseIncludeFromLine(line); + if(headerFileName != null){ + hasIncludeDirectives = true; + // Incrementing the found directive into the identifier list + if(queryString.length() > 0){ + queryString = queryString + + APIQueryParameters.SEARCH_ITEM_SEPARATOR_CHAR + + headerFileName; + } + else{ + queryString = headerFileName; + } + } + } + return hasIncludeDirectives; + } + + /** + * Checks if there is an include directive in the given line + * and stores the header name as the selected identifier. + * @param doc Document to check for. + * @param lineno Line number in document to check for. + * @return true if a valid include definitions was stored + */ + private boolean checkForIncludeDirectiveFromGivenLine(IDocument doc, int lineno) { + + IRegion lineRegion; + try { + lineRegion = doc.getLineInformation(lineno); + String line = doc.get(lineRegion.getOffset(), lineRegion.getLength()); + + if(SourceCodeParsingUtilities.hasIncludes(line)){ + queryString = SourceCodeParsingUtilities.parseIncludeFromLine(line); + return true; + } + } catch (BadLocationException e) { + // Ignoring possible bad location exceptions + // when this method returns false. + } + + return false; + } + + /** + * Returns the document interface for the currently active document + * in the given editor. + * @param editor Editor to ask currently active document from. + * @return Document interface if found, otherwise null. + */ + private IDocument getDocument(TextEditor editor) { + + TextFileDocumentProvider documentProvider = (TextFileDocumentProvider) editor.getDocumentProvider(); + if(documentProvider != null){ + return documentProvider.getDocument(editor.getEditorInput()); + } + return null; + } + + /** + * Returns the document interface for the currently active document + * in the given editor. + * @param editor Editor to ask currently active document from. + * @return Document interface if found, otherwise null. + */ + private IDocument getDocument(FormEditor editor) { + try { + IEditorPart part = editor.getActiveEditor(); + ITextEditor textEditor = (ITextEditor) part; + + TextFileDocumentProvider documentProvider = (TextFileDocumentProvider) textEditor.getDocumentProvider(); + if(documentProvider != null){ + return documentProvider.getDocument(editor.getEditorInput()); + } + } catch (Exception e) { + // No operation if fails, just returning null, if document is null, false will return from handleHeaderNameActionStateCheck(...) + e.printStackTrace(); + } + return null; + } + + /** + * Starts query for the current identifier selection with + * the given query type. + * @param queryType + */ + private void startQuery(int queryType){ + startQuery(queryType, false); + } + + /** + * Starts query for the current identifier selection with + * the given query type. + * @param queryType + * @param useExactMatch true if search string will be searched with exact match + * instead of contains. + */ + private void startQuery(int queryType, boolean useExactMatch){ + DbgUtility.println(DbgUtility.PRIORITY_CLASS, "Starting '" //$NON-NLS-1$ + + APIQueryParameters.getDescriptionForQueryType(queryType) + + "' query with identifier '" //$NON-NLS-1$ + + this.queryString + "'."); //$NON-NLS-1$ + try { + MainView.runAPIQueryFromExternalClass(queryType, this.queryString, useExactMatch); + } catch (QueryOperationFailedException e) { + e.printStackTrace(); + String errMsg = Messages.getString("CheckIdentifierAction.Query_Failed_From_Context_Menu_ErrorMsg") + e.getMessage(); //$NON-NLS-1$ + APIQueryConsole.getInstance().println(errMsg, IConsolePrintUtility.MSG_ERROR); + new APIQueryMessageBox(errMsg, SWT.ICON_ERROR | SWT.OK).open(); + } + } + + + /** + * Run API Query action directly with using action class. + * @param quertString queried string + * @param queryType query type + */ + public void runAPIQuery(String quertString, int queryType) { + this.queryString = quertString; + startQuery(queryType, true); + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/popup/actions/CheckProjectAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/popup/actions/CheckProjectAction.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,326 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.popup.actions; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.IJobChangeListener; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.SaveAsDialog; +import org.eclipse.ui.ide.IDE; + +import com.nokia.s60tools.apiquery.job.ActiveProjectQueryJob; +import com.nokia.s60tools.apiquery.servlets.APIQueryWebServerConfigurator; +import com.nokia.s60tools.apiquery.shared.plugin.APIQueryPlugin; +import com.nokia.s60tools.apiquery.shared.resources.Messages; +import com.nokia.s60tools.apiquery.shared.ui.dialogs.APIQueryMessageBox; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.apiquery.ui.dialogs.OpenReportStatusDialog; +import com.nokia.s60tools.util.console.IConsolePrintUtility; + +/** + * Check project action is invoked from API Query > for Active Project popup menu. + * The action finds all the identifier candidates from the project and used them + * to form a query used to figure out which APIs the project is using. This + * action supports only projects with Carbide.c++ project nature. + */ +public class CheckProjectAction implements IObjectActionDelegate, IJobChangeListener { + + + private static final String DEFAULT_EXPORT_FILENAME_SUFFIX = "-project_is_using_APIs.html"; //$NON-NLS-1$ + + /** + * The project that user has selected from a project. + */ + IProject selectedProject; + + + /** + * Constructor. + */ + public CheckProjectAction() { + super(); + + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) + */ + public void setActivePart(IAction action, IWorkbenchPart targetPart) { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public void run(IAction action) { + try { + + final IPath path = openSaveAsDialog(); + if(path == null){ + return ; + } + + //When API Query for project is started, making sure that web server is running + APIQueryWebServerConfigurator.startServer(APIQueryWebServerConfigurator.Active_Project_Start); + + //Creating job, must be running inside of Runnable, because of UI Thread connections + final ActiveProjectQueryJob job = new ActiveProjectQueryJob( + Messages.getString("CheckProjectAction.APIQuery_JobName_Msg")+action.getText() +" (" + getProjectName() //$NON-NLS-1$ //$NON-NLS-2$ + +").", selectedProject, path); //$NON-NLS-1$ + + job.setPriority(Job.DECORATE); + //Cant .join() to job because of deathlock @see .join() documentation. + job.addJobChangeListener(this); + job.reportStartTime(); + //Start to run + job.schedule(); + + } catch (Exception e) { + e.printStackTrace(); + APIQueryConsole.getInstance().println(e.getMessage(), + IConsolePrintUtility.MSG_ERROR); + showErrorDialog(Messages.getString("CheckProjectAction.CannotGenerateReport_ErrMsg") //$NON-NLS-1$ + +getProjectName() +". " +e.getMessage()); //$NON-NLS-1$ + } + } + + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + // Storing the selected file instance used for resolving the active project + StructuredSelection structSel = (StructuredSelection) selection; + Object elem = structSel.getFirstElement(); + if(elem instanceof IProject){ + this.selectedProject = (IProject) elem; + } + else if(elem instanceof IFile){ + this.selectedProject = ((IFile) elem).getProject(); + } + else if(elem instanceof IFolder){ + this.selectedProject = ((IFolder) elem).getProject(); + } + else{ + action.setEnabled(false); + return; + } + action.setEnabled(true); + } + + + /** + * Shows save as dialog and set this.exportFileName + * @return IPath path if fileName was set, null if dialog was not epened or cancel was pushed + * + */ + private IPath openSaveAsDialog() { + Shell shell = APIQueryPlugin.getCurrentlyActiveWbWindowShell(); + SaveAsDialog saveAs = new SaveAsDialog(shell); + IFile file = selectedProject.getFile(getDefaultFileName()); + saveAs.setOriginalFile(file); + + int status = saveAs.open(); + if(status == SaveAsDialog.OK ){ + IPath path = saveAs.getResult(); + if(saveAs.getReturnCode() == SaveAsDialog.OK ){ + return path; + }else{ + return null; + } + } + else{ + return null; + } + } + + + /** + * Asking user if he/she want's to open created file or not + * by opening a Dialog + * @param newFile + * @return + */ + private boolean openRequired(IFile newFile){ + Shell sh = APIQueryPlugin.getCurrentlyActiveWbWindowShell(); + String fileName = newFile.getName(); + OpenReportStatusDialog in = new OpenReportStatusDialog(sh, fileName); + + in.open(); + if( in.getReturnCode() == OpenReportStatusDialog.OK){ + return true; + } + else{ + return false; + } + } + + /** + * Opens generated report to workspace + * @param newFile + * @throws CoreException + */ + private void openReport(final IFile newFile) throws CoreException{ + + if(!openRequired(newFile)){ + return; + } + + final IWorkspace workspace = ResourcesPlugin.getWorkspace(); + //Runnable to open new file + final IWorkspaceRunnable runOpen = new IWorkspaceRunnable() { + public void run(IProgressMonitor monitor) throws CoreException { + // do the actual work in here + + IWorkbenchPage page = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage(); + try { + IDE.openEditor(page, newFile, true); + + } catch (Exception e) { + //PartInitException may occur + e.printStackTrace(); + Status status = new Status(IStatus.ERROR, + "com.nokia.s60tools.apiquery", 0, e.getMessage(), e); //$NON-NLS-1$ + + throw new CoreException(status); + } + + } + }; + workspace.run(runOpen, null, IWorkspace.AVOID_UPDATE, null); + } + + + /** + * get default name export file to + * @return filename + */ + private String getDefaultFileName() { + String name = getProjectName() +DEFAULT_EXPORT_FILENAME_SUFFIX; + return name; + } + + + /** + * get project name + * @return project name + */ + private String getProjectName() { + return selectedProject.getName(); + } + + /** + * Show an error Dialog + * @param errMsg + */ + + private void showErrorDialog(String errMsg) { + APIQueryMessageBox mbox = new APIQueryMessageBox(errMsg, SWT.ICON_ERROR | SWT.OK); + mbox.open(); + } + + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#aboutToRun(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void aboutToRun(IJobChangeEvent event) { + } + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#awake(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void awake(IJobChangeEvent event) { + } + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#running(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void running(IJobChangeEvent event) { + } + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#scheduled(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void scheduled(IJobChangeEvent event) { + } + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#sleeping(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void sleeping(IJobChangeEvent event) { + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#done(org.eclipse.core.runtime.jobs.IJobChangeEvent) + * + * When done, asking if user wants to open created file. If Cancelled, doing nothing, + * if an error occurs, system will show an error dialog. + * + */ + public void done(IJobChangeEvent event) { + + ActiveProjectQueryJob job = (ActiveProjectQueryJob) event.getJob(); + + job.reportEndTime(); + + IStatus status = job.getResult(); + + if(status.getSeverity() == IStatus.OK){ + final IFile file = job.getGeneratedReportFile(); + + + // Must do query in Runnable, because of UI actions from job + Runnable activeProjectQueryJobRunnable = new Runnable() { + public void run() { + try { + openReport(file); + } catch (CoreException e) { + APIQueryConsole.getInstance().println(Messages.getString("CheckProjectAction.UnableToOpenReport_ErrMsg") + e.getMessage(), //$NON-NLS-1$ + IConsolePrintUtility.MSG_ERROR); + e.printStackTrace(); + } + } + }; + + // Showing a visible message has to be done in its own thread + // in order not to cause invalid thread access + Display.getDefault().asyncExec(activeProjectQueryJobRunnable); + + + } + + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/popup/actions/CheckProjectReport.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/popup/actions/CheckProjectReport.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,415 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.popup.actions; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Hashtable; +import java.util.Set; +import java.util.SortedMap; +import java.util.Vector; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; + +import com.nokia.s60tools.apiquery.servlets.APIQueryWebServerConfigurator; +import com.nokia.s60tools.apiquery.servlets.ReportActionConstants; +import com.nokia.s60tools.apiquery.settings.UserSettings; +import com.nokia.s60tools.apiquery.shared.common.ProductInfoRegistry; +import com.nokia.s60tools.apiquery.shared.datatypes.APIDetailField; +import com.nokia.s60tools.apiquery.shared.datatypes.APIDetails; +import com.nokia.s60tools.apiquery.shared.datatypes.APIQueryParameters; +import com.nokia.s60tools.apiquery.shared.plugin.APIQueryPlugin; +import com.nokia.s60tools.apiquery.shared.resources.Messages; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.util.resource.FileUtils; + +/** + * Class representing Actice Project API Query report. + * Initialize by constructor and ask for HTML or CSV -report. + * + */ +public class CheckProjectReport { + + /** + *   + */ + private static final String HTML_WHITE_SPACE = " "; //$NON-NLS-1$ + + /** + * _ + */ + public static final String UNKNOWN_API_NAME_SEPARATOR = "_"; //$NON-NLS-1$ + + /** + * Unknown + */ + public static final String UNKNOWN_API_NAME = Messages.getString("CheckProjectReport.Unknown_MSg"); //$NON-NLS-1$ + + /** + * API name, Headers which is used from that API + */ + private final SortedMap> usedHeaders; + + /** + * API name, Files which is using that API + */ + private final Hashtable> usingFiles; + + /** + * APIs which project is using + */ + private final Hashtable projectUsingAPIDetails; + + /** + * Fields to be added to report from APIDetails besides API Name, Used Headers and Using Files + */ + String [] apiDetailsToReport = null; + + private final IProject selectedProject; + + + + /** + * + * @param usedHeaders + * @param usingFiles + * @param projectUsingAPIDetails APIs which project is using + * @throws IllegalArgumentException if usedHeaders and usingFiles is not same sized or argument is null. + */ + public CheckProjectReport(SortedMap> usedHeaders, + Hashtable> usingFiles, + Hashtable projectUsingAPIDetails, String [] apiDetailsToReport, + IProject selectedProject) + throws IllegalArgumentException + { + if(usedHeaders == null || usingFiles == null || usedHeaders.size() != usingFiles.size()){ + throw new IllegalArgumentException( + Messages.getString("CheckProjectReport.UsedHeader_ErrMsg")); //$NON-NLS-1$ + } + this.usedHeaders = usedHeaders; + this.usingFiles = usingFiles; + this.projectUsingAPIDetails = projectUsingAPIDetails; + this.apiDetailsToReport = apiDetailsToReport; + this.selectedProject = selectedProject; + + } + + + /** + * Generating report as HTML format + * @param title + * @return a report + */ + public String toHTML(String title) { + StringBuffer html = new StringBuffer(); + //Get API Names from used Headers keys + Set apis = usedHeaders.keySet(); + Vector tmpVect; + + //Add HTML header to report + html.append(getHTMLHeader(title)); + String note = Messages.getString("CheckProjectReport.NoteForReportLinks_Msg"); //$NON-NLS-1$ + html.append("

" + note //$NON-NLS-1$ + + "

"); //$NON-NLS-1$ + + html.append(""); //$NON-NLS-1$ + html.append("" ); //$NON-NLS-1$ + //Adding titles to API Details information + for (int i = 0; i < apiDetailsToReport.length; i++) { + html.append(""); //$NON-NLS-1$ + } + + html.append(""); //$NON-NLS-1$ + html.append("\n"); //$NON-NLS-1$ + + String [] detailsToReport ;//For API Details + //Add all APIs used in project to report + for (String api : apis) { + html.append(""); //$NON-NLS-1$ + + tmpVect = usedHeaders.get(api); + html.append("\n"); //$NON-NLS-1$ + } + + html.append("\n\n\n\n"); //$NON-NLS-1$ + } + + html.append("
"); //$NON-NLS-1$ + html.append(Messages.getString("CheckProjectReport.APIName_Msg")); //$NON-NLS-1$ + html.append(""); //$NON-NLS-1$ + html.append(apiDetailsToReport[i]); + html.append("");//$NON-NLS-1$ + html.append(Messages.getString("CheckProjectReport.UsedHeader_Msg")); //$NON-NLS-1$ + html.append("");//$NON-NLS-1$ + html.append(Messages.getString("CheckProjectReport.UsingFile_Msg")); //$NON-NLS-1$ + html.append("
"); //$NON-NLS-1$ + //Adding API Name to html. If details for API could not be found, adding name this.UNKNOWN_API_NAME + if(!api.startsWith(UNKNOWN_API_NAME + UNKNOWN_API_NAME_SEPARATOR)){ + + //Creating link for launching action to run API Query by API Name + html.append("" +api +""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + //API Is unknown + else{ + html.append(""); //$NON-NLS-1$ + html.append(UNKNOWN_API_NAME); + html.append(""); //$NON-NLS-1$ + } + //Adding API Details to html + detailsToReport = getApiDetails(api); + for (int i = 0; i < detailsToReport.length; i++) { + html.append(""); //$NON-NLS-1$ + int searchMethodId = UserSettings.getInstance().getCurrentlySelectedSearchMethod(). + getQueryTypeByAPIDetailNameInDetails(apiDetailsToReport[i]); + //If search method is supported + if(searchMethodId != -1 + && UserSettings.getInstance().getCurrentlySelectedSearchMethod().isSupportedQueryType(searchMethodId) + && !detailsToReport[i].equals(HTML_WHITE_SPACE)){ + + String comma = ","; //$NON-NLS-1$ + String [] items = detailsToReport[i].split(comma); + for (int j = 0; j < items.length; j++) { + + //Creating link for launching action to run API Query by a type + html.append("" +items[j] +""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + if(j < (items.length-1)){ + html.append(comma); + } + } + + } + //If current topic is not supported for API Query + else{ + html.append(detailsToReport[i]); + } + html.append(""); //$NON-NLS-1$ + //Adding "used headers" to html + for (String header : tmpVect) { + //Creating link for launching action to open file + html.append(""); //$NON-NLS-1$ //$NON-NLS-2$ + html.append(header); + html.append(""); //$NON-NLS-1$ + html.append(" "); //$NON-NLS-1$ + } + html.append(""); //$NON-NLS-1$ + Vector usingFileTmpVect = usingFiles.get(api); + + Vector allreadyAdded = new Vector(); + //Adding "using files" to html + for (IFile file : usingFileTmpVect) { + //To prevent adding duplicates of same file + if(!allreadyAdded.contains(file)){ + //Creating link for launching action to open file + html.append(""); //$NON-NLS-1$ //$NON-NLS-2$ + html.append(file.getName()); + html.append(""); //$NON-NLS-1$ + html.append(" "); //$NON-NLS-1$ + allreadyAdded.add(file); + } + + } + html.append("
"); //$NON-NLS-1$ + html.append("\n"); //$NON-NLS-1$ + + + //Add HTML end tags to report + html.append(getHTMLEndTags()); + return html.toString(); + } + + private String getProjectNameParam(){ + return "&" +ReportActionConstants.PARAM_PROJECT_NAME +"=" +selectedProject.getName(); //$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * Get URL for actio Servlet + * @return http://[server]:[port]/[servlet] + */ + private String getServletURL(){ + return "http://" +APIQueryWebServerConfigurator.WEB_SERVER_HOST //$NON-NLS-1$ + +":" +APIQueryWebServerConfigurator.WEB_SERVER_HTTP_PORT //$NON-NLS-1$ + +"/" +ReportActionConstants.SERVLET_NAME; //$NON-NLS-1$ + } + + /** + * get API Details to report. Founding API_DETAILS_TO_REPORT keys from + * projectUsingAPIDetails by api. + * @param api + * @return + */ + private String[] getApiDetails(String api){ + String[] detailsToReport = new String [apiDetailsToReport.length]; + APIDetails details = projectUsingAPIDetails.get(api); + if(details != null){ + APIDetailField field; + for (int i = 0; i < apiDetailsToReport.length; i++) { + field = details.getDetail(apiDetailsToReport[i]); + //To fill up empty HTML table columns, adding an white space ( ) + //to detail where is no real data. This looks bettre in UI (HTML report) + if(field.getValue() != null && !field.getValue().trim().equals("")){ //$NON-NLS-1$ + detailsToReport[i] = field.getValue(); + } + //To avoid HTML table different behavior with empty slots, putting a white space to emtpy slots + else{ + detailsToReport[i] = HTML_WHITE_SPACE; + } + } + } + else { + //To avoid HTML table different behavior with empty slots, putting a white space to emtpy slots + for (int i = 0; i < apiDetailsToReport.length; i++) { + detailsToReport[i] = HTML_WHITE_SPACE; + } + } + return detailsToReport; + } + + /** + * + * Not implemented. + * + * Generate report in CSV format. + * @return null + */ + public String toCSV() { + //Not implemented + return null; + } + + /** + * Writes this.toHTML() to file + * @param title + * @param fileName + */ + public void toHTMLFile(String title, String fileName ) { + + try { + BufferedWriter out = new BufferedWriter(new FileWriter( + fileName)); + out.write(toHTML(title)); + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + /** + * + * Not implemented until {@link #toCSV()} is implemented. + * + * Writes this.toCSV() to file + * @param title + * @param fileName + */ + public void toCSVFile(String title, String fileName ) { + + try { + BufferedWriter out = new BufferedWriter(new FileWriter( + fileName)); + out.write(toCSV()); + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * generating html header and opening body and adding title to it + * @param title + * @return + */ + private StringBuffer getHTMLHeader(String title){ + StringBuffer b = new StringBuffer(); + b.append(""); //$NON-NLS-1$ + b.append(title); + b.append("\n"); //$NON-NLS-1$ + b.append(getHTMLStyles()); + + b.append("\n\n"); //$NON-NLS-1$ + b.append("

"); //$NON-NLS-1$ + b.append(title); + b.append("

\n"); //$NON-NLS-1$ + return b; + } + /** + * get body and html end tags + * @return + */ + private StringBuffer getHTMLEndTags(){ + StringBuffer b = new StringBuffer(); + b.append(""); //$NON-NLS-1$ + return b; + } + /** + * get HTML style sheet + * @return styles + */ + private StringBuffer getHTMLStyles(){ + + String cssPath = null; + + try { + //Get location for stylesheet file + cssPath = APIQueryPlugin.getDefault().getPluginInstallPath() + + File.separatorChar + ProductInfoRegistry.getResourcesRelativePath() + +File.separatorChar + ProductInfoRegistry.getReportCSSFileName(); + //return contents of the stylesheet file + return FileUtils.loadDataFromFile(cssPath); + } catch (Exception e) { + //FileNotFoundException or IOException may occur + e.printStackTrace(); + APIQueryConsole.getInstance().println( + Messages.getString("CheckProjectReport.UnableToLoadCSS_Part1_ErrMsg") +cssPath +Messages.getString("CheckProjectReport.UnableToLoadCSS_Part2_ErrMsg") +e, //$NON-NLS-1$ //$NON-NLS-2$ + APIQueryConsole.MSG_ERROR); + //If there was an error, returning dummy (hard coded) styles + return getDummyCSS(); + } + + } + + /** + * If there is something wrong, hard coded styles can be used + * @return dummy styles + */ + private StringBuffer getDummyCSS() { + StringBuffer b = new StringBuffer(); + b.append(""); //$NON-NLS-1$ + return b; + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/popup/actions/OpenFileAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/popup/actions/OpenFileAction.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,410 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +package com.nokia.s60tools.apiquery.popup.actions; + +import java.io.File; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Vector; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.IJobChangeListener; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IEditorDescriptor; +import org.eclipse.ui.IEditorRegistry; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IDE; + +import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin; +import com.nokia.carbide.cdt.builder.EpocEngineHelper; +import com.nokia.carbide.cdt.builder.ICarbideBuildManager; +import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration; +import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo; +import com.nokia.s60tools.apiquery.shared.exceptions.QueryOperationFailedException; +import com.nokia.s60tools.apiquery.shared.job.FindFileFromFoldersJob; +import com.nokia.s60tools.apiquery.shared.plugin.APIQueryPlugin; +import com.nokia.s60tools.apiquery.shared.resources.Messages; +import com.nokia.s60tools.apiquery.shared.ui.dialogs.APIQueryMessageBox; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; + +/** + * Action class for find and then open wanted file to Editor area. + * File can be seeked under SDK include paths or + * under given project in Carbides Workspace. + */ +public class OpenFileAction implements IJobChangeListener{ + + /** + * Current default build configuration SDK ID. + */ + private String sdkUniqueId = null; + private String fileName = null; + private String projectName; + + /** + * Opens file from given project in Carbide workspace. + * @param fileName + * @param projectName + */ + public void openFileFromProject(String fileName, String projectName) { + + this.fileName = fileName; + this.projectName = projectName; + try { + + APIQueryConsole.getInstance().println(Messages.getString("OpenFileAction.StartingSeek_Msg_Part1") +fileName +Messages.getString("OpenFileAction.StartingSeek_Msg_Part2") +projectName +"'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + + IProject project = getProject(projectName); + + IResource[] members = project.members(); + + Vector files = getMatchingResources(fileName, members); + + if(!files.isEmpty()){ + + //It should not be possible that there is multiple foundings for resource, because path is added when file was seeked + IResource res = files.get(0); + IPath path = res.getFullPath(); + URI uri = res.getLocationURI(); + openFile(uri, path.lastSegment()); + }else{ + String message = Messages.getString("OpenFileAction.CannotFoundFile_ErrMsg_Part1") +fileName +Messages.getString("OpenFileAction.CannotFoundFile_ErrMsg_Part2") +projectName +"'."; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + showErrorMessage(message); + + } + + } catch (Exception e) { + showUnexpectedErrorMsg(e); + } + + } + + + /** + * Logs and shows error message for unexpected error situations. + * @param fileName + * @param projectName + * @param e {@link Exception} + */ + private void showUnexpectedErrorMsg(Exception e) { + e.printStackTrace(); + String msg = Messages.getString("OpenFileAction.Unexpected_ErrMsg_Part1")+fileName +Messages.getString("OpenFileAction.Unexpected_ErrMsg_Part2") +projectName +"'."; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + String consoleMsg = msg +Messages.getString("OpenFileAction.Unexpected_ErrMsg_Part3") +e; //$NON-NLS-1$ + APIQueryConsole.getInstance().println(consoleMsg, APIQueryConsole.MSG_ERROR); + showErrorMessage(msg); + } + + + + /** + * Show an error message to user and logs same message to console. + * @param message + */ + private void showErrorMessage(final String message) { + APIQueryConsole.getInstance().println(message, APIQueryConsole.MSG_ERROR); + Runnable run = new Runnable(){ + public void run(){ + new APIQueryMessageBox(message, + SWT.ICON_ERROR | SWT.OK).open(); + + } + }; + Display.getDefault().asyncExec(run); + } + + + + /** + * Check recursively all folders inside given resources and seeks give file + * @param fileName + * @param members + * @return resources found + * @throws CoreException + */ + private Vector getMatchingResources(String fileName, + IResource[] members) throws CoreException { + Vector files = new Vector(); + + for (int i = 0; i < members.length; i++) { + IResource res = members[i]; + //If resource is folder, seeking all folders and files under it + if (res instanceof IFolder) { + IFolder fold = (IFolder) res; + IResource[] folderMembers = fold.members(); + files.addAll(getMatchingResources(fileName, folderMembers)); + } + //If resource is file, checking if thats file we are interest of + else if (res instanceof IFile) { + + String name = res.getName(); + //If file name match to resource name adding to + if (fileName.equalsIgnoreCase(name)) { + files.add(res); + }else if(fileName.equalsIgnoreCase(res.getProjectRelativePath().toOSString())){ + files.add(res); + } + } + //Else we have no interest of resource + } + return files; + } + + /** + * Open file given to Editor area. + * @param uri + * @param fileName + */ + public void openFile(final URI uri, final String fileName) { + + //Runnable to open new file + final Runnable runOpen = new Runnable() { + public void run() { + // do the actual work in here + + try { + IWorkbench workbench = PlatformUI.getWorkbench(); + IWorkbenchPage page = APIQueryPlugin.getCurrentlyActivePage(); + //Find default editor for that file + IEditorRegistry reg = workbench.getEditorRegistry(); + IEditorDescriptor editor = reg.getDefaultEditor(fileName); + //We open editor by it's ID + final String editorId = editor.getId(); + //Opening file in editor + IDE.openEditor(page, uri, editorId, true); + + } catch (Exception e) { + showUnexpectedErrorMsg(e); + } + + } + }; + Display.getDefault().asyncExec(runOpen); + } + + + /** + * Open file to Editor area + * @param file + * @throws URISyntaxException + */ + private void openFile(File file) throws URISyntaxException { + String path = file.getAbsolutePath(); + String uriStr = path.replace("\\", "/");; //$NON-NLS-1$ //$NON-NLS-2$ + uriStr = "file://" + uriStr; //$NON-NLS-1$ + URI uri = new URI(uriStr); + openFile(uri, file.getName()); + } + + /** + * Opens file from SDK. Projects default build configuration is used as SDK, + * MMP files from that project is seeked, and file is seeked under inc paths found in + * MMP files. + * + * File is opened or error message is shown when done. + * + * @param fileName + * @param projectName + */ + public void openFileFromSDK(String fileName, String projectName) { + + this.fileName = fileName; + this.projectName = projectName; + try { + //Get project by name + IProject project = getProject(projectName); + //Gets Include paths for project. Header files must be found from includepaths. + List paths = getIncludePaths(project); + APIQueryConsole.getInstance().println( + Messages.getString("OpenFileAction.TargetFound_Msg_Part1") +sdkUniqueId //$NON-NLS-1$ + +Messages.getString("OpenFileAction.TargetFound_Msg_Part2") +projectName //$NON-NLS-1$ + +Messages.getString("OpenFileAction.TargetFound_Msg_Part3") +fileName +"'."); //$NON-NLS-1$ //$NON-NLS-2$ + + //Seeking paths where file(s) are found + //it will happened asynchronously, and when done, file will be opened. + findFiles(fileName, paths); + + } catch (QueryOperationFailedException e) { + showErrorMessage(e.getMessage()); + }catch (Exception e) { + showUnexpectedErrorMsg(e); + } + + + } + + + /** + * Get include paths for project + * @param project + * @return absolutely include paths for project, found in MMP files. + * @throws QueryOperationFailedException + */ + private List getIncludePaths(IProject project) throws QueryOperationFailedException { + List paths = new ArrayList(); + + ICarbideBuildManager buildMgr = CarbideBuilderPlugin.getBuildManager(); + ICarbideProjectInfo cpi = null; + if (buildMgr.isCarbideProject(project)){ + // check to make sure this is a Carbide project + cpi = buildMgr.getProjectInfo(project); + // Get the default build configuration + ICarbideBuildConfiguration defaultConfig = cpi.getDefaultConfiguration(); + sdkUniqueId = defaultConfig.getSDK().getUniqueId(); + + List _userPaths = new ArrayList(); + List _systemPaths = new ArrayList(); + EpocEngineHelper.getProjectIncludePaths(cpi, defaultConfig, _userPaths, _systemPaths) ; + paths.addAll(_userPaths); + paths.addAll(_systemPaths); + } + else{ + throw new QueryOperationFailedException(Messages.getString("OpenFileAction.NotCarbideProject_ErrMsg_Part1") +projectName +Messages.getString("OpenFileAction.NotCarbideProject_ErrMsg_Part2")); //$NON-NLS-1$ //$NON-NLS-2$ + } + + + return paths; + } + + /** + * Get project by name. + * @param projectName + * @return project + * @throws CoreException + * @throws QueryOperationFailedException + */ + private IProject getProject(String projectName) throws CoreException, QueryOperationFailedException { + IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); + if(!prj.exists()){ + throw new QueryOperationFailedException (Messages.getString("OpenFileAction.ProjectNotExist_ErrMsg_Part1") +projectName +Messages.getString("OpenFileAction.ProjectNotExist_ErrMsg_Part2")); //$NON-NLS-1$ //$NON-NLS-2$ + } + if(!prj.isOpen()){ + //If project is closed, just opening it before returning + prj.open(new NullProgressMonitor()); + } + prj.getWorkspace(); + return prj; + } + + + + /** + * Find file under folders given + * @param fileName + * @param includePaths + */ + private void findFiles(String fileName, List includePaths) { + // System.out.println(Messages.getString("OpenFileAction.18")); //$NON-NLS-1$ + FindFileFromFoldersJob job = new FindFileFromFoldersJob(Messages.getString("OpenFileAction.JobName_Msg") +fileName, includePaths, fileName, sdkUniqueId); //$NON-NLS-1$ + job.setPriority(Job.DECORATE); + //Listener will be called when seeking is done + job.addJobChangeListener(this); + job.schedule(); + + } + + + + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#done(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void done(IJobChangeEvent event) { + + // + // When job is done, this will be called, and found file will be opened + + try { + FindFileFromFoldersJob job = (FindFileFromFoldersJob) event + .getJob(); + Collection files = job.getFoundSourceFiles(); + + if (files.isEmpty()) { + String message = Messages.getString("OpenFileAction.CannotFoundFile_Msg_Part1") + fileName //$NON-NLS-1$ + + Messages.getString("OpenFileAction.CannotFoundFile_Msg_Part2") + sdkUniqueId //$NON-NLS-1$ + + "'."; //$NON-NLS-1$ + showErrorMessage(message); + } + //Else we just open first file that we found + else{ + File file = ((File[]) files.toArray(new File[0]))[0]; + openFile(file); + } + } catch (Exception e) { + showUnexpectedErrorMsg(e); + } + + } + + + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#aboutToRun(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void aboutToRun(IJobChangeEvent event) { + //Not needed + } + + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#awake(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void awake(IJobChangeEvent event) { + //Not needed + + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#running(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void running(IJobChangeEvent event) { + //Not needed + } + + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#scheduled(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void scheduled(IJobChangeEvent event) { + //Not needed + } + + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.IJobChangeListener#sleeping(org.eclipse.core.runtime.jobs.IJobChangeEvent) + */ + public void sleeping(IJobChangeEvent event) { + //Not needed + } + + + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/popup/actions/QueryErrorInfo.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/popup/actions/QueryErrorInfo.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.popup.actions; + +/** + * Simple class for storing error information returned query operations. + * This is needed because queries are runned inside a runnable and + * error info is got via try/catch, and the error information usage + * related needs to be done outside runnable where catch is made. + * This class should stay with package private visibility. + */ +class QueryErrorInfo{ + /** + * Error description is set on failure. + */ + private String errorDescription = new String(); + + /** + * Gets error description. + * @return the errorDescription + */ + public String getErrorDescription() { + return errorDescription; + } + + /** + * Sets error description. + * @param errorDescription the errorDescription to set + */ + public void setErrorDescription(String errorDescription) { + this.errorDescription = errorDescription; + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/servlets/APIQueryWebServerConfigurator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/servlets/APIQueryWebServerConfigurator.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,169 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +package com.nokia.s60tools.apiquery.servlets; + +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.Hashtable; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.equinox.http.jetty.JettyConfigurator; +import org.eclipse.equinox.http.jetty.JettyConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Display; +import org.osgi.framework.Bundle; + +import com.nokia.s60tools.apiquery.shared.plugin.APIQueryPlugin; +import com.nokia.s60tools.apiquery.shared.resources.Messages; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.util.debug.DbgUtility; + +/** + * Class for handling API Query Web server functionalities. E.g. start and stop Web Server. + */ +public class APIQueryWebServerConfigurator { + + /** + * Host where report server is running (localhost) + */ + public static final String WEB_SERVER_HOST = "localhost"; //$NON-NLS-1$ + + /** + * HTTP port to be used with running HTTP server + */ + public static final int WEB_SERVER_HTTP_PORT = 4191; + + /** + * Name of the API Query Web Server + */ + private static final String API_QUERY_WEB_SERVER_NAME = "API Query Server"; //$NON-NLS-1$ + + /** + * + */ +public static final int Active_Project_Start = 0; + +public static final int Carbide_Instance_start =1; + +static boolean activeProjectStartedServer = false; + + + /** + * Starts API Query Web Server. Web Server is used for launch actions in HTML report. + * Reports are created with Export report functionality (API Query for Active project). + * @see JettyConfigurator#startServer(String, java.util.Dictionary) + */ +public static void startServer(int msgdialogueCode) { + try { + + if (msgdialogueCode == Active_Project_Start) activeProjectStartedServer = true; + // Check if server is already running + if (allreadyRunning()) { + //Show the dialogue box + + if (msgdialogueCode==Carbide_Instance_start && APIQueryPlugin.isFirstLaunch&&!activeProjectStartedServer) + { + APIQueryPlugin.isFirstLaunch = false; + MessageDialog.openInformation(APIQueryPlugin.getCurrentlyActiveWbWindowShell(), "APIQuery Plugin: Active Project Option Information", "Active project report links may not work. Close other Carbide.C++ instances and restart API Query plug-in."); + } + return; + } + + Hashtable set = new Hashtable(); + set.put(JettyConstants.HTTP_PORT, WEB_SERVER_HTTP_PORT); + JettyConfigurator.startServer(API_QUERY_WEB_SERVER_NAME, set); + + Bundle bundle = Platform + .getBundle("org.eclipse.equinox.http.registry"); //$NON-NLS-1$ + + if (bundle.getState() == Bundle.RESOLVED) { + bundle.start(Bundle.START_TRANSIENT); + } + APIQueryConsole + .getInstance() + .println( + Messages + .getString("APIQueryWebServerConfigurator.StartServer_Msg_Part1")//$NON-NLS-1$ + + API_QUERY_WEB_SERVER_NAME + + Messages + .getString("APIQueryWebServerConfigurator.StartServer_Msg_Part2")//$NON-NLS-1$ + + "http://" + WEB_SERVER_HOST + ":" + WEB_SERVER_HTTP_PORT //$NON-NLS-1$ //$NON-NLS-2$ + + Messages + .getString("APIQueryWebServerConfigurator.StartServer_Msg_Part3")); //$NON-NLS-1$ + + } catch (Exception e) { + e.printStackTrace(); + APIQueryConsole + .getInstance() + .println( + Messages + .getString("APIQueryWebServerConfigurator.StartServer_ErrMsg_Part1") + API_QUERY_WEB_SERVER_NAME + Messages.getString("APIQueryWebServerConfigurator.StartServer_ErrMsg_Part2") + e, APIQueryConsole.MSG_ERROR); //$NON-NLS-1$ //$NON-NLS-2$ + + } + } + + + + /** + * Check if HTTP Server is already running + * @return true if server is alreaydy running and false if not. + */ + private static boolean allreadyRunning() { + + + try { + //Servlet URL + String servletURL = "http://" +WEB_SERVER_HOST +":" +WEB_SERVER_HTTP_PORT + "/" + ReportActionConstants.SERVLET_NAME; + URL url = new URL(servletURL); + //Try to keep http connection alive + System.setProperty("http.keepAlive", "true"); + + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "-----> Reading URL: " + url.toString()); + //Getting connection to check if server is running + HttpURLConnection con = (HttpURLConnection) url.openConnection(); + if (con.getResponseCode() == HttpURLConnection.HTTP_OK) { + return true; + } + + } catch (IOException e) { + // IOExeption occurs if HttpURLConnection is not alive + //and when HttpURLConnection.getResponseCode() is called + //then we know that HTTP server is not up and running + } + catch (Exception e) { + //No operation if something else happens, just returning false + } + + return false; + } + + /** + * Stops API Query Web Server. + * @see JettyConfigurator#stopServer(String) + */ + public static void stopServer(){ + try { + JettyConfigurator.stopServer(API_QUERY_WEB_SERVER_NAME); + APIQueryConsole.getInstance().println(Messages.getString("APIQueryWebServerConfigurator.StoptServer_Msg_Part1") +API_QUERY_WEB_SERVER_NAME +Messages.getString("APIQueryWebServerConfigurator.StoptServer_Msg_Part2")); //$NON-NLS-1$ //$NON-NLS-2$ + } catch (Exception e) { + e.printStackTrace(); + APIQueryConsole.getInstance().println(Messages.getString("APIQueryWebServerConfigurator.StoptServer_ErrMsg_Part1") +API_QUERY_WEB_SERVER_NAME +Messages.getString("APIQueryWebServerConfigurator.StoptServer_ErrMsg_Part2") +e, APIQueryConsole.MSG_ERROR); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/servlets/ReportActionConstants.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/servlets/ReportActionConstants.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +package com.nokia.s60tools.apiquery.servlets; + + +/** + * Constants for {@link ReportActionServlet} and relative classes. + */ +public class ReportActionConstants { + + + /** + * Servlet name taking action request and forwards it to actions + */ + public static final String SERVLET_NAME = "reportAction"; //$NON-NLS-1$ + + /** + * Parameter name for API Query For + */ + public static final String PARAM_QUERY_FOR = "apiQueryFor"; //$NON-NLS-1$ + + /** + * Parameter name for API Query Type + */ + public static final String ACTION_QUERY_TYPE = "apiQueryType"; //$NON-NLS-1$ + + /** + * Parameter name for Open Used Header + */ + public static final String ACTION_OPEN_USED_HEADER = "openUsedHeader"; //$NON-NLS-1$ + + /** + * Parameter name for Open Using File + */ + public static final String ACTION_OPEN_USING_FILE = "openUsingFile"; //$NON-NLS-1$ + + /** + * Name of the project what report stands for + */ + public static final String PARAM_PROJECT_NAME = "projectName"; //$NON-NLS-1$ + + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/servlets/ReportActionServlet.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/servlets/ReportActionServlet.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,194 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +package com.nokia.s60tools.apiquery.servlets; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.Servlet; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; + +import com.nokia.s60tools.apiquery.popup.actions.CheckIdentifierAction; +import com.nokia.s60tools.apiquery.popup.actions.OpenFileAction; +import com.nokia.s60tools.apiquery.settings.UserSettings; +import com.nokia.s60tools.apiquery.shared.exceptions.QueryOperationFailedException; +import com.nokia.s60tools.apiquery.shared.resources.Messages; +import com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension; +import com.nokia.s60tools.apiquery.shared.ui.dialogs.APIQueryMessageBox; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.apiquery.ui.views.main.MainView; + +/** + * Servlet that takes request from API Query report and forwards it to action. + * Web Server inside Carbide must be up and running when Servlet is executed. + * + * The Web server is running when API Query {@link MainView} is alive. + * + * @see APIQueryWebServerConfigurator#startServer() + */ +public class ReportActionServlet extends HttpServlet implements Servlet { + + + /** + * Default ID. + */ + private static final long serialVersionUID = 1L; + + + + /* (non-Javadoc) + * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) + */ + protected void doGet(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + + String queryType = req.getParameter(ReportActionConstants.ACTION_QUERY_TYPE); + try { + String projectName; + if(req.getParameter(ReportActionConstants.ACTION_QUERY_TYPE) != null){ + int type = 1; + if(queryType != null){ + type = Integer.parseInt(queryType); + } + String searchString = (String) req.getParameter(ReportActionConstants.PARAM_QUERY_FOR); + runAPIQueryFor(searchString, type); + } + else if(req.getParameter(ReportActionConstants.ACTION_OPEN_USED_HEADER) != null){ + String headerName = (String) req.getParameter(ReportActionConstants.ACTION_OPEN_USED_HEADER); + projectName = (String) req.getParameter(ReportActionConstants.PARAM_PROJECT_NAME); + openFileFromSDK(headerName, projectName); + } + else if(req.getParameter(ReportActionConstants.ACTION_OPEN_USING_FILE) != null){ + String fileName = (String) req.getParameter(ReportActionConstants.ACTION_OPEN_USING_FILE); + projectName = (String) req.getParameter(ReportActionConstants.PARAM_PROJECT_NAME); + openFileFromProject(fileName, projectName); + } + else{ + String msg = Messages.getString("ReportActionServlet.NotSupportedAction_Msg"); //$NON-NLS-1$ + APIQueryConsole.getInstance().println(msg); + } + + + PrintWriter out = resp.getWriter(); + //When actual servlet page is loaded (Action is launched) directing user back where come from + //by loading java script on body load. + out.println("\n" + //$NON-NLS-1$ + "\n" + //$NON-NLS-1$ + "\n" + //$NON-NLS-1$ + "\n" + //$NON-NLS-1$ + ""); //$NON-NLS-1$ + } catch (NumberFormatException e) { + String msg = Messages.getString("ReportActionServlet.NotSupportedQueryType_ErrMsg_Part1") +queryType +Messages.getString("ReportActionServlet.NotSupportedQueryType_ErrMsg_Part2"); //$NON-NLS-1$ //$NON-NLS-2$ + APIQueryConsole.getInstance().println(msg, APIQueryConsole.MSG_ERROR); + e.printStackTrace(); + } catch (QueryOperationFailedException e) { + showErrorMessage(e.getMessage()); + } + + } + + /** + * Shows on error message to user. + * @param message + */ + private void showErrorMessage(final String message) { + Runnable run = new Runnable(){ + public void run(){ + new APIQueryMessageBox(message, + SWT.ICON_ERROR | SWT.OK).open(); + + } + }; + Display.getDefault().asyncExec(run); + } + + + /** + * Open File from project + * @param fileName + * @param projectName + */ + private void openFileFromProject(String fileName, String projectName) { + OpenFileAction action = new OpenFileAction(); + action.openFileFromProject(fileName, projectName); + } + + /** + * Open file from SDK + * @param fileName + * @param projectName + */ + private void openFileFromSDK(String fileName, String projectName) { + OpenFileAction action = new OpenFileAction(); + action.openFileFromSDK(fileName, projectName); + } + + + + /** + * Runs API Query for selected String with selected type + * @param searchString String to search for + * @param type API Query type + * @throws QueryOperationFailedException + */ + private void runAPIQueryFor(final String searchString, final int type) throws QueryOperationFailedException{ + + ISearchMethodExtension currentlySelectedSearchMethod = UserSettings.getInstance().getCurrentlySelectedSearchMethod(); + + //Check if search method is supported for selected type. Cannot really occur until + //some data source is giving API Query report details for API that some other Data source is not supporting + //and report is generated with different Data source that is currently in use. + boolean isSupported = currentlySelectedSearchMethod.isSupportedQueryType(type); + if(!isSupported){ + String msg = Messages.getString("ReportActionServlet.NotSupportedSearchMethod_ErrMsg_Part1") //$NON-NLS-1$ + + currentlySelectedSearchMethod.getAPIDetailNameInDetailsByQueryType(type) + +Messages.getString("ReportActionServlet.NotSupportedSearchMethod_ErrMsg_Part2") //$NON-NLS-1$ + + currentlySelectedSearchMethod.getExtensionInfo().getDescription() + +"'."; //$NON-NLS-1$ + APIQueryConsole.getInstance().println(msg, APIQueryConsole.MSG_ERROR); + throw new QueryOperationFailedException( + msg); + } + + + //Runnable to run API Query action + final Runnable run = new Runnable() { + public void run() { + // do the actual work in here + try { + CheckIdentifierAction act = new CheckIdentifierAction(); + act.runAPIQuery(searchString, type); + } catch (Exception e) { + e.printStackTrace(); + String msg = Messages.getString("ReportActionServlet.Unexpected_ErrMsg_Part1") //$NON-NLS-1$ + + searchString +Messages.getString("ReportActionServlet.Unexpected_ErrMsg_Part2") +type +Messages.getString("ReportActionServlet.Unexpected_ErrMsg_Part3") +e; //$NON-NLS-1$ //$NON-NLS-2$ + APIQueryConsole.getInstance().println(msg, APIQueryConsole.MSG_ERROR); + } + + } + }; + Display.getDefault().asyncExec(run); + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/settings/IUserSettingsListener.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/settings/IUserSettingsListener.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.settings; + +/** + * Interface for the listeners that want to get user setting modifications events. + */ +public interface IUserSettingsListener { + + /** + * Notifies the listener that user settings have changed. + */ + public void userSettingsChanged(); + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/settings/UserSettings.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/settings/UserSettings.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,127 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.settings; + +import java.util.ArrayList; + +import com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension; +import com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtensionInfo; +import com.nokia.s60tools.apiquery.shared.searchmethodregistry.SearchMethodExtensionRegistry; +import com.nokia.s60tools.util.debug.DbgUtility; + + + + +/** + * Singleton class that is created on plugin + * startup, and is kept active as long as plugin is active. + * + * The purpose of this class is store run-time instance + * of active user settings. + */ +public class UserSettings { + + /** + * Singleton instance. + */ + static private UserSettings instance = null; + + /** + * Currently selected search method. + */ + private ISearchMethodExtensionInfo currentlySelectedSearchMethodInfo = null; + + /** + * Listeners that can be attached for listening the changes in the user settings. + */ + private ArrayList settingsListeners = new ArrayList(); + + /** + * Public Singleton instance accessor. + * @return Returns instance of this singleton class- + */ + public static UserSettings getInstance(){ + if( instance == null ){ + instance = new UserSettings(); + } + return instance; + } + + /** + * Private default constructor. + */ + private UserSettings() { + DbgUtility.println(DbgUtility.PRIORITY_CLASS, "-- <> --> " + getClass().getName()); //$NON-NLS-1$ + } + + /** + * Gets the search method that is currently selected by user. + * @return Returns the currentlySelectedSearchMethodInfo, or + * null if not set. + */ + public ISearchMethodExtensionInfo getCurrentlySelectedSearchMethodInfo() { + return currentlySelectedSearchMethodInfo; + } + + /** + * Gets the currently selected search method. + * @return The currently selected search method. + */ + public ISearchMethodExtension getCurrentlySelectedSearchMethod() { + ISearchMethodExtensionInfo currSelExtInfo = getInstance().getCurrentlySelectedSearchMethodInfo(); + String id = currSelExtInfo.getId(); + ISearchMethodExtension currSelExt = SearchMethodExtensionRegistry.getInstance().getById(id); + return currSelExt; + } + + /** + * Sets the search method that is currently selected by user. + * @param currentlySelectedSearchMethodInfo The currentlySelectedSearchMethodInfo to set. + */ + public void setCurrentlySelectedSearchMethodInfo( + ISearchMethodExtensionInfo currentlySelectedSearchMethodInfo) { + this.currentlySelectedSearchMethodInfo = currentlySelectedSearchMethodInfo; + settingsChanged(); + } + + /** + * Adds a user settings listener. + * @param listener Setting listener to add. + */ + public void addUserSettingListener(IUserSettingsListener listener){ + settingsListeners.add(listener); + } + + /** + * Removes a user settings listener. + * @param listener Setting listener to remove. + */ + public void removeUserSettingListener(IUserSettingsListener listener){ + settingsListeners.remove(listener); + } + + /** + * Notifies listeners that the settings has been changed. + */ + public void settingsChanged(){ + for (IUserSettingsListener listener : settingsListeners) { + listener.userSettingsChanged(); + } + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/common/Product.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/common/Product.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.common; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * Class for getting properties from product.properties file, located in same package. + */ +public class Product { + private static final String BUNDLE_NAME = "com.nokia.s60tools.apiquery.shared.common.product"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + private Product() { + } + /** + * @param key to product.properties -file + * @return a String from product.properties -file + */ + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/common/ProductInfoRegistry.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/common/ProductInfoRegistry.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.shared.common; + +/** + * This class stores product information such as product name, + * version, console view name etc. + * The idea is to have the product information in one place. + */ +public class ProductInfoRegistry { + + private static final String PRODUCT_NAME = Product.getString("ProductInfoRegistry.Product_Name"); //$NON-NLS-1$ + private static final String CONSOLE_WINDOW_NAME = PRODUCT_NAME + " " + Product.getString("ProductInfoRegistry.Console_Window_Name_Postfix"); //$NON-NLS-1$ //$NON-NLS-2$ + private static final String IMAGES_DIRECTORY = Product.getString("ProductInfoRegistry.Images_Directory"); //$NON-NLS-1$ + private static final String RESOURCES_RELATIVE_PATH = Product.getString("ProductInfoRegistry.Resources_Relative_Path"); //$NON-NLS-1$ + private static final String REPORT_CSS_FILE_NAME = Product.getString("ProductInfoRegistry.report_css_File_Name"); //$NON-NLS-1$ + + /** + * @return Returns the CONSOLE_WINDOW_NAME. + */ + public static String getConsoleWindowName() { + return CONSOLE_WINDOW_NAME; + } + /** + * @return Returns the PRODUCT_NAME. + */ + public static String getProductName() { + return PRODUCT_NAME; + } + + /** + * @return Returns the IMAGES_DIRECTORY. + */ + public static String getImagesDirectoryName() { + return IMAGES_DIRECTORY; + } + /** + * @return Returns the RESOURCES_RELATIVE_PATH. + */ + public static String getResourcesRelativePath() { + return RESOURCES_RELATIVE_PATH; + } + /** + * @return Returns the REPORT_CSS_FILE_NAME. + */ + public static String getReportCSSFileName() { + return REPORT_CSS_FILE_NAME; + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/common/product.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/common/product.properties Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,22 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# + +ProductInfoRegistry.Product_Name=API Query +ProductInfoRegistry.Console_Window_Name_Postfix=Console +ProductInfoRegistry.Images_Directory=icons +ProductInfoRegistry.Resources_Relative_Path=resources +ProductInfoRegistry.report_css_File_Name=htmlReportStyles.css diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/APIDetailField.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/APIDetailField.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.datatypes; + +/** + * Stores a single field of information + * for API details. + */ +public class APIDetailField { + + public static final String VALUE_FIELD_SEPARATOR = ", "; //$NON-NLS-1$ + + /** + * Description for the detail field. + */ + private final String description; + /** + * Value for the detail field. + */ + private String value; + + /** + * Constructor. + * @param description Description for the detail field. + * @param value Value for the detail field. + */ + public APIDetailField(String description, String value){ + this.description = description; + this.value = value; + + } + + /** + * Gets the description of the field. + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Gets the value of the field. + * @return the value + */ + public String getValue() { + return value; + } + + /** + * Appends new data to existing value string. + * @param strToAppend String to be appended to existing value string. + */ + public void appendToExistingValue(String strToAppend) { + value = value + VALUE_FIELD_SEPARATOR + strToAppend; + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/APIDetails.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/APIDetails.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.datatypes; + +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +/** + * Stores API details information in the format + * that is directly used by UI components. + */ +public class APIDetails implements Iterable{ + + /** + * Stores detail fields. + */ + private Map details; + + /** + * Constructor. + */ + public APIDetails(){ + //Linked hash map preserves the order of the fields + //which is needed in this case. + details = new LinkedHashMap (); + } + + /** + * Adds a new field into API details. + * @param description Description for the detail. + * @param value Value for the detail. + */ + public void addOrUpdateField(String description, String value){ + APIDetailField oldApiDetail = details.get(description); + if(oldApiDetail != null){ + oldApiDetail.appendToExistingValue(value); + } + else{ + details.put(description, new APIDetailField(description, value)); + } + } + + /** + * Adds a new field into API details. + * @param field to be added. + */ + public void addOrUpdateField(APIDetailField field){ + APIDetailField oldApiDetail = details.get(field.getDescription()); + if(oldApiDetail != null){ + oldApiDetail.appendToExistingValue(field.getValue()); + } + else{ + details.put(field.getDescription(), field); + } + } + + /** + * Gets the details as an iterator. + * @return Iterator containing detail fields. + */ + public Iterator iterator(){ + return details.values().iterator(); + } + + /** + * Gets the keys. Can be used for getting fields by description this.getDetail(key) + * @return Iterator containing detail fields. + */ + public Set getKeys(){ + return details.keySet(); + } + + /** + * Get value for for the description + * @param description + * @return API Detail Field or new APIDetailField with given description and empty ("") value if not exist. + * @see com.nokia.s60tools.apiquery.shared.util.xml.XMLUtils + * public static variables for description keys. + */ + public APIDetailField getDetail(String description){ + APIDetailField detail = details.get(description); + if(detail != null){ + return detail; + }else{ + return new APIDetailField(description,""); //$NON-NLS-1$ + } + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/APIQueryParameters.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/APIQueryParameters.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,243 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.datatypes; + +import java.util.ArrayList; + +import com.nokia.s60tools.apiquery.shared.resources.Messages; + +/** + * Used to store parameters for an API query. + */ +public class APIQueryParameters { + + + // + // Query types + // + public static final int QUERY_BY_API_NAME = 1; + public static final int QUERY_BY_SUBSYSTEM_NAME = 2; + public static final int QUERY_BY_DLL_NAME = 3; + public static final int QUERY_BY_LIB_NAME = 4; + public static final int QUERY_BY_HEADER_NAME = 5; + public static final int QUERY_BY_CRPS_KEY_NAME = 6; + + /** + * Search can contain multiple search items that can be + * separated with this separator char. + */ + public static final String SEARCH_ITEM_SEPARATOR_CHAR = ";"; //$NON-NLS-1$ + + /** + * Query type. + */ + private final int queryType; + + /** + * Search string used for the query. + */ + private final String searchString; + + /** + * Is query from UI thread or not + */ + private boolean isQueryFromUI = true; + + /** + * is API Details ment to add to Descriptions when search is done. + */ + private boolean isDetailsMentToAddToDescriptions = false; + + /** + * If Exact match shoud be used instead of contains when search results is gathered. + */ + boolean isExactMatchInUse = false; + + /** + * Constructor. + * @param queryType Query type. + * @param searchString Search string used for the query. + * @throws java.lang.IllegalArgumentException + * @see java.lang.IllegalArgumentException + */ + public APIQueryParameters(int queryType, String searchString){ + this.queryType = queryType; + this.searchString = searchString.trim(); + validateArguments(); + } + + + /** + * @return the isQueryFromUI + */ + public boolean isQueryFromUI() { + return isQueryFromUI; + } + + + /** + * @param isQueryFromUI the isQueryFromUI to set + */ + public void setQueryFromUI(boolean isQueryFromUI) { + this.isQueryFromUI = isQueryFromUI; + } + + + /** + * Validating the parameter data. + * @throws java.lang.IllegalArgumentException + * @see java.lang.IllegalArgumentException + */ + private void validateArguments() { + if(queryType < 1 || queryType >6){ + throw new IllegalArgumentException(Messages.getString("APIQueryParameters.UnsupportedQueryType_Msg") + queryType); //$NON-NLS-1$ + } + } + + + /** + * @return the queryType + */ + public int getQueryType() { + return queryType; + } + + + /** + * @return the searchString + */ + public String getSearchString() { + return searchString; + } + + /** + * Returns currently supported query types. + * @return Array of integer constants for the currently + * supported query types. + */ + public static Integer[] getQueryTypes(){ + ArrayList queryTypesArr = new ArrayList(); + for (int i = QUERY_BY_API_NAME; i <= QUERY_BY_CRPS_KEY_NAME; i++) { + queryTypesArr.add(new Integer(i)); + } + return queryTypesArr.toArray(new Integer[0]); + } + + /** + * Maps query type to description. + * @param queryType Query type constant. + * @return Description for the given query type. + */ + public static String getDescriptionForQueryType(int queryType){ + + String desc = null; + + switch (queryType) { + + case QUERY_BY_API_NAME: + desc = Messages.getString("APIQueryParameters.APIName_Msg"); //$NON-NLS-1$ + break; + + case QUERY_BY_SUBSYSTEM_NAME: + desc = Messages.getString("APIQueryParameters.SubsystemName_Msg"); //$NON-NLS-1$ + break; + + case QUERY_BY_DLL_NAME: + desc = Messages.getString("APIQueryParameters.DLLName_Msg"); //$NON-NLS-1$ + break; + + case QUERY_BY_LIB_NAME: + desc = Messages.getString("APIQueryParameters.LIBName_Msg"); //$NON-NLS-1$ + break; + + case QUERY_BY_HEADER_NAME: + desc = Messages.getString("APIQueryParameters.HeaderName_Msg"); //$NON-NLS-1$ + break; + + case QUERY_BY_CRPS_KEY_NAME: + desc = Messages.getString("APIQueryParameters.CR_PS_Name_Msg"); //$NON-NLS-1$ + break; + + default: + throw new IllegalArgumentException(Messages.getString("APIQueryParameters.QueryTypePart1_ErrMsg") //$NON-NLS-1$ + + queryType + + Messages.getString("APIQueryParameters.QueryTypePart2_ErrMsg") //$NON-NLS-1$ + ); + } + + return desc; + } + + + + + /** + * Maps query type to description. + * @param queryType Query type constant as Integer object.. + * @return Description for the given query type. + */ + public static String getDescriptionForQueryType(Integer queryType){ + return getDescriptionForQueryType(queryType.intValue()); + } + + /** + * Gets default query type. + * @return Returns default query type. + */ + public static int getDefaultQueryType(){ + // NOTE: This query type SHOULD be supported by ALL search methods. + return QUERY_BY_API_NAME; + } + + + /** + * Check if {@link APIDetails} should be added to {@link APIShortDescription}:s when + * query is executed. + * @return true if API Details should be added to Descriptions, false otherwise. + */ + public boolean isDetailsMentToAddToDescriptions() { + return isDetailsMentToAddToDescriptions ; + } + /** + * Set if {@link APIDetails} should be added to {@link APIShortDescription}:s when + * query is executed. + * @param true if {@link APIDetails} should be added to {@link APIShortDescription}:s when + * query is executed. + */ + public void setDetailsMentToAddToDescriptions( + boolean isDetailsMentToAddToDescriptions) { + this.isDetailsMentToAddToDescriptions = isDetailsMentToAddToDescriptions; + } + + /** + * Check if exact match should be used instead of contain when search results are compared + * @return the isExactMatchInUse true if exact match should be used, false otherwise. + */ + public boolean isExactMatchInUse() { + return isExactMatchInUse; + } + + + /** + * Set if exact match should be used instead of contain when search results are compared. + * @param isExactMatchInUse true if exact match should be used, false otherwise. + */ + public void setExactMatchInUse(boolean isExactMatchInUse) { + this.isExactMatchInUse = isExactMatchInUse; + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/APIShortDescription.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/APIShortDescription.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,116 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.datatypes; + +import java.util.ArrayList; + +/** + * Stores information related to a single API Summary + * object to be shown in UI. + */ +public class APIShortDescription { + + /** + * Name of the API in question. + */ + private final String name; + + /** + * Source this informatio summary is got from. + */ + private final String source; + + /** + * Description for the source shown in the UI. + */ + private final String sourceDescription; + + private ArrayList detailsShortData = null; + + + private APIDetails apiDetails = null; + + /** + * Constructor. + * @param name Name of the API. + * @param source Source this information summary is got from. Can be used + * to find further details. + * @param sourceDescription Description for the source shown in the UI. + */ + public APIShortDescription(String name, String source, String sourceDescription){ + this.name = name; + this.source = source; + this.sourceDescription = sourceDescription; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @return the source + */ + public String getSource() { + return source; + } + + /** + * @return the sourceDescription + */ + public String getSourceDescription() { + return sourceDescription; + } + + /** + * Set API Details for this Description + * @param apiDetails + */ + public void setAPIDetails(APIDetails apiDetails) { + this.apiDetails = apiDetails; + } + + /** + * Get API Details for this Description + * @param apiDetails or null if not set. + */ + public APIDetails getAPIDetails() { + return apiDetails; + } + + /** + * Check if this Description has {@link APIDetails} added. + * @return true if API Details is added, false otherwise. + */ + public boolean hasAPIDetails(){ + return apiDetails != null; + } + + public void addSerachedData (ArrayList serachedData) { + + this.detailsShortData =serachedData; + } + +public ArrayList getSearchedData() +{ + return detailsShortData; +} + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/APIShortDescriptionSearchResults.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/APIShortDescriptionSearchResults.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,114 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.datatypes; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +import com.nokia.s60tools.apiquery.shared.exceptions.QueryOperationFailedException; + +/** + * Class for holding search results and search errors. + */ +public class APIShortDescriptionSearchResults { + + public APIShortDescriptionSearchResults(){ + searchResults = new ArrayList(); + searchErrors = new ArrayList(); + } + + /** + * Search results + */ + private Collection searchResults = null; + + /** + * Search errors + */ + private Collection searchErrors = null; + + /** + * @return the searchResults + */ + public Collection getSearchResults() { + return searchResults; + } + + /** + * @param searchResults the searchResults to set + */ + public void addSearchResults(Collection searchResults) { + //Can't add null to results + if(searchResults != null){ + this.searchResults.addAll(searchResults); + } + } + + /** + * Get errors occurred when queries was executed + * @return the searchErrors + */ + public Collection getSearchErrors() { + return searchErrors; + } + + /** + * Add one search error. + * @param searchError + */ + public void addSearchError(QueryOperationFailedException searchError) { + + if(searchError != null){ + this.searchErrors.add(searchError); + } + } + + /** + * Check if there was some errors whit queries. + * @return true if there was some errors false otherwise. + */ + public boolean hasErrors(){ + return !this.searchErrors.isEmpty(); + } + + /** + * Get all error messages. One message takes one line, so if there is many errors there is as many lines of text also. + * @return Errors as list or empty string if there was not any. + */ + public String getErrorMessages(){ + if(!hasErrors()){ + return new String(); + } + else{ + StringBuffer errors = new StringBuffer(); + int count = searchErrors.size(); + int i = 0; + for (Iterator iterator = searchErrors.iterator(); iterator.hasNext();) { + QueryOperationFailedException err = (QueryOperationFailedException) iterator.next(); + errors.append(err.getMessage()); + if(count > 1 && i < (count - 1)){ + errors.append("\n");//$NON-NLS-1$ + } + i++; + } + return errors.toString(); + } + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/FieldMappingRules.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/FieldMappingRules.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.datatypes; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import com.nokia.s60tools.apiquery.shared.resources.Messages; + +/** + * Stores field mapping rules that can be used to + * map API detail field descriptions to XML + * and vice versa. + */ +public class FieldMappingRules { + + /** + * Storage for the mapping rules. + */ + Map ruleMap; + + /** + * Constructor + */ + public FieldMappingRules(){ + ruleMap = new HashMap(); + } + + /** + * Adds a new rule to the mapping rules. + * @param mapFromStr String to map from. + * @param mapToStr String to map into. + */ + public void addRule(String mapFromStr, String mapToStr){ + ruleMap.put(mapFromStr, mapToStr); + } + + /** + * Gets the string that was mapped into the given parameter string. + * @param keyStr Key string to ask mapped result for. + * @return Returns result string or throws IllegalArgumentException + * if no . + * @throws java.lang.IllegalArgumentException + * @see java.lang.IllegalArgumentException + */ + public String mapFrom(String keyStr){ + String resultStr = ruleMap.get(keyStr); + if(resultStr == null){ + throw new IllegalArgumentException(Messages.getString("FieldMappingRules.NoMappingRule_ErrMsg") + keyStr); //$NON-NLS-1$ + } + return resultStr; + } + + /** + * Returns key set that this field mapping rule instance + * has mapping rules for. + * @return Set of String key values. + */ + public Set getMapFromKeySet(){ + return ruleMap.keySet(); + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/QueryErrorInfo.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/QueryErrorInfo.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.datatypes; + +/** + * Simple class for storing error information returned query operations. + * This is needed because queries are runned inside a runnable and + * error info is got via try/catch, and the error information usage + * related needs to be done outside runnable where catch is made. + * This class should stay with package private visibility. + */ +public class QueryErrorInfo{ + /** + * Error description is set on failure. + */ + private String errorDescription = new String(); + + /** + * Gets error description. + * @return the errorDescription + */ + public String getErrorDescription() { + return errorDescription; + } + + /** + * Sets error description. + * @param errorDescription the errorDescription to set + */ + public void setErrorDescription(String errorDescription) { + this.errorDescription = errorDescription; + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/XMLToUIMappingRules.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/XMLToUIMappingRules.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,132 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.datatypes; + +import java.util.HashMap; +import java.util.Map; + +/** + * Extends field mapping rules class by + * including definitions for attributes. + */ +public class XMLToUIMappingRules extends FieldMappingRules { + + /** + * Storage for attributes that are examined for a certain + * element. + */ + private Map > attributeMap; + + /** + * Storing rules that enforces that rule does not match + * unless the parent element also matches. + * It is optional to set this restriction for a rule. + */ + private Map parentElementRestrictionMap = null; + + + /** + * Constructor. + */ + public XMLToUIMappingRules(){ + super(); + attributeMap = new HashMap>(); + parentElementRestrictionMap = new HashMap(); + } + + /** + * Adds a new rule to the mapping rules including + * a set of attribute names to be stored. + * @param elementNameStr Element name string to map from. + * @param mapToStr String to map into. + * @param attributes Set of attribute names to be converted. + */ + public void addRule(String elementNameStr, String mapToStr, Map attributes){ + super.addRule(elementNameStr, mapToStr); + attributeMap.put(elementNameStr, attributes); + } + + + /** + * @return the attributeMap + */ + public Map> getAttributeMap() { + return attributeMap; + } + + /** + * Adds a new rule to the mapping rules. + * @param mapFromStr String to map from. + * @param mapToStr String to map into. + * @param parentElementRestriction Rule matches only if the parent name matches. + */ + public void addRule(String mapFromStr, String mapToStr, String parentElementRestriction){ + this.parentElementRestrictionMap.put(mapFromStr, parentElementRestriction); + ruleMap.put(mapFromStr, mapToStr); + } + + /** + * Adds a new rule to the mapping rules including + * a set of attribute names to be stored. + * @param elementNameStr Element name string to map from. + * @param mapToStr String to map into. + * @param parentElementRestriction Rule matches only if the parent name matches. + * @param attributes Set of attribute names to be converted. + */ + public void addRule(String elementNameStr, String mapToStr, + String parentElementRestriction, Map attributes){ + super.addRule(elementNameStr, mapToStr); + this.parentElementRestrictionMap.put(elementNameStr, parentElementRestriction); + attributeMap.put(elementNameStr, attributes); + } + + + /** + * Gets parent element restriction for an element. + * @param elementNameStr Element name. + * @return parent element restriction or null if does not exist. + */ + public String getParentElementRestriction(String elementNameStr) { + return parentElementRestrictionMap.get(elementNameStr); + } + + /** + * Check existence of parent element restriction for an element. + * @param elementNameStr Element name. + * @return true if has restriction, otherwise false. + */ + public boolean hasParentElementRestriction(String elementNameStr) { + return parentElementRestrictionMap.containsKey(elementNameStr); + } + + /** + * Return parent restrictions for conversion rules. + * @return Parent restrictions for conversion rules. + */ + public Map getParentElementRestrictionMap() { + return parentElementRestrictionMap; + } + + /** + * Get map for attribute header names + * @return attribute headers or null if not set + */ + public Map getAttributeNamesMap(String elementNameStr) { + return getAttributeMap().get(elementNameStr); + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/config/AbstractEntry.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/config/AbstractEntry.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,129 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.datatypes.config; + +import com.nokia.s60tools.apiquery.settings.UserSettings; +import com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension; +import com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtensionInfo; +import com.nokia.s60tools.apiquery.shared.searchmethodregistry.SearchMethodExtensionRegistry; + + +/** + * Abstract entry base class that contains only id for the + * entry and method that are common for all entry types. + * + * To be subclassed in order to create concrete entry types. + */ +public abstract class AbstractEntry { + + /** + * User configurable id for the entry. The entries + * are identified by there unique id per search method + * configuration storage. + */ + protected final String id; + /** + * Set to true if user has selected this entry to + * be part of the search, otherwise false, + */ + protected boolean isSelected; + + /** + * Constructor + * @param id Entry id.that is unique per search method. + * @param isSelected Is the entry used for queries by default. + */ + protected AbstractEntry(String id, boolean isSelected){ + this.id = id; + this.isSelected = isSelected; + } + + /** + * @return the id for the entry. + */ + public String getId() { + return id; + } + + /** + * @return the isSelected + */ + public boolean isSelected() { + return isSelected; + } + + /** + * Sets selection status for the entry + * and notifies storage about the modification. + * @param isSelected the isSelected to set + */ + public void setSelected(boolean isSelected) { + this.isSelected = isSelected; + if(isSelected){ + notifyModification(IConfigurationChangedListener.ENTRY_CHECKED); + } + else{ + notifyModification(IConfigurationChangedListener.ENTRY_UNCHECKED); + } + } + + /** + * Sets selection status for the entry + * and notifies storage about the modification. + * @param isSelected the isSelected to set + * @param dontNotifyListeners if true listeners will not be notified. + */ + public void setSelected(boolean isSelected, boolean dontNotifyListeners) { + if(dontNotifyListeners){ + this.isSelected = isSelected; + } + else { + setSelected(isSelected); + } + } + + /** + * Notifies storage object that this entry has been modified. + * @param eventType Event type of the modification. + */ + protected void notifyModification(int eventType){ + ISearchMethodExtensionInfo currSelExtInfo = UserSettings.getInstance().getCurrentlySelectedSearchMethodInfo(); + String id = currSelExtInfo.getId(); + ISearchMethodExtension currSelExt = SearchMethodExtensionRegistry.getInstance().getById(id); + AbstractEntryStorage storage = currSelExt.getEntryStorageInstance(); + storage.entryModified(this, eventType); + } + + /** + * Calls template method to updates concrete type entry-specific data fields + * and notifies listeners about the modification. + * @param entryWithUpdatedData Entry with new data. + */ + public void updateDataFields(AbstractEntry entryWithUpdatedData){ + updateEntryTypeSpecificDataFields(entryWithUpdatedData); + notifyModification(IConfigurationChangedListener.ENTRY_MODIFIED); + } + + /** + * The following template method updates concrete type entry-specific data fields. + * @param entryWithUpdatedData Entry with new data. + */ + public abstract void updateEntryTypeSpecificDataFields(AbstractEntry entryWithUpdatedData); + + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/config/AbstractEntryStorage.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/config/AbstractEntryStorage.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,261 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.datatypes.config; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; + +import com.nokia.s60tools.apiquery.shared.resources.Messages; + +/** + * Abstract entry storage base class that contains only + * the methods that are common for all entry types. + * + * To be subclassed in order to create concrete entry storage. + */ +public abstract class AbstractEntryStorage { + + /** + * Entry storage Map. + */ + protected Map entriesMap = new LinkedHashMap(); + /** + * Configuration change listener list. + */ + protected ArrayList configChangeListeners = new ArrayList(); + + /** + * Constructor + */ + protected AbstractEntryStorage(){ + } + + /** + * Adds configuration change listener. + * @param listener Configuration change listener. + */ + public void addConfigurationChangeListener(IConfigurationChangedListener listener) { + configChangeListeners.add(listener); + } + + /** + * Removes configuration change listener. + * @param listener Configuration change listener. + */ + public void removeConfigurationChangeListener(IConfigurationChangedListener listener) { + configChangeListeners.remove(listener); + } + + /** + * Notifies listeners about the configuration change. + * @param eventType Event type . + */ + public void notifyConfigurationChangeListeners(int eventType) { + for (IConfigurationChangedListener listener : configChangeListeners) { + listener.configurationChanged(eventType); + } + } + + /** + * Adds an entry to the storage. + * @param entry Entry to be added. + * @throws DuplicateEntryException + */ + public void addEntry(AbstractEntry entry) throws DuplicateEntryException { + if(entriesMap.get(entry.getId()) != null){ + String duplicateEntriesErrMsg = Messages.getString("AbstractEntryStorage.Duplicate_ErrMsg"); //$NON-NLS-1$ + throw new DuplicateEntryException(duplicateEntriesErrMsg); + } + entriesMap.put(entry.getId(), entry); + notifyConfigurationChangeListeners(IConfigurationChangedListener.ENTRY_ADDED); + } + + /** + * Updates an entry to the storage. + * @param entryWithNewData Entry object containing new data. + * @throws EntryNotFoundException + */ + public void updateEntry(AbstractEntry entryWithNewData) throws EntryNotFoundException { + AbstractEntry entryWithOldData = (AbstractEntry) entriesMap.get(entryWithNewData.getId()); + if(entryWithOldData == null){ + String nonExistingEntryMsg = Messages.getString("AbstractEntryStorage.NonExistingEntry_ErrMsg") + entryWithNewData.getId(); //$NON-NLS-1$ + throw new EntryNotFoundException(nonExistingEntryMsg); + } + // Updating data fields (which triggers notification to configuration change listeners) + entryWithOldData.updateDataFields(entryWithNewData); + } + + /** + * Removes the given entry from the storage. + * @param entry Entry. + */ + public void removeEntry(AbstractEntry entry) { + entriesMap.remove(entry.getId()); + notifyConfigurationChangeListeners(IConfigurationChangedListener.ENTRY_REMOVED); + } + + /** + * Remove all entrys. + */ + public void removeAllEntrys() { + entriesMap.clear(); + notifyConfigurationChangeListeners(IConfigurationChangedListener.ALL_ENTRYS_REMOVED); + } + + + /** + * Returns the iterator for the currently registered entries. + * @return Returns the currently registered entries. + */ + public Collection getEntries() { + return entriesMap.values(); + } + + /** + * Gets the amount of currently registered entries. + * @return Returns the amount of currently registered entries. + */ + public int getEntryCount() { + return getEntries().size(); + } + + /** + * Gets the entry that matches with the given id. + * @param entryId Id for the entry. + * @return The entry matching the id or null if not found. + */ + public AbstractEntry getByEntryId(String entryId) { + for (AbstractEntry entry : getEntries()) { + if(entry.getId().equals(entryId)){ + return entry; + } + } + return null; + } + + + /** + * Returns those entries that are selected by used from entry storage. + * @return Colletion of selected entries. + */ + public Collection getSelectedEntriesCollection() { + ArrayList selectedList = new ArrayList(); + for (Iterator iter = getEntries().iterator(); iter.hasNext();) { + AbstractEntry entry = (AbstractEntry) iter.next(); + if(entry.isSelected()){ + selectedList.add(entry); + } + } + return selectedList; + } + + /** + * Returns those entries that are selected by used from entry storage. + * @return Array of selected entries. + */ + public AbstractEntry[] getSelectedEntries() { + ArrayList selectedList = new ArrayList(); + for (Iterator iter = getEntries().iterator(); iter.hasNext();) { + AbstractEntry entry = (AbstractEntry) iter.next(); + if(entry.isSelected()){ + selectedList.add(entry); + } + } + return selectedList.toArray(new AbstractEntry[0]); + } + + /** + * Checks if the given entry is part of the storage. + * @param entry Entry object. + * @return true if part of the storage, otherwise false. + */ + public boolean contains(AbstractEntry entry) { + return entriesMap.containsKey(entry.getId()); + } + + /** + * Informs storage that an entry has been modified. Storage + * informs further the configuration listeners, if this + * entry was part active configuration. + * @param entry Entry object. + * @param eventType Event type for modification. + */ + public void entryModified(AbstractEntry entry, int eventType) { + if(contains(entry)){ + // Active configuration has been changed. + notifyConfigurationChangeListeners(eventType); + } + } + + /** + * Selects all stored entries and notifies listeners. + */ + public void selectAll() { + for (AbstractEntry entry : getEntries()) { + ((AbstractEntry)entry).setSelected(true); + } + notifyConfigurationChangeListeners(IConfigurationChangedListener.ALL_ENTRIES_CHECKED); + } + + /** + * Selects all stored entries and notifies listeners. + */ + public void deselectAll() { + for (AbstractEntry entry : getEntries()) { + ((AbstractEntry)entry).setSelected(false); + } + notifyConfigurationChangeListeners(IConfigurationChangedListener.ALL_ENTRIES_UNCHECKED); + } + + /** + * Selects all stored entries and notifies listeners. + * @param notifyListenersOnlyWhenAllDeselected if true listeners will be + * notified only when all entrys is deselected, not one by one when deselecting entrys. + */ + public void deselectAll(boolean notifyListenersOnlyWhenAllDeselected) { + + if(notifyListenersOnlyWhenAllDeselected){ + for (AbstractEntry entry : getEntries()) { + ((AbstractEntry)entry).setSelected(false, true); + } + notifyConfigurationChangeListeners(IConfigurationChangedListener.ALL_ENTRIES_UNCHECKED); + }else{ + deselectAll(); + } + + } + + /** + * Saves the configuration into an external configuration file. + * Note: Overwrites the contents of the external file. + * @param destinationFileAbsolutePathName Absolute pathname for the external configuration file to be used. + * @throws IOException + */ + public abstract void save(String destinationFileAbsolutePathName) throws IOException; + + /** + * Loads the configuration into an external configuration file. + * @param storageFilePathName Absolute path name for the configuration file. + * @throws IOException + */ + public abstract void load(String storageFilePathName) throws IOException; +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/config/DuplicateEntryException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/config/DuplicateEntryException.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.datatypes.config; + +/** + * This exception might be raised by the search methods + * when query operation fails due to some reason. + * + * There might be several reasons for the failure such as: + * + * - Missing or invalid configuration information to run + * the query operation. + * - Required data is not availabe (due to network restrictions, cached data + * is missing from the local disk etc.) + */ +public class DuplicateEntryException extends Exception { + + /** + * Serial versio UID. + */ + private static final long serialVersionUID = -4168668065952326532L; + + /** + * Default constructor is hidden from the user. + */ + @SuppressWarnings("unused") + private DuplicateEntryException(){ + super(); + } + + /** + * Only publicly available constructor is one with detailed error information. + * @param errorMessage Detailed information about the error that caused the exception. + */ + public DuplicateEntryException(String errorMessage){ + super(errorMessage); + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/config/EntryNotFoundException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/config/EntryNotFoundException.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.datatypes.config; + +/** + * This exception might be raised by the search methods + * when query operation fails due to some reason. + * + * There might be several reasons for the failure such as: + * + * - Missing or invalid configuration information to run + * the query operation. + * - Required data is not availabe (due to network restrictions, cached data + * is missing from the local disk etc.) + */ +public class EntryNotFoundException extends Exception { + + /** + * Serial versio UID. + */ + private static final long serialVersionUID = 803831180171819626L; + + /** + * Default constructor is hidden from the user. + */ + @SuppressWarnings("unused") + private EntryNotFoundException(){ + super(); + } + + /** + * Only publicly available constructor is one with detailed error information. + * @param errorMessage Detailed information about the error that caused the exception. + */ + public EntryNotFoundException(String errorMessage){ + super(errorMessage); + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/config/IConfigurationChangedListener.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/datatypes/config/IConfigurationChangedListener.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.shared.datatypes.config; + +/** + * Interface for the services that needs to know if + * configuration has been changed. + */ +public interface IConfigurationChangedListener { + + /** + * Entry added event type. + */ + public static final int ENTRY_ADDED = 0; + + /** + * Entry modified event type. + */ + public static final int ENTRY_MODIFIED = 1; + + /** + * Entry removed event type. + */ + public static final int ENTRY_REMOVED = 2; + + /** + * Entry selected event type. + */ + public static final int ENTRY_CHECKED = 3; + + /** + * Entry deselected event type. + */ + public static final int ENTRY_UNCHECKED = 4; + + /** + * All entries selected event type. + */ + public static final int ALL_ENTRIES_CHECKED = 5; + + /** + * All entries deselected event type. + */ + public static final int ALL_ENTRIES_UNCHECKED = 6; + + /** + * All Entrys removed event type. + */ + public static final int ALL_ENTRYS_REMOVED = 7; + + /** + * All Entrys updated event type. + */ + public static final int ALL_ENTRYS_UPDATED = 8; + + /** + * All selected Entrys removed event type. + */ + public static final int ALL_SELECTED_ENTRYS_REMOVED = 9; + + /** + * Configuration change notification method. + * @param eventType One of the event types define in this interface. + */ + public void configurationChanged(int eventType); +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/exceptions/QueryOperationFailedException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/exceptions/QueryOperationFailedException.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.exceptions; + +import java.util.Collection; + +import com.nokia.s60tools.apiquery.shared.datatypes.APIShortDescription; + +/** + * This exception might be raised by the search methods + * when query operation fails due to some reason. + * + * There might be several reasons for the failure such as: + * + * - Missing or invalid configuration information to run + * the query operation. + * - Required data is not availabe (due to network restrictions, cached data + * is missing from the local disk etc.) + */ +public class QueryOperationFailedException extends Exception { + + /** + * Serial versio UID. + */ + private static final long serialVersionUID = -8124615355279044581L; + + /** + * API Query summarys for search if those was gathered before error occurred + */ + private Collection summary = null; + + /** + * Default constructor is hidden from the user. + */ + @SuppressWarnings("unused") + private QueryOperationFailedException(){ + super(); + } + + /** + * Only publicly available constructor is one with detailed error information. + * @param errorMessage Detailed information about the error that caused the exception. + */ + public QueryOperationFailedException(String errorMessage){ + super(errorMessage); + } + + /** + * Set summarys for this exeption + * @param summary + */ + public void setSummarys(Collection summary) { + this.summary = summary; + } + /** + * @return the summarys or null if not set + */ + public Collection getSummarys() { + return summary; + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/exceptions/XMLNotValidException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/exceptions/XMLNotValidException.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.exceptions; + +/** + * Thrown when invalid XML data is encountered. + */ +public class XMLNotValidException extends Exception { + + private static final long serialVersionUID = -3037053770134709611L; + private String fileName = null; + + /** + * Private hidden constructor. + */ + @SuppressWarnings("unused") + private XMLNotValidException(){ + super(); + } + /** + * Public constructor coming always with descriptive message. + */ + public XMLNotValidException(String message){ + super(message); + } + + /** + * Public constructor coming always with descriptive message. + */ + public XMLNotValidException(String message, String fileName){ + super(message); + this.fileName = fileName; + } + + /** + * Get file name + * @return file name or null if not set. + */ + public String getFileName() { + return fileName; + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/job/AbstractJob.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/job/AbstractJob.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,159 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.shared.job; + +import java.util.Date; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.jobs.Job; + +import com.nokia.s60tools.apiquery.shared.resources.Messages; +import com.nokia.s60tools.util.debug.DbgUtility; + +/** + * Abstract implementation of {@link Job}. Implements few functionalities so sub classes + * can be written with less code. + */ +public abstract class AbstractJob extends Job implements IJobProgressStatus, IManageableJob{ + + protected static final int PROGRESS_COMPLETED_PERCENTAGE = 100; + protected int previousPercentage = 0; + private IProgressMonitor monitor = null; + private Process process = null; + private long runMethodStartTime; + + protected int steps = 100; // percentage figure + + /** + * Use only this constructor + * + * @param name Job name (root component name) + */ + public AbstractJob(String name) { + super(name); + } + + /** + * Get start time and print it + * @return start time in ms (System.currentTimeMillis()) + */ + public long reportStartTime(){ + this.runMethodStartTime = System.currentTimeMillis(); + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, + "Job: '" +super.getName() + "' start time: " //$NON-NLS-1$ //$NON-NLS-2$ + + new Date(runMethodStartTime).toString()); + return runMethodStartTime; + } + + /** + * count time taken since startTime, printing it + * @param runMethodStartTime + */ + public void reportEndTime(){ + long endTime = System.currentTimeMillis(); + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, + "Job " +super.getName() + " ended: " + new Date(endTime).toString()); //$NON-NLS-1$ //$NON-NLS-2$ + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, + "TOTAL: " //$NON-NLS-1$ + + (endTime-runMethodStartTime)/1000.0 + " seconds!"); //$NON-NLS-1$ + } + + + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.shared.job.IJobProgressStatus#progress(int, java.lang.String) + */ + public void progress(int percentage, String prosessing) + throws JobCancelledByUserException { + + if (isCanceled()){ + String msg = Messages.getString("AbstractJob.JobCancelled_Part1_ErrMsg") +super.getName() + Messages.getString("AbstractJob.JobCancelled_Part2_ErrMsg"); //$NON-NLS-1$ //$NON-NLS-2$ + throw new JobCancelledByUserException(msg); + } + //Making sure that there is no percentages higher than 100 + if(percentage > PROGRESS_COMPLETED_PERCENTAGE){ + percentage = PROGRESS_COMPLETED_PERCENTAGE; + } + + monitor.subTask(percentage + Messages.getString("AbstractJob.Percentage_Complete_Msg") //$NON-NLS-1$ + + Messages.getString("AbstractJob.Prosessing_Msg") //$NON-NLS-1$ + + prosessing); + monitor.worked(percentage - previousPercentage); + previousPercentage = percentage; + + } + + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.shared.job.IJobProgressStatus#isCanceled() + */ + public boolean isCanceled() { + return monitor.isCanceled(); + } + + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.shared.job.IManageableJob#forcedShutdown() + */ + public void forcedShutdown() { + if(process != null){ + process.destroy(); + try { + process.waitFor(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + + + /** + * Get Process + * @return Process + */ + protected Process getProcess() { + return process; + } + + + /** + * Set process + * @param process + */ + protected void setProcess(Process process) { + this.process = process; + } + + /** + * Get progress monitor + * @return + */ + protected IProgressMonitor getMonitor() { + return monitor; + } + + /** + * Set progress monitor to this Job + * @param monitor + */ + protected void setMonitor(IProgressMonitor monitor) { + this.monitor = monitor; + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/job/FindFileFromFoldersJob.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/job/FindFileFromFoldersJob.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,235 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.job; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; + +import com.nokia.s60tools.apiquery.shared.resources.Messages; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.util.resource.FileFinder; +import com.nokia.s60tools.util.resource.IFileFinderObserver; + +/** + * Job for seeking header file from under SDK:s include paths given given. + */ +public class FindFileFromFoldersJob extends AbstractJob implements IFileFinderObserver { + + + + /** + * Total steps as double, to be able to count percentages. + */ + double stepsAsDouble = 1; + + /** + * Name of the file to be seeked + */ + private final String fileName; + + /** + * Paths where to seek the file + */ + private final List paths; + + /** + * Unique ID of SDK where file is seeked. + */ + private final String sdkId; + + /** + * Collection holds files found to be returned for client. + */ + private Collection foundFiles = null; + + + /** + * Create a Job to seek .metaxml files under selected SDK. + * @param name + * @param sdkInformation + */ + public FindFileFromFoldersJob(String name, List paths, String fileName, String sdkId) { + super(name); + this.paths = paths; + this.fileName = fileName; + this.sdkId = sdkId; + setUser(true); + } + + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) + */ + protected IStatus run(IProgressMonitor monitor) { + setMonitor(monitor); + try { + reportStartTime(); + FileFinder finder = new FileFinder(APIQueryConsole.getInstance()); + + String fileNames [] = new String[1]; + fileNames[0] = fileName; + String [] folders = new String[paths.size()]; + int i = 0; + for (Iterator iterator = paths.iterator(); iterator.hasNext();) { + File file = (File) iterator.next(); + folders[i] = file.getAbsolutePath(); + i++; + } + finder.seekFilesFromFolders(this, fileNames, folders); + return Job.ASYNC_FINISH; + } catch (Exception e) { + IStatus status = new Status( + Status.ERROR,Platform.PI_RUNTIME, + Status.ERROR,Messages.getString("FindFileFromFoldersJob.ErrorOnSeekin_StatusMsg_Part1") +fileName +Messages.getString("FindFileFromFoldersJob.ErrorOnSeekin_StatusMsg_Part2") +sdkId, e); //$NON-NLS-1$ //$NON-NLS-2$ + return status; + } + + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.util.resource.IFileFinderObserver#completed(int, java.util.Collection) + */ + public void completed(int exitValue, Collection files) { + + try { + if(isCanceled() || exitValue == IStatus.CANCEL){ + interrupted(Messages.getString("FindFileFromFoldersJob.CancelledByUser_Msg")); //$NON-NLS-1$ + } + else if(exitValue == IStatus.OK){ + handleSeekCompleatedOK(files); + } + else{ + handleSeekCompleatedError(exitValue); + } + reportEndTime(); + } catch (Exception e) { + //Handle file not found e.g. errors. + e.printStackTrace(); + handleSeekCompleatedError(e); + } + } + + /** + * Handle Error situations after getting data + * @param e + */ + private void handleSeekCompleatedError(Exception e) { + String message = Messages.getString("FindFileFromFoldersJob.ErrorSeekingFile_ErrMsg_Part1") +fileName +Messages.getString("FindFileFromFoldersJob.ErrorSeekingFile_ErrMsg_Part2") +sdkId; //$NON-NLS-1$ //$NON-NLS-2$ + APIQueryConsole.getInstance().println(message, APIQueryConsole.MSG_ERROR); + IStatus status = new Status( + Status.ERROR,Platform.PI_RUNTIME, + Status.ERROR,message, e); + + done(status); + } + + /** + * Handle error return values + * @param exitValue + */ + private void handleSeekCompleatedError(int exitValue) { + String message = Messages.getString("FindFileFromFoldersJob.ErrorSeekingFileWithValue_ErrMsg_Part1") +fileName +Messages.getString("FindFileFromFoldersJob.ErrorSeekingFileWithValue_ErrMsg_Part2") +sdkId + Messages.getString("FindFileFromFoldersJob.ErrorSeekingFileWithValue_ErrMsg_Part3") +exitValue; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + APIQueryConsole.getInstance().println(message, APIQueryConsole.MSG_ERROR); + IStatus status = new Status( + Status.ERROR,Platform.PI_RUNTIME, + Status.ERROR,message, null); + + done(status); + } + + /** + * If status was OK, handling completed situation + * @param files + * @throws FileNotFoundException + * @throws IOException + */ + private void handleSeekCompleatedOK(Collection files) throws FileNotFoundException, IOException { + + //We are pretty much done, so marking that we are in 100% of progress, opening file found won't happen in this job anyway + progress(steps, Messages.getString("FindFileFromFoldersJob.FileFound_Progress_Msg_Part1") +fileName +Messages.getString("FindFileFromFoldersJob.FileFound_Progress_Msg_Part2")); //$NON-NLS-1$ //$NON-NLS-2$ + foundFiles = files; + reportEndTime(); + done(Status.OK_STATUS); + } + + + /** + * Get file found in job + * @return files found + */ + public Collection getFoundSourceFiles(){ + return foundFiles; + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.util.resource.IFileFinderObserver#interrupted(java.lang.String) + */ + public void interrupted(String reasonMsg) { + done(Status.CANCEL_STATUS); + super.cancel(); + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.util.resource.IFileFinderObserver#isCancelled() + */ + public boolean isCanceled(){ + return getMonitor().isCanceled(); + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.util.resource.IFileFinderObserver#beginTask(java.lang.String, int) + */ + public void beginTask(String name, int steps) { + + //Its not allowed to dived with "0" + if(steps < 1){ + steps = 1; + } + this.steps = steps; + stepsAsDouble = new Double(steps).doubleValue(); + + getMonitor().beginTask(name, PROGRESS_COMPLETED_PERCENTAGE); + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.shared.job.AbstractJob#progress(int, java.lang.String) + */ + public void progress(int stepsCompleated, String prosessing) { + + try { + int persentage = (new Double( stepsCompleated / stepsAsDouble * 100)).intValue(); + + super.progress(persentage, prosessing); + } catch (JobCancelledByUserException e) { + e.printStackTrace(); + done(Status.CANCEL_STATUS); + } + } + + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/job/IJobCompletionListener.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/job/IJobCompletionListener.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.shared.job; + +import com.nokia.s60tools.apiquery.shared.job.IManageableJob;; + + + +/** + * Listener interface for object requiring information + * about successfull cache creation. + */ +public interface IJobCompletionListener { + + /** + * Informs the listener about successful cache index creation. + * @param cacheIndexObj Cache index that was just created. + */ + public void backgroundJobCompleted(IManageableJob jobObject); + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/job/IJobProgressStatus.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/job/IJobProgressStatus.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.job; + + +public interface IJobProgressStatus { + /** + * Reports progress of a batch process like + * execution. It depends on the invoked command + * if any progress information can be gained. + * @param percentage Progress percentage. + * @param processedItem Item that is currently under processing. + * @throws JobCancelledByUserException + */ + public void progress(int percentage, String processedItem) throws JobCancelledByUserException; + + /** + * Checks if job has been cancelld by the user. + * @return Returns true if jobs has been cancelled by user, + * otherwise false. + */ + public boolean isCanceled(); +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/job/IManageableJob.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/job/IManageableJob.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.shared.job; + +/** + * Jobs that implement this interface can be asked to + * shutdown themselves during their execution. For example, + * when a plugin is disposed it is a good idea to request + * for all the managed jobs to also interrupt their + * execution. + */ +public interface IManageableJob { + public void forcedShutdown(); +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/job/JobCancelledByUserException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/job/JobCancelledByUserException.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.job; + +/** + * {@link Exception} class for Job cancelled by User. + */ +public class JobCancelledByUserException extends Exception { + + public JobCancelledByUserException(String msg) { + super(msg); + } + + + private static final long serialVersionUID = -235428303120175424L; + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/plugin/APIQueryPlugin.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/plugin/APIQueryPlugin.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,532 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.shared.plugin; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.URL; +import java.util.Collection; +import java.util.Properties; + +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +import com.nokia.s60tools.apiquery.settings.IUserSettingsListener; +import com.nokia.s60tools.apiquery.settings.UserSettings; +import com.nokia.s60tools.apiquery.shared.common.ProductInfoRegistry; +import com.nokia.s60tools.apiquery.shared.resources.ImageKeys; +import com.nokia.s60tools.apiquery.shared.resources.Messages; +import com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension; +import com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtensionInfo; +import com.nokia.s60tools.apiquery.shared.searchmethodregistry.SearchMethodExtensionRegistry; +import com.nokia.s60tools.apiquery.shared.ui.dialogs.APIQueryMessageBox; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.apiquery.ui.dialogs.FirstTimePopUpDialog; +import com.nokia.s60tools.util.console.IConsolePrintUtility; +import com.nokia.s60tools.util.debug.DbgUtility; + +/** + * The main plugin class to be used in the desktop. + */ +public class APIQueryPlugin extends AbstractUIPlugin implements IUserSettingsListener { + + + /** + * API Query plugin ID + */ + public static final String PLUGIN_ID ="com.nokia.s60tools.apiquery";//$NON-NLS-1$ + + /** + * Extension point declared by this plugin the extender + * plugins can use for adding new search methods. + */ + private static final String SEARCH_METHOD_EXTENSION_POINT_ID = "com.nokia.s60tools.apiquery.searchMethods"; //$NON-NLS-1$ + + /** + * Attribute for the extension point that store the name of the class + * that implements a search method extension. + */ + private static final String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$ + + /** + * Default name for file to store user-configured server entries. + */ + private static final String DATA_SOURCES_PROPERTIES_FILE_NAME = "datasources.properties"; //$NON-NLS-1$ + + /** + * Property name for getting selected data source + */ + private static final String DATA_SOURCES_PROPERTIES_SELECTED_DATA_SOURCE = "selected_datasource"; //$NON-NLS-1$ + + /** + * Absolute path name for the plug-in specific configuration file. + */ + private static String configFilePath; + + /** + * Shared plugin instance. + */ + private static APIQueryPlugin plugin; + + /** + * Plugin installation location. + */ + private static String pluginInstallLocation; + + /** + * Data Source registry for storing the currently + * installed search methods. The registry must be + * alive as long as the plugin class is alive. + */ + private static SearchMethodExtensionRegistry smeRegistry = SearchMethodExtensionRegistry.getInstance(); + + /** + * User settings instance. The settings instance must be + * alive as long as the plugin class is alive. + */ + private static UserSettings settings = UserSettings.getInstance(); + + /** + * Storing preferences + */ + private static IPreferenceStore prefsStore; + + static public boolean isFirstLaunch = false; + + /** + * The constructor. + */ + public APIQueryPlugin() { + System.out.println("Plugin start"); + isFirstLaunch = true; + plugin = this; + DbgUtility.println(DbgUtility.PRIORITY_CLASS, "-- <> --> " + getClass().getName()); //$NON-NLS-1$ + } + + /** + * + * @return plugin install path + * @throws IOException + */ + public String getPluginInstallPath() throws IOException{ + // URL to the plugin's root ("/") + URL relativeURL = getBundle().getEntry("/"); //$NON-NLS-1$ + // Converting into local path + URL localURL = FileLocator.toFileURL(relativeURL); + // Getting install location in correct form + File f = new File(localURL.getPath()); + String pluginInstallLocation = f.getAbsolutePath(); + + return pluginInstallLocation; + } + + /** + * Gets images path relative to given plugin install path. + * @return Path were image resources are located. + */ + private String getImagesPath(){ + return pluginInstallLocation + + File.separatorChar + + ProductInfoRegistry.getImagesDirectoryName(); + } + + + + /** + * This method is called upon plug-in activation + */ + public void start(BundleContext context) throws Exception { + super.start(context); + //This startup debug println has been left into the code in purpose + System.out.println("APIQuery Plugin STARTUP..."); //$NON-NLS-1$ + + pluginInstallLocation = getPluginInstallPath(); + + + //This startup debug println has been left into the code in purpose + System.out.println("pluginInstallLocation: " + pluginInstallLocation); //$NON-NLS-1$ + + // Call to getImagesPath requires that getPluginInstallPath() is + // called beforehand. + String imagesPath = getImagesPath(); + + //This startup debug println has been left into the code in purpose + System.out.println("imagesPath: " + imagesPath); //$NON-NLS-1$ + + // Seeking for the plugins that extend the SEARCH_METHOD_EXTENSION_POINT_ID + fetchExistingSearchMethodExtensionInstances(); + + // User settings initialization has to be done after fetching search methods. + initializeUserSettings(); + + + } + + + + + + /** + * Returns runtime workspace directory path for the plugin, which + * can be used e.g. to store plugin/workspace-specific configuration data. + * + * @return Workspace directory path for the plugin. + */ + public static String getPluginWorkspacePath(){ + IPath runtimeWorkspacePath = plugin.getStateLocation(); + runtimeWorkspacePath.makeAbsolute(); + return runtimeWorkspacePath.toOSString(); + } + + /** + * Loading the previously stored user settings if any. + */ + private void initializeUserSettings() { + // In here will be implemented the load part of the functionality. + + try { + String wsPath = getPluginWorkspacePath(); + configFilePath = wsPath + File.separator + DATA_SOURCES_PROPERTIES_FILE_NAME; + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "Data Source's config file: " + configFilePath); //$NON-NLS-1$ + File configFile = new File(configFilePath); + //If User setting has not been chaged, there is no configuration file + if(configFile.exists()){ + Properties props = new Properties(); + props.load( new FileInputStream(configFile)); + String currentDataSource = props.getProperty(DATA_SOURCES_PROPERTIES_SELECTED_DATA_SOURCE); + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "Currently selected data source is: " +currentDataSource); //$NON-NLS-1$ + + //Getting search extension by id + ISearchMethodExtension ext = smeRegistry.getById(currentDataSource); + //If no errors exist, saving currently selected Data Source to Runtime from propertie file. + if(ext != null){ + ISearchMethodExtensionInfo info = ext.getExtensionInfo(); + UserSettings.getInstance().setCurrentlySelectedSearchMethodInfo(info); + } + + } + //If there is no configuration file, we know that this is the first time + //user is starting application (at least in this work space, if user is cleaned workspace + //or created a new works space he/she might been started application before, but we can't know that). + else{ + //Create a config file by calling userSettingsChanged() + userSettingsChanged(); + //Launching first time popup (quick help) + FirstTimePopUpDialog.open(getCurrentlyActiveWbWindowShell()); + + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + APIQueryConsole.getInstance().println(Messages.getString("APIQueryPlugin.Configuration_file_ErrMsg") //$NON-NLS-1$ + + e.getMessage() , IConsolePrintUtility.MSG_ERROR); + } catch (IOException e) { + e.printStackTrace(); + APIQueryConsole.getInstance().println(Messages.getString("APIQueryPlugin.Configuration_file_ErrMsg") //$NON-NLS-1$ + + e.getMessage() , IConsolePrintUtility.MSG_ERROR); + }catch (Exception e) { + e.printStackTrace(); + APIQueryConsole.getInstance().println(Messages.getString("APIQueryPlugin.Configuration_file_ErrMsg") //$NON-NLS-1$ + + e.getMessage() , IConsolePrintUtility.MSG_ERROR); + } + } + + + + /** + * Seeking for the plugins that extend the SEARCH_METHOD_EXTENSION_POINT_ID + * and registering them to the SearchMethodExtensionRegistry. + */ + private void fetchExistingSearchMethodExtensionInstances() { + + try { + + System.out.println("Fetching for search method extensions..."); //$NON-NLS-1$ + // Searching for search method extensions + IExtensionRegistry extensionReg = Platform.getExtensionRegistry(); + IExtensionPoint extPoint = extensionReg + .getExtensionPoint(SEARCH_METHOD_EXTENSION_POINT_ID); + IExtension[] searchMethods = extPoint.getExtensions(); + for (int i = 0; i < searchMethods.length; i++) { + IExtension ext = searchMethods[i]; + IConfigurationElement[] configElements = ext + .getConfigurationElements(); + for (int j = 0; j < configElements.length; j++) { + IConfigurationElement configElem = configElements[j]; + + String searchMethodClassFullName = configElem.getAttribute(CLASS_ATTRIBUTE); + + try { + // Creating search method extension intance + Object classInstance = configElem + .createExecutableExtension(CLASS_ATTRIBUTE); + + ISearchMethodExtension searchMethod = (ISearchMethodExtension) classInstance; + + System.out.println("Found search method: " //$NON-NLS-1$ + + searchMethod.getClass().getName()); + + ISearchMethodExtensionInfo info = searchMethod.getExtensionInfo(); + + System.out.println("\t id: " + info.getId()); //$NON-NLS-1$ + System.out.println("\t description: " //$NON-NLS-1$ + + info.getDescription()); + + boolean isDefault = info.isDefault(); + System.out.println("\t isDefault: " //$NON-NLS-1$ + + isDefault); + + // Adding the extension to local extension registry + smeRegistry.addExtension(searchMethod); + } catch (Exception e) { + APIQueryConsole.getInstance().println(Messages.getString("APIQueryPlugin.Search_Method_Instantiate_Failed_Msg_Start") //$NON-NLS-1$ + + searchMethodClassFullName + + Messages.getString("APIQueryPlugin.Search_Method_Instantiate_Failed_Msg_End") //$NON-NLS-1$ + + e.getMessage() , IConsolePrintUtility.MSG_ERROR); + e.printStackTrace(); + } + } + } + } catch (Exception e) { + APIQueryConsole.getInstance().println(Messages.getString("APIQueryPlugin.Search_Method_Instantiate_Failed_Console_Msg") //$NON-NLS-1$ + + e.getMessage() , IConsolePrintUtility.MSG_ERROR); + e.printStackTrace(); + } + + if(!(smeRegistry.getExtensionCount() > 0)){ + String errMsg = Messages.getString("APIQueryPlugin.No_Search_Method_Installed_ErrorMsg_Start") //$NON-NLS-1$ + + ProductInfoRegistry.getProductName() + Messages.getString("APIQueryPlugin.No_Search_Method_Installed_ErrorMsg_End"); //$NON-NLS-1$ + APIQueryConsole.getInstance().println(errMsg, IConsolePrintUtility.MSG_ERROR); + new APIQueryMessageBox(errMsg, SWT.ICON_ERROR | SWT.OK).open(); + throw new RuntimeException(errMsg); + } + + // Finding out the search method that is selected initally + setCurrentlySelectedSearchMethod(smeRegistry.getExtensions()); + + + // Listening further changes in the user settings. + settings.addUserSettingListener(this); + } + + /** + * Sets the default search method as the currently selected search method + * if there is no previous user preference. + * @param searchMethodExtensions + */ + private void setCurrentlySelectedSearchMethod(Collection searchMethodExtensions) { + + // Querying for the current user preference + ISearchMethodExtensionInfo userSelectedExtensionInfo = settings.getCurrentlySelectedSearchMethodInfo(); + + // The result of the decision process is stored into the following variable + ISearchMethodExtensionInfo selectedExtInfo = null; + + if(userSelectedExtensionInfo == null){ + + // There were no previous user settings existing + + // If there is no existing user preference, we select + // among the available search methods. + // + // Current decision algorithm is to select the first one + // from the list that has default status. If no search + // methods with default status were not found settings, + // the last search method found is set as default. + + for (ISearchMethodExtension ext : searchMethodExtensions) { + selectedExtInfo = ext.getExtensionInfo(); + + if(selectedExtInfo.isDefault()){ + break; + } + } + } + else{ + + // There was a previous user preference + + // Browsing through the extension list and setting as default + // the search that has the id equal with the user preference. + // + // If no search methods that match with the user preference + // the last search method found is set as default. + + for (ISearchMethodExtension ext : searchMethodExtensions) { + selectedExtInfo = ext.getExtensionInfo(); + + if(selectedExtInfo.hasEqualId(settings.getCurrentlySelectedSearchMethodInfo())){ + break; + } + } + + } + + settings.setCurrentlySelectedSearchMethodInfo(selectedExtInfo); + } + + /** + * This method is called when the plug-in is stopped + */ + public void stop(BundleContext context) throws Exception { + super.stop(context); + smeRegistry.notifyPluginShutdown(); + plugin = null; + } + + /** + * Returns the shared instance. + */ + public static APIQueryPlugin getDefault() { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path. + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return AbstractUIPlugin.imageDescriptorFromPlugin("com.nokia.s60tools.apiquery.plugin", path); //$NON-NLS-1$ + } + + /** + * This must be called from UI thread. If called + * from non-ui thread this returns null. + * @return Currently active workbench page. + */ + public static IWorkbenchPage getCurrentlyActivePage(){ + return getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(); + } + + /** + * This must be called from UI thread. If called + * from non-ui thread this returns null. + * @return The shell of the currently active workbench window.. + */ + public static Shell getCurrentlyActiveWbWindowShell(){ + IWorkbenchPage page = getCurrentlyActivePage(); + if(page != null){ + return page.getWorkbenchWindow().getShell(); + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry) + */ + protected void initializeImageRegistry(ImageRegistry imgReg) { + + // + // Storing images to plugin's image registry + // + Display disp = Display.getCurrent(); + Image img = null; + + img = new Image( disp, getImagesPath() + "\\apiquery_tsk.png" ); //$NON-NLS-1$ + imgReg.put( ImageKeys.IMG_APP_ICON, img ); + + img = new Image( disp, getImagesPath() + "\\apiquery_wiz.png" ); //$NON-NLS-1$ + imgReg.put( ImageKeys.IMG_APP_WIZARD_ICON, img ); + + } + + /** + * Returns image descriptor for the given key from the plugin's image registry. + * @param key Key to search descriptor for. + * @return Image descriptor for the given key from the plugin's image registry. + */ + public static ImageDescriptor getImageDescriptorForKey( String key ){ + ImageRegistry imgReg = getDefault().getImageRegistry(); + return imgReg.getDescriptor( key ); + } + + /** + * Returns image for the given key from the plugin's image registry. + * @param key Key to search image for. + * @return Image for the given key from the plugin's image registry. + */ + public static Image getImageForKey( String key ){ + ImageRegistry imgReg = getDefault().getImageRegistry(); + return imgReg.get(key); + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.settings.IUserSettingsListener#userSettingsChanged() + * Saves selected Data Source to configuration file. + */ + public void userSettingsChanged() { + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, getClass().getName() + ": User settings has been changed!"); //$NON-NLS-1$ + + //Saving selected Data Source Id to .properties file + try { + File configFile = new File(configFilePath); + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "API Query loading Data Source's configuration"); //$NON-NLS-1$ + Properties props = new Properties(); + String value = UserSettings.getInstance().getCurrentlySelectedSearchMethodInfo().getId(); + props.put(DATA_SOURCES_PROPERTIES_SELECTED_DATA_SOURCE, value); + props.store(new FileOutputStream(configFile), Messages.getString("APIQueryPlugin.DefaultDataSourceSelByUser_Msg") ); //$NON-NLS-1$ + } catch (FileNotFoundException e) { + APIQueryConsole.getInstance().println(Messages.getString("APIQueryPlugin.Configuration_file_ErrMsg") //$NON-NLS-1$ + + e.getMessage() , IConsolePrintUtility.MSG_ERROR); + e.printStackTrace(); + } catch (IOException e) { + APIQueryConsole.getInstance().println(Messages.getString("APIQueryPlugin.Configuration_file_ErrMsg") //$NON-NLS-1$ + + e.getMessage() , IConsolePrintUtility.MSG_ERROR); + e.printStackTrace(); + }catch (Exception e) { + APIQueryConsole.getInstance().println(Messages.getString("APIQueryPlugin.Configuration_file_ErrMsg") //$NON-NLS-1$ + + e.getMessage() , IConsolePrintUtility.MSG_ERROR); + e.printStackTrace(); + } + } + + /** + * Returns the PreferenceStore where plugin preferences are stored + * + * @return the PreferenceStore where plugin preferences are stored + */ + public static IPreferenceStore getPrefsStore() { + if (prefsStore == null){ + prefsStore = getDefault().getPreferenceStore(); + } + + return prefsStore; + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/preferences/APIQueryPreferenceConstants.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/preferences/APIQueryPreferenceConstants.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.shared.preferences; + + +/** + * Class for storing keys to preferences. + */ +public class APIQueryPreferenceConstants { + + + + /** + * true value + */ + public static final String TRUE = "true"; //$NON-NLS-1$ + + /** + * false value + */ + public static final String FALSE = "false"; //$NON-NLS-1$ + + + /** + * preference DB key for Show only API Names in search results + */ + public static final String SHOW_ONLY_APINAMES = "apiQueryShowOnlyApiNames"; //$NON-NLS-1$ + + /** + * preference DB key for showing data source on results or not + */ + public static final String SHOW_DATASOURCE_IN_RESULTS = "apiQueryShowDataSourceInResults"; //$NON-NLS-1$ + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/preferences/APIQueryPreferenceInitializer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/preferences/APIQueryPreferenceInitializer.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.shared.preferences; + + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; + +import com.nokia.s60tools.apiquery.shared.plugin.APIQueryPlugin; + +/** + * Class used to initialize default preference values. + */ +public class APIQueryPreferenceInitializer extends AbstractPreferenceInitializer { + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() + */ + public void initializeDefaultPreferences() { + + APIQueryPlugin.getPrefsStore().setDefault(APIQueryPreferenceConstants.SHOW_DATASOURCE_IN_RESULTS, true); + } +} + diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/preferences/APIQueryPreferences.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/preferences/APIQueryPreferences.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.preferences; + +import org.eclipse.jface.preference.IPreferenceStore; + +import com.nokia.s60tools.apiquery.shared.plugin.APIQueryPlugin; + +/** + * Helper class to use Dependency Explorer preferences. Use this class for accessing DE preferences + * instead of accessing directly through {@link org.eclipse.jface.util.IPropertyChangeListener.IPreferenceStore}. + */ +public class APIQueryPreferences { + + + + /** + * Get "Show only API names" value + * @return true if preference "Show only API names" is cheked, false otherwise. + */ + public static boolean getShowOnlyAPINames(){ + + String value = APIQueryPlugin.getPrefsStore().getString(APIQueryPreferenceConstants.SHOW_ONLY_APINAMES); + if(value != null && value.equalsIgnoreCase(APIQueryPreferenceConstants.TRUE)){ + return true; + }else{ + return false; + } + + } + + /** + * Set "Show only API names" value + * @param isDontAskAgainChecked true if "Show only API names" is selected, false otherwise. + */ + public static void setShowOnlyAPINames(boolean isShowOnlyAPINamesChecked){ + + IPreferenceStore store = APIQueryPlugin.getPrefsStore(); + + if(isShowOnlyAPINamesChecked){ + store.setValue(APIQueryPreferenceConstants.SHOW_ONLY_APINAMES, APIQueryPreferenceConstants.TRUE); + }else{ + store.setValue(APIQueryPreferenceConstants.SHOW_ONLY_APINAMES, APIQueryPreferenceConstants.FALSE); + } + } + + /** + * Get "Show Data Source in results" value + * @return true if preference "Show Data Source in results" is cheked, false otherwise. + */ + public static boolean getShowDataSourceInResults(){ + + boolean value = APIQueryPlugin.getPrefsStore().getBoolean(APIQueryPreferenceConstants.SHOW_DATASOURCE_IN_RESULTS); + return value; + + } + + /** + * Set "Show Data Source in results" value + * @param isDontAskAgainChecked true if "Show Data Source in results" is selected, false otherwise. + */ + public static void setShowDataSourceInResults(boolean isShowDataSourceInResultsChecked){ + + IPreferenceStore store = APIQueryPlugin.getPrefsStore(); + store.setValue(APIQueryPreferenceConstants.SHOW_DATASOURCE_IN_RESULTS, isShowDataSourceInResultsChecked); + } + + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/resources/ImageKeys.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/resources/ImageKeys.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.shared.resources; + +/** + * Lists the images keys used store and access images from plugin's image registry. + */ +public class ImageKeys { + public final static String IMG_APP_ICON = "APIQUERY_IMG_APP_ICON"; //$NON-NLS-1$ + public final static String IMG_APP_WIZARD_ICON = "APIQUERY_IMG_APP_WIZARD_ICON"; //$NON-NLS-1$ +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/resources/Messages.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/resources/Messages.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.resources; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * Class to get messages from localization file + */ +public class Messages { + private static final String BUNDLE_NAME = "com.nokia.s60tools.apiquery.shared.resources.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + private Messages() { + } + + /** + * Get message by key + * @param key + * @return message + */ + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/resources/messages.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/resources/messages.properties Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,165 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# +MainView.Search_Tab_Title=Search +MainView.Properties_Tab_Title=Properties +APIQueryPlugin.Configuration_file_ErrMsg=Failed to load/save Data Source configuration file - reason: +APIQueryPlugin.DefaultDataSourceSelByUser_Msg=Default Data Source, selected by user. +APIQueryParameters.UnsupportedQueryType_Msg=Unsupported query type: +APIQueryParameters.SubsystemName_Msg=Subsystem name +APIQueryParameters.HeaderName_Msg=Header name +APIQueryParameters.CR_PS_Name_Msg=CR/P&&S key name +APIQueryParameters.QueryTypePart1_ErrMsg=Given query type ' +APIQueryParameters.QueryTypePart2_ErrMsg=' cannot be mapped to any description\! +APIQueryPlugin.Search_Method_Instantiate_Failed_Msg_Start=Failed to instantiate ' +APIQueryPlugin.Search_Method_Instantiate_Failed_Msg_End=' search method extension - reason: +APIQueryPlugin.Search_Method_Instantiate_Failed_Console_Msg=Failed to fetch search method extensions - reason: +APIQueryPlugin.No_Search_Method_Installed_ErrorMsg_Start=There were no search method extension plugins installed. Cannot start +APIQueryPlugin.No_Search_Method_Installed_ErrorMsg_End=\ tool. +XMLDataSAXHandler.XML_Parse_Error_ConsoleMsg=XML Parsing error encountered: +XMLDataSAXHandler.XML_Parse_FatalError_ConsoleMsg=XML Parsing fatal error encountered: +XMLDataSAXHandler.XML_Parse_Warning_ConsoleMsg=XML Parsing warning encountered: +SearchMethodExtensionRegistry.Failed_To_Add_Ext_ConsoleMsg=Failed to add extension\! +SearchMethodExtensionRegistry.Extension_Prefix=Extension ' +SearchMethodExtensionRegistry.Is_Registered_Already_MsgPostfix=' is registered already\! +SearchMethodExtensionRegistry.Failed_To_Remove_Ext_ConsoleMsg=Failed to remove extension\! +CheckIdentifierAction.Query_Failed_From_Context_Menu_ErrorMsg=Failed to start API query from context menu: +SearchTabComposite.API_Query_ErrMsg=API query failed: +QueryTypeSelectionComposite.Query_By_Msg=Query by: +QueryResultsComposite.SearchResults_Msg=Search results +QueryResultsComposite.ShowOnlyAPINames_MSg=Show only API names +QueryTypeSelectionComposite.Query_Type_Was_Not_Selected_Msg=Query type was not selected\! +QueryTypeSelectionComposite.Not_Supported_ErrMsg=The query type is not supported by the currently selected search method. +QueryResultsComposite.APIDetailsQueryFailde_ErrMsg=API details query failed: +QueryTypeSelectionComposite.Query_Type_Not_Available_ErrMsg=The query type is not available for the currently selected search method. +FirstTimePopUpDialog.Title_Msg="API Query - Quick Help" +FirstTimePopUpDialog.Topic_Msg=Welcome to use API Query! +FirstTimePopUpDialog.Tool_Is_For_Msg=API Query is a tool for searching information about APIs. +FirstTimePopUpDialog.Properties_Msg_Configure=To configure Data Sources, open the Properties tab at the bottom of the API Query view. +FirstTimePopUpDialog.Properties_Msg_Option_Three_DataSources=Three types of Data Sources are currently available: %s, %s and %s. +FirstTimePopUpDialog.Properties_Msg_Option_Two_DataSources=Two types of Data Sources are currently available: %s and %s. +FirstTimePopUpDialog.Properties_Msg_Option_One_DataSources=One type of Data Source is currently available: %s. +FirstTimePopUpDialog.Properties_Msg_WebDescription=There are three Web servers configured by default, but only two of them are enabled. +FirstTimePopUpDialog.Seach_Msg=To search for APIs, type the query string into the Search string field on the Search tab. Leaving this field empty will search for all items, which may take a long time. +FirstTimePopUpDialog.Results_Msg=When APIs are found, click the search results to get more detailed information about them. +FirstTimePopUpDialog.Project_Query_Msg=API Query for one file or a whole project can be started by right-clicking the .c, .cpp, .h or .hpp file, or on the project/folder node in Package Explorer. API Query for a project will be saved to a file and it contains information about the APIs used in the project. +FieldMappingRules.NoMappingRule_ErrMsg=No mapping rule was defined for key: +FindFileFromFoldersJob.CancelledByUser_Msg=Cancelled by user +FindFileFromFoldersJob.ErrorOnSeekin_StatusMsg_Part1=Error seeking file: +FindFileFromFoldersJob.ErrorOnSeekin_StatusMsg_Part2=\ from SDK: +FindFileFromFoldersJob.ErrorSeekingFile_ErrMsg_Part1=Error seeking file: +FindFileFromFoldersJob.ErrorSeekingFile_ErrMsg_Part2=\ from SDK: +FindFileFromFoldersJob.ErrorSeekingFileWithValue_ErrMsg_Part1=Error seeking file: +FindFileFromFoldersJob.ErrorSeekingFileWithValue_ErrMsg_Part2=\ from SDK: +FindFileFromFoldersJob.ErrorSeekingFileWithValue_ErrMsg_Part3=. Exit value was: +FindFileFromFoldersJob.FileFound_Progress_Msg_Part1=File: ' +FindFileFromFoldersJob.FileFound_Progress_Msg_Part2=' found. +FirstTimePopUpDialog.More_Information_Msg=More instructions are available in API Query help. To open the help, go to Help > Help Contents, then select Carbide Tools > API Query. +ActiveProjectQueryJob.StartingToRun_Msg=Starting to run +ActiveProjectQueryJob.Title_Project_Msg=Project +ActiveProjectQueryJob.ErrorsOnJob_ErrMsg=Errors on job: +ActiveProjectQueryJob.TaskStarted_Msg=Started +ActiveProjectQueryJob.APIQueryForProject_Msg=API query for project: ' +ActiveProjectQueryJob.APIQueryForProject_OnProgress_Part2_Msg=' on progress... +ActiveProjectQueryJob.Progresbar_Step1_Msg=Searching included headers from project. +ActiveProjectQueryJob.Progresbar_Step2_Msg=Getting information of used APIs. +ActiveProjectQueryJob.Progresbar_Step3_Msg=Getting API Details from selected Search Method. +ActiveProjectQueryJob.Progresbar_Step4_Msg=Generating report. +ActiveProjectQueryJob.CouldNotGetAPISUmmaries_ErrMsg=Could not get API summaries. +ActiveProjectQueryJob.Title_IsUsingFollowingAPIs_Msg=\ is using following APIs and headers in files +ActiveProjectQueryJob.Progresbar_Done_Msg=Done +ActiveProjectQueryJob.APIQueryForProject_Compeleated_Msg=' compleated. +ActiveProjectQueryJob.Starting_Part1_Msg=Starting ' +ActiveProjectQueryJob.Starting_Part2_Msg=' query to project ' +ActiveProjectQueryJob.Starting_Part3_Msg=' with search string ' +ActiveProjectQueryJob.NoDetailsForAPI_Msg=No details for API: +ActiveProjectQueryJob.APIQueryFailed_ErrMsg=API query errors encountered for following reason(s): +CheckProjectReport.Unknown_MSg=Unknown +CheckProjectReport.APIName_Msg=API Name +CheckProjectReport.NoteForReportLinks_Msg=Note: You can only open links from the report when the API Query Carbide.c++ Extension is running. +CheckProjectReport.UsingFile_Msg=Using files +CheckProjectReport.UsedHeader_ErrMsg=Used headers and Using files must be same sized and not null. +CheckProjectAction.APIQuery_JobName_Msg=API Query +CheckProjectAction.CannotGenerateReport_ErrMsg=Cannot generate report for project: +CheckProjectAction.UnableToOpenReport_ErrMsg=Unable to open report, reason: +CheckProjectReport.UsedHeader_Msg=Used headers +CheckProjectAction.ExportAPIQueryForProject_Msg=Export API Query for project +CheckProjectReport.UnableToLoadCSS_Part1_ErrMsg=Unable to get stylesheet from: +CheckProjectReport.UnableToLoadCSS_Part2_ErrMsg=, error was: +APIQueryParameters.APIName_Msg=API name +APIQueryParameters.DLLName_Msg=DLL name +APIQueryParameters.LIBName_Msg=LIB name +APIQueryWebServerConfigurator.StartServer_ErrMsg_Part1=Unable to start +APIQueryWebServerConfigurator.StartServer_ErrMsg_Part2=. Error was: +APIQueryWebServerConfigurator.StartServer_Msg_Part1=Web server: ' +APIQueryWebServerConfigurator.StartServer_Msg_Part2=' started and running on address: ' +APIQueryWebServerConfigurator.StartServer_Msg_Part3='. API Query report links are now functional. +APIQueryWebServerConfigurator.StoptServer_ErrMsg_Part1=Unable to stop +APIQueryWebServerConfigurator.StoptServer_ErrMsg_Part2=. Error was: +APIQueryWebServerConfigurator.StoptServer_Msg_Part1=Web server: ' +APIQueryWebServerConfigurator.StoptServer_Msg_Part2=' stopped. API Query report links are now unfunctional. +AbstractEntryStorage.Duplicate_ErrMsg=There cannot exist two entries with the same name +AbstractJob.JobCancelled_Part1_ErrMsg=Job: +AbstractJob.JobCancelled_Part2_ErrMsg=\ cancelled by user. +AbstractJob.Percentage_Complete_Msg=% complete. +AbstractEntryStorage.NonExistingEntry_ErrMsg=Tried to update a non-existing entry: +AbstractSearchMethodExtension.UnknownHost_ErrMsg=Unknown host +AbstractSearchMethodExtension.MalformedURL_ErrMsg=Malformed URL +AbstractSearchMethodExtension.IOException_ErrMsg=I/O Exception +AbstractSearchMethodExtension.InvalidXML_ErrMsg=Invalid XML +AbstractJob.Prosessing_Msg=\ Processing: +AbstractSearchMethodExtension.UnexpectedException_ErrMsg=Unexpected exception +AbstractSearchMethodExtension.NoServerEntries_ErrMsg=No server entries configured or selected in Properties-tab. +AbstractUiFractionComposite.ParentDisplayNULL_ErrMsg=Parent's display is NULL\!\!\! +OpenFileAction.18=DEBUG: find files +OpenFileAction.CannotFoundFile_ErrMsg_Part1=File: ' +OpenFileAction.CannotFoundFile_ErrMsg_Part2=' can not be found from project: ' +OpenFileAction.CannotFoundFile_Msg_Part1=File: ' +OpenFileAction.CannotFoundFile_Msg_Part2=' can not be found under SDK: ' +OpenFileAction.JobName_Msg=Seek file: +OpenFileAction.NotCarbideProject_ErrMsg_Part1=Project: ' +OpenFileAction.NotCarbideProject_ErrMsg_Part2=' is not Carbide project. +OpenFileAction.ProjectNotExist_ErrMsg_Part1=Project: ' +OpenFileAction.ProjectNotExist_ErrMsg_Part2=' does not exist. +OpenFileAction.StartingSeek_Msg_Part1=Starting to seek file: ' +OpenFileAction.StartingSeek_Msg_Part2=' from project: ' +OpenFileAction.TargetFound_Msg_Part1=Target SDK: ' +OpenFileAction.TargetFound_Msg_Part2=' for project: ' +OpenFileAction.TargetFound_Msg_Part3=' found, starting to seek file: ' +OpenFileAction.Unexpected_ErrMsg_Part1=Unexpected error occurded when seeking file: ' +OpenFileAction.Unexpected_ErrMsg_Part2=' from project: ' +OpenFileAction.Unexpected_ErrMsg_Part3=\ Error was: +OpenReportStatusDialog.OpenReport_Msg=Open report +OpenReportStatusDialog.DoYouWantOpenReport_Msg=Do you want to open created report +PropertiesTabComposite.DataSource_Msg=Data Source +PropertiesTabComposite.ShowDataSourceInResults_Msg=Show Data Source in Search results +QueryDefComposite.SearchString_Msg=Search string: +QueryResultsComposite.APIDetails_MSg=API details: +QueryDefComposite.Search_Msg=Search +QueryResultsComposite.APIs_Msg=match +QueryResultsComposite.Found_Msg=Found +QueryResultsComposite.UnableToGetAPIDetails_ErrMsg_Part1=Unable to get API Details for: ' +QueryResultsComposite.UnableToGetAPIDetails_ErrMsg_Part2='. Error was: +SearchTabUIFieldsMediator.APIListQueryFailed_ErrMsg=API list query errors encountered for following reason(s): +QueryDefComposite.Context_ErrMsg=Unable to set Context sensitive Help ID:s, error was: +ReportActionServlet.NotSupportedAction_Msg=API Query report action Servlet called with no valid action. +ReportActionServlet.NotSupportedQueryType_ErrMsg_Part1=Errors in report, not supported query type: ' +ReportActionServlet.NotSupportedQueryType_ErrMsg_Part2='. Please rerun API Query for Active project. +ReportActionServlet.NotSupportedSearchMethod_ErrMsg_Part1=Not supported search method: ' +ReportActionServlet.NotSupportedSearchMethod_ErrMsg_Part2=' for selected Data source: ' +ReportActionServlet.Unexpected_ErrMsg_Part1=Unexpected error occur when API Query was started for Search string: ' +ReportActionServlet.Unexpected_ErrMsg_Part2=' with search type: ' +ReportActionServlet.Unexpected_ErrMsg_Part3='. Error was: diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/searchmethod/AbstractSearchMethodExtension.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/searchmethod/AbstractSearchMethodExtension.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,311 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.shared.searchmethod; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.UnknownHostException; +import java.util.Collection; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExecutableExtension; +import org.eclipse.core.runtime.IProgressMonitor; + +import com.nokia.s60tools.apiquery.shared.datatypes.APIDetails; +import com.nokia.s60tools.apiquery.shared.datatypes.APIQueryParameters; +import com.nokia.s60tools.apiquery.shared.datatypes.APIShortDescription; +import com.nokia.s60tools.apiquery.shared.datatypes.APIShortDescriptionSearchResults; +import com.nokia.s60tools.apiquery.shared.datatypes.config.AbstractEntry; +import com.nokia.s60tools.apiquery.shared.exceptions.QueryOperationFailedException; +import com.nokia.s60tools.apiquery.shared.exceptions.XMLNotValidException; +import com.nokia.s60tools.apiquery.shared.job.JobCancelledByUserException; +import com.nokia.s60tools.apiquery.shared.resources.Messages; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.apiquery.shared.util.xml.XMLUtils; +import com.nokia.s60tools.util.debug.DbgUtility; + +/** + * Abstract class that provides common services for all search methods. + */ +public abstract class AbstractSearchMethodExtension implements ISearchMethodExtension, IExecutableExtension { + + public static final String ID_ATTRIBUTE = "id"; //$NON-NLS-1$ + public static final String DESCRIPTION_ATTRIBUTE = "description"; //$NON-NLS-1$ + public static final String IS_DEFAULT_ATTRIBUTE = "isDefault"; //$NON-NLS-1$ + + private SearchMethodExtensionInfo extensionInfo; + + /** + * The subclasses of this abstract class is created by using createExecutableExtension + * method from IConfigurationElement class, and therefore + * the constructor cannot have any parameters. + * @see org.eclipse.core.runtime.IConfigurationElement#createExecutableExtension + */ + public AbstractSearchMethodExtension(){ + extensionInfo = new SearchMethodExtensionInfo(); + } + + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object) + */ + public void setInitializationData(IConfigurationElement configElem, String classPropertyName, Object data) throws CoreException { + extensionInfo.setId(configElem.getAttribute(ID_ATTRIBUTE)); + extensionInfo.setDescription(configElem.getAttribute(DESCRIPTION_ATTRIBUTE)); + extensionInfo.setDefault(Boolean.parseBoolean(configElem.getAttribute(IS_DEFAULT_ATTRIBUTE))); + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension#getExtensionInfo() + */ + public SearchMethodExtensionInfo getExtensionInfo() { + return extensionInfo; + } + + /** + * Throws an exception for user with the given message. + * @param errorMsg Main error message for the user. + * @param detailedMsg More detailed message shown in parenthesis. + * @throws QueryOperationFailedException + */ + protected void queryFailed(String errorMsg, String detailedMsg) throws QueryOperationFailedException { + APIQueryConsole.getInstance().println(errorMsg, APIQueryConsole.MSG_ERROR); + String combinedMsg = getCombinedMessage(errorMsg, detailedMsg); + throw new QueryOperationFailedException(combinedMsg); + } + + + private String getCombinedMessage(String errorMsg, String detailedMsg) { + String combinedMsg = errorMsg + " (" + detailedMsg + ")."; //$NON-NLS-1$ //$NON-NLS-2$ + return combinedMsg; + } + + /** + * Throws an exception for user with the given message. + * @param errorMsg Main error message for the user. + * @param detailedMsg More detailed message shown in parenthesis. + * @param QueryOperationFailedException + * @throws QueryOperationFailedException + */ + private void queryFailed(String errorMsg, String detailedMsg, QueryOperationFailedException e) throws QueryOperationFailedException { + APIQueryConsole.getInstance().println(errorMsg, APIQueryConsole.MSG_ERROR); + String combinedMsg = getCombinedMessage(errorMsg, detailedMsg); + QueryOperationFailedException ex = new QueryOperationFailedException(combinedMsg); + ex.setSummarys(e.getSummarys()); + throw ex; + } + + /** + * Examines the type of throwable parameter, and adds appropriate + * error message or default message, and forwards the information + * for further processing. + * @param throwable Throwable to be examined. + * @throws QueryOperationFailedException + */ + protected void examineAndHandleQueryFailureException(Throwable throwable) throws QueryOperationFailedException{ + + String errMsg = Messages.getString("AbstractSearchMethodExtension.UnexpectedException_ErrMsg"); //$NON-NLS-1$ + + if(throwable instanceof QueryOperationFailedException) { + errMsg = "Query error"; + queryFailed(errMsg, throwable.getMessage(), (QueryOperationFailedException)throwable); + } else{ + if (throwable instanceof UnknownHostException) { + errMsg = Messages.getString("AbstractSearchMethodExtension.UnknownHost_ErrMsg"); //$NON-NLS-1$ + } + else if(throwable instanceof MalformedURLException) { + errMsg = Messages.getString("AbstractSearchMethodExtension.MalformedURL_ErrMsg"); //$NON-NLS-1$ + } + else if(throwable instanceof IOException) { + errMsg = Messages.getString("AbstractSearchMethodExtension.IOException_ErrMsg"); //$NON-NLS-1$ + } + else if(throwable instanceof XMLNotValidException) { + errMsg = Messages.getString("AbstractSearchMethodExtension.InvalidXML_ErrMsg"); //$NON-NLS-1$ + } + + queryFailed(errMsg, throwable.getMessage()); + } + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension#getAPIDetails(com.nokia.s60tools.apiquery.shared.datatypes.APIShortDescription) + */ + public APIDetails getAPIDetails(APIShortDescription summary) throws QueryOperationFailedException { + String detailsXMLData = null; + APIDetails details = null; + + try { + detailsXMLData = getAPIDetailsAsXML(summary); + details = XMLUtils.xmlToAPIDetails(detailsXMLData.toString()); + } catch (Exception e) { + DbgUtility.println(DbgUtility.PRIORITY_CLASS, "###Errors on parsing API Details. API Name was: " //$NON-NLS-1$ + +summary.getName() +", API source was: " +summary.getSource()); //$NON-NLS-1$ + e.printStackTrace(); + examineAndHandleQueryFailureException(e); + } + + return details; + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension#runAPIQuery(com.nokia.s60tools.apiquery.shared.datatypes.APIQueryParameters) + */ + public APIShortDescriptionSearchResults runAPIQuery(APIQueryParameters parameters) { + + APIShortDescriptionSearchResults results = new APIShortDescriptionSearchResults(); + + // Making query for each configured and selected server entry. + AbstractEntry[] selEntryArr = getEntryStorageInstance().getSelectedEntries(); + + // Were any entries configured or selected? + if(selEntryArr.length == 0){ + results.addSearchError(new QueryOperationFailedException(Messages.getString("AbstractSearchMethodExtension.NoServerEntries_ErrMsg"))); //$NON-NLS-1$ + return results; + } + for (int i = 0; i < selEntryArr.length; i++) { + AbstractEntry entry = selEntryArr[i]; + if(parameters.getSearchString().contains(APIQueryParameters.SEARCH_ITEM_SEPARATOR_CHAR)){ + //Adding results for results, if there was errors, adding error to results + try { + results.addSearchResults(handleMultiEntryQuery(parameters, entry)); + } catch (QueryOperationFailedException e) { + results.addSearchError(e); + if(e.getSummarys() != null){ + results.addSearchResults(e.getSummarys()); + } + } + }else{ + //Adding results for results, if there was errors, adding error to results + try { + results.addSearchResults(handleSingleEntryQuery(parameters, entry)); + } catch (QueryOperationFailedException e) { + results.addSearchError(e); + if(e.getSummarys() != null){ + results.addSearchResults(e.getSummarys()); + } + } + } + } + + return results; + } + + /** + * Handles API summary query for a given server entry. + * @param parameters Query parameters. + * @param srvEntry Entry to be query data from. + * @return Collection of API summaries for the given server entry. + * @throws QueryOperationFailedException + */ + protected abstract Collection handleSingleEntryQuery(APIQueryParameters parameters, AbstractEntry entry) throws QueryOperationFailedException; + + /** + * Handles API summary query for a given server entry. + * + * Used when search string contains multiple search strings semi-colon (;) separated. + * Eg. multiple headers as semi-colon separated. + * + * Should call when APIQueryParameters.getSearchString().contains(APIQueryParameters.SEARCH_ITEM_SEPARATOR_CHAR) + * occurs. + * + * @param parameters Query parameters. Where getSearchString() contains semi-colons. + * @param srvEntry Entry to be query data from. + * @return Collection of API summaries for the given server entry. + * @throws QueryOperationFailedException + */ + protected abstract Collection handleMultiEntryQuery(APIQueryParameters parameters, AbstractEntry entry) throws QueryOperationFailedException; + + + // + // Abstract methods to be defined by subclasses. + // + + /** + * Gets API Details as XML formatted string for given summary. + * Abstract method that must be implemented by all sub classes. + * @param summary API summary data to get details for. + * @return API Detail XML data as string. + */ + protected abstract String getAPIDetailsAsXML(APIShortDescription summary) throws Exception; + + /** + * Handles API summary query for a given server entry. + * @param parameters Query parameters. + * @param srvEntry Entry to be query data from. + * @return API summaries for the given server entry as XML formatted string. + * @throws QueryOperationFailedException + */ + protected abstract String runAPIQueryForSingleEntryAndReturnXMLString(APIQueryParameters parameters, AbstractEntry entry) throws Exception; + + + /** + * Web query job cancellat + * @param parameters + * @param progressMonitor + * @return + * @throws JobCancelledByUserException + */ + public APIShortDescriptionSearchResults runAPIQuery(APIQueryParameters parameters,IProgressMonitor progressMonitor)throws JobCancelledByUserException { + + + + + APIShortDescriptionSearchResults results = new APIShortDescriptionSearchResults(); + + // Making query for each configured and selected server entry. + AbstractEntry[] selEntryArr = getEntryStorageInstance().getSelectedEntries(); + + + + + // Were any entries configured or selected? + if(selEntryArr.length == 0){ + results.addSearchError(new QueryOperationFailedException(Messages.getString("AbstractSearchMethodExtension.NoServerEntries_ErrMsg"))); //$NON-NLS-1$ + return results; + } + for (int i = 0; i < selEntryArr.length; i++) { + AbstractEntry entry = selEntryArr[i]; + if(parameters.getSearchString().contains(APIQueryParameters.SEARCH_ITEM_SEPARATOR_CHAR)){ + //Adding results for results, if there was errors, adding error to results + try { + results.addSearchResults(handleMultiEntryQuery(parameters, entry,progressMonitor)); + } catch (QueryOperationFailedException e) { + results.addSearchError(e); + } + }else{ + //Adding results for results, if there was errors, adding error to results + try { + results.addSearchResults(handleSingleEntryQuery(parameters, entry,progressMonitor)); + } catch (QueryOperationFailedException e) { + results.addSearchError(e); + } + } + } + + + return results; + } + + + + protected abstract Collection handleSingleEntryQuery(APIQueryParameters parameters, AbstractEntry entry,IProgressMonitor monitor) throws JobCancelledByUserException,QueryOperationFailedException; + protected abstract Collection handleMultiEntryQuery(APIQueryParameters parameters, AbstractEntry entry,IProgressMonitor progressMonitor) throws QueryOperationFailedException,JobCancelledByUserException; + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/searchmethod/ISearchMethodExtension.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/searchmethod/ISearchMethodExtension.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,162 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.shared.searchmethod; + +import java.util.Collection; +import java.util.Hashtable; +import java.util.Set; +import org.eclipse.swt.widgets.Composite; +import com.nokia.s60tools.apiquery.shared.datatypes.APIDetails; +import com.nokia.s60tools.apiquery.shared.datatypes.APIQueryParameters; +import com.nokia.s60tools.apiquery.shared.datatypes.APIShortDescription; +import com.nokia.s60tools.apiquery.shared.datatypes.APIShortDescriptionSearchResults; +import com.nokia.s60tools.apiquery.shared.datatypes.config.AbstractEntryStorage; +import com.nokia.s60tools.apiquery.shared.exceptions.QueryOperationFailedException; +import com.nokia.s60tools.apiquery.shared.searchmethod.ui.AbstractUiFractionComposite; + +/** + * Interface that has to be implemnted by all + * search method instances. + */ +public interface ISearchMethodExtension { + + /** + * Gets the extension info for the search method. + * @return Returns extension info for the search method. + */ + ISearchMethodExtensionInfo getExtensionInfo(); + + /** + * This method is called when we do not need + * the services of this extension. This gives + * possibilities for the extension to make + * any shutdown related operations it sees + * as necessary. + */ + public void notifyExtensionShutdown(); + + /** + * Returns the search method specific configuration UI as + * UI Composite that can be disposed and re-created whenever needed. + * @param parent Parent composite for the created configuration UI. + * @return Returns the search method specific configuration UI. + */ + public AbstractUiFractionComposite createExtensionConfigurationUi(Composite parent); + + /** + * Runs API Query with the given parameters. + * Throws QueryOperationFailedException if something failed + * during query operation. + * @param parameters Parameters guiding the query. + * @return APIShortDescriptionSearchResults containing Collection of API summary objects + * for the APIs found based on the query and possible QueryOperationFailedException search errors Collection. + */ + public APIShortDescriptionSearchResults runAPIQuery(APIQueryParameters parameters); + + /** + * Gets API details for the given API. + * Throws QueryOperationFailedException if something failed + * during query operation. + * @param summary API summary object to get details for. + * @return API details for the given summary object. + * @throws QueryOperationFailedException + */ + public APIDetails getAPIDetails(APIShortDescription summary) throws QueryOperationFailedException; + + /** + * Gets API details for the given APIs. + * Throws QueryOperationFailedException if something failed + * during query operation. + * @param list of API summary objects to get details for. + * @return API details for the given summary objects. Given API name as key and APIDetails as value. + * If cant found or parse a Details, an empty Details is added to collection. + * @throws QueryOperationFailedException + */ + Hashtable getAPIDetails(Collection apis) throws QueryOperationFailedException; + + + /** + * Can be used to check if a certain query type + * is supported by the search method. + * @param queryType Query type defined in APIQueryParameters to be checked. + * @return true if the query type is supported, otherwise false. + * @see APIQueryParameters#QUERY_BY_API_NAME + * @see APIQueryParameters#QUERY_BY_SUBSYSTEM_NAME + * @see APIQueryParameters#QUERY_BY_DLL_NAME + * @see APIQueryParameters#QUERY_BY_LIB_NAME + * @see APIQueryParameters#QUERY_BY_HEADER_NAME + * @see APIQueryParameters#QUERY_BY_CRPS_KEY_NAME + */ + public boolean isSupportedQueryType(int queryType); + + /** + * Returns search method specific configuration storage instance. + * @return Data Source specific configuration storage instance. + */ + public AbstractEntryStorage getEntryStorageInstance(); + + /** + * Get API details to show in report. + * @return API Detail topics to be shown in report + */ + public String[] getAPIDetailsToReport(Set usedAPIs, Hashtable projectUsingAPIDetails); + + /** + * Maps query type to API Detail topic in API Details. + * @param queryType Query type constant. + * @return Name of the API Detail. + */ + public String getAPIDetailNameInDetailsByQueryType(int queryType); + + /** + * Maps API Detail topic in API Details to query type. + * @param queryType Query type constant. + * @return Query type int described in {@link APIQueryParameters} or -1 if not supported. + */ + public int getQueryTypeByAPIDetailNameInDetails(String queryType); + + /** + * + * @return true for web query and false for other data sources + */ + public boolean isAsyncQueryPreferred(); + + /** + * if it's for a header serach,then should the headerlink be enabled so that user can click on it and open it. + */ + public boolean serachHeaderLinkEnable(); + +/** + * opens the supplied header file.Provide an implementation if headerlink is enabled. + * @param header : header name + * @param source : APIShortDescription.getSource() + * @return 0-successfully opened , 1-error + */ + public int openHeaderFile(String headerName,String source); + + /* + * + */ + public String[] getHeaderSourceList(); + + + + + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/searchmethod/ISearchMethodExtensionInfo.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/searchmethod/ISearchMethodExtensionInfo.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.shared.searchmethod; + +/** + * Stores the informative metadata for + * a search method extension. + */ +public interface ISearchMethodExtensionInfo { + /** + * Gets the id of the search method. + * @return Id of the search method. + */ + public String getId(); + + /** + * Gets the description for the search method. + * @return Description for the search method. + */ + public String getDescription(); + + /** + * Checks if this search method is the default one, unless + * otherwise decided according user settings. + * @return Returns true if this search method is the default one, + * otherwise returns false. + */ + public boolean isDefault(); + + /** + * Compares the Id's of the two search methods + * @return true if the two search Ids match, otherwise false. + */ + public boolean hasEqualId(ISearchMethodExtensionInfo extInfo); +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/searchmethod/SearchMethodExtensionInfo.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/searchmethod/SearchMethodExtensionInfo.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.shared.searchmethod; + +public class SearchMethodExtensionInfo implements ISearchMethodExtensionInfo{ + + private String id; + private String description; + private boolean isDefault; + + public SearchMethodExtensionInfo(){ + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.searchmethodregistry.ISearchMethodExtensionInfo#getDescription() + */ + public String getDescription() { + return description; + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.searchmethodregistry.ISearchMethodExtensionInfo#getId() + */ + public String getId() { + return id; + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.searchmethodregistry.ISearchMethodExtensionInfo#isDefault() + */ + public boolean isDefault() { + return isDefault; + } + + /** + * Sets the description. + * @param description The description to set. + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Sets the id. + * @param id The id to set. + */ + public void setId(String id) { + this.id = id; + } + + /** + * Sets the isDefault status. + * @param isDefault The isDefault to set. + */ + public void setDefault(boolean isDefault) { + this.isDefault = isDefault; + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.searchmethodregistry.ISearchMethodExtensionInfo#hasEqualId(com.nokia.s60tools.apiquery.searchmethodregistry.ISearchMethodExtensionInfo) + */ + public boolean hasEqualId(ISearchMethodExtensionInfo extInfo) { + return this.getId().equalsIgnoreCase(extInfo.getId()); + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/searchmethod/ui/AbstractUiFractionComposite.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/searchmethod/ui/AbstractUiFractionComposite.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,116 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.shared.searchmethod.ui; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Layout; + +import com.nokia.s60tools.apiquery.shared.resources.Messages; + +/** + * Abstract class that defines an abstract template + * for the composites that should be used to populate + * the contents a tab area or a sub area inside a tab + * (or inside any other UI element). Just utilizing + * Eclipse UI functionality, but making it simpler + * and more compact to use UI Composites from at the + * source code level. + */ +public abstract class AbstractUiFractionComposite extends Composite { + + /** + * Constructor. + * @param parentComposite Parent composite for the created composite. + * @param style The used style for the composite. + */ + public AbstractUiFractionComposite(Composite parentComposite, int style) { + super(parentComposite, style); + checkParent(parentComposite); + initComposite(); + } + + /** + * Checks that parent has a valid display. + * @param parentComposite Parent composite for the created composite. + */ + private void checkParent(Composite parentComposite) { + if (parentComposite.getDisplay() == null){ + throw new RuntimeException(Messages.getString("AbstractUiFractionComposite.ParentDisplayNULL_ErrMsg")); //$NON-NLS-1$ + } + } + + /** + * Constructor. + * @param parentComposite Parent composite for the created composite. + */ + public AbstractUiFractionComposite(Composite parentComposite) { + super(parentComposite, SWT.NONE); + initComposite(); + } + + /** + * Performs template methods that take care + * of finalizing composite construction. + */ + private void initComposite(){ + setLayout(createLayout()); + setLayoutData(createLayoutData()); + createControls(); + } + + /** + * Sub classes can override this. + * @return Width hint for the composite. + */ + public int getWidthHint(){ + return SWT.DEFAULT; + } + + /** + * Sub classes can override this. + * @return Height hint for the composite. + */ + public int getHeightHint(){ + return SWT.DEFAULT; + } + + /** + * Template method to be implementd in sub classes. + * Sub class should initialize the composite's layout + * in the implementation of this method. + * @return Layout for the composite. + */ + protected abstract Layout createLayout(); + + /** + * Template method to be implementd in sub classes. + * Sub class should initialize the composite's layout data + * in the implementation of this method. + * @return Layout for the composite. + */ + protected abstract Object createLayoutData(); + + /** + * Template method to be implementd in sub classes. + * Sub class should create all the composite's controls + * in the implementation of this method. + */ + protected abstract void createControls(); +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/searchmethodregistry/SearchMethodExtensionRegistry.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/searchmethodregistry/SearchMethodExtensionRegistry.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,170 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.shared.searchmethodregistry; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import com.nokia.s60tools.apiquery.shared.resources.Messages; +import com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension; +import com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtensionInfo; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.util.console.IConsolePrintUtility; +import com.nokia.s60tools.util.debug.DbgUtility; + + + + +/** + * Singleton class that is created on plugin + * startup, and is kept active as long as plugin is active. + * + * The purpose of this class is to store search method + * extensions that were found from the system. + */ +public class SearchMethodExtensionRegistry { + + /** + * Singleton instance. + */ + static private SearchMethodExtensionRegistry instance = null; + + /** + * Listeners interested in job completions operations. + */ + private static Map extensions = Collections.synchronizedMap(new HashMap()); + + /** + * Public Singleton instance accessor. + * @return Returns instance of this singleton class- + */ + public static SearchMethodExtensionRegistry getInstance(){ + if( instance == null ){ + instance = new SearchMethodExtensionRegistry(); + } + return instance; + } + + /** + * Private default constructor. + */ + private SearchMethodExtensionRegistry() { + DbgUtility.println(DbgUtility.PRIORITY_CLASS, "-- <> --> " + getClass().getName()); //$NON-NLS-1$ + } + + /** + * Add a new Search Method + * @param extension + */ + public void addExtension(ISearchMethodExtension extension){ + synchronized(extensions){ + ISearchMethodExtensionInfo info = extension.getExtensionInfo(); + String id = info.getId(); + ISearchMethodExtension possibleDuplicate = extensions.get(id); + if( possibleDuplicate != null ){ + String errMsg = Messages.getString("SearchMethodExtensionRegistry.Failed_To_Add_Ext_ConsoleMsg") //$NON-NLS-1$ + + Messages.getString("SearchMethodExtensionRegistry.Extension_Prefix") //$NON-NLS-1$ + + id + + Messages.getString("SearchMethodExtensionRegistry.Is_Registered_Already_MsgPostfix"); //$NON-NLS-1$ + APIQueryConsole.getInstance().println(errMsg, IConsolePrintUtility.MSG_ERROR); + throw new RuntimeException(errMsg); + } + extensions.put(id, extension); + } // synchronized + } + + /** + * Remove a Search Method + * @param extension + */ + public void removeExtension(ISearchMethodExtension extension){ + synchronized(extensions){ + ISearchMethodExtensionInfo info = extension.getExtensionInfo(); + String id = info.getId(); + ISearchMethodExtension possibleDuplicate = extensions.get(id); + if( possibleDuplicate == null ){ + String errMsg = Messages.getString("SearchMethodExtensionRegistry.Failed_To_Remove_Ext_ConsoleMsg") //$NON-NLS-1$ + + Messages.getString("SearchMethodExtensionRegistry.Extension_Prefix") //$NON-NLS-1$ + + id + + Messages.getString("SearchMethodExtensionRegistry.Is_Registered_Already_MsgPostfix"); //$NON-NLS-1$ + APIQueryConsole.getInstance().println(errMsg, IConsolePrintUtility.MSG_ERROR); + throw new RuntimeException(errMsg); + } + extension.notifyExtensionShutdown(); + extensions.remove(extension); + } // synchronized + } + + /** + * Called before host plugin shutdown. + */ + public void notifyPluginShutdown(){ + for (ISearchMethodExtension ext : getExtensions()) { + ext.notifyExtensionShutdown(); + } + } + + /** + * Returns the iterator for the currently registered extensions. + * @return Returns the currently registered extensions. + */ + public Collection getExtensions(){ + return extensions.values(); + } + + /** + * Gets the amount of currently registered extensions. + * @return Returns the amount of currently registered extensions. + */ + public int getExtensionCount(){ + return getExtensions().size(); + } + + /** + * Gets the extension that matches with the given description. + * @param extensionDescription Description of the search method. + * @return The extension matching the description or null if not found. + */ + public ISearchMethodExtension getByDescription(String extensionDescription) { + for (ISearchMethodExtension ext : getExtensions()) { + ISearchMethodExtensionInfo extInfo = ext.getExtensionInfo(); + if(extInfo.getDescription().equals(extensionDescription)){ + return ext; + } + } + return null; + } + + /** + * Gets the extension that matches with the given id. + * @param id Id of the search method. + * @return The extension matching the id or null if not found. + */ + public ISearchMethodExtension getById(String id) { + for (ISearchMethodExtension ext : getExtensions()) { + ISearchMethodExtensionInfo extInfo = ext.getExtensionInfo(); + if(extInfo.getId().equals(id)){ + return ext; + } + } + return null; + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/services/QueryServices.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/services/QueryServices.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.services; + +import com.nokia.s60tools.apiquery.shared.exceptions.QueryOperationFailedException; +import com.nokia.s60tools.apiquery.ui.views.main.MainView; + +public class QueryServices { + + /** + * Enables the starting of API queries + * also from the other plug-ins that should + * not know anything about internal UI components. + * However, this method must be called from an UI thread, or + * use Display.getDefault().asyncExec(...) method + * and pass runnable as parameter in order to schedule + * query request to UI thread. + * @param queryType Query type. + * @param queryString Query string. + * @throws QueryOperationFailedException + */ + public static void runAPIQuery(int queryType, String queryString) throws QueryOperationFailedException{ + MainView.runAPIQueryFromExternalClass(queryType, + queryString, false); + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/settings/UserSettingListenerNotificator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/settings/UserSettingListenerNotificator.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.settings; + +import com.nokia.s60tools.apiquery.settings.UserSettings; + +public class UserSettingListenerNotificator { + + /** + * Public interface to notify listeners that something is happend. + */ + public static void notifyListeners(){ + UserSettings.getInstance().settingsChanged(); + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/ui/AbstractEntryTableViewerUiComposite.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/ui/AbstractEntryTableViewerUiComposite.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,280 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.ui; + +import java.util.Collection; + +import org.eclipse.jface.viewers.CheckStateChangedEvent; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.IBaseLabelProvider; +import org.eclipse.jface.viewers.ICheckStateListener; +import org.eclipse.jface.viewers.IContentProvider; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.ViewerSorter; +import org.eclipse.swt.SWTException; +import org.eclipse.swt.widgets.Composite; + +import com.nokia.s60tools.apiquery.shared.datatypes.config.AbstractEntry; +import com.nokia.s60tools.apiquery.shared.datatypes.config.AbstractEntryStorage; +import com.nokia.s60tools.apiquery.shared.datatypes.config.IConfigurationChangedListener; +import com.nokia.s60tools.apiquery.shared.searchmethod.ui.AbstractUiFractionComposite; +import com.nokia.s60tools.util.debug.DbgUtility; + +/** + * Common abstract base class for entry table viewer UI composites. + */ +public abstract class AbstractEntryTableViewerUiComposite extends AbstractUiFractionComposite implements ICheckStateListener, + IConfigurationChangedListener{ + /** + * Entry check state listener reference. + * @see com.nokia.s60tools.apiquery.web.searchmethod.ui.IEntryCheckStateListener + */ + protected IEntryCheckStateListener entryCheckStateListener = null; + protected CheckboxTableViewer entriesViewer; + + /** + * Constructor. + * @param parentComposite Parent composite for the created composite. + * @param style The used style for the composite. + */ + public AbstractEntryTableViewerUiComposite(Composite parentComposite, int style) { + super(parentComposite, style); + } + + /** + * Creates concrete entry viewer specific storage entry table viewer instance. + * @param parent Parent composite for the created composite. + * @return New CheckboxTableViewer object instance. + */ + protected abstract CheckboxTableViewer createEntryTableViewer(Composite parent); + + /** + * Gets concrete entry viewer specific storage instance. + * @return Concrete entry viewer specific storage instance. + */ + protected abstract AbstractEntryStorage getEntryStorageInstance(); + + /** + * Gets concrete entry viewer specific viewer sorter. + * @return Concrete entry viewer specific viewer sorter. + */ + protected abstract ViewerSorter createViewerSorter(); + + /** + * Gets concrete entry viewer specific label provider. + * @return Concrete entry viewer specific label provider. + */ + protected abstract IBaseLabelProvider createLabelProvider(); + + /** + * Gets concrete entry viewer specific content provider. + * @return Concrete entry viewer specific content provider. + */ + protected abstract IContentProvider createContentProvider(); + + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.shared.searchmethod.ui.AbstractUiFractionComposite#createControls() + */ + protected void createControls() { + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "-- createControls() --> " + getClass().getName()); //$NON-NLS-1$ + + // Concrete viewer instantiation is done by sub classes + entriesViewer = createEntryTableViewer(this); + + // As well as creation of concrete providers and concrete entry storage + IContentProvider entryContentProvider = createContentProvider(); + entriesViewer.setContentProvider(entryContentProvider); + IBaseLabelProvider labelProvider = createLabelProvider(); + entriesViewer.setLabelProvider(labelProvider); + entriesViewer.setInput(entryContentProvider); + ViewerSorter entrySorter = createViewerSorter(); + entriesViewer.setSorter(entrySorter); + // Storing entry storage instance reference. + AbstractEntryStorage entryConfigStorage = getEntryStorageInstance(); + // Adding checked statuses before adding check state listener... + entriesViewer.setCheckedElements(entryConfigStorage.getSelectedEntries()); + // ...and start listening for status changes. + entriesViewer.addCheckStateListener(this); + // Listening for configuration change events for enabling UI refresh + entryConfigStorage.addConfigurationChangeListener(this); + } + + /** + * Refreshes the entry UI. + */ + public void refresh() { + try { + entriesViewer.refresh(); + // Check state might have been changed due to refresh + notifyEntryCheckStateListener(); + } catch (SWTException e) { + // We might get time-to-time non-fatal SWTException: Widget is disposed, + // which can be ignored. + } catch (Exception e) { + // Stack trace is shown for other exceptions + e.printStackTrace(); + } + } + + /** + * Gets entry table viewer instance. + * @return Entry table viewer instance. + */ + public TableViewer getEntryViewer() { + return entriesViewer; + } + + /** + * Adds check mark to all entries. + */ + private void checkAll() { + // Removing possible earlier check status listener + entriesViewer.removeCheckStateListener(this); + entriesViewer.setAllChecked(true); + // and start listening for status changes again. + entriesViewer.addCheckStateListener(this); + if(entryCheckStateListener != null){ + entryCheckStateListener.allEntriesChecked(); + } + } + + /** + * Removes check mark from all entries. + */ + private void uncheckAll() { + // Removing possible earlier check status listener + entriesViewer.removeCheckStateListener(this); + // Clearing all previous check marks + entriesViewer.setAllChecked(false); + // and start listening for status changes again. + entriesViewer.addCheckStateListener(this); + if(entryCheckStateListener != null){ + entryCheckStateListener.allEntriesUnchecked(); + } + } + + /** + * Adds selection listener to the table viewer. + */ + public void addSelectionChangedListener(ISelectionChangedListener listener) { + entriesViewer.addSelectionChangedListener(listener); + } + + /** + * Removes selection listener fromthe table viewer. + */ + public void removeSelectionChangedListener(ISelectionChangedListener listener) { + entriesViewer.removeSelectionChangedListener(listener); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent) + */ + public void checkStateChanged(CheckStateChangedEvent event) { + // Updating checked state information for the entry + AbstractEntry entry = (AbstractEntry) event.getElement(); + entry.setSelected(event.getChecked()); + notifyEntryCheckStateListener(); + } + + public void configurationChanged(int eventType) { + // Updating check state information to UI + if(eventType == IConfigurationChangedListener.ALL_ENTRIES_CHECKED){ + checkAll(); + } + else if(eventType == IConfigurationChangedListener.ALL_ENTRIES_UNCHECKED){ + uncheckAll(); + } + else{ + // In other check cases UI must be refreshed... + refresh(); + // ...before querying the latest information from storage + Collection entryColl = getEntryStorageInstance().getEntries(); + for (AbstractEntry entry : entryColl) { + entriesViewer.setChecked(entry, entry.isSelected()); + } + } + + // Refreshing UI always when configuration has been changed. + refresh(); + } + + /** + * Sets entry check state listener. + * @param listener Listener to be set. + */ + public void setEntryCheckStateListener(IEntryCheckStateListener listener) { + entryCheckStateListener = listener; + // Checking and notifying the current check status for possible listeners + notifyEntryCheckStateListener(); + } + + /** + * Checks current check status and notifies to listener + * if such is set. + */ + private void notifyEntryCheckStateListener() { + if(entryCheckStateListener != null){ + int checkElemCount = entriesViewer.getCheckedElements().length; + int elemCount = entriesViewer.getTable().getItemCount(); + if(checkElemCount == 0){ + entryCheckStateListener.allEntriesUnchecked(); + } + else if(checkElemCount == elemCount){ + entryCheckStateListener.allEntriesChecked(); + } + else{ + entryCheckStateListener.someEntriesChecked(); + } + } + } + + /** + * Adds a listener for double-clicks for the entry viewer. + * Call is delegated further to viewer class. + * @param listener a double-click listener + * @see org.eclipse.jface.viewers.StructuredViewer#addDoubleClickListener + */ + public void addDoubleClickListener(IDoubleClickListener listener) { + entriesViewer.addDoubleClickListener(listener); + } + + /** + * Removes the given double-click listener from this viewer. + * Call is delegated further to viewer class. + * @param listener a double-click listener + * @see org.eclipse.jface.viewers.StructuredViewer#removeDoubleClickListener + */ + public void removeDoubleClickListener(IDoubleClickListener listener) { + entriesViewer.removeDoubleClickListener(listener); + } + + /* (non-Javadoc) + * @see org.eclipse.swt.widgets.Widget#dispose() + */ + public void dispose(){ + super.dispose(); + AbstractEntryStorage entryConfigStorage = getEntryStorageInstance(); + if(entryConfigStorage != null){ + entryConfigStorage.removeConfigurationChangeListener(this); + } + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/ui/IEntryCheckStateListener.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/ui/IEntryCheckStateListener.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.ui; + +/** + * Notifies listeners when ever either all + * or none of the items are checke in the UI. + */ +public interface IEntryCheckStateListener { + + /** + * All entries were checked. + */ + public void allEntriesChecked(); + + /** + * All entries were unchecked. + */ + public void allEntriesUnchecked(); + + /** + * Some entries has been checked. + */ + public void someEntriesChecked(); +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/ui/dialogs/APIQueryMessageBox.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/ui/dialogs/APIQueryMessageBox.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,132 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.shared.ui.dialogs; + +import org.eclipse.swt.widgets.MessageBox; +import org.eclipse.swt.widgets.Shell; + +import com.nokia.s60tools.apiquery.shared.common.ProductInfoRegistry; +import com.nokia.s60tools.apiquery.shared.plugin.APIQueryPlugin; + +/** + * This class wraps the MessageBox in order to + * enhance it with product name, and run it in + * AppDep plugin's active shell context. + * + * @see org.eclipse.swt.widgets.MessageBox + */ +public class APIQueryMessageBox { + + MessageBox msgBox; + + /** + * Constructor. + * @param message User visible message. + * @param style Style bits. + */ + public APIQueryMessageBox(String message, int style){ + Shell sh = APIQueryPlugin.getCurrentlyActiveWbWindowShell(); + msgBox = new MessageBox(sh, style); + msgBox.setMessage(message); + msgBox.setText(ProductInfoRegistry.getProductName()); + } + + /** + * Constructor. + * @param sh Parent shell for the new instance. + * @param message User visible message. + * @param style Style bits. + */ + public APIQueryMessageBox(Shell sh, String message, int style){ + msgBox = new MessageBox(sh, style); + msgBox.setMessage(message); + msgBox.setText(ProductInfoRegistry.getProductName()); + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + public boolean equals(Object arg0) { + return msgBox.equals(arg0); + } + + /* (non-Javadoc) + * @see org.eclipse.swt.widgets.MessageBox#getMessage() + */ + public String getMessage() { + return msgBox.getMessage(); + } + + /* (non-Javadoc) + * @see org.eclipse.swt.widgets.Dialog#getParent() + */ + public Shell getParent() { + return msgBox.getParent(); + } + + /* (non-Javadoc) + * @see org.eclipse.swt.widgets.Dialog#getStyle() + */ + public int getStyle() { + return msgBox.getStyle(); + } + + /* (non-Javadoc) + * @see org.eclipse.swt.widgets.Dialog#getText() + */ + public String getText() { + return msgBox.getText(); + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + public int hashCode() { + return msgBox.hashCode(); + } + + /* (non-Javadoc) + * @see org.eclipse.swt.widgets.MessageBox#setMessage(java.lang.String) + */ + public void setMessage(String string) { + msgBox.setMessage(string); + } + + /* (non-Javadoc) + * @see org.eclipse.swt.widgets.Dialog#setText(java.lang.String) + */ + public void setText(String string) { + msgBox.setText(string); + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + public String toString() { + return msgBox.toString(); + } + + /* (non-Javadoc) + * @see org.eclipse.swt.widgets.MessageBox#open() + */ + public int open() { + return msgBox.open(); + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/util/LogUtils.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/util/LogUtils.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.shared.util; + +import org.eclipse.swt.widgets.Display; + +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.util.console.IConsolePrintUtility; + +/** + * Miscellaneous logging utilities to be used as tracing aid in case of error + * for which is otherwise hard to find information about the error in end-user environment + * unless properly logged also in production environment with exact error data. + */ +public class LogUtils { + + /** + * Logs error message and expection's stack trace to product console if we are running code + * in Eclipse workbench environment. If not (i.e running JUnit tests) + * catching the exceptions and ignoring them. + * + * Logging done here because we loose important information because + * cache data load is done inside job that looses stack trace. + * + * @param errorMsg Error message to log. + * @param e Exception to log. + */ + public static void logStackTrace(final String errorMsg, final Exception e) { + try { + if(e != null) e.printStackTrace(); + // Scheduling log task to UI thread. + Display.getDefault().asyncExec(new Runnable(){ + public void run() { + APIQueryConsole.getInstance().println(errorMsg, IConsolePrintUtility.MSG_ERROR); + if(e != null){ + StackTraceElement[] stackTrace = e.getStackTrace(); + APIQueryConsole.getInstance().printStackTrace(stackTrace); + } + } + }); + } catch (Exception e2) { + // Ignoring possible errors due to not having workbench environment running. + } + } + + /** + * Logs internal error message to tool's console and throws run-time exception. + * @param errMsg Error message to log and pass as message to runtime exception. + * @throws RuntimeException + */ + static public void logInternalErrorAndThrowException(String errMsg) throws RuntimeException { + APIQueryConsole.getInstance().println("INTERNAL ERROR: " + errMsg ); //$NON-NLS-1$ + throw new RuntimeException(errMsg); + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/util/SourceCodeParsingUtilities.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/util/SourceCodeParsingUtilities.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,101 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.util; + +/** + * Miscellaneous utilities for parsing source code. + */ +public class SourceCodeParsingUtilities { + + /** + * Parses header name from include directive line. + * @param line Line to check for. + * @return Name of the header file if found, otherwise null. + */ + public static String parseIncludeFromLine(String line) { + String include = null; + //If include is system inculde (#include ) + //This can be really a user include, if user has been using + //SYSTEMINCLUDE and USERINCLUDE in "wrong" ways + if(hasSystemInclude(line)){ + include = line.substring(line.indexOf("<") +1, line.indexOf(">")); //$NON-NLS-1$ //$NON-NLS-2$ + include = removeIncludePath(include); + + } + //If include is user inculde (#include "myapi.h") + //this can be really a system include, if user has been using + //SYSTEMINCLUDE and USERINCLUDE in "wrong" ways + else if(hasUserInclude(line)){ + include=line.substring(line.indexOf("\"") +1, line.lastIndexOf("\"")); //$NON-NLS-1$ //$NON-NLS-2$ + include = removeIncludePath(include); + } + return include; + } + + /** + * Removes path from the include, if exists, and returns only header's basename. + * @param include Absolute header path name. + * @return Header's basename. + */ + private static String removeIncludePath(String include) { + if(include.contains("\\")){ //$NON-NLS-1$ + include = include.substring(include.lastIndexOf("\\") + 1); //$NON-NLS-1$ + } + if(include.contains("/")){ //$NON-NLS-1$ + include = include.substring(include.lastIndexOf("/") + 1); //$NON-NLS-1$ + } + return include; + } + + /** + * Checks if line contains include directive. + * @param line Line to check for. + * @return true if include was found. + */ + private static boolean hasInclude(String line) { + return line.contains("#include"); //$NON-NLS-1$ + } + + /** + * Checks if line contains user include directive. + * @param line Line to check for. + * @return true if include was found. + */ + public static boolean hasUserInclude(String line) { + return hasInclude(line) && line.contains("\""); //$NON-NLS-1$ + } + + /** + * Checks if line contains system include directive. + * @param line Line to check for. + * @return true if include was found. + */ + public static boolean hasSystemInclude(String line) { + return hasInclude(line) && line.contains("<") && line.contains(">"); //$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * Checks if line contains system or user include directives. + * @param line Line to check for. + * @return true if an include was found. + */ + public static boolean hasIncludes(String line) { + return hasUserInclude(line) || hasSystemInclude(line); + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/util/console/APIQueryConsole.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/util/console/APIQueryConsole.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.shared.util.console; + +import org.eclipse.jface.resource.ImageDescriptor; + +import com.nokia.s60tools.apiquery.shared.common.ProductInfoRegistry; +import com.nokia.s60tools.apiquery.shared.plugin.APIQueryPlugin; +import com.nokia.s60tools.apiquery.shared.resources.ImageKeys; +import com.nokia.s60tools.util.console.AbstractProductSpecificConsole; +import com.nokia.s60tools.util.console.IConsolePrintUtility; + +/** + * Singleton class that offers console printing + * services for the API Query product. + */ +public class APIQueryConsole extends AbstractProductSpecificConsole { + + /** + * Singleton instance of the class. + */ + static private APIQueryConsole instance = null; + + /** + * Public accessor method. + * @return Singleton instance of the class. + */ + static public APIQueryConsole getInstance(){ + if(instance == null ){ + instance = new APIQueryConsole(); + } + return instance; + } + + /** + * Private constructor forcing Singleton usage of the class. + */ + private APIQueryConsole(){ + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.util.console.AbstractProductSpecificConsole#getProductConsoleName() + */ + protected String getProductConsoleName() { + return ProductInfoRegistry.getConsoleWindowName(); + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.util.console.AbstractProductSpecificConsole#getProductConsoleImageDescriptor() + */ + protected ImageDescriptor getProductConsoleImageDescriptor() { + return APIQueryPlugin.getImageDescriptorForKey(ImageKeys.IMG_APP_ICON); + } + + /** + * Prints given stack trace element array contents to console as error message. + * @param stackTrace stack trace to be printed into the console + */ + public void printStackTrace(StackTraceElement[] stackTrace) { + for (int i = 0; i < stackTrace.length; i++) { + StackTraceElement stackTraceElement = stackTrace[i]; + String traceString = stackTraceElement.toString(); + println(traceString, IConsolePrintUtility.MSG_ERROR); + } + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/util/xml/XMLDataSAXHandler.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/util/xml/XMLDataSAXHandler.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,263 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.util.xml; + +import java.util.EmptyStackException; +import java.util.LinkedHashMap; +import java.util.ListIterator; +import java.util.Map; +import java.util.Set; +import java.util.Stack; +import java.util.Vector; + +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; +import org.xml.sax.helpers.DefaultHandler; + +import com.nokia.s60tools.apiquery.shared.resources.Messages; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.util.debug.DbgUtility; + +/** + * SAX parser callback class that parses the XML into + * into XMLElementData object array. The set of elements + * and attributes to be parsed are specified in constructor. + * + * This class can parse elements that do not themselves contain + * any child elements. I.e. the elements to be parsed must be + * of flat XML. The parsed elements themselves can, of course, + * be contained by some parent element(s) that are not parsed + * by this handler. + */ +public class XMLDataSAXHandler extends DefaultHandler{ + + /** + * Set of element names we are interested in. + * Other elements are ignored. + */ + private final Set elemNameSet; + + /** + * Vector for storing the parsed elements. + */ + private final Vector parsedElementsVector; + + /** + * Flag is set to true when we are inside an element that is recognized. + */ + private boolean isInsideAcceptedElement = false; + + /** + * Name for the element currently under parsing. + */ + private String parsedElementName = null; + + /** + * Value for the element currently under parsing. + */ + private String parsedElementValue = null; + + /** + * Array for storing attribute data found for the element. + */ + private Map parsedAttributeData = null; + + /** + * Element -> Attribute set map containg attributes + * that should be checked for the element. + */ + private final Map> attributeMap; + + /** + * Parent restrictions for the elements. + */ + private final Map parentElementRestrictionMap; + + /** + * Storing elements to stack in order to resolve parent + * for the current element. + */ + private final Stack elementStack; + + /** + * Constructor. + * @param elemNameSet Set of element names that this handler + * will take into account. + * @param attributeMap Element -> Attribute set map containg attributes + * that should be checked for the element. + * @param parentElementRestrictionMap Parent element restrictions for parsing. + */ + public XMLDataSAXHandler(Set elemNameSet, Map> attributeMap, + Map parentElementRestrictionMap){ + this.elemNameSet = elemNameSet; + this.attributeMap = attributeMap; + this.parentElementRestrictionMap = parentElementRestrictionMap; + parsedElementsVector = new Vector(); + parsedAttributeData = new LinkedHashMap(); + elementStack = new Stack(); + } + + /* (non-Javadoc) + * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) + */ + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + + + //Storing parent for the current element + String parentElement = null; + try { + parentElement = elementStack.peek(); + } catch (EmptyStackException e) { + // Ignoring this exception + } + // Parent element is stored => We can add current element to stack. + elementStack.push(localName); + + if(elemNameSet.contains(localName)){ + + // Checking if possible parent element + // restriction should be taken into account. + boolean parentElementCheckOk = true; // By default there is no restrictions + String parentRestriction = parentElementRestrictionMap.get(localName); + if(parentRestriction != null){ + + if(parentElement == null || (! parentElement.equalsIgnoreCase(parentRestriction))){ + // Parent restriction is required, and does not match + parentElementCheckOk = false; + } + } + + if(parentElementCheckOk){ + // This is an element we are interested in + isInsideAcceptedElement = true; + parsedElementName = localName; + + // Checking for possible attributes + Map attrMap = attributeMap.get(localName); + if(attrMap != null && attrMap.size() > 0){ + + Set attrSet = attrMap.keySet(); + for (int i = 0; i < attributes.getLength(); i++) { + String attrName = attributes.getLocalName(i); + if(attrSet.contains(attrName)){ + String attrValue = attributes.getValue(i); + parsedAttributeData.put(attrMap.get(attrName), attrValue); + } + }//for + } + } + } + } + + /* (non-Javadoc) + * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int) + */ + public void characters(char[] ch, int start, int length) throws SAXException { + String characterDataString = new String(ch, start, length); + + if(isInsideAcceptedElement){ + if(parsedElementValue == null){ + parsedElementValue = characterDataString; + } + else{ + parsedElementValue = parsedElementValue + characterDataString; + } + } + } + + /* (non-Javadoc) + * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String) + */ + public void endElement(String uri, String localName, String qName) throws SAXException { + + elementStack.pop(); // Updating element stack + + if(isInsideAcceptedElement){ + // Adding element into parsed elements + if(parsedElementValue == null){ + // If element did not contain value => using an empty string instead + parsedElementValue = ""; //$NON-NLS-1$ + } + parsedElementsVector.add(new XMLElementData(parsedElementName, + parsedElementValue, + parsedAttributeData)); + isInsideAcceptedElement = false; + parsedElementName = null; + parsedElementValue = null; + // For the next element there is competely new data object reserved + parsedAttributeData = new LinkedHashMap(); + } + } + + /* (non-Javadoc) + * @see org.xml.sax.helpers.DefaultHandler#error(org.xml.sax.SAXParseException) + */ + public void error(SAXParseException e) throws SAXException { + String xmlParseFailedUserMsg = Messages.getString("XMLDataSAXHandler.XML_Parse_Error_ConsoleMsg" //$NON-NLS-1$ + + "( " + getCurrentParsePath() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, + xmlParseFailedUserMsg); + APIQueryConsole.getInstance().println(xmlParseFailedUserMsg + e.getMessage(), APIQueryConsole.MSG_ERROR); + throw new SAXException(e.getMessage()); + } + + /* (non-Javadoc) + * @see org.xml.sax.helpers.DefaultHandler#fatalError(org.xml.sax.SAXParseException) + */ + public void fatalError(SAXParseException e) throws SAXException { + String xmlParseFailedUserMsg = Messages.getString("XMLDataSAXHandler.XML_Parse_FatalError_ConsoleMsg") //$NON-NLS-1$ + + "( " + getCurrentParsePath() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, + xmlParseFailedUserMsg); + APIQueryConsole.getInstance().println(xmlParseFailedUserMsg + e.getMessage(), APIQueryConsole.MSG_ERROR); + throw new SAXException(e.getMessage()); + } + + /* (non-Javadoc) + * @see org.xml.sax.helpers.DefaultHandler#warning(org.xml.sax.SAXParseException) + */ + public void warning(SAXParseException e) throws SAXException { + String xmlParseFailedUserMsg = Messages.getString("XMLDataSAXHandler.XML_Parse_Warning_ConsoleMsg" //$NON-NLS-1$ + + "( " + getCurrentParsePath() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, + xmlParseFailedUserMsg); + APIQueryConsole.getInstance().println(xmlParseFailedUserMsg + e.getMessage(), APIQueryConsole.MSG_WARNING); + } + + /** + * Element data that was parsed. + * @return Elements parsed. + */ + public XMLElementData[] getParsedElements(){ + return parsedElementsVector.toArray(new XMLElementData[0]); + } + + /** + * Returns current parse path based on the information stored in the stack. + */ + private String getCurrentParsePath(){ + StringBuffer path = new StringBuffer("/"); //$NON-NLS-1$ + for (ListIterator iter = elementStack.listIterator(); iter.hasNext();) { + String elemName = (String) iter.next(); + path.append(elemName + "/"); //$NON-NLS-1$ + } + return path.toString(); + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/util/xml/XMLElementData.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/util/xml/XMLElementData.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.util.xml; + +import java.util.Map; + +/** + * Stores data for a single XML element that + * has simple string content and no sub elements. + * Only attribute data is stored. + */ +public class XMLElementData { + + /** + * Content for the element. + */ + private final String elementContent; + + /** + * Name of the element. + */ + private final String elementName; + + /** + * Attribute data for the element. + */ + private final Map attrData; + + public XMLElementData(String elementName, String elementContent, Map attrData){ + this.elementName = elementName; + this.elementContent = elementContent; + this.attrData = attrData; + } + + /** + * @return the elementContent + */ + public String getElementContent() { + return elementContent; + } + + /** + * @return the elementName + */ + public String getElementName() { + return elementName; + } + + /** + * @return the attrData + */ + public Map getAttributes() { + return attrData; + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/util/xml/XMLUtils.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/shared/util/xml/XMLUtils.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,652 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.shared.util.xml; + +import java.io.IOException; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.XMLReaderFactory; + +import com.nokia.s60tools.apiquery.shared.datatypes.APIDetailField; +import com.nokia.s60tools.apiquery.shared.datatypes.APIDetails; +import com.nokia.s60tools.apiquery.shared.datatypes.APIShortDescription; +import com.nokia.s60tools.apiquery.shared.datatypes.XMLToUIMappingRules; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.util.debug.DbgUtility; + +/** + * XML Transformation utils for transforming XML data into + * object formats supported by user interface components. + * This class contains static utility methods of making + * conversion. + */ +public class XMLUtils { + + // + //Public static variables to XML elements + //These element names is not ment to show in UI, + //but are element names only in XML document. + // + + + /** + * Element name in XML api + */ + public static final String API_ELEMENT = "api"; //$NON-NLS-1$ + /** + * Element name in XML source + */ + public static final String API_ELEMENT_SOURCE_ATTRIBUTE = "source"; //$NON-NLS-1$ + /** + * Element name in XML filename + */ + public static final String API_ELEMENT_FILENAME = "filename";//$NON-NLS-1$ + /** + * Element name in XML name + */ + public static final String API_ELEMENT_NAME = "name";//$NON-NLS-1$ + /** + * Element name in XML clients + */ + public static final String API_ELEMENT_CLIENTS = "clients";//$NON-NLS-1$ + /** + * Element name in XML client_org + */ + public static final String API_ELEMENT_CLIENT_ORG = "client_org";//$NON-NLS-1$ + /** + * Element name in XML note + */ + public static final String API_ELEMENT_NOTE = "note";//$NON-NLS-1$ + /** + * Element name in XML owner + */ + public static final String API_ELEMENT_OWNER = "owner";//$NON-NLS-1$ + /** + * Element name in XML base_service + */ + public static final String API_ELEMENT_BASE_SERVICE = "base_service";//$NON-NLS-1$ + /** + * Element name in XML partner_contacts + */ + public static final String API_ELEMENT_PARTNER_CONTACTS = "partner_contacts";//$NON-NLS-1$ + /** + * Element name in XML partners + */ + public static final String API_ELEMENT_PARTNERS = "partners";//$NON-NLS-1$ + /** + * Element name in XML extended_sdk_removed + */ + public static final String API_ELEMENT_EXTENDED_SDK_REMOVED = "extended_sdk_removed";//$NON-NLS-1$ + /** + * Element name in XML extended_sdk_deprecated + */ + public static final String API_ELEMENT_EXTENDED_SDK_DEPRECATED = "extended_sdk_deprecated";//$NON-NLS-1$ + /** + * Element name in XML extended_sdk_since + */ + public static final String API_ELEMENT_EXTENDED_SDK_SINCE = "extended_sdk_since";//$NON-NLS-1$ + /** + * Element name in XML for_adaptation_removed + */ + public static final String API_ELEMENT_FOR_ADAPTATION_REMOVED = "for_adaptation_removed";//$NON-NLS-1$ + /** + * Element name in XML for_adaptation_deprecated + */ + public static final String API_ELEMENT_FOR_ADAPTATION_DEPRECATED = "for_adaptation_deprecated";//$NON-NLS-1$ + /** + * Element name in XML for_adaptation_since + */ + public static final String API_ELEMENT_FOR_ADAPTATION_SINCE = "for_adaptation_since";//$NON-NLS-1$ + /** + * Element name in XML removed + */ + public static final String API_ELEMENT_REMOVED = "removed";//$NON-NLS-1$ + /** + * Element name in XML deprecated + */ + public static final String API_ELEMENT_DEPRECATED = "deprecated";//$NON-NLS-1$ + /** + * Element name in XML subsystem + */ + public static final String API_ELEMENT_SUBSYSTEM = "subsystem";//$NON-NLS-1$ + /** + * Element name in XML other + */ + public static final String API_ELEMENT_OTHER = "other";//$NON-NLS-1$ + /** + * Element name in XML import_lib + */ + public static final String API_ELEMENT_IMPORT_LIB = "import_lib";//$NON-NLS-1$ + /** + * Element name in XML dll + */ + public static final String API_ELEMENT_DLL = "dll";//$NON-NLS-1$ + /** + * Element name in XML specification + */ + public static final String API_ELEMENT_SPECIFICATION = "specification";//$NON-NLS-1$ + /** + * Element name in XML adaptation + */ + public static final String API_ELEMENT_ADAPTATION = "adaptation";//$NON-NLS-1$ + /** + * Element name in XML private + */ + public static final String API_ELEMENT_PRIVATE = "private";//$NON-NLS-1$ + /** + * Element name in XML internal + */ + public static final String API_ELEMENT_INTERNAL = "internal";//$NON-NLS-1$ + /** + * Element name in XML domain + */ + public static final String API_ELEMENT_DOMAIN = "domain";//$NON-NLS-1$ + /** + * Element name in XML sdk + */ + public static final String API_ELEMENT_SDK = "sdk";//$NON-NLS-1$ + /** + * Element name in XML responsible + */ + public static final String API_ELEMENT_RESPONSIBLE = "responsible";//$NON-NLS-1$ + /** + * Element name in XML type + */ + public static final String API_ELEMENT_TYPE = "type";//$NON-NLS-1$ + /** + * Element name in XML purpose + */ + public static final String API_ELEMENT_PURPOSE = "purpose";//$NON-NLS-1$ + /** + * Element name in XML key_name + */ + public static final String API_ELEMENT_KEY_NAME = "key_name";//$NON-NLS-1$ + /** + * Element name in XML value + */ + public static final String API_ELEMENT_VALUE = "value";//$NON-NLS-1$ + /** + * Element name in XML header + */ + public static final String API_ELEMENT_HEADER = "header";//$NON-NLS-1$ + + // + //Public static variables to UI elements. + //These variables matches to XML element names, but is ment to show in UI. + // + + /** + * XML element name ment to show in UI and used as key in object model Clients + */ + public static final String DESCRIPTION_CLIENTS = "Clients";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Client Org + */ + public static final String DESCRIPTION_CLIENT_ORG = "Client Org";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Note + */ + public static final String DESCRIPTION_NOTE = "Note";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Owner + */ + public static final String DESCRIPTION_OWNER = "Owner";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Base service + */ + public static final String DESCRIPTION_BASE_SERVICE = "Base service";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Partner contacts + */ + public static final String DESCRIPTION_PARTNER_CONTACTS = "Partner contacts";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Partners + */ + public static final String DESCRIPTION_PARTNERS = "Partners";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Extended SDK Removed + */ + public static final String DESCRIPTION_EXTENDED_SDK_REMOVED = "Extended SDK Removed";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Extended SDK Deprecated + */ + public static final String DESCRIPTION_EXTENDED_SDK_DEPRECATED = "Extended SDK Deprecated";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Extended SDK Since + */ + public static final String DESCRIPTION_EXTENDED_SDK_SINCE = "Extended SDK Since";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model For Adaptation Removed + */ + public static final String DESCRIPTION_FOR_ADAPTATION_REMOVED = "For Adaptation Removed";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model For Adaptation Deprecated + */ + public static final String DESCRIPTION_FOR_ADAPTATION_DEPRECATED = "For Adaptation Deprecated";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Other + */ + public static final String DESCRIPTION_OTHER = "Other";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model LIBs + */ + public static final String DESCRIPTION_LIBS = "LIBs";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model DLLs + */ + public static final String DESCRIPTION_DLLS = "DLLs";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Specification + */ + public static final String DESCRIPTION_SPECIFICATION = "Specification";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Adaptation + */ + public static final String DESCRIPTION_ADAPTATION = "Adaptation";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Responsible + */ + public static final String DESCRIPTION_RESPONSIBLE = "Responsible";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Type + */ + public static final String DESCRIPTION_TYPE = "Type";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Purpose + */ + public static final String DESCRIPTION_PURPOSE = "Purpose";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Key Name + */ + public static final String DESCRIPTION_KEY_NAME = "Key Name";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Subsystem + */ + public static final String DESCRIPTION_SUBSYSTEM = "Subsystem";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Removed + */ + public static final String DESCRIPTION_REMOVED = "Removed"; //$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model For Adaptation Since + */ + public static final String DESCRIPTION_FOR_ADAPTATION_SINCE = "For Adaptation Since";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Deprecated + */ + public static final String DESCRIPTION_DEPRECATED = "Deprecated";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Private + */ + public static final String DESCRIPTION_PRIVATE = "Private";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Internal + */ + public static final String DESCRIPTION_INTERNAL = "Internal";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Domain + */ + public static final String DESCRIPTION_DOMAIN = "Domain";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Sdk + */ + public static final String DESCRIPTION_SDK = "Sdk";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model API Name + */ + public static final String DESCRIPTION_API_NAME = "API Name";//$NON-NLS-1$ + /** + * XML element name ment to show in UI and used as key in object model Headers + */ + public static final String DESCRIPTION_HEADERS = "Headers";//$NON-NLS-1$ + + // + // Public service methods + // + + /** + * Converts XML data to API details object. + * @param dataStrXML XML formatted data. + * @return API details object. + * @throws IOException + */ + public static APIDetails xmlToAPIDetails(String dataStrXML) throws IOException{ + + XMLToUIMappingRules convRules = getAPIDetailsConversionRules(); + + return extractAPIDetailsData(dataStrXML, convRules); + } + + /** + * Get Conversion rules to get API Details from XML. + * @return + */ + public static XMLToUIMappingRules getAPIDetailsConversionRules() { + XMLToUIMappingRules convRules = new XMLToUIMappingRules(); + + // + // Defining mapping rules API details + // + + // API name field + convRules.addRule(API_ELEMENT_NAME, DESCRIPTION_API_NAME); //$NON-NLS-1$ //$NON-NLS-2$ + // Headers field + Map headerAttributes = new LinkedHashMap (); + headerAttributes.put(API_ELEMENT_FILENAME, API_ELEMENT_FILENAME); //$NON-NLS-1$ //$NON-NLS-2$ + convRules.addRule(API_ELEMENT_HEADER, DESCRIPTION_HEADERS, headerAttributes); //$NON-NLS-1$ //$NON-NLS-2$ + // Key field + Map keyNameAttributes = new LinkedHashMap (); + keyNameAttributes.put(API_ELEMENT_VALUE, API_ELEMENT_VALUE); //$NON-NLS-1$ //$NON-NLS-2$ + convRules.addRule(API_ELEMENT_KEY_NAME, DESCRIPTION_KEY_NAME, keyNameAttributes); //$NON-NLS-1$ //$NON-NLS-2$ + // Other fields + convRules.addRule(API_ELEMENT_PURPOSE, DESCRIPTION_PURPOSE, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_TYPE, DESCRIPTION_TYPE, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_RESPONSIBLE, DESCRIPTION_RESPONSIBLE, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_SDK, DESCRIPTION_SDK, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_DOMAIN, DESCRIPTION_DOMAIN, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_INTERNAL, DESCRIPTION_INTERNAL, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_PRIVATE, DESCRIPTION_PRIVATE, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_ADAPTATION, DESCRIPTION_ADAPTATION, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_SPECIFICATION, DESCRIPTION_SPECIFICATION, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_DLL, DESCRIPTION_DLLS, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_IMPORT_LIB, DESCRIPTION_LIBS, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_OTHER, DESCRIPTION_OTHER, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_SUBSYSTEM, DESCRIPTION_SUBSYSTEM, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_DEPRECATED, DESCRIPTION_DEPRECATED, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_REMOVED, DESCRIPTION_REMOVED, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_FOR_ADAPTATION_SINCE, DESCRIPTION_FOR_ADAPTATION_SINCE, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_FOR_ADAPTATION_DEPRECATED, DESCRIPTION_FOR_ADAPTATION_DEPRECATED, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_FOR_ADAPTATION_REMOVED, DESCRIPTION_FOR_ADAPTATION_REMOVED, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_EXTENDED_SDK_SINCE, DESCRIPTION_EXTENDED_SDK_SINCE, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_EXTENDED_SDK_DEPRECATED, DESCRIPTION_EXTENDED_SDK_DEPRECATED, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_EXTENDED_SDK_REMOVED, DESCRIPTION_EXTENDED_SDK_REMOVED, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_PARTNERS, DESCRIPTION_PARTNERS, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_PARTNER_CONTACTS, DESCRIPTION_PARTNER_CONTACTS, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_BASE_SERVICE, DESCRIPTION_BASE_SERVICE, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ + convRules.addRule(API_ELEMENT_OWNER, DESCRIPTION_OWNER, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_NOTE, DESCRIPTION_NOTE, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_CLIENT_ORG, DESCRIPTION_CLIENT_ORG, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + convRules.addRule(API_ELEMENT_CLIENTS, DESCRIPTION_CLIENTS, API_ELEMENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + return convRules; + } + + /** + * Converts XML data to API details object. + * @param dataStrXML XML formatted data. + * @param sourceDescription Description for the source shown in the UI. + * @return API details object. + * @throws IOException + */ + public static Collection xmlToAPIShortDescription(String dataStrXML, String sourceDescription) throws IOException{ + XMLToUIMappingRules convRules = new XMLToUIMappingRules(); + + // + // Defining mapping rules API summary + // + + // API field is the only element to be parsed + // The element data contains API name and + // API_ELEMENT_SOURCE_ATTRIBUTE contains the + // source for accessing API details information. + Map apiAttributes = new LinkedHashMap (); + apiAttributes.put(API_ELEMENT_SOURCE_ATTRIBUTE, API_ELEMENT_SOURCE_ATTRIBUTE); + convRules.addRule(API_ELEMENT, "API", apiAttributes); //$NON-NLS-1$ + + return extractAPIShortDescriptionData(dataStrXML, convRules, sourceDescription); + } + + /** + * Checks that there are no forbidden characters and replaces + * with valid ones if needed. + * @param in String to be checked. + * @return Returns checked and corrected string. + */ + public static String replaceForbiddenCharacters(String in){ + String out = in.replace("&","&"); //$NON-NLS-1$ //$NON-NLS-2$ + out = out.replace("<","<"); //$NON-NLS-1$ //$NON-NLS-2$ + out = out.replace(">",">"); //$NON-NLS-1$ //$NON-NLS-2$ + out = out.replace("\"","""); //$NON-NLS-1$ //$NON-NLS-2$ + out = out.replace("'","'"); //$NON-NLS-1$ //$NON-NLS-2$ + return out; + } + + // + // Internal classes + // + + + // + // Private methods for the class + // + + /** + * Parses the given elements from the XML data + * and returns the resulting elements. + * @param XMLData XML data to be parser. + * @param elemNameSet Set of element names that this handler + * will take into account. + * @param attributeMap Element -> Attribute set map containg a set of attributes + * that should be checked for the element. + * @return XML elements found. + * @throws IOException + */ + public static XMLElementData[] parseXML(String XMLData, Set elemNameSet, + Map>attributeMap) throws IOException{ + return parseXML(XMLData, elemNameSet, attributeMap, new HashMap()); + } + + /** + * Parses the given elements from the XML data + * and returns the resulting elements. + * @param XMLData XML data to be parser. + * @param elemNameSet Set of element names that this handler + * will take into account. + * @param attributeMap Element -> Attribute set map containg a set of attributes + * that should be checked for the element. + * @param parentElementRestrictionMap Parent element restrictions for parsing. + * @return XML elements found. + * @throws IOException + */ + public static XMLElementData[] parseXML(String XMLData, Set elemNameSet, + Map>attributeMap, + Map parentElementRestrictionMap) throws IOException{ + + // Creates SAX handler that takes information into generic data structure + XMLDataSAXHandler handler = new XMLDataSAXHandler(elemNameSet, attributeMap, parentElementRestrictionMap); + + // Triggering actual XML parsing + try { + InputSource dataSource = createInputSourceFromString(XMLData); + + XMLReader parser = XMLReaderFactory.createXMLReader(); + + + parser.setContentHandler(handler); + parser.setErrorHandler(handler); + + parser.parse(dataSource); + + } catch (SAXException e) { + e.printStackTrace(); + APIQueryConsole.getInstance().printStackTrace(e.getStackTrace()); + throw new IOException ("XML parsing failed" + " (" + e.getMessage() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } catch (IOException e) { + e.printStackTrace(); + APIQueryConsole.getInstance().printStackTrace(e.getStackTrace()); + throw e; + } + + return handler.getParsedElements(); + } + + /** + * Creates input source from XML data string. + * @param XMLData XML data string to be created input source from. + * @return Input source from the given string. + */ + private static InputSource createInputSourceFromString(String XMLData){ + StringReader rdr = new StringReader(XMLData); + return new InputSource(rdr); + } + + /** + * Parsed API summary objects from given XML data string. + * @param XMLData XML data string to be parsed. + * @param mappingRules Mapping rules used to convert XML elements into + * corresponding descriptions. + * @param sourceDescription Description for the source shown in the UI. + * @return Collection of API summary objects extracted from the XML data. + * @throws IOException + */ + private static Collection extractAPIShortDescriptionData(String XMLData, + XMLToUIMappingRules mappingRules, + String sourceDescription) throws IOException{ + + // Printing with loop-priority because there will be a lot of data printed out + DbgUtility.println(DbgUtility.PRIORITY_LOOP, "-*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-"); //$NON-NLS-1$ + DbgUtility.println(DbgUtility.PRIORITY_LOOP, "API Summary data: " + XMLData); //$NON-NLS-1$ + DbgUtility.println(DbgUtility.PRIORITY_LOOP, "-*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-"); //$NON-NLS-1$ + + ArrayList summaryList = new ArrayList(); + + XMLElementData[] elementArr = parseXML(XMLData, + mappingRules.getMapFromKeySet(), + mappingRules.getAttributeMap()); + + // Mapping data fields into corresponding API summary fields + for (int i = 0; i < elementArr.length; i++) { + // Validating first that we have data that we should have + if(! elementArr[i].getElementName().equals(API_ELEMENT)){ + throw new RuntimeException("Internal error (XMLUtils): Invalid XML, expected '" + API_ELEMENT + "' element, but encountered: " + elementArr[i].getElementName()); //$NON-NLS-1$ //$NON-NLS-2$ + } + if(elementArr[i].getAttributes().size() != 1){ + throw new RuntimeException("Internal error (XMLUtils): Invalid XML, '" + API_ELEMENT + "' should be always attached with '" + API_ELEMENT_SOURCE_ATTRIBUTE + "' attribute"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + + // Converting values into API summary + String source = elementArr[i].getAttributes().get(API_ELEMENT_SOURCE_ATTRIBUTE); + String value = elementArr[i].getElementContent(); // API name + summaryList.add(new APIShortDescription(value, source, sourceDescription)); + } + + return summaryList; + } + + /** + * Parsed API details object from given XML data string. + * @param XMLData XML data string to be parsed. + * @param mappingRules Mapping rules used to convert XML elements into + * corresponding descriptions. + * @return API details object extracted from the XML data. + * @throws IOException + */ + public static APIDetails extractAPIDetailsData(String XMLData, + XMLToUIMappingRules mappingRules) throws IOException{ + + // Printing with loop-priority because there will be a lot of data printed out + DbgUtility.println(DbgUtility.PRIORITY_LOOP, "-*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-"); //$NON-NLS-1$ + DbgUtility.println(DbgUtility.PRIORITY_LOOP, "API Details data: " + XMLData); //$NON-NLS-1$ + DbgUtility.println(DbgUtility.PRIORITY_LOOP, "-*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-"); //$NON-NLS-1$ + + APIDetails details = new APIDetails(); + + XMLElementData[] elementArr = parseXML(XMLData, + mappingRules.getMapFromKeySet(), + mappingRules.getAttributeMap(), + mappingRules.getParentElementRestrictionMap()); + + // Mapping data fields into corresponding API detail fields + for (int i = 0; i < elementArr.length; i++) { + XMLElementData data = elementArr[i]; + String description = mappingRules.mapFrom(data.getElementName()); + String value = ""; //$NON-NLS-1$ + Map attrData = data.getAttributes(); + boolean wasNamedParameters = false; + + //If there is some attributes... + if(attrData.size()> 0){ + Map attrNames = mappingRules.getAttributeNamesMap(data.getElementName()); + + Set keys = attrData.keySet(); + + // Attribute data overrides element data + // Attributes are used for , and
elements. + boolean first = true; + + for (String key : keys) { + String attr = attrData.get(key); + String attrKey = getKeyByValue(key, attrNames); + + //set parameter description if has one! + if(attrNames != null && attrNames.containsValue(key) && !key.equals(attrKey)){ + details.addOrUpdateField(key, attr); + wasNamedParameters = true; + } + //Comma separated values --> + else if(first){ + value = attr; + first = false; + }else{ + value = value + APIDetailField.VALUE_FIELD_SEPARATOR + attr; + } + } + + } + else{ + value = data.getElementContent(); + } + //If there was only attributes set as own rows, must be checked that if there was some other content as well + // Either addig or updating an existing field. + //If there was named parameters, and there was no non-named parameters, then element it self is + //not ment to occur in UI, only independent parameters. + if(!wasNamedParameters || value.trim().length() > 0){ + details.addOrUpdateField(description, value); + } + } + + return details; + } + + /** + * Get XML element name by UI element name. + * @param value + * @param attrNames + * @return + */ + private static String getKeyByValue(String value, + Map attrNames) { + Set keys = attrNames.keySet(); + for (String key : keys) { + String value_ = attrNames.get(key); + if(value_.equals(value)){ + return key; + } + } + return null; + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/actions/AbstractMainViewAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/actions/AbstractMainViewAction.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.ui.actions; + +import org.eclipse.jface.action.Action; + +import com.nokia.s60tools.apiquery.ui.views.main.MainView; + +/** + * Common abstract base class for all main view + * related actions. + */ +public abstract class AbstractMainViewAction extends Action { + + /** + * Reference to the view. + */ + MainView view; + + /** + * Constructor. + * @param view Reference to the view. + */ + public AbstractMainViewAction(MainView view) { + super(); + this.view = view; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.action.IAction#run() + */ + public void run() { + view.updateActionButtonStates(); + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/actions/ToolsMenuAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/actions/ToolsMenuAction.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.ui.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IViewReference; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; + +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.apiquery.ui.views.main.MainView; +import com.nokia.s60tools.util.console.IConsolePrintUtility; + +public class ToolsMenuAction implements IWorkbenchWindowActionDelegate { + + /** + * Reference to workbench window + */ + private IWorkbenchWindow window; + + /** + * Constructor. + */ + public ToolsMenuAction(){ + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() + */ + public void dispose() { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) + */ + public void init(IWorkbenchWindow window) { + this.window = window; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public void run(IAction action) { + try { + IWorkbenchPage page = window.getActivePage(); + + // Checking if view is already open + IViewReference[] viewRefs = page.getViewReferences(); + for (int i = 0; i < viewRefs.length; i++) { + IViewReference reference = viewRefs[i]; + String id = reference.getId(); + if(id.equalsIgnoreCase(MainView.ID)){ + // Found, restoring the view + IViewPart viewPart = reference.getView(true); + page.activate(viewPart); + return; + } + } + + // View was not found, opening it up as a new view. + page.showView(MainView.ID); + + } catch (Exception e) { + e.printStackTrace(); + APIQueryConsole.getInstance().println(e.getMessage(), + IConsolePrintUtility.MSG_ERROR); + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/dialogs/FirstTimePopUpDialog.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/dialogs/FirstTimePopUpDialog.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,169 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.ui.dialogs; + +import java.util.Collection; +import java.util.Iterator; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Shell; + +import com.nokia.s60tools.apiquery.shared.resources.Messages; +import com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension; +import com.nokia.s60tools.apiquery.shared.searchmethodregistry.SearchMethodExtensionRegistry; + +/** + * Class for showing First time pop up dialog (Quick help). + * + * This dialog is ment to open when API Query application + * is started for the wery first time. + * + */ +public class FirstTimePopUpDialog { + + private static final String NEW_LINE = "\n\n"; //$NON-NLS-1$ + + /** + * For checking if Web data source is available to build message, we need to check + * id Web data source was found and we cannot have dependency to data source + * plug-ins in main plug-in. Thats why we keep this duplicate ID here. + */ + private static final String WEB_DATASOURCE_ID = "web"; + + /** + * No construction, only static method to use. + * + */ + private FirstTimePopUpDialog(){ + } + + /** + * Open the first time pop up dialog (quick help). + * + */ + public static void open(Shell parent) { + + StringBuffer msg = new StringBuffer(); + + msg.append(Messages.getString("FirstTimePopUpDialog.Topic_Msg")); //$NON-NLS-1$ + msg.append(NEW_LINE); + msg.append(Messages.getString("FirstTimePopUpDialog.Tool_Is_For_Msg")); //$NON-NLS-1$ + + String dataSourcesMsg = getDataSourcesMsg(); + + msg.append(NEW_LINE); + msg.append(dataSourcesMsg); + msg.append(NEW_LINE); + msg.append(Messages.getString("FirstTimePopUpDialog.Seach_Msg")); //$NON-NLS-1$ + msg.append(NEW_LINE); + msg.append(Messages.getString("FirstTimePopUpDialog.Results_Msg")); //$NON-NLS-1$ + msg.append(NEW_LINE); + msg.append(Messages.getString("FirstTimePopUpDialog.Project_Query_Msg")); //$NON-NLS-1$ + msg.append(NEW_LINE); + msg.append(Messages.getString("FirstTimePopUpDialog.More_Information_Msg")); //$NON-NLS-1$ + + MessageDialog.openInformation(parent, + Messages.getString("FirstTimePopUpDialog.Title_Msg"),msg.toString());//$NON-NLS-1$ + } + + /** + * Get part of the dialog messages where data sources are described. + * Message content depends on current data source configuration + * @return msg to show in UI + */ + private static String getDataSourcesMsg() { + + //Message with 3 data sources will be: + //To configure Data Sources, open the Properties tab at the bottom of the API Query view. + //Three types of Data Sources are currently available: + //Web Server, API Metadata files from the SDK and Excel Interface Sheets. + //There are three Web servers configured by default, but only two of them are enabled. + + SearchMethodExtensionRegistry smeRegistry = SearchMethodExtensionRegistry.getInstance(); + int extensionCount = smeRegistry.getExtensionCount(); + //If we have web data source or not + boolean isWeb = false; + + Collection extensions = smeRegistry.getExtensions(); + String dataSourcesMsg = Messages.getString("FirstTimePopUpDialog.Properties_Msg_Configure"); //$NON-NLS-1$ + dataSourcesMsg += " ";//$NON-NLS-1$ + //If we have only one data source + if(extensionCount == 1){ + dataSourcesMsg =Messages.getString("FirstTimePopUpDialog.Properties_Msg_Option_One_DataSources"); //$NON-NLS-1$ + String ds1 = null; + for (Iterator iterator = extensions.iterator(); iterator.hasNext();) { + ISearchMethodExtension extension = (ISearchMethodExtension) iterator.next(); + isWeb = isExtensionWeb(isWeb, extension); + ds1 = extension.getExtensionInfo().getDescription(); + } + dataSourcesMsg = String.format(dataSourcesMsg, ds1); + + } + //If we have 2 data sources available + else if(extensionCount == 2){ + dataSourcesMsg = Messages.getString("FirstTimePopUpDialog.Properties_Msg_Option_Two_DataSources"); //$NON-NLS-1$ + String ds1 = null; + String ds2 = null; + for (Iterator iterator = extensions.iterator(); iterator.hasNext();) { + ISearchMethodExtension extension = (ISearchMethodExtension) iterator.next(); + isWeb = isExtensionWeb(isWeb, extension); + if(ds1 == null){ + ds1 = extension.getExtensionInfo().getDescription(); + }else{ + ds2 = extension.getExtensionInfo().getDescription(); + } + } + dataSourcesMsg = String.format(dataSourcesMsg, ds1, ds2); + } + //if we have 3 data sources available + else{//else it will be 3, but just in case having just else case + dataSourcesMsg = Messages.getString("FirstTimePopUpDialog.Properties_Msg_Option_Three_DataSources"); //$NON-NLS-1$ + String ds1 = null; + String ds2 = null; + String ds3 = null; + for (Iterator iterator = extensions.iterator(); iterator.hasNext();) { + ISearchMethodExtension extension = (ISearchMethodExtension) iterator.next(); + isWeb = isExtensionWeb(isWeb, extension); + if(ds1 == null && ds2 == null){ + ds1 = extension.getExtensionInfo().getDescription(); + }else if(ds2 == null){ + ds2 = extension.getExtensionInfo().getDescription(); + }else { + ds3 = extension.getExtensionInfo().getDescription(); + } + } + dataSourcesMsg = String.format(dataSourcesMsg, ds1, ds2, ds3); + } + //If we have web data source, adding web data source information to the end + if(isWeb){ + dataSourcesMsg += " ";//$NON-NLS-1$ + dataSourcesMsg += Messages.getString("FirstTimePopUpDialog.Properties_Msg_WebDescription"); //$NON-NLS-1$ + } + return dataSourcesMsg; + } + + /** + * Checking if this is Web extension + * @param isWebAllreadyFound boolean that indicates that web is already found + * @param extension + * @return true if is false otherwise + */ + private static boolean isExtensionWeb(boolean isWebAllreadyFound , ISearchMethodExtension extension) { + return isWebAllreadyFound || extension.getExtensionInfo().getId().equalsIgnoreCase(WEB_DATASOURCE_ID); + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/dialogs/OpenReportStatusDialog.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/dialogs/OpenReportStatusDialog.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.ui.dialogs; + +import org.eclipse.jface.dialogs.StatusDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; + +import com.nokia.s60tools.apiquery.shared.resources.Messages; + +/** + * Simple dialog asking if user want to open created file or not. + * + */ +public class OpenReportStatusDialog extends StatusDialog { + + private final String fileName; + + /** + * Open a Dialog + * @param parent + * @param fileName + */ + public OpenReportStatusDialog(Shell parent, String fileName) { + super(parent); + this.fileName = fileName; + init(); + + } + + /** + * Set title, default orientation and help not available + */ + private void init() { + setTitle(Messages.getString("OpenReportStatusDialog.OpenReport_Msg")); //$NON-NLS-1$ + setHelpAvailable(false); + setDefaultOrientation(SWT.CENTER); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ + protected Control createDialogArea(Composite parent) { + + Composite composite = (Composite) super.createDialogArea(parent); + + final int cols = 1; + GridLayout gdl = new GridLayout(cols, false); + GridData gd = new GridData(GridData.FILL_BOTH); + + composite.setLayout(gdl); + composite.setLayoutData(gd); + + Label label = new Label(composite,SWT.HORIZONTAL); + label.setText(Messages.getString("OpenReportStatusDialog.DoYouWantOpenReport_Msg") +fileName +"?"); //$NON-NLS-1$ //$NON-NLS-2$ + + return composite; + } + + + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/MainView.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/MainView.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,352 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.ui.views.main; + +import java.util.Collection; +import java.util.concurrent.ExecutionException; + +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CTabFolder; +import org.eclipse.swt.custom.CTabItem; +import org.eclipse.swt.custom.SashForm; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IViewReference; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.part.ViewPart; + +import com.nokia.s60tools.apiquery.servlets.APIQueryWebServerConfigurator; +import com.nokia.s60tools.apiquery.shared.datatypes.APIShortDescription; +import com.nokia.s60tools.apiquery.shared.exceptions.QueryOperationFailedException; +import com.nokia.s60tools.apiquery.shared.plugin.APIQueryPlugin; +import com.nokia.s60tools.apiquery.shared.resources.Messages; +import com.nokia.s60tools.apiquery.ui.views.main.properties.PropertiesTabComposite; +import com.nokia.s60tools.apiquery.ui.views.main.search.SearchTabComposite; +import com.nokia.s60tools.util.debug.DbgUtility; + +/** + * This class comprises the Main View of the API Query + * application. + * + * This example main view demonstrated the creation of a + * view with two tabbed view. The second tab also demonstrated + * how context menus can be attached to some control + */ +public class MainView extends ViewPart { + + /** + * We can get view ID at runtime once the view is instantiated, but we + * also need static access to ID in order to be able to invoke the view. + */ + public static final String ID = "com.nokia.s60tools.apiquery.ui.views.main.MainView"; //$NON-NLS-1$ + + + // + // Controls and related classes (providers etc.) + // + + private CTabItem searchTab; + private CTabItem propertiesTab; + +static private PropertiesTabComposite propertiesTabContents; + private SearchTabComposite searchTabContents; + + /** + * The constructor. + */ + public MainView() { + //Starting APIQuery WebServer + APIQueryWebServerConfigurator.startServer(APIQueryWebServerConfigurator.Carbide_Instance_start); + } + + + public static void enablePropTabcontents(boolean enable) + { + if(propertiesTabContents!=null) + { + if(enable) propertiesTabContents.enablePropTabComponents(); + else propertiesTabContents.disablePropTabComponents(); + } + + + } + + + + + + /** + * This is called by framework when the controls for + * the view should be created. + */ + public void createPartControl(Composite parent) { + + try { + + // + // Creating controls + // + + // The left side contains component hierarchy tree view + SashForm mainViewSashForm = new SashForm(parent, + SWT.HORIZONTAL); + + // The right side contains tabbed panes for showing... + CTabFolder mainViewTabFolder = new CTabFolder( + mainViewSashForm, SWT.BOTTOM); + //... search tab + createSearchTabControl(mainViewTabFolder); + //... properties tab + createPropertiesTabControl(mainViewTabFolder); + + // Default selection for tab folder + mainViewTabFolder.setSelection(searchTab); + + + } catch (Exception e) { + e.printStackTrace(); + } + + } + + + /** + * Creates search tab. + * @param parentTabFolder Parent tab folder. + */ + private void createSearchTabControl(CTabFolder parentTabFolder) { + SashForm searchTabSashForm = new SashForm(parentTabFolder, SWT.VERTICAL); + searchTab = new CTabItem(parentTabFolder, SWT.NONE); + searchTab.setControl(searchTabSashForm); + searchTab.setText(Messages.getString("MainView.Search_Tab_Title")); //$NON-NLS-1$ + createSearchTabContents(searchTabSashForm); + } + + /** + * Creates search tab contents. This can be also delegated to a class of its own. + * @param parentComposite Parent composite. + */ + private void createSearchTabContents(Composite parentComposite) { + // Contents creation is delegated to an external class + searchTabContents = new SearchTabComposite(parentComposite); + } + + /** + * Creates properties tab. + * @param parentTabFolder Parent tab folder. + */ + private void createPropertiesTabControl(CTabFolder parentTabFolder) { + SashForm propertiesTabSashForm = new SashForm(parentTabFolder, SWT.VERTICAL); + propertiesTab = new CTabItem(parentTabFolder, SWT.NONE); + propertiesTab.setControl(propertiesTabSashForm); + propertiesTab.setText(Messages.getString("MainView.Properties_Tab_Title")); //$NON-NLS-1$ + createPropertiesTabContents(propertiesTabSashForm); + } + + /** + * Creates properties tab contents. + * @param parentComposite Parent composite. + */ + private void createPropertiesTabContents(Composite parentComposite) { + // Contents creation is delegated to an external class + propertiesTabContents = new PropertiesTabComposite(parentComposite); + } + + + /** + * Focus request should be passed to the view's primary control. + */ + public void setFocus() { + } + + /** + * Allows other classes to update content description. + * @param newContentDescription New description. + */ + public void updateDescription(String newContentDescription){ + setContentDescription(newContentDescription); + IToolBarManager tbManager = getViewSite().getActionBars().getToolBarManager(); + tbManager.update(true); + } + + /** + * The view should refresh all its UI components in this method. + */ + public void refresh(){ + } + + /** + * Sets enabled/disabled states for actions commands + * on this view, based on the current application state. + * This method should be called whenever an operation is + * started or stopped that migh have effect on action + * button states. + */ + public void updateActionButtonStates(){ + // Currently there is no states that should be set here + } + + /** + * Enables to get reference of the main view + * from the classes that do not actually + * have reference to the main view instance. + * This method opens activates/opens up the + * view if it was not visible. + * @throws PartInitException + */ + public static MainView getViewInstance() throws PartInitException{ + + IWorkbenchPage page = APIQueryPlugin.getCurrentlyActivePage(); + return getViewInstance(page); + + } + /** + * Enables to get reference of the main view + * from the classes that do not actually + * have reference to the main view instance. + * This method opens activates/opens up the + * view if it was not visible. + * @throws PartInitException + */ + public static MainView getViewInstance(IWorkbenchPage page) throws PartInitException{ + + boolean viewAlreadyVisible = false; + IViewPart viewPart = null; + + // Checking if view is already open + IViewReference[] viewRefs = page.getViewReferences(); + for (int i = 0; i < viewRefs.length; i++) { + IViewReference reference = viewRefs[i]; + String id = reference.getId(); + if(id.equalsIgnoreCase(MainView.ID)){ + viewAlreadyVisible = true; + // Found, restoring the view + viewPart = reference.getView(true); + page.activate(viewPart); + } + } + // View was not opened + if(! viewAlreadyVisible){ + viewPart = page.showView(MainView.ID); + } + return ((MainView) viewPart); + } + + /** + * Enables update request for the main view + * also from the classes that do not actually + * have reference to the main view instance. + */ + public static void update(){ + try { + + getViewInstance().inputUpdated(); + + } catch (PartInitException e) { + e.printStackTrace(); + } + } + + /** + * Enables the starting of API queries + * also from the classes that do not actually + * have reference to the main view instance. + * @param queryType Query type. + * @param queryString Query string. + * @param useExactMatch true if search string will be searched with exact match + * instead of contains. + * @throws QueryOperationFailedException + */ + public static void runAPIQueryFromExternalClass(int queryType, String queryString, boolean useExactMatch ) throws QueryOperationFailedException{ + try { + + MainView view = getViewInstance(); + view.runAPIQuery(queryType, queryString, useExactMatch); + + } catch (PartInitException e) { + e.printStackTrace(); + throw new QueryOperationFailedException(e.getMessage()); + } + } + + /** + * Enables the starting of API queries + * also from the classes that do not actually + * have reference to the main view instance. + * @param queryType Query type. + * @param queryString Query string. + * @return collection of APIShortDescription objects or empty list if not found any + * or null if MainView cannot found + */ + public static Collection runActiveProjectQueryFromExternalClass(int queryType, String queryString){ + try { + + MainView view = getViewInstance(); + return view.runActiveProjectQuery(queryType, queryString); + + } catch (PartInitException e) { + e.printStackTrace(); + } + return null; + } + + + /** + * Starts API query operation programmatically. + * @param queryType Query type. + * @param queryString Query string. + */ + private Collection runActiveProjectQuery(int queryType, String queryString){ + return searchTabContents.runActiveProjectQuery(queryType, queryString); + } + + + /** + * Starts API query operation programmatically. + * @param queryType Query type. + * @param queryString Query string. + * @param useExactMatch true if search string will be searched with exact match + * instead of contains. + */ + public void runAPIQuery(int queryType, String queryString, boolean useExactMatch){ + searchTabContents.runAPIQuery(queryType, queryString, useExactMatch); + } + + /** + * The view should refresh all its UI components in this method. + */ + private void inputUpdated() { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.WorkbenchPart#dispose() + */ + public void dispose() { + super.dispose(); + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "-- Dispose() --> " + getClass().getName()); //$NON-NLS-1$ + searchTabContents.dispose(); + propertiesTabContents.dispose(); + //Stopping APIQuery WebServer + APIQueryWebServerConfigurator.stopServer(); + + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/properties/PropertiesTabComposite.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/properties/PropertiesTabComposite.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,320 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.ui.views.main.properties; + +import org.eclipse.jface.viewers.ComboViewer; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Layout; +import org.eclipse.ui.PlatformUI; + +import com.nokia.s60tools.apiquery.APIQueryHelpContextIDs; +import com.nokia.s60tools.apiquery.settings.UserSettings; +import com.nokia.s60tools.apiquery.shared.preferences.APIQueryPreferences; +import com.nokia.s60tools.apiquery.shared.resources.Messages; +import com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension; +import com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtensionInfo; +import com.nokia.s60tools.apiquery.shared.searchmethod.ui.AbstractUiFractionComposite; +import com.nokia.s60tools.apiquery.shared.searchmethodregistry.SearchMethodExtensionRegistry; +import com.nokia.s60tools.util.debug.DbgUtility; + +public class PropertiesTabComposite extends AbstractUiFractionComposite { + + /** + * Amount of columns in the used grid layout. + */ + private final int COLUMN_COUNT = 1; + + private ComboViewer searchMethodsComboViewer; + private Group searchMethodSpecificUiFractionGroup; + private AbstractUiFractionComposite searchMethodSpecificUiComposite; + + private Button showDataSourceInResultsBtn; + + private static Object mutex = new Object(); + + private static int serachcount = 0; + + /** + * Constructor. + * @param parentComposite Parent composite for the created composite. + */ + public PropertiesTabComposite(Composite parentComposite) { + super(parentComposite); + } + + +public void enablePropTabComponents() { + + + synchronized (mutex) { + if((--serachcount)<=0)serachcount=0; + + if (serachcount == 0) { + Display.getDefault().syncExec(new Runnable() { + public void run() { + try { + if (!searchMethodsComboViewer.getControl().isEnabled()) + searchMethodsComboViewer.getControl().setEnabled( + true); + if (!searchMethodSpecificUiFractionGroup.isEnabled()) + searchMethodSpecificUiFractionGroup + .setEnabled(true); + if (!showDataSourceInResultsBtn.isEnabled()) + showDataSourceInResultsBtn.setEnabled(true); + }catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + } + + } + + public void disablePropTabComponents() { + + synchronized (mutex) { + serachcount++; + + Display.getDefault().syncExec(new Runnable() { + public void run() { + try{ + if (searchMethodsComboViewer.getControl().isEnabled()) + searchMethodsComboViewer.getControl().setEnabled(false); + if (searchMethodSpecificUiFractionGroup.isEnabled()) + searchMethodSpecificUiFractionGroup.setEnabled(false); + if (showDataSourceInResultsBtn.isEnabled()) + showDataSourceInResultsBtn.setEnabled(false); + }catch (Exception e) { + e.printStackTrace(); + // TODO: handle exception + } + + } + }); + + } + + } + + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.ui.views.main.AbstractTabComposite#createLayout() + */ + protected Layout createLayout() { + return new GridLayout(COLUMN_COUNT, false); + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.ui.views.main.AbstractTabComposite#createLayoutData() + */ + protected Object createLayoutData(){ + return new GridData(GridData.FILL_HORIZONTAL); + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.ui.views.main.AbstractTabComposite#createControls() + */ + protected void createControls() { + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "-- createControls() --> " + getClass().getName()); //$NON-NLS-1$ + + // Setting layout information + Composite tabContentsComposite = new Composite(this, SWT.NONE); + + final int cols = 1; + GridLayout gdl = new GridLayout(cols, false); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + tabContentsComposite.setLayout(gdl); + tabContentsComposite.setLayoutData(gd); + + // Creating controls + Label comboTitleLabel = new Label(tabContentsComposite, SWT.LEFT); + String searchMethodComboName = Messages.getString("PropertiesTabComposite.DataSource_Msg"); //$NON-NLS-1$ + comboTitleLabel.setText(searchMethodComboName + ":"); //$NON-NLS-1$ + searchMethodsComboViewer = new ComboViewer(tabContentsComposite, SWT.DROP_DOWN | SWT.READ_ONLY); + + // Declared as 'final' in order to be able to use in anonymous class using the data + final Combo cmb = searchMethodsComboViewer.getCombo(); + cmb.setText(searchMethodComboName); + cmb.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + SearchMethodExtensionRegistry reg = SearchMethodExtensionRegistry.getInstance(); + + int currentlySelectedMethodIndex = 0; + ISearchMethodExtensionInfo currSelInfo = UserSettings.getInstance().getCurrentlySelectedSearchMethodInfo(); + + for (ISearchMethodExtension ext : reg.getExtensions()) { + ISearchMethodExtensionInfo info = ext.getExtensionInfo(); + cmb.add(info.getDescription()); + if(info.hasEqualId(currSelInfo)){ + currentlySelectedMethodIndex = cmb.getItemCount()-1; + } + + } + cmb.select(currentlySelectedMethodIndex); + + //Add button + + String desc = Messages.getString("PropertiesTabComposite.ShowDataSourceInResults_Msg"); //$NON-NLS-1$ + showDataSourceInResultsBtn = new Button(tabContentsComposite, SWT.CHECK); + showDataSourceInResultsBtn.setText(desc); + boolean showDataSourceInResults = APIQueryPreferences.getShowDataSourceInResults(); + showDataSourceInResultsBtn.setSelection(showDataSourceInResults); + showDataSourceInResultsBtn.addSelectionListener(new ShowDataSourceInResultsSelectionListener()); + // Storing to Button array for later reference + + // Adding anonymous selection changed listener + // Possibly taken in future into its own class. + searchMethodsComboViewer.addSelectionChangedListener(new ISelectionChangedListener( + ){ + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) + */ + public void selectionChanged(SelectionChangedEvent event) { + int selIndx = cmb.getSelectionIndex(); + SearchMethodExtensionRegistry smeReg = SearchMethodExtensionRegistry.getInstance(); + ISearchMethodExtension ext = smeReg.getByDescription(cmb.getItem(selIndx)); + if(ext != null){ + UserSettings.getInstance().setCurrentlySelectedSearchMethodInfo(ext.getExtensionInfo()); + } + updateGroupControlContentsBasedOnTheCurrentSelection(); + } + + }); + + // Adding group that will be populated by the search method-specific extensions. + + searchMethodSpecificUiFractionGroup = new Group(this, SWT.SHADOW_NONE); + searchMethodSpecificUiFractionGroup.setText(getGroupDescriptionBasedOnTheCurrentSelection()); + GridLayout gdl2 = new GridLayout(cols, false); + GridData gd2 = new GridData(GridData.FILL_HORIZONTAL); + searchMethodSpecificUiFractionGroup.setLayout(gdl2); + searchMethodSpecificUiFractionGroup.setLayoutData(gd2); + + // Adding Search method-specific UI fraction. + searchMethodSpecificUiComposite = getSearchMethodSpecifiUIFraction(); + + setContextSensitiveHelpIDs(tabContentsComposite); + } + + + /** + * Class that listens button state changes and updates preferences and results composite + */ + private class ShowDataSourceInResultsSelectionListener implements SelectionListener{ + + public void widgetDefaultSelected(SelectionEvent e) { + } + + public void widgetSelected(SelectionEvent e) { + + //Setting selection preferences + APIQueryPreferences.setShowDataSourceInResults(showDataSourceInResultsBtn.getSelection()); + UserSettings.getInstance().settingsChanged(); + } + + } + + /** + * Set context sensitive help ids to components that can have focus + * @param cmb + */ + private void setContextSensitiveHelpIDs(Composite cmb) { + PlatformUI.getWorkbench().getHelpSystem().setHelp(cmb, + APIQueryHelpContextIDs.API_QUERY_HELP_PROPERTIES_TAB); + } + /** + * Resolves the group area description based on the current selection. + * @return Returns the group area description for the currently selected search method. + */ + private String getGroupDescriptionBasedOnTheCurrentSelection(){ + return getSearchMethodDescriptionBasedOnTheCurrentSelection() + "s"; //$NON-NLS-1$ + } + + /** + * Resolves the description for the current selection. + * @return Returns the descriptipn for the current selection. + */ + private String getSearchMethodDescriptionBasedOnTheCurrentSelection(){ + Combo cmb = searchMethodsComboViewer.getCombo(); + return cmb.getItem(cmb.getSelectionIndex()); + } + + /** + * Updates the contents of the group area based on the current selection. + */ + private void updateGroupControlContentsBasedOnTheCurrentSelection(){ + + // Updating UI description + searchMethodSpecificUiFractionGroup.setText(getGroupDescriptionBasedOnTheCurrentSelection()); + + // Disposing existing UI and re-creating search method specifiv UI fraction. + if(searchMethodSpecificUiComposite != null){ + searchMethodSpecificUiComposite.dispose(); + searchMethodSpecificUiComposite = getSearchMethodSpecifiUIFraction(); + searchMethodSpecificUiFractionGroup.layout(true); + int wHint = searchMethodSpecificUiComposite.getWidthHint(); + int hHint = searchMethodSpecificUiComposite.getHeightHint(); + Point size = searchMethodSpecificUiFractionGroup.computeSize(wHint, hHint); + searchMethodSpecificUiFractionGroup.setSize(size); + } + } + + /** + * Created UI fraction for the currently selected search method. + * @return UI fraction as AbstractUiFractionComposite. + */ + private AbstractUiFractionComposite getSearchMethodSpecifiUIFraction(){ + + String selectedExtDescription = getSearchMethodDescriptionBasedOnTheCurrentSelection(); + SearchMethodExtensionRegistry smeReg = SearchMethodExtensionRegistry.getInstance(); + ISearchMethodExtension selectedExtension = smeReg.getByDescription(selectedExtDescription); + + return selectedExtension.createExtensionConfigurationUi(searchMethodSpecificUiFractionGroup); + } + + + /* (non-Javadoc) + * @see org.eclipse.swt.widgets.Widget#dispose() + */ + public void dispose() { + super.dispose(); + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "-- Dispose() --> " + getClass().getName()); //$NON-NLS-1$ + + searchMethodsComboViewer.getCombo().dispose(); + searchMethodSpecificUiFractionGroup.dispose(); + searchMethodSpecificUiComposite.dispose(); + + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/search/APIDataTaskList.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/search/APIDataTaskList.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * + */ + +package com.nokia.s60tools.apiquery.ui.views.main.search; +import java.util.Vector; + +/** + * Class that plays the role of the domain model in the TableViewerExample + * In real life, this class would access a persistent store of some kind. + * + */ + +//Data Objects + +public class APIDataTaskList { + + private Vector tasks ; + public APIDataTaskList() { + super(); + tasks = new Vector(); + } + public void addTask(APITask task) + { + tasks.add(task); + } + + public Vector getTasks() { + return tasks; + } + + public void removeTaksList() + { + tasks = new Vector(); + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/search/APITask.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/search/APITask.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.ui.views.main.search; + +public class APITask { + + private String[] Columns = null; + + + + public APITask(String[] columnData) { + + super(); + Columns = columnData; + + } + + + public String getColumnData(int index) { + return Columns[index]; + } + + + + public void setColumnData(String string, int index) { + Columns[index] = string; + } + + + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/search/DataLabelProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/search/DataLabelProvider.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.ui.views.main.search; + + +import org.eclipse.jface.viewers.ITableLabelProvider; + +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; + + +/** + * Label provider for the TableViewerExample + * + * @see org.eclipse.jface.viewers.LabelProvider + */ +public class DataLabelProvider + extends LabelProvider + implements ITableLabelProvider { + + public String getColumnText(Object element, int columnIndex) { + APITask task = (APITask) element; + return task.getColumnData(columnIndex); + } + + public Image getColumnImage(Object element, int columnIndex) { + return null; + } + + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/search/DataSorter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/search/DataSorter.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.ui.views.main.search; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerSorter; +import org.eclipse.swt.SWT; + +/** + * Sorter for the results table viewer + */ +public class DataSorter extends ViewerSorter { + + private int columnNum; + private int sortDirection; + + public DataSorter(int dir, int criteria) { + this.sortDirection = dir; + this.columnNum = criteria; + } + + public int compare(Viewer viewer, Object o1, Object o2) { + + int returnValue = 0; + + String s1 = ((APITask)o1).getColumnData(columnNum); + String s2 = ((APITask)o2).getColumnData(columnNum); + + returnValue = s1.compareTo(s2); + + if(sortDirection == SWT.UP) + return returnValue; + else + return returnValue * -1; + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/search/IQueryDefCompositeListener.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/search/IQueryDefCompositeListener.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.ui.views.main.search; + +/** + * Defines interface for listening query action events + * from query search string definition UI composite. + */ +interface IQueryDefCompositeListener { + + /** + * Notifies listener that the query string has been modified. + * @param searchString Search string written by the user. + */ + public void queryModified(String searchString); + + /** + * Notifies listener that the query is started by the user. + * @param searchString Search string given by the user. + * @param useExactMatch true if search string will be searched with exact match + * instead of contains. + */ + public void queryStarted(String searchString, boolean useExactMatch); +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/search/IResultSettingsListener.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/search/IResultSettingsListener.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +package com.nokia.s60tools.apiquery.ui.views.main.search; + +/** + * Interface to pass Result view settings between mediator and composite classes + */ +public interface IResultSettingsListener { + + /** + * Call when result view setting is changed in UI from + * "Show only API names" to show results in query type centric way + * and vice versa. + */ + public void resultSettingsChanged(); + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/search/QueryDefComposite.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/search/QueryDefComposite.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,365 @@ +/* + * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * + */ + +package com.nokia.s60tools.apiquery.ui.views.main.search; + +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; + +import org.eclipse.jface.fieldassist.AutoCompleteField; +import org.eclipse.jface.fieldassist.TextContentAdapter; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Layout; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.PlatformUI; + +import com.nokia.s60tools.apiquery.APIQueryHelpContextIDs; +import com.nokia.s60tools.apiquery.shared.plugin.APIQueryPlugin; +import com.nokia.s60tools.apiquery.shared.resources.Messages; +import com.nokia.s60tools.apiquery.shared.searchmethod.ui.AbstractUiFractionComposite; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.util.debug.DbgUtility; + +/** + * UI composite that shows the search field and Search button in Search tab. + * + */ +class QueryDefComposite extends AbstractUiFractionComposite implements + SelectionListener, ModifyListener { + + /** + * Amount of columns in the used grid layout. + */ + private final int COLUMN_COUNT = 2; + + private static String CACHE_NAME = "Cache.txt"; + + /** + * Group giving common layout and containing controls- + */ + private Group searchStringDefinitionGroup; + + /** + * Search string entering field. + */ + private Text searchStringTxtField; + + /** + * Action button for starting the query. + */ + private Button runQueryBtn; + + /** + * + */ + private IQueryDefCompositeListener queryActionListener = null; + static DataOutputStream dos; + public static String cacheFileName = APIQueryPlugin.getPluginWorkspacePath() + File.separator + CACHE_NAME; + public static ArrayList wordsCaches = new ArrayList(); + public AutoCompleteField auto; + + + /** + * Constructor. + * + * @param parentComposite + * Parent composite for the created composite. + */ + public QueryDefComposite(Composite parentComposite) { + super(parentComposite); + } + + /* + * (non-Javadoc) + * + * @see + * com.nokia.s60tools.apiquery.ui.views.main.AbstractTabComposite#createLayout + * () + */ + protected Layout createLayout() { + return new GridLayout(COLUMN_COUNT, false); + } + + /* + * (non-Javadoc) + * + * @seecom.nokia.s60tools.apiquery.ui.views.main.AbstractTabComposite# + * createLayoutData() + */ + protected Object createLayoutData() { + return new GridData(GridData.FILL_HORIZONTAL); + } + + /** + * Set context sensitive help ids to components that can have focus + * + */ + private void setContextSensitiveHelpIds() { + try { + PlatformUI.getWorkbench().getHelpSystem().setHelp( + searchStringTxtField, + APIQueryHelpContextIDs.API_QUERY_HELP_SEARCH_TAB); + PlatformUI.getWorkbench().getHelpSystem().setHelp(runQueryBtn, + APIQueryHelpContextIDs.API_QUERY_HELP_SEARCH_TAB); + } catch (Exception e) { + e.printStackTrace(); + APIQueryConsole + .getInstance() + .println( + Messages + .getString("QueryDefComposite.Context_ErrMsg") + e, APIQueryConsole.MSG_ERROR); //$NON-NLS-1$ + } + } + + /* + * (non-Javadoc) + * + * @see + * com.nokia.s60tools.apiquery.ui.views.main.AbstractTabComposite#createControls + * () + */ + protected void createControls() { + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, + "-- createControls() --> " + getClass().getName()); //$NON-NLS-1$ + searchStringDefinitionGroup = new Group(this, SWT.SHADOW_NONE); + searchStringDefinitionGroup.setText(Messages + .getString("QueryDefComposite.SearchString_Msg")); //$NON-NLS-1$ + + GridLayout gdl2 = new GridLayout(COLUMN_COUNT, false); + GridData gd2 = new GridData(GridData.FILL_HORIZONTAL); + + searchStringDefinitionGroup.setLayout(gdl2); + searchStringDefinitionGroup.setLayoutData(gd2); + + final int textFieldStyleBits = SWT.LEFT | SWT.SINGLE | SWT.BACKGROUND + | SWT.BORDER; + searchStringTxtField = new Text(searchStringDefinitionGroup, + textFieldStyleBits); + searchStringTxtField.setLayoutData((new GridData( + GridData.FILL_HORIZONTAL))); + searchStringTxtField.setEditable(true); + searchStringTxtField.addModifyListener(this); + searchStringTxtField.addSelectionListener(this); + + runQueryBtn = new Button(searchStringDefinitionGroup, SWT.PUSH); + runQueryBtn.setText(Messages.getString("QueryDefComposite.Search_Msg")); //$NON-NLS-1$ + runQueryBtn.addSelectionListener(this); + + // Query enabled by default + enableQuery(); + + // if it really exists + if (!isFileExists(cacheFileName)) { + writeToFile(cacheFileName, " \n", false); + } else {// load the entries into the array list + fileToHashTable(cacheFileName, wordsCaches); + } + + auto = new AutoCompleteField(searchStringTxtField, new TextContentAdapter(), getKeys()); + + setContextSensitiveHelpIds(); + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse + * .swt.events.SelectionEvent) + */ + public void widgetDefaultSelected(SelectionEvent event) { + if (event.widget == searchStringTxtField) { + // widgetDefaultSelected is typically called + // when ENTER is pressed in a single-line text. + if (queryActionListener != null) { + queryActionListener.queryStarted(searchStringTxtField.getText(), false); + String value = searchStringTxtField.getText(); + putKey(value); + auto.setProposals(getKeys()); + } + } + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt + * .events.SelectionEvent) + */ + public void widgetSelected(SelectionEvent event) { + if (event.widget == runQueryBtn) { + if (queryActionListener != null) { + queryActionListener.queryStarted(searchStringTxtField.getText(), false); + String value = searchStringTxtField.getText(); + putKey(value); + auto.setProposals(getKeys()); + } + /*else if (event.widget == searchStringTxtField) { + // widgetDefaultSelected is typically called + // when ENTER is pressed in a single-line text. + if (queryActionListener != null) { + String value = searchStringTxtField.getText(); + queryActionListener.queryStarted( + searchStringTxtField.getText(), false); + putKey(wordsCaches, value, cacheFileName); + //auto.setProposals(getKeys(wordsCaches)); + } + }*/ + + } + } + + /** + * Adds listener that listens for query actions. + * + * @param queryActionListener + * Query action listener. + */ + public void setCompositeListener( + IQueryDefCompositeListener queryActionListener) { + this.queryActionListener = queryActionListener; + } + + /** + * Disables query button. + */ + public void disableQuery() { + runQueryBtn.setEnabled(false); + } + + /** + * Enables query button. + */ + public void enableQuery() { + runQueryBtn.setEnabled(true); + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events + * .ModifyEvent) + */ + public void modifyText(ModifyEvent arg0) { + if (queryActionListener != null) { + queryActionListener.queryModified(searchStringTxtField.getText()); + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.swt.widgets.Widget#dispose() + */ + public void dispose() { + super.dispose(); + DbgUtility.println(DbgUtility.PRIORITY_OPERATION,"-- Dispose() --> " + getClass().getName()); + searchStringDefinitionGroup.dispose(); + searchStringTxtField.dispose(); + runQueryBtn.dispose(); + } + + /** + * Sets the query string. + * + * @param queryString + * Query string to be set. + */ + public void setQueryString(String queryString) { + searchStringTxtField.setText(queryString); + } + + public boolean writeToFile(String fileName, String dataLine, boolean isAppendMode) { + + try { + File outFile = new File(fileName); + if (isAppendMode) { + dos = new DataOutputStream(new FileOutputStream(fileName, true)); + } else { + dos = new DataOutputStream(new FileOutputStream(outFile)); + } + + dos.writeBytes(dataLine); + dos.close(); + } catch (FileNotFoundException ex) { + return (false); + } catch (IOException ex) { + return (false); + } + return (true); + + } + + public boolean isFileExists(String fileName) { + File file = new File(fileName); + return file.exists(); + } + + public boolean deleteFile(String fileName) { + File file = new File(fileName); + return file.delete(); + } + + public void fileToHashTable(String fileName, ArrayList arr) { + String inputLine; + try { + File inFile = new File(fileName); + BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(inFile))); + while ((inputLine = br.readLine()) != null) { + if(wordsCaches.indexOf(inputLine.trim())==-1) + wordsCaches.add(inputLine.trim()); + } + br.close(); + } + catch (FileNotFoundException ex) { + ex.printStackTrace(); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + + // puts key to both file and hash table + public void putKey(String value) { + if (wordsCaches.contains(value)) + return; + wordsCaches.add(value.trim()); + writeToFile(cacheFileName, value.trim() + "\n", true); + } + + // readhashTableKeys + public String[] getKeys() { + return wordsCaches.toArray(new String[wordsCaches.size()]); + } +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/search/QueryResultsComposite.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/search/QueryResultsComposite.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,925 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.s60tools.apiquery.ui.views.main.search; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.browser.Browser; +import org.eclipse.swt.browser.LocationEvent; +import org.eclipse.swt.browser.LocationListener; +import org.eclipse.swt.custom.BusyIndicator; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Layout; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.ui.PlatformUI; + +import com.nokia.s60tools.apiquery.APIQueryHelpContextIDs; +import com.nokia.s60tools.apiquery.settings.UserSettings; +import com.nokia.s60tools.apiquery.shared.datatypes.APIDetailField; +import com.nokia.s60tools.apiquery.shared.datatypes.APIDetails; +import com.nokia.s60tools.apiquery.shared.datatypes.APIQueryParameters; +import com.nokia.s60tools.apiquery.shared.datatypes.APIShortDescription; +import com.nokia.s60tools.apiquery.shared.datatypes.QueryErrorInfo; +import com.nokia.s60tools.apiquery.shared.exceptions.QueryOperationFailedException; +import com.nokia.s60tools.apiquery.shared.plugin.APIQueryPlugin; +import com.nokia.s60tools.apiquery.shared.preferences.APIQueryPreferences; +import com.nokia.s60tools.apiquery.shared.resources.Messages; +import com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension; +import com.nokia.s60tools.apiquery.shared.searchmethod.ui.AbstractUiFractionComposite; +import com.nokia.s60tools.apiquery.shared.ui.dialogs.APIQueryMessageBox; +import com.nokia.s60tools.apiquery.shared.util.console.APIQueryConsole; +import com.nokia.s60tools.util.debug.DbgUtility; + + +/** + * UI composite containing controls that show the query results. + */ +class QueryResultsComposite extends AbstractUiFractionComposite { + + /** + * Amount of columns in the used grid layout. + */ + private final int COLUMN_COUNT = 1; + + /** + * Search results label text to be shown for user. + */ + private static final String SEARCH_RESULTS_LABEL_TEXT = Messages + .getString("QueryResultsComposite.SearchResults_Msg"); //$NON-NLS-1$ + + private static final String SEARCH_RESULTS_LABEL_API_TEXT = Messages + .getString("QueryResultsComposite.APIs_Msg"); //$NON-NLS-1$ + + /** + * Preferred size for the search result list control. Targeted currently to + * show 10 items without need for scrolling. + */ + private final int SEARCH_RESULT_FIELD_HEIGHT = 150; + + private TableViewer tableViewer; + + private APIDataTaskList taskList = null; + + // private APIShortDescription shortDescription = null; + + // + // Setting static data section for HTML data shown in the browser component + // + private final String HTML_DATA_BODY_STYLE = "body {margin-left: 0px;margin-right: 0px;margin-top: 0px;margin-bottom: 0px;}"; //$NON-NLS-1$ + + private final String HTML_DATA_TABLE_STYLE = "table{border-collapse: collapse; font-family: Tahoma; font-size: 11px}"; //$NON-NLS-1$ + + private final String HTML_DATA_STYLE = ""; //$NON-NLS-1$ //$NON-NLS-2$ + + private final String HTML_DATA_HEAD = "" + HTML_DATA_STYLE + ""; //$NON-NLS-1$ //$NON-NLS-2$ + + private final String HTML_DATA_HEADER = "" + HTML_DATA_HEAD + ""; //$NON-NLS-1$ //$NON-NLS-2$ + + private final String HTML_DATA_FOOTER = ""; //$NON-NLS-1$ + + private final String HTML_DATA_TABLE_START = ""; //$NON-NLS-1$ + + private final String HTML_DATA_TABLE_END = "
"; //$NON-NLS-1$ + + private final String EMPTY_HTML_DOC = HTML_DATA_HEADER + HTML_DATA_FOOTER; + + private static final String COMMA = ",";//$NON-NLS-1$ + + // boolean sourceNeeded = false; + // boolean onlyAPIInfo = false; + // int columns = 0; + + int apiIndex = -1; + + int otherFiledIndex = -1; + + int sourceIndex = -1; + + /** + * Listener for changing how the results is shown + */ + private IResultSettingsListener resultSettingsListener; + + /** + * List item for showing list of APIs + */ + // private List searchResultList; + /** + * Button to change how results are shown + */ + private Button showOnlyAPINamesBtn; + + /** + * Map that stores indexes for searchResults data by searchResultList name + * (matches UI text to {@link APIShortDescription} id). + */ + private Map searchResultIndexes; + + /** + * Label item to be updated with API count. + */ + Label searchResultsLabel; + + /** + * Summary data to be shown in the API list. + */ + private APIShortDescription[] searchResultData; + + /** + * Details data to be shown in browser control. + */ + private APIDetails details; + + static int TABLE_STYLE_BITS = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL + | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.RESIZE; + + /** + * Browser control for showing API details data. + */ + private Browser browserControl; + + private APIQueryParameters params; + + private Table table; + + + String[] src = { "API NAME", "SUBSYSTEM NAME", " DLL NAME", "LIB NAME", + "HEADER NAME", "CRPS KEY NAME", " ", "SOURCE" }; + + /** + * Constructor. + * + * @param parentComposite + * Parent composite for the created composite. + */ + public QueryResultsComposite(Composite parentComposite) { + super(parentComposite); + } + + /* + * (non-Javadoc) + * + * @see com.nokia.s60tools.apiquery.ui.views.main.AbstractTabComposite#createLayout() + */ + protected Layout createLayout() { + return new GridLayout(COLUMN_COUNT, false); + } + + /* + * (non-Javadoc) + * + * @see com.nokia.s60tools.apiquery.ui.views.main.AbstractTabComposite#createLayoutData() + */ + protected Object createLayoutData() { + return new GridData(GridData.FILL_BOTH); + } + + /** + * Set context sensitive help ids to components that can have focus + * + */ + private void setContextSensitiveHelpIds() { + + PlatformUI.getWorkbench().getHelpSystem().setHelp(showOnlyAPINamesBtn, + APIQueryHelpContextIDs.API_QUERY_HELP_SEARCH_TAB); + } + + private void createTableViewer() { + + tableViewer = new TableViewer(table); + tableViewer.setUseHashlookup(true); + + } + + private void createTable(Composite parent, int numberOfColumns, + String[] columnNames) { + + table = new Table(parent, TABLE_STYLE_BITS); + + GridData gridData = new GridData(GridData.FILL_HORIZONTAL); + gridData.heightHint = SEARCH_RESULT_FIELD_HEIGHT; + table.setLayoutData(gridData); + table.setLinesVisible(true); + table.setHeaderVisible(true); + + table.addSelectionListener(new SelectionListener() { + + public void widgetDefaultSelected(SelectionEvent arg0) { + } + + public void widgetSelected(SelectionEvent arg0) { + getAPIDetailsData(); + } + + }); + + int size = 150; + for (int i = 0; i < numberOfColumns; i++) { + TableColumn column = new TableColumn(table, SWT.LEFT, i); + column.setText(columnNames[i]); + column.setWidth(size); + size = size - 50; + final int j = i; + column.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event event) { + TableColumn sortedColumn = table.getSortColumn(); + TableColumn currentSelected = (TableColumn)event.widget; + + int dir = table.getSortDirection(); + if(sortedColumn == currentSelected){ + dir = dir == SWT.UP ? SWT.DOWN : SWT.UP; + } + else{ + table.setSortColumn(currentSelected); + dir = SWT.UP; + } + + if(currentSelected == table.getColumn(j)) + { + tableViewer.setSorter(new DataSorter(dir, j)); + } + + table.setSortDirection(dir); + + } + }); + + } + + } + + /* + * (non-Javadoc) + * + * @see com.nokia.s60tools.apiquery.ui.views.main.AbstractTabComposite#createControls() + */ + protected void createControls() { + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, + "-- createControls() --> " + getClass().getName()); //$NON-NLS-1$ + // + // Creating label and list for showing APIs found based on the query. + // + searchResultsLabel = new Label(this, SWT.HORIZONTAL | SWT.LEFT); + searchResultsLabel.setText(SEARCH_RESULTS_LABEL_TEXT + ":"); //$NON-NLS-1$ + + // final int listBoxStyleBits = SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL; + // searchResultList = new List(this, listBoxStyleBits); + createTable(this, 3, new String[] { " ", " ", " " }); + createTableViewer(); + + searchResultIndexes = new HashMap(); + GridData listData1 = new GridData(GridData.FILL_HORIZONTAL); + listData1.heightHint = SEARCH_RESULT_FIELD_HEIGHT; + + // + // Creating button to change how the results are shown + // + String desc = Messages + .getString("QueryResultsComposite.ShowOnlyAPINames_MSg"); //$NON-NLS-1$ "Show only API names"; + showOnlyAPINamesBtn = new Button(this, SWT.CHECK); + showOnlyAPINamesBtn.setText(desc); + + showOnlyAPINamesBtn.setSelection(APIQueryPreferences + .getShowOnlyAPINames()); + showOnlyAPINamesBtn + .addSelectionListener(new ShowOnlyAPINamesSelectionListener()); + + // + // Creating label and browser control for showing API details for the + // selected API. + // + Label apiDetailsLabel = new Label(this, SWT.HORIZONTAL | SWT.LEFT); + apiDetailsLabel.setText(Messages + .getString("QueryResultsComposite.APIDetails_MSg")); //$NON-NLS-1$ + + // Browser control does not seem to support SWT.BORDER style bit. + // Therefore need to add separate border component. + Composite browserBorder = new Composite(this, SWT.BORDER); + FillLayout borderLayout = new FillLayout(SWT.VERTICAL | SWT.HORIZONTAL); + browserBorder.setLayout(borderLayout); + browserBorder.setLayoutData(new GridData(GridData.FILL_BOTH)); + + // Adding browser control + browserControl = new Browser(browserBorder, SWT.NONE); + + browserControl.addLocationListener(new LocationListener() { + + public void changed(LocationEvent arg0) { + + } + + public void changing(LocationEvent arg0) { + + // //get the setting + final ISearchMethodExtension serachMethod = UserSettings + .getInstance().getCurrentlySelectedSearchMethod(); + + if (!arg0.location.contains("about:blank")) { + + arg0.doit = false; + final String headerName = arg0.location.substring(2, + arg0.location.length()).trim(); + String apidetailsName = "Name"; + if (serachMethod.isAsyncQueryPreferred()) + apidetailsName = "API Name"; + APIDetailField det = details.getDetail(apidetailsName); + + serachMethod.openHeaderFile(headerName, det.getValue() + .trim()); + + } + } + }); + + setContextSensitiveHelpIds(); + } + + /** + * Class that listens button state changes and updates preferences and + * results composite + */ + private class ShowOnlyAPINamesSelectionListener implements + SelectionListener { + + public void widgetDefaultSelected(SelectionEvent e) { + } + + public void widgetSelected(SelectionEvent e) { + + // Setting selection preferences + // APIQueryPreferences.setShowOnlyAPINames(showOnlyAPINamesBtn.getSelection()); + // Update view, do not get information again from data source, but + // just update data + resultSettingsListener.resultSettingsChanged(); + + } + + } + + /** + * Converts API details into html-data. + * + * @param details + * API details object to be converted. + * @return + */ + private String buildHtmlDataFromDetails(APIDetails details) { + StringBuffer htmlTextBuf = new StringBuffer(); + + htmlTextBuf.append(HTML_DATA_HEADER); + + // Appending table start + htmlTextBuf.append(HTML_DATA_TABLE_START); + + // Converting API details into html data + for (APIDetailField detailField : details) { + // System.out.println("datailValue" + detailField.getValue() + " + // getdesc" + detailField.getDescription()); + convertSingleDetailField(detailField, htmlTextBuf); + } + + // Appending table end + htmlTextBuf.append(HTML_DATA_TABLE_END); + htmlTextBuf.append(HTML_DATA_FOOTER); + + + return htmlTextBuf.toString(); + } + + /** + * @param field + * @param htmlTextBuf + */ + private void convertSingleDetailField(APIDetailField field, + StringBuffer htmlTextBuf) { + String desc = field.getDescription(); + String val = field.getValue(); + // System.out.println("values" +val); + + htmlTextBuf.append(""); //$NON-NLS-1$ + htmlTextBuf.append(desc); + htmlTextBuf.append(":"); //$NON-NLS-1$ + + boolean isSelectedSearchType = getIsSelectedSearchType(desc); + // String what user was set to be searched + String[] serachStrings = params.getSearchString().split(";"); + String searchString = params.getSearchString(); + // Checking if empty string was searched (empty search lists all) + boolean isEmptySearchString = false; + if (searchString == null || searchString.trim().equals("")) {//$NON-NLS-1$ + isEmptySearchString = true; + } + boolean isValueContainingSearchString = false; + + for (int i = 0; i < serachStrings.length; i++) { + String temp = serachStrings[i].trim(); + isValueContainingSearchString = isValueContainingSearchString(val, + temp); + if (isValueContainingSearchString) { + searchString = temp; + break; + } + } + + // get the setting + ISearchMethodExtension serachMethod = UserSettings.getInstance() + .getCurrentlySelectedSearchMethod(); + + // Checking search criteria and set matching search string as red when + // found + if (!isEmptySearchString && isSelectedSearchType + && isValueContainingSearchString) { + String[] vals = val.split(COMMA); + for (int i = 0; i < vals.length; i++) { + + if (vals[i].toLowerCase().indexOf(searchString.toLowerCase()) != -1) { + String s = "" + vals[i] + ""; + if (params.getQueryType() == APIQueryParameters.QUERY_BY_HEADER_NAME + && serachMethod.serachHeaderLinkEnable()) + s = "" + s + ""; + //System.out.println("link" + s); + htmlTextBuf.append(s);//$NON-NLS-1$ //$NON-NLS-2$ + } else { + htmlTextBuf.append(vals[i]); + } + if (i < (vals.length - 1)) { + htmlTextBuf.append(COMMA); + } + } + } else { + htmlTextBuf.append(val); + } + + htmlTextBuf.append(""); //$NON-NLS-1$ + + } + + /** + * Check if value contains search string (case in sensitive) + * + * @param val + * @param searchString + * @return true if val contains searchString, false + * othrewise. + */ + private boolean isValueContainingSearchString(String val, + String searchString) { + return val != null + && val.toLowerCase().contains(searchString.toLowerCase()); + } + + /** + * Check if given string is same as selected search type + * + * @param desc + * @return true if is, false otherwise. + */ + private boolean getIsSelectedSearchType(String desc) { + // UI name in API Details for selected search type + String searchTypeInReport = UserSettings.getInstance() + .getCurrentlySelectedSearchMethod() + .getAPIDetailNameInDetailsByQueryType(params.getQueryType()); + // Check if this value is same type as users search criteria + boolean isSelectedSearchType = searchTypeInReport + .equalsIgnoreCase(desc); + return isSelectedSearchType; + } + + /** + * Updates summary field with the queried data. If only one result was + * found, API Details for that API is shown. + * + * @param summaryDataColl + * API summary data to be shown. + */ + public void updateAPIShortDescriptionData( + Collection summaryDataColl, + APIQueryParameters params) { + + + // boolean sourceNeeded = false; + boolean onlyAPIInfo = false; + + apiIndex = -1; + otherFiledIndex = -1; + sourceIndex = -1; + + if (!params.isDetailsMentToAddToDescriptions() + || params.getQueryType() == APIQueryParameters.QUERY_BY_API_NAME) { + onlyAPIInfo = true; + } + + int columns = 1; + + if (!onlyAPIInfo) + ++columns; + + if (APIQueryPreferences.getShowDataSourceInResults()) + columns++; + + int[] indicies = new int[3]; + + indicies[2] = src.length - 2; + + if (columns == 3) { + indicies[0] = (params.getQueryType() - 1); + indicies[1] = 0; + indicies[2] = src.length - 1; + otherFiledIndex = 0; + apiIndex = 1; + sourceIndex = 2; + + } else if (columns == 2) { + if (APIQueryPreferences.getShowDataSourceInResults() && onlyAPIInfo) { + + indicies[0] = 0; + indicies[1] = src.length - 1; + + apiIndex = 0; + sourceIndex = 1; + } else { + indicies[0] = params.getQueryType() - 1; + indicies[1] = 0; + otherFiledIndex = 0; + apiIndex = 1; + } + + } + + else { + indicies[0] = 0; + indicies[1] = src.length - 2; + apiIndex = 0; + } + + + TableColumn[] tableColumns = table.getColumns(); + for (int i = 0; i < tableColumns.length; i++) { + tableColumns[i].setText(src[indicies[i]]); + + } + + // add the contents to table + + this.params = params; + // Clearing... + // searchResultList.removeAll(); + searchResultIndexes.clear(); + + // Storing the data + searchResultData = summaryDataColl.toArray(new APIShortDescription[0]); + taskList = new APIDataTaskList(); + + // Populating the list + for (int i = 0; i < searchResultData.length; i++) { + + APIShortDescription summary = searchResultData[i]; + String shortUIText = summary.getName(); + + // Checking if Data source should add to item + if (APIQueryPreferences.getShowDataSourceInResults()) { + + shortUIText += " [" + summary.getSourceDescription() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ + } + + // Checking from preferences should we show only API Names or also + // queried items + // if we want only API Names, just adding text to list. When API + // Name is search criteria, only API Names will be added anyway. + if (!params.isDetailsMentToAddToDescriptions() + || params.getQueryType() == APIQueryParameters.QUERY_BY_API_NAME) { + + taskList + .addTask(new APITask( + new String[] { + summary.getName(), + (APIQueryPreferences + .getShowDataSourceInResults()) ? summary + .getSourceDescription() + : " ", " " })); + + // searchResultList.add(shortUIText); //$NON-NLS-1$ + // //$NON-NLS-2$ + searchResultIndexes.put(shortUIText, new Integer(i)); + } + // If details for query type is ment to add for list, getting items + // that match for query + else { + String[] queriedMatchingItems = getQueriedMatchingItemNames( + summary, params.getSearchString()); + if (queriedMatchingItems != null) { + for (int j = 0; j < queriedMatchingItems.length; j++) { + taskList + .addTask(new APITask( + new String[] { + queriedMatchingItems[j], + summary.getName(), + (APIQueryPreferences + .getShowDataSourceInResults()) ? summary + .getSourceDescription() + : " " })); + String longUIText = "[" + queriedMatchingItems[j] + "] in " + shortUIText; //$NON-NLS-1$ //$NON-NLS-2$ + // searchResultList.add(longUIText); + searchResultIndexes.put(longUIText, new Integer(i)); + + } + } + }// else + } // if + + tableViewer.setContentProvider(new APIContentProvider()); + tableViewer.setLabelProvider(new DataLabelProvider()); + + // The input for the table viewer is the instance of ExampleTaskList + + tableViewer.setInput(taskList); + + searchResultsLabel.setText(SEARCH_RESULTS_LABEL_TEXT + + " (" + Messages.getString("QueryResultsComposite.Found_Msg") //$NON-NLS-1$ //$NON-NLS-2$ + + table.getItemCount() + " " //$NON-NLS-1$ + + SEARCH_RESULTS_LABEL_API_TEXT + "):"); //$NON-NLS-1$ + searchResultsLabel.pack(); // Adjusting the label size to match new + + // If we have only one result, that will be selected automatically + if (table.getItemCount() == 1) { + table.setSelection(0); + getAPIDetailsData(); + } + + // update the serachstring for the serached query + + } + + /** + * @param summary + * @param searchString + * @return list of + */ + private String[] getQueriedMatchingItemNames(APIShortDescription summary, + String searchString) { + + String[] ars = searchString.split(";"); + + ArrayList results = new ArrayList(); + if (UserSettings.getInstance().getCurrentlySelectedSearchMethod() + .isAsyncQueryPreferred()) { + + ArrayList data = summary.getSearchedData(); + for (int i = 0; i < data.size(); i++) { + for (int j = 0; j < ars.length; j++) { + if (data.get(i).toLowerCase().contains( + ars[j].trim().toLowerCase())) + results.add(data.get(i).trim()); + } + + } + return (String[]) results.toArray(new String[0]); + } + + // Details can be allreay stored to summary, if so, we don't need to get + // details again + APIDetails det = null; + if (summary.hasAPIDetails()) { + det = summary.getAPIDetails(); + } else { + try { + // Get currenty selected search method extension + // get api details + det = UserSettings.getInstance() + .getCurrentlySelectedSearchMethod().getAPIDetails( + summary); + } catch (QueryOperationFailedException e) { + APIQueryConsole + .getInstance() + .println( + Messages + .getString("QueryResultsComposite.UnableToGetAPIDetails_ErrMsg_Part1") + summary.getName() + Messages.getString("QueryResultsComposite.UnableToGetAPIDetails_ErrMsg_Part2") + e, APIQueryConsole.MSG_ERROR); //$NON-NLS-1$ //$NON-NLS-2$ + return null; + } + } + + // ArrayList results = new ArrayList(); + + // Converting API details into fields and checking matching items by API + // Query params + for (APIDetailField field : det) { + // Checking if there matching items + String desc = field.getDescription(); + String val = field.getValue(); + boolean isSelectedSearchType = getIsSelectedSearchType(desc); + if (isSelectedSearchType) { + String[] vals = val.split(COMMA); + for (int i = 0; i < vals.length; i++) { + for (int j = 0; j < ars.length; j++) { + boolean isValueContainingSearchString = isValueContainingSearchString( + vals[i], ars[j].trim()); + // Add matching item to results + if (isValueContainingSearchString) { + // System.out.println("values : "+ vals[i]); + results.add(vals[i].trim()); + } + } + } + } + + } + return (String[]) results.toArray(new String[0]); + + } + + /** + * Gets API details for the API selected from the API list. Shows busy + * cursor to user during the operation. + */ + private void getAPIDetailsData() { + + final QueryErrorInfo errInfo = new QueryErrorInfo(); + + Runnable performAPIDetailsQueryRunnable = new Runnable() { + public void run() { + performAPIDetailsQuery(errInfo); + } + }; + + // Showing busy cursor during operation + Display d = APIQueryPlugin.getCurrentlyActiveWbWindowShell() + .getDisplay(); + BusyIndicator.showWhile(d, performAPIDetailsQueryRunnable); + + // Did we succeed? + if (details != null) { + // Populating browser control with the HTML formatted data. + browserControl.setText(buildHtmlDataFromDetails(details)); + } else { + // Something failed + String errMsg = Messages + .getString("QueryResultsComposite.APIDetailsQueryFailde_ErrMsg") + errInfo.getErrorDescription(); //$NON-NLS-1$ + APIQueryConsole.getInstance().println(errMsg, + APIQueryConsole.MSG_ERROR); + APIQueryMessageBox mbox = new APIQueryMessageBox(errMsg, + SWT.ICON_ERROR | SWT.OK); + mbox.open(); + } + } + + /** + * Performs the actual API details query. + * + * @param errInfo + * Error info to be filled in error situation. + */ + private void performAPIDetailsQuery(QueryErrorInfo errInfo) { + + // details = null; // Resetting previous searches + // check if the details already in localstorage + // int currSelIndex = searchResultList.getSelectionIndex(); + + // details=(APIDetails)apiDetailsStorage.elementAt(currSelIndex); + // if(details!=null)return; + + // Table data + + TableItem[] ar = table.getSelection(); + String shortUIText = ar[0].getText(apiIndex).trim(); + if (sourceIndex != -1) + shortUIText += " [" + ar[0].getText(sourceIndex).trim() + "]"; + if (otherFiledIndex != -1) + shortUIText = "[" + ar[0].getText(0).trim() + "] in " + shortUIText; + + // ////// + + // String s = searchResultList.getItems()[currSelIndex]; + // System.out.println("Text in secrh res infices : " + s); + // Not getting ID from list directly, because same API can be there + // multiple times, ID is taken from indexes list + // int currShortDescIndex = searchResultIndexes.get(searchResultList + // .getItems()[currSelIndex]); + + int currShortDescIndex = searchResultIndexes.get(shortUIText); + + APIShortDescription summary = searchResultData[currShortDescIndex]; + // shortDescription = summary; + + // API Details can be already stored in summary, if so, we don't need + // get details again + if (summary.hasAPIDetails()) { + details = summary.getAPIDetails(); + } + // Else get api details by using selected search method extension + else { + ISearchMethodExtension currSelExt = UserSettings.getInstance() + .getCurrentlySelectedSearchMethod(); + try { + details = currSelExt.getAPIDetails(summary); + summary.setAPIDetails(details); + } catch (QueryOperationFailedException e) { + errInfo.setErrorDescription(e.getMessage()); + } + } + + } + + /** + * Clears all the previously shown data. + */ + public void clear() { + // Clearing summary data + // searchResultList.removeAll(); + table.removeAll(); + // taskList.removeTaksList(); + // tableViewer.setInput(taskList); + // Clearing found APIs count + searchResultsLabel.setText(SEARCH_RESULTS_LABEL_TEXT + ":"); //$NON-NLS-1$ + // Clearing details data + browserControl.setText(EMPTY_HTML_DOC); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.swt.widgets.Widget#dispose() + */ + public void dispose() { + super.dispose(); + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, + "-- Dispose() --> " + getClass().getName()); //$NON-NLS-1$ + } + + /** + * Check if show only api names is selected + * + * @return true if Show only API names is selected + * false otherwise. + */ + public boolean isShowOnlyAPINamesSelected() { + return showOnlyAPINamesBtn.getSelection(); + } + + /** + * Adds listener that listens for result setting changes. + * + * @param searchTabUIFieldsMediator + * Result settings changes listener + */ + public void setResultSettingsListener( + IResultSettingsListener resultSettingsListener) { + this.resultSettingsListener = resultSettingsListener; + } + + /** + * InnerClass that acts as a proxy for the ExampleTaskList providing content + * for the Table. It implements the ITaskListViewer interface since it must + * register changeListeners with the ExampleTaskList + */ + class APIContentProvider implements IStructuredContentProvider { + + public void inputChanged(Viewer v, Object oldInput, Object newInput) { + + } + + public void dispose() { + + } + + // Return the tasks as an array of Objects + public Object[] getElements(Object parent) { + return taskList.getTasks().toArray(); + } + + } + +} diff -r 000000000000 -r a02c979e8dfd srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/search/QueryTypeSelectionComposite.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/apiquerytool/com.nokia.s60tools.apiquery/src/com/nokia/s60tools/apiquery/ui/views/main/search/QueryTypeSelectionComposite.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,237 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.apiquery.ui.views.main.search; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Layout; +import org.eclipse.ui.PlatformUI; + +import com.nokia.s60tools.apiquery.APIQueryHelpContextIDs; +import com.nokia.s60tools.apiquery.settings.IUserSettingsListener; +import com.nokia.s60tools.apiquery.settings.UserSettings; +import com.nokia.s60tools.apiquery.shared.datatypes.APIQueryParameters; +import com.nokia.s60tools.apiquery.shared.resources.Messages; +import com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension; +import com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtensionInfo; +import com.nokia.s60tools.apiquery.shared.searchmethod.ui.AbstractUiFractionComposite; +import com.nokia.s60tools.apiquery.shared.searchmethodregistry.SearchMethodExtensionRegistry; +import com.nokia.s60tools.util.debug.DbgUtility; + +/** + * UI composite that shows the search type selections in Search tab. + * + */ +class QueryTypeSelectionComposite extends AbstractUiFractionComposite implements IUserSettingsListener{ + + /** + * Amount of columns in the used grid layout. + */ + private final int COLUMN_COUNT = 3; + private Group queryTypeSelectionGroup; + private Map queryTypeBtnMap; + + /** + * Constructor. + * @param parentComposite Parent composite for the created composite. + */ + public QueryTypeSelectionComposite(Composite parentComposite) { + super(parentComposite); + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.ui.views.main.AbstractTabComposite#createLayout() + */ + protected Layout createLayout() { + return new GridLayout(COLUMN_COUNT, false); + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.ui.views.main.AbstractTabComposite#createLayoutData() + */ + protected Object createLayoutData(){ + return new GridData(GridData.FILL_HORIZONTAL); + } + + /** + * Set context sensitive help ids to components that can have focus + * + */ + private void setContextSensitiveHelpIds(Button btn){ + PlatformUI.getWorkbench().getHelpSystem().setHelp(btn, + APIQueryHelpContextIDs.API_QUERY_HELP_SEARCH_TAB); + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.ui.views.main.AbstractTabComposite#createControls() + */ + protected void createControls() { + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "-- createControls() --> " + getClass().getName()); //$NON-NLS-1$ + + queryTypeSelectionGroup = new Group(this, SWT.SHADOW_NONE); + queryTypeSelectionGroup.setText(Messages.getString("QueryTypeSelectionComposite.Query_By_Msg")); //$NON-NLS-1$ + + GridLayout gdl2 = new GridLayout(COLUMN_COUNT, false); + GridData gd2 = new GridData(GridData.FILL_HORIZONTAL); + + queryTypeSelectionGroup.setLayout(gdl2); + queryTypeSelectionGroup.setLayoutData(gd2); + + // Adding different query types + Integer[] queryTypesArr = APIQueryParameters.getQueryTypes(); + int queryTypeCnt = queryTypesArr.length; + + // Query buttons are store into an internal array for later reference + queryTypeBtnMap = new HashMap(queryTypeCnt); + + for (Integer queryType : queryTypesArr) { + String desc = APIQueryParameters.getDescriptionForQueryType(queryType); + Button queryBtn = new Button(queryTypeSelectionGroup, SWT.RADIO); + queryBtn.setText(desc); + queryBtn.setSelection(false); + // Storing to Button array for later reference + queryTypeBtnMap.put(queryType, queryBtn); + setContextSensitiveHelpIds(queryBtn); + } + + // Checking the statuses supported query types for currently + // selected search method. + checkSupportedQueryTypesAndUpdateUi(); + + // Starting to listen user settings change events + UserSettings.getInstance().addUserSettingListener(this); + } + + /** + * Checks the statuses of currently supported query types and updates UI. + */ + private void checkSupportedQueryTypesAndUpdateUi() { + try { + // Setting enable and disable statuses for query types + ISearchMethodExtensionInfo currSelExtInfo = UserSettings.getInstance().getCurrentlySelectedSearchMethodInfo(); + String id = currSelExtInfo.getId(); + ISearchMethodExtension currSelExt = SearchMethodExtensionRegistry.getInstance().getById(id); + + Set queryTypesSet = queryTypeBtnMap.keySet(); + for (Integer qType : queryTypesSet) { + Button btn = queryTypeBtnMap.get(qType); + boolean isSupported = currSelExt.isSupportedQueryType(qType); + btn.setSelection(false); + btn.setEnabled(isSupported); + } + + // Setting default query type that should be supported by all extensions. + // and therefore is always enabled and set as default selection. + // It is on the responsibility of extension developer to make + // sure that the default query type is supported. + int defaultQueryType = APIQueryParameters.getDefaultQueryType(); + Button defQueryTypeBtn = queryTypeBtnMap.get(defaultQueryType); + defQueryTypeBtn.setEnabled(true); + defQueryTypeBtn.setSelection(true); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Gets query type for the currently selected query type. + * @return Returns query type for the currently selected query type. + */ + public int getSelectedQueryType(){ + Set queryTypeSet = queryTypeBtnMap.keySet(); + for (Integer queryType : queryTypeSet) { + Button btn = queryTypeBtnMap.get(queryType); + if(btn.getSelection()){ + // This query type was selected + return queryType; + } + } + // We should never get into here + throw new RuntimeException(Messages.getString("QueryTypeSelectionComposite.Query_Type_Was_Not_Selected_Msg")); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see com.nokia.s60tools.apiquery.settings.IUserSettingsListener#userSettingsChanged() + */ + public void userSettingsChanged() { + // Settings have changed which might mean that + // the user has changed the currently used query type. + checkSupportedQueryTypesAndUpdateUi(); + } + + /* (non-Javadoc) + * @see org.eclipse.swt.widgets.Widget#dispose() + */ + public void dispose(){ + super.dispose(); + DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "-- Dispose() --> " + getClass().getName()); //$NON-NLS-1$ + queryTypeSelectionGroup.dispose(); + Collection