srcanaapps/depexplorer/com.nokia.s60tools.appdep/src/com/nokia/s60tools/appdep/ui/actions/AbstractShowSourceFileAction.java
author noe\swadi
Sat, 09 Jan 2010 10:04:11 +0530
changeset 0 a02c979e8dfd
permissions -rw-r--r--
1. Copyrights changed to EPL 2. Feature updates mentioned in release notes.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
     1
/*
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
     2
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
     3
* All rights reserved.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
     4
* This component and the accompanying materials are made available
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
     6
* which accompanies this distribution, and is available
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
     8
*
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
     9
* Initial Contributors:
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    11
*
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    12
* Contributors:
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    13
*
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    14
* Description:
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    15
*
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    16
*/
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    17
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    18
 
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    19
package com.nokia.s60tools.appdep.ui.actions;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    20
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    21
import java.io.File;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    22
import java.io.IOException;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    23
import java.net.URI;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    24
import java.net.URISyntaxException;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    25
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    26
import org.eclipse.core.resources.IWorkspace;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    27
import org.eclipse.core.resources.IWorkspaceRunnable;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    28
import org.eclipse.core.resources.ResourcesPlugin;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    29
import org.eclipse.core.runtime.CoreException;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    30
import org.eclipse.core.runtime.IProgressMonitor;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    31
import org.eclipse.core.runtime.IStatus;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    32
import org.eclipse.core.runtime.Status;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    33
import org.eclipse.jface.text.IDocument;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    34
import org.eclipse.swt.SWT;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    35
import org.eclipse.ui.IEditorDescriptor;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    36
import org.eclipse.ui.IEditorPart;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    37
import org.eclipse.ui.IEditorRegistry;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    38
import org.eclipse.ui.IWorkbenchPage;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    39
import org.eclipse.ui.PartInitException;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    40
import org.eclipse.ui.PlatformUI;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    41
import org.eclipse.ui.editors.text.TextEditor;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    42
import org.eclipse.ui.editors.text.TextFileDocumentProvider;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    43
import org.eclipse.ui.ide.IDE;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    44
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    45
import com.nokia.s60tools.appdep.core.AppDepSettings;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    46
import com.nokia.s60tools.appdep.core.ITargetPlatform;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    47
import com.nokia.s60tools.appdep.core.data.ComponentNode;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    48
import com.nokia.s60tools.appdep.exceptions.CacheFileDoesNotExistException;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    49
import com.nokia.s60tools.appdep.exceptions.CacheIndexNotReadyException;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    50
import com.nokia.s60tools.appdep.resources.Messages;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    51
import com.nokia.s60tools.appdep.ui.dialogs.AppDepMessageBox;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    52
import com.nokia.s60tools.appdep.ui.views.main.MainView;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    53
import com.nokia.s60tools.appdep.ui.views.main.MainViewDataPopulator;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    54
import com.nokia.s60tools.appdep.util.AppDepConsole;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    55
import com.nokia.s60tools.sdk.SdkInformation;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    56
import com.nokia.s60tools.util.sourcecode.ISourceFinder;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    57
import com.nokia.s60tools.util.sourcecode.SourceFileLocation;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    58
import com.nokia.s60tools.util.sourcecode.SourceFinderFactory;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    59
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    60
/**
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    61
 * Real implementation for show source action.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    62
 */
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    63
public abstract class AbstractShowSourceFileAction extends AbstractMainViewAction{
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    64
	
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    65
	/**
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    66
	 * Build variant used for source file search (=target Platform used).
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    67
	 */
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    68
	protected String variant;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    69
	/**
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    70
	 * SDK used for source file search.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    71
	 */
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    72
	protected SdkInformation sdkInfo;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    73
	/**
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    74
	 * Set to <code>true</code> if current target selection contains SIS file targets.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    75
	 */
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    76
	protected boolean showSISfileWarningDialog = false;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    77
	/**
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    78
	 * EPOCROOT used for source file search.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    79
	 */
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    80
	protected String epocRootPath;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    81
	/**
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    82
	 * Build type used for source file search.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    83
	 */
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    84
	protected String build;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    85
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    86
	/**
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    87
	 * Constructor.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    88
	 * @param view Reference to the view.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    89
	 */
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    90
	public AbstractShowSourceFileAction(MainView view){
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    91
		super(view);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    92
		
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    93
		setText(Messages.getString("ShowSourceFileMainViewAction.ShowSource_Action_Text")); //$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    94
		setToolTipText(Messages.getString("ShowSourceFileMainViewAction.ShowSource_Action_Tooltip")); //$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    95
	
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    96
	}
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    97
	
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    98
	/**
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
    99
	 * Real run method implementation for run() method.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   100
	 * @see com.nokia.s60tools.appdep.ui.actions.AbstractMainViewAction#run()
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   101
	 * @param methodName method name from user selection
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   102
	 * @param ordinal from user selection
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   103
	 */
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   104
	protected void runImpl(String methodName,
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   105
	String ordinal) {
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   106
		Object obj = view.getComponentTreeSelectedElement();
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   107
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   108
		if (obj == null) {
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   109
			// We might get null-selections when
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   110
			// tree is expanded/collapsed.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   111
			// Getting component node that is cached.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   112
			obj = view.getMostRecentlySelectedComponentNode();
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   113
			if(obj == null){
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   114
				return;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   115
			}
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   116
		}
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   117
		try {
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   118
			// Component is for sure a component node
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   119
			ComponentNode node = (ComponentNode) obj;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   120
			String componentName = node.getName();
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   121
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   122
			AppDepSettings settings = AppDepSettings.getActiveSettings();
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   123
			if (settings.getCurrentlyAnalyzedComponentName() != null) {
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   124
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   125
				AppDepConsole.getInstance().println(
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   126
						Messages.getString("ShowSourceFileMainViewAction.ShowSource_Query_Start_Console_Msg_Part1") //$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   127
										+ componentName//$NON-NLS-1$ 
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   128
										+Messages.getString("ShowSourceFileMainViewAction.ShowSource_Query_Start_Console_Msg_Part2") //$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   129
										+ ordinal//$NON-NLS-1$										
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   130
										+ "'..."); //$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   131
				
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   132
				// Collection needed information to get source file path
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   133
				ISourceFinder finder = SourceFinderFactory
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   134
						.createSourceFinder(AppDepConsole.getInstance());
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   135
				
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   136
				// Resolving source search parameters based on the settings and component name
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   137
				resolveSearchParameters(componentName, settings);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   138
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   139
				//Search source file location by collected information
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   140
				SourceFileLocation location = finder.findSourceFile(ordinal,
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   141
						methodName, componentName, variant, build, epocRootPath);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   142
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   143
				if(location.getSourceFileLocation() == null){
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   144
					
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   145
					String msg = Messages.getString("ShowSourceFileMainViewAction.SourceFileCannotBeFound_Msg_Part1") //$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   146
						+ componentName//$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   147
						+Messages.getString("ShowSourceFileMainViewAction.SourceFileCannotBeFound_Msg_Part2") //$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   148
						+ ordinal//$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   149
						+Messages.getString("ShowSourceFileMainViewAction.SourceFileCannotBeFound_Msg_Part3") //$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   150
						+ methodName//$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   151
						+"'";//$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   152
					
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   153
					AppDepConsole.getInstance().println(msg, AppDepConsole.MSG_WARNING); 
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   154
					
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   155
					showErrorMsgDialog(msg);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   156
					
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   157
				}else{
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   158
					//Open found file, and set focus to method line
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   159
					openFileAndSetFocus(location);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   160
				}
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   161
				
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   162
				//If SIS file is in analysis, showing on information dialog, that opened suorce file is not neccessarily same than used when SIS was build.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   163
				if(showSISfileWarningDialog ){
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   164
					AppDepMessageBox msgBox = new AppDepMessageBox(
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   165
							Messages.getString("ShowSourceFileMainViewAction.SourceFileOpenedFromSISFile_Info_Msg"),  //$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   166
							SWT.ICON_INFORMATION | SWT.OK);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   167
					msgBox.open();						
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   168
				}
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   169
				
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   170
			}
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   171
		} catch (Exception e) {
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   172
			e.printStackTrace();
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   173
			String msg = Messages.getString("ShowSourceFileMainViewAction.SourceFileCannotBeFound_ErrMsg") //$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   174
			+" "//$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   175
			+ e;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   176
			AppDepConsole.getInstance().println(
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   177
					msg,  //$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   178
					AppDepConsole.MSG_ERROR);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   179
			showErrorMsgDialog(Messages.getString("ShowSourceFileMainViewAction.SourceFileCannotBeFound_ErrMsg_ToUser"));//$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   180
			
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   181
		}		
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   182
		// Remember to always call AbstractMainViewAction
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   183
		// base class implementation
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   184
		super.run();
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   185
	}
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   186
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   187
	/**
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   188
	 * Resolves source search parameters based on the settings and component name
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   189
	 * @param componentName Component name.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   190
	 * @param settings Used settings.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   191
	 * @throws IOException
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   192
	 * @throws CacheIndexNotReadyException
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   193
	 * @throws CacheFileDoesNotExistException
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   194
	 */
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   195
	protected void resolveSearchParameters(String componentName,
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   196
			AppDepSettings settings) throws IOException,
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   197
			CacheIndexNotReadyException, CacheFileDoesNotExistException {
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   198
		sdkInfo = settings.getCurrentlyUsedSdk();
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   199
		epocRootPath = sdkInfo.getEpocRootDir();
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   200
		build = settings.getBuildType().getBuildTypeName();
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   201
		
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   202
		variant = MainViewDataPopulator.getTargetPlatformIdStringForComponent(settings, componentName);		
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   203
		
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   204
		showSISfileWarningDialog = includesSISFileTarget(settings);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   205
	}
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   206
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   207
	/**
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   208
	 * Checks if target platform array includes a SIS file target.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   209
	 * @param settings settings object to be used for getting target platform data
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   210
	 * @return <code>true</code> if includes a SIS file target, otherwise <code>false</code>.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   211
	 */
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   212
	private boolean includesSISFileTarget(AppDepSettings settings) {
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   213
		ITargetPlatform[] usedPlatforms = settings.getCurrentlyUsedTargetPlatforms();
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   214
		for (int i = 0; i < usedPlatforms.length; i++) {
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   215
			ITargetPlatform platform = usedPlatforms[i];
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   216
			if(platform.getId().equals(AppDepSettings.TARGET_TYPE_ID_SIS)){
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   217
				return true;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   218
			}
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   219
		}
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   220
		return false;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   221
	}
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   222
	
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   223
	/**
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   224
	 * Show on error message
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   225
	 * @param msg Error message.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   226
	 */
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   227
	protected void showErrorMsgDialog(String msg){
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   228
		AppDepMessageBox msgBox = new AppDepMessageBox(msg, SWT.ICON_ERROR | SWT.OK);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   229
		msgBox.open();			
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   230
	}
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   231
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   232
	/**
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   233
	 * OpensFile in editor
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   234
	 * @param location Source file location
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   235
	 * @throws URISyntaxException
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   236
	 * @throws CoreException
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   237
	 */
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   238
	private void openFileAndSetFocus(final SourceFileLocation location) throws URISyntaxException, CoreException {
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   239
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   240
		AppDepConsole.getInstance().println(
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   241
				Messages.getString("ShowSourceFileMainViewAction.OpeningFile_Msg") //$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   242
					+ location.getSourceFileLocation() //$NON-NLS-1$)					
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   243
					+ "'"); //$NON-NLS-1$)
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   244
		
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   245
		File file = new File(location.getSourceFileLocation());
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   246
		if(file == null || !file.exists()){
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   247
			AppDepConsole.getInstance().println(
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   248
					Messages.getString("ShowSourceFileMainViewAction.SourceFileDoesNotExist_ErrMsg_Part1") //$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   249
						+ location.getSourceFileLocation() 
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   250
						+Messages.getString("ShowSourceFileMainViewAction.SourceFileDoesNotExist_ErrMsg_Part2"), AppDepConsole.MSG_ERROR); //$NON-NLS-1$)
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   251
			return;			
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   252
		}
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   253
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   254
		//Create URI to open file
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   255
		String uriStr = location.getSourceFileLocation().replace("\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   256
		uriStr = "file://" + uriStr; //$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   257
		final URI srcURI = new URI(uriStr);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   258
		
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   259
		//Find default editor for that file
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   260
		IEditorRegistry reg = PlatformUI.getWorkbench().getEditorRegistry();
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   261
		
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   262
		
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   263
		IEditorDescriptor editor = reg.getDefaultEditor(file.getName());
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   264
		//We open editor by it's ID
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   265
		final String editorId = editor.getId();
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   266
					
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   267
		
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   268
		//Runnable to open new file
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   269
		final IWorkspaceRunnable runOpen = new IWorkspaceRunnable() {
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   270
			public void run(IProgressMonitor monitor) throws CoreException {
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   271
				// do the actual work in here
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   272
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   273
				IWorkbenchPage page = PlatformUI.getWorkbench()
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   274
						.getActiveWorkbenchWindow().getActivePage();
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   275
				try {
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   276
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   277
					IEditorPart part = IDE.openEditor(page, srcURI, editorId, true);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   278
					
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   279
					if(part != null){
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   280
						//Set focus to correct line
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   281
						 setFocusToLineWhereMethodIs(location);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   282
					}
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   283
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   284
				} catch (PartInitException e) {
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   285
					e.printStackTrace();
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   286
					Status status = new Status(IStatus.ERROR,
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   287
							"com.nokia.s60tools.metadataeditor", 0, e //$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   288
									.getMessage(), e);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   289
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   290
					throw new CoreException(status);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   291
				} 
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   292
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   293
			}
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   294
		};		
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   295
		ResourcesPlugin.getWorkspace().run(runOpen, null, IWorkspace.AVOID_UPDATE, null);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   296
		
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   297
	}
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   298
	
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   299
	/**
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   300
	 * Setting the focus in opened file there where the method name occurs,
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   301
	 * must call after file is opened and only if opening was successful
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   302
	 * @param location Source file location
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   303
	 * @throws CoreException
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   304
	 */
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   305
	protected void setFocusToLineWhereMethodIs(
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   306
			final SourceFileLocation location) throws CoreException {
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   307
		//Runnable to open new file
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   308
		final IWorkspaceRunnable runSetFocus = new IWorkspaceRunnable() {
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   309
			public void run(IProgressMonitor monitor) throws CoreException {
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   310
				// do the actual work in here
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   311
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   312
				try {
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   313
					//Setting focus to correct line
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   314
					IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   315
					IEditorPart activeEditor = activePage.getActiveEditor();
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   316
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   317
					if(activeEditor != null && activeEditor instanceof TextEditor){
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   318
						
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   319
						// This is actually an instance of 'org.eclipse.cdt.internal.ui.editor.CEditor' 
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   320
						// that extends org.eclipse.ui.editors.text.TextEditor
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   321
						TextEditor editor = (TextEditor) activeEditor;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   322
						IDocument doc =  getDocument(editor);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   323
						if(doc != null){
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   324
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   325
							String text = doc.get();
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   326
							int methodOffset = location.getMethodOffset();
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   327
							if(methodOffset == SourceFileLocation.OFFSET_NOT_FOUND){
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   328
								// Removing parameters and getting new offset.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   329
								String methodNameWithOutParams = location.getMethodName();
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   330
								methodNameWithOutParams = methodNameWithOutParams.substring(0, methodNameWithOutParams.indexOf("(")); //$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   331
								methodOffset = text.indexOf(methodNameWithOutParams);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   332
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   333
								if(methodOffset == SourceFileLocation.OFFSET_NOT_FOUND){
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   334
									// Removing possible namespace and getting new offset.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   335
									String separator = "::"; //$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   336
									int separatorLocation = methodNameWithOutParams.lastIndexOf(separator);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   337
									if(separatorLocation > 0){
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   338
										methodNameWithOutParams = methodNameWithOutParams.substring(separatorLocation + separator.length());
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   339
										methodOffset = text.indexOf(methodNameWithOutParams);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   340
									}
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   341
								}
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   342
							}
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   343
							
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   344
							editor.setHighlightRange(methodOffset, 0, true);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   345
						}							
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   346
					}					
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   347
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   348
				} catch (Exception e) {
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   349
					e.printStackTrace();
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   350
					Status status = new Status(IStatus.ERROR,
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   351
							Messages.getString("ShowSourceFileActionGeneralMessage.OpenFileAndSetLineFocus_ErrMsg"), 0, e //$NON-NLS-1$
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   352
									.getMessage(), e);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   353
					throw new CoreException(status);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   354
				} 
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   355
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   356
			}
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   357
		};
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   358
		
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   359
		
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   360
		ResourcesPlugin.getWorkspace().run(runSetFocus, null, IWorkspace.AVOID_UPDATE, null);
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   361
	}
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   362
	
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   363
	/**
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   364
	 * Returns the document interface for the currently active document 
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   365
	 * in the given editor.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   366
	 * @param editor Editor to ask currently active document from. 
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   367
	 * @return Document interface if found, otherwise <code>null</code>.
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   368
	 */
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   369
	private IDocument getDocument(TextEditor editor) {
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   370
		
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   371
		TextFileDocumentProvider  documentProvider = (TextFileDocumentProvider) editor.getDocumentProvider();
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   372
		if(documentProvider != null){
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   373
			return  documentProvider.getDocument(editor.getEditorInput());
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   374
			}								
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   375
		return null;
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   376
	}	
a02c979e8dfd 1. Copyrights changed to EPL
noe\swadi
parents:
diff changeset
   377
}