diff options
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal')
5 files changed, 0 insertions, 579 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/DebuggerConnector.java b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/DebuggerConnector.java deleted file mode 100644 index 238cad32f..000000000 --- a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/DebuggerConnector.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.ide.eclipse.pdt.internal; - -import com.android.ide.eclipse.ddms.IDebuggerConnector; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationType; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; - -import java.util.HashMap; -import java.util.Map; - -/** - * Implementation of the com.android.ide.ddms.debuggerConnector extension point. - */ -public class DebuggerConnector extends DevTreeProjectProvider implements IDebuggerConnector { - - private final static String ATTR_CONNECT_MAP_PORT = "port"; //$NON-NLS-1$ - private final static String ATTR_CONNECT_MAP_HOSTNAME = "hostname"; //$NON-NLS-1$ - - @Override - public boolean isWorkspaceApp(String appName) { - return getProject() != null; - } - - @Override - public boolean connectDebugger(String appName, int appPort, int selectedPort) { - IProject project = getProject(); - - if (project != null) { - // get the launch manager - ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); - - // get the config for the remote launch config. - ILaunchConfigurationType configType = manager.getLaunchConfigurationType( - IJavaLaunchConfigurationConstants.ID_REMOTE_JAVA_APPLICATION); - - String projectName = project.getName(); - - // look for an existing launch config - ILaunchConfiguration config = findConfig(manager, configType, projectName, - selectedPort); - - if (config == null) { - // Didn't find a matching config, so we make one. - // It'll be made in the "working copy" object first. - ILaunchConfigurationWorkingCopy wc = null; - - try { - // make the working copy object with a unique name - wc = configType.newInstance(null, - manager.generateUniqueLaunchConfigurationNameFrom(projectName)); - - // set the project name - wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, - projectName); - - // set the connect map info - Map<String, String> connectMap = new HashMap<String, String>(); - connectMap.put(ATTR_CONNECT_MAP_PORT, Integer.toString(selectedPort)); - connectMap.put(ATTR_CONNECT_MAP_HOSTNAME, "localhost"); //$NON-NLS-1$ - wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, connectMap); - - // set the VM connector ID - wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_CONNECTOR, - IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR); - - // save the working copy to get the launch config object which we return. - config = wc.doSave(); - - } catch (CoreException e) { - - } - - } - - if (config != null) { - DebugUITools.launch(config, ILaunchManager.DEBUG_MODE); - return true; - } - } - - return false; - } - - /** - * Looks for and returns an existing {@link ILaunchConfiguration} object for a - * specified project and connection port. - * @param manager The {@link ILaunchManager}. - * @param type The {@link ILaunchConfigurationType}. - * @param projectName The name of the project - * @param connectionPort the remote connection port. - * @return an existing <code>ILaunchConfiguration</code> object matching the project, or - * <code>null</code>. - */ - private static ILaunchConfiguration findConfig(ILaunchManager manager, - ILaunchConfigurationType type, - String projectName, int connectionPort) { - try { - ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type); - - // look for one set up for the project with a debug equal to the selected debug port. - for (ILaunchConfiguration config : configs) { - - Map<?, ?> attributes = config.getAttributes(); - - String name = (String) attributes.get( - IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME); - - if (name == null || name.equals(projectName) == false) { - continue; - } - - Map<?, ?> connectMap = (Map<?, ?>) attributes.get( - IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP); - - if (connectMap != null) { - String portStr = (String) connectMap.get(ATTR_CONNECT_MAP_PORT); - if (portStr != null) { - Integer port = Integer.valueOf(portStr); - if (connectionPort == port) { - return config; - } - } - } - - } - } catch (CoreException e) { - } - - // didn't find anything that matches. Return null - return null; - } -} diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/DevTreeProjectProvider.java b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/DevTreeProjectProvider.java deleted file mode 100644 index b44d2cb49..000000000 --- a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/DevTreeProjectProvider.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.ide.eclipse.pdt.internal; - -import com.android.ide.eclipse.pdt.PdtPlugin; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.window.Window; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.ListDialog; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * Base class providing a {@link #getProject()} method to find the project matching the dev tree. - * - */ -class DevTreeProjectProvider { - protected IProject getProject() { - // Get the list of project for the current workspace - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - List<IProject> projects = Arrays.asList(workspace.getRoot().getProjects()); - if (projects.size() == 0) { - return null; - } - - // get the location of the Dev tree - String devTree = PdtPlugin.getDevTree(); - IPath devTreePath = null; - if (devTree != null) { - devTreePath = new Path(devTree); - } - - // filter the list of projects in workspace by 2 conditions: - // 1. Only look at Java projects - // 2. If dev tree location is set, only look at projects within the dev tree - - List<IProject> devTreeProjects = new ArrayList<IProject>(projects.size()); - - for (IProject p: projects) { - if (!p.isOpen()) { - continue; - } - - if (!hasJavaNature(p)) { - continue; - } - - if (devTreePath == null || devTreePath.isPrefixOf(p.getLocation())) { - devTreeProjects.add(p); - } - } - - return selectProject(devTreeProjects); - } - - private IProject selectProject(List<IProject> devTreeProjects) { - if (devTreeProjects.size() == 0) { - return null; - } - - if (devTreeProjects.size() == 1) { - return devTreeProjects.get(0); - } - - // if there are multiple choices, prompt the user - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) { - return null; - } - - ListDialog dlg = new ListDialog(window.getShell()); - dlg.setMessage("Select Project"); - dlg.setInput(devTreeProjects); - dlg.setContentProvider(new IStructuredContentProvider() { - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - - @Override - public void dispose() { - } - - @Override - public Object[] getElements(Object inputElement) { - return ((List<?>) inputElement).toArray(); - } - }); - dlg.setLabelProvider(new LabelProvider() { - @Override - public String getText(Object element) { - return ((IProject) element).getName(); - } - }); - dlg.setHelpAvailable(false); - - if (dlg.open() == Window.OK) { - Object[] selectedMatches = dlg.getResult(); - if (selectedMatches.length > 0) { - return (IProject) selectedMatches[0]; - } - } - - return null; - } - - private boolean hasJavaNature(IProject p) { - try { - return p.hasNature(JavaCore.NATURE_ID); - } catch (CoreException e) { - return false; - } - } -} diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/SourceRevealer.java b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/SourceRevealer.java deleted file mode 100644 index 51011e119..000000000 --- a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/SourceRevealer.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.ide.eclipse.pdt.internal; - -import com.android.ide.eclipse.ddms.ISourceRevealer; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IMethod; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.search.IJavaSearchConstants; -import org.eclipse.jdt.core.search.SearchEngine; -import org.eclipse.jdt.core.search.SearchMatch; -import org.eclipse.jdt.core.search.SearchParticipant; -import org.eclipse.jdt.core.search.SearchPattern; -import org.eclipse.jdt.core.search.SearchRequestor; -import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.jdt.ui.actions.OpenJavaPerspectiveAction; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IRegion; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IPerspectiveRegistry; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.WorkbenchException; -import org.eclipse.ui.texteditor.IDocumentProvider; -import org.eclipse.ui.texteditor.ITextEditor; - -/** - * Implementation of the com.android.ide.ddms.sourceRevealer extension point. - * This implementation is a copy of com.android.ide.eclipse.adt.SourceRevealer. - */ -public class SourceRevealer extends DevTreeProjectProvider implements ISourceRevealer { - - @Override - public boolean reveal(String applicationName, String className, int line) { - IProject project = getProject(); - - if (project != null) { - // Inner classes are pointless: All we need is the enclosing type to find the file, - // and the line number. - // Since the anonymous ones will cause IJavaProject#findType to fail, we remove - // all of them. - int pos = className.indexOf('$'); - if (pos != -1) { - className = className.substring(0, pos); - } - - // get the java project - IJavaProject javaProject = JavaCore.create(project); - - try { - // look for the IType matching the class name. - IType result = javaProject.findType(className); - if (result != null && result.exists()) { - // before we show the type in an editor window, we make sure the current - // workbench page has an editor area (typically the ddms perspective doesn't). - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); - IWorkbenchPage page = window.getActivePage(); - if (page.isEditorAreaVisible() == false) { - // no editor area? we open the java perspective. - new OpenJavaPerspectiveAction().run(); - } - - IEditorPart editor = JavaUI.openInEditor(result); - if (editor instanceof ITextEditor) { - // get the text editor that was just opened. - ITextEditor textEditor = (ITextEditor)editor; - - IEditorInput input = textEditor.getEditorInput(); - - // get the location of the line to show. - IDocumentProvider documentProvider = textEditor.getDocumentProvider(); - IDocument document = documentProvider.getDocument(input); - IRegion lineInfo = document.getLineInformation(line - 1); - - // select and reveal the line. - textEditor.selectAndReveal(lineInfo.getOffset(), lineInfo.getLength()); - } - - return true; - } - } catch (JavaModelException e) { - } catch (PartInitException e) { - } catch (BadLocationException e) { - } - } - - return false; - } - - @Override - public boolean revealMethod(String fqmn, String fileName, int lineNumber, String perspective) { - SearchEngine se = new SearchEngine(); - SearchPattern searchPattern = SearchPattern.createPattern( - fqmn, - IJavaSearchConstants.METHOD, - IJavaSearchConstants.DECLARATIONS, - SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE); - MethodSearchRequestor requestor = new MethodSearchRequestor(perspective); - try { - se.search(searchPattern, - new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, - SearchEngine.createWorkspaceScope(), - requestor, - new NullProgressMonitor()); - } catch (CoreException e) { - return false; - } - - return requestor.didMatch(); - } - - private static class MethodSearchRequestor extends SearchRequestor { - private boolean mFoundMatch = false; - private final String mPerspective; - - public MethodSearchRequestor(String perspective) { - mPerspective = perspective; - } - - public boolean didMatch() { - return mFoundMatch; - } - - @Override - public void acceptSearchMatch(SearchMatch match) throws CoreException { - Object element = match.getElement(); - if (element instanceof IMethod && !mFoundMatch) { - if (mPerspective != null) { - SourceRevealer.switchToPerspective(mPerspective); - } - - IMethod method = (IMethod) element; - JavaUI.openInEditor(method); - mFoundMatch = true; - } - } - } - - public static void switchToPerspective(String perspectiveId) { - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); - IPerspectiveRegistry perspectiveRegistry = workbench.getPerspectiveRegistry(); - if (perspectiveId != null - && perspectiveId.length() > 0 - && perspectiveRegistry.findPerspectiveWithId(perspectiveId) != null) { - try { - workbench.showPerspective(perspectiveId, window); - } catch (WorkbenchException e) { - // ignore exception, perspective won't be switched - } - } - } - -} diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/ToolsLocator.java b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/ToolsLocator.java deleted file mode 100644 index a7291cbc7..000000000 --- a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/ToolsLocator.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.ide.eclipse.pdt.internal; - -import com.android.ide.eclipse.ddms.IToolsLocator; -import com.android.ide.eclipse.pdt.PdtPlugin; - -/** - * Implementation of the com.android.ide.ddms.adbLocator extension point. - */ -public class ToolsLocator implements IToolsLocator { - - @Override - public String getAdbLocation() { - return PdtPlugin.getAdbLocation(); - } - - @Override - public String getHprofConvLocation() { - return PdtPlugin.getHprofConvLocation(); - } - - @Override - public String getTraceViewLocation() { - return PdtPlugin.getTraceViewLocation(); - } -} diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/preferences/PrefPage.java b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/preferences/PrefPage.java deleted file mode 100644 index 565b6adbe..000000000 --- a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/preferences/PrefPage.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.ide.eclipse.pdt.internal.preferences; - -import com.android.ide.eclipse.pdt.PdtPlugin; - -import org.eclipse.jface.preference.DirectoryFieldEditor; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -public class PrefPage extends FieldEditorPreferencePage implements - IWorkbenchPreferencePage { - - public final static String PREFS_DEVTREE_DIR = PdtPlugin.PLUGIN_ID + ".devtree"; //$NON-NLS-1$ - - private DirectoryFieldEditor mDirectoryField; - - public PrefPage() { - super(GRID); - IPreferenceStore store = PdtPlugin.getDefault().getPreferenceStore(); - setPreferenceStore(store); - setDescription("Android Preferences"); - } - - @Override - protected void createFieldEditors() { - mDirectoryField = new DirectoryFieldEditor(PREFS_DEVTREE_DIR, - "Dev Tree Location:", getFieldEditorParent()); - - addField(mDirectoryField); - } - - @Override - public void init(IWorkbench workbench) { - } - - @Override - public void dispose() { - super.dispose(); - - if (mDirectoryField != null) { - mDirectoryField.dispose(); - mDirectoryField = null; - } - } - -} |