summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorCamilo Bernal2012-08-21 17:04:56 (EDT)
committer Roland Grunberg2012-08-29 11:15:39 (EDT)
commitffab3beb832279e43d72a8190ae2216b6a76f1be (patch)
tree4bb82725f0355c508d907bf14f663f723d80374d
parentec190155d457d0363cc33f02245d718cdfb6547f (diff)
downloadorg.eclipse.linuxtools-ffab3beb832279e43d72a8190ae2216b6a76f1be.zip
org.eclipse.linuxtools-ffab3beb832279e43d72a8190ae2216b6a76f1be.tar.gz
org.eclipse.linuxtools-ffab3beb832279e43d72a8190ae2216b6a76f1be.tar.bz2
Refactor launch provider to allow other plug-ins to extend its functionality.
This plug-in is a refactoring of the current snapshot launch provider plug-in, removing all harcoded references of a specific profiling type and replacing them with abstract getters. This allows for launch provider plug-ins to extend the existing functionality and set their specific profiling types. Change-Id: Ibab63109cba5589f3657123f7911abacab30f3b6 Reviewed-on: https://git.eclipse.org/r/7352 Reviewed-by: Sami Wagiaalla <swagiaal@redhat.com> IP-Clean: Sami Wagiaalla <swagiaal@redhat.com> Tested-by: Sami Wagiaalla <swagiaal@redhat.com> Reviewed-by: Roland Grunberg <rgrunber@redhat.com> IP-Clean: Roland Grunberg <rgrunber@redhat.com> Tested-by: Roland Grunberg <rgrunber@redhat.com>
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider/.classpath7
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider/.project28
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider/.settings/org.eclipse.jdt.core.prefs91
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider/META-INF/MANIFEST.MF18
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider/build.properties5
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider/plugin.xml14
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider/pom.xml44
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/AbstractProviderPreferencesPage.java81
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/ProviderLaunchConfigurationTabGroup.java18
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/ProviderOptionsTab.java230
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/ProviderPreferencesPage.java31
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/Messages.java27
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/ProviderLaunchConfigurationDelegate.java74
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/ProviderLaunchShortcut.java39
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/messages.properties4
15 files changed, 711 insertions, 0 deletions
diff --git a/profiling/org.eclipse.linuxtools.profiling.provider/.classpath b/profiling/org.eclipse.linuxtools.profiling.provider/.classpath
new file mode 100644
index 0000000..64c5e31
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.provider/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/profiling/org.eclipse.linuxtools.profiling.provider/.project b/profiling/org.eclipse.linuxtools.profiling.provider/.project
new file mode 100644
index 0000000..67a50c9
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.provider/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.linuxtools.profiling.provider</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/profiling/org.eclipse.linuxtools.profiling.provider/.settings/org.eclipse.jdt.core.prefs b/profiling/org.eclipse.linuxtools.profiling.provider/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..61d2eb3
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.provider/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,91 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=disabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=disabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/profiling/org.eclipse.linuxtools.profiling.provider/META-INF/MANIFEST.MF b/profiling/org.eclipse.linuxtools.profiling.provider/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..7f8c5f8
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.provider/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Snapshot Profiling Plugin
+Bundle-SymbolicName: org.eclipse.linuxtools.profiling.provider;singleton:=true
+Bundle-Version: 1.1.0.qualifier
+Bundle-Vendor: Eclipse
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.debug.ui,
+ org.eclipse.ui.ide
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Import-Package: org.eclipse.cdt.core.model,
+ org.eclipse.cdt.launch,
+ org.eclipse.linuxtools.internal.profiling.launch,
+ org.eclipse.linuxtools.profiling.launch
+Export-Package: org.eclipse.linuxtools.internal.profiling.provider,
+ org.eclipse.linuxtools.internal.profiling.provider.launch
diff --git a/profiling/org.eclipse.linuxtools.profiling.provider/build.properties b/profiling/org.eclipse.linuxtools.profiling.provider/build.properties
new file mode 100644
index 0000000..2b0d95b
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.provider/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .
diff --git a/profiling/org.eclipse.linuxtools.profiling.provider/plugin.xml b/profiling/org.eclipse.linuxtools.profiling.provider/plugin.xml
new file mode 100644
index 0000000..2305d91
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.provider/plugin.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ class="org.eclipse.linuxtools.internal.profiling.provider.ProviderPreferencesPage"
+ id="org.eclipse.linuxtools.profiling.provider.MainPreferencePage"
+ name="Profiling">
+ </page>
+ </extension>
+
+
+</plugin>
diff --git a/profiling/org.eclipse.linuxtools.profiling.provider/pom.xml b/profiling/org.eclipse.linuxtools.profiling.provider/pom.xml
new file mode 100644
index 0000000..d92fa5c
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.provider/pom.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (C) 2011, Red Hat, Inc.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>linuxtools-profiling-parent</artifactId>
+ <groupId>org.eclipse.linuxtools.profiling</groupId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>org.eclipse.linuxtools.profiling.provider</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+
+ <name>Linux Tools Profiling Launch Plug-in</name>
+
+ <build>
+ <!-- workaround for https://issues.sonatype.org/browse/TYCHO-168 -->
+ <resources>
+ <resource>
+ <directory>src</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-source-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/AbstractProviderPreferencesPage.java b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/AbstractProviderPreferencesPage.java
new file mode 100644
index 0000000..a3b75ad
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/AbstractProviderPreferencesPage.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.profiling.provider;
+
+import java.util.HashMap;
+import java.util.Map.Entry;
+
+import org.eclipse.core.runtime.preferences.ConfigurationScope;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.RadioGroupFieldEditor;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+import org.eclipse.linuxtools.internal.profiling.provider.launch.Messages;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTabGroup;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchShortcut;
+
+public abstract class AbstractProviderPreferencesPage extends
+ FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+
+ private static IScopeContext configScopeInstance = ConfigurationScope.INSTANCE;
+ public static final String PREFS_KEY = "provider"; //$NON-NLS-1$
+
+ public AbstractProviderPreferencesPage() {
+ super(GRID);
+ }
+
+ public void init(IWorkbench workbench) {
+ final IPreferenceStore store = new ScopedPreferenceStore(
+ configScopeInstance, getProfilingType());
+ setPreferenceStore(store);
+
+ }
+
+ public void initializeDefaultPreferences() {
+ super.performDefaults();
+ String providerId = ProfileLaunchShortcut
+ .getDefaultLaunchShortcutProviderId(getProfilingType());
+ configScopeInstance.getNode(getProfilingType())
+ .put(PREFS_KEY, providerId);
+
+ }
+
+ @Override
+ protected void createFieldEditors() {
+ HashMap<String, String> map = ProfileLaunchConfigurationTabGroup
+ .getProviderNamesForType(getProfilingType());
+ // 2d array containing launch provider names on the first column and
+ // corresponding id's on the second.
+ String[][] providerList = new String[map.size()][2];
+ int i = 0;
+ for (Entry<String, String> entry : map.entrySet()) {
+ providerList[i][0] = entry.getKey();
+ providerList[i][1] = entry.getValue();
+ i++;
+ }
+ RadioGroupFieldEditor editor = new RadioGroupFieldEditor(PREFS_KEY,
+ Messages.ProviderPreferencesPage_1, 1, providerList,
+ getFieldEditorParent());
+ addField(editor);
+
+ }
+
+ /**
+ * Get profiling type of this plug-in.
+ *
+ * @return String profiling type this plug-in supports.
+ */
+ protected abstract String getProfilingType();
+
+}
diff --git a/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/ProviderLaunchConfigurationTabGroup.java b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/ProviderLaunchConfigurationTabGroup.java
new file mode 100644
index 0000000..3667840
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/ProviderLaunchConfigurationTabGroup.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.profiling.provider;
+
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTabGroup;
+
+public abstract class ProviderLaunchConfigurationTabGroup extends
+ ProfileLaunchConfigurationTabGroup {
+ // Marker for a our own tab kind.
+}
diff --git a/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/ProviderOptionsTab.java b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/ProviderOptionsTab.java
new file mode 100644
index 0000000..3c6498c
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/ProviderOptionsTab.java
@@ -0,0 +1,230 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.profiling.provider;
+
+import java.util.HashMap;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTab;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTabGroup;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CTabFolder;
+import org.eclipse.swt.custom.CTabItem;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+
+public abstract class ProviderOptionsTab extends ProfileLaunchConfigurationTab {
+
+ Composite top;
+ Combo providerCombo;
+ AbstractLaunchConfigurationTab[] tabs;
+ ILaunchConfiguration initial;
+ HashMap<String, String> comboItems;
+ CTabFolder tabgroup;
+ Boolean initialized;
+ private static final String PROVIDER_CONFIG_ATT = "provider"; //$NON-NLS-1$
+
+ public void createControl(Composite parent) {
+ top = new Composite(parent, SWT.NONE);
+ setControl(top);
+ top.setLayout(new GridLayout(1, true));
+ providerCombo = new Combo(top, SWT.READ_ONLY);
+ comboItems = ProfileLaunchConfigurationTabGroup
+ .getProviderNamesForType(getProfilingType());
+ Set<String> providerNames = comboItems.keySet();
+ providerCombo.setItems(providerNames.toArray(new String[0]));
+
+ tabgroup = new CTabFolder(top, SWT.NONE);
+ tabgroup.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true,
+ true));
+
+ providerCombo.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ String curProviderId = comboItems.get(providerCombo.getText());
+ loadTabGroupItems(tabgroup, curProviderId);
+ initializeFrom(initial);
+ top.layout();
+ }
+ });
+ }
+
+ public void loadTabGroupItems(CTabFolder tabgroup, String curProviderId) {
+ // dispose of old tabs
+ for (CTabItem item : tabgroup.getItems()) {
+ item.dispose();
+ }
+
+ ProfileLaunchConfigurationTabGroup tabGroupConfig;
+
+ if (curProviderId == null || "".equals(curProviderId)) {
+ // get id of highest priority provider
+ curProviderId = ProfileLaunchConfigurationTabGroup
+ .getHighestProviderId(getProfilingType());
+ }
+ tabGroupConfig = ProfileLaunchConfigurationTabGroup
+ .getTabGroupProviderFromId(curProviderId);
+ if (tabGroupConfig == null) {
+ // no provider found
+ return;
+ }
+ tabs = tabGroupConfig.getProfileTabs();
+ setProvider(curProviderId);
+
+ // Show provider name in combo.
+ int itemIndex = getComboItemIndexFromId(curProviderId);
+ providerCombo.select(itemIndex);
+
+ // create the tab item, and load the specified tab inside
+ for (ILaunchConfigurationTab tab : tabs) {
+ tab.setLaunchConfigurationDialog(getLaunchConfigurationDialog());
+ CTabItem item = new CTabItem(tabgroup, SWT.NONE);
+ item.setText(tab.getName());
+ item.setImage(tab.getImage());
+
+ tab.createControl(tabgroup);
+ item.setControl(tab.getControl());
+ }
+ }
+
+ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
+ if (providerCombo != null && !providerCombo.getText().equals("")) {
+ for (AbstractLaunchConfigurationTab tab : tabs) {
+ tab.setDefaults(configuration);
+ }
+ }
+ }
+
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ /**
+ * First time the configuration is selected.
+ *
+ * This is a cheap way to get access to the launch configuration. Our
+ * tabs are loaded dynamically, so the tab group doesn't "know" about
+ * them. We get access to this launch configuration to ensure that we
+ * can properly load the widgets the first time.
+ */
+
+ // starting initialization of this tab's controls
+ initialized = false;
+
+ // update current configuration (initial) with configuration being
+ // passed in
+ initial = configuration;
+
+ // check if there exists a launch provider id in the configuration
+ if (initial != null) {
+ try {
+ String providerId = initial.getAttribute(PROVIDER_CONFIG_ATT, "");
+ if (providerId != null && !providerId.equals("")) {
+ // load provider corresponding to specified id
+ loadTabGroupItems(tabgroup, providerId);
+ } else {
+ // load highest priority provider if none found
+ loadTabGroupItems(tabgroup, null);
+ }
+ } catch (CoreException e) {
+ // continue, initialize tabs
+ }
+ }
+ if (tabs != null) {
+ for (AbstractLaunchConfigurationTab tab : tabs) {
+ tab.initializeFrom(configuration);
+ }
+ }
+ // finished initialization
+ initialized = true;
+ }
+
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ // make sure tabs are not null, and the tab's controls have been
+ // initialized.
+ if (tabs != null && initialized) {
+ for (AbstractLaunchConfigurationTab tab : tabs) {
+ tab.performApply(configuration);
+ }
+ }
+ }
+
+ /**
+ * Set the provider attribute in the specified configuration.
+ *
+ * @param configuration a configuration
+ */
+ public void setProvider(String providerId) {
+ try {
+ ILaunchConfigurationWorkingCopy wc = initial.getWorkingCopy();
+ wc.setAttribute(PROVIDER_CONFIG_ATT, providerId);
+ initial = wc.doSave();
+ } catch (CoreException e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ /**
+ * Get Combo item name from specified id
+ *
+ * @param id provider id
+ * @return name of item, <code>null</code> if no entry found with given id.
+ */
+ private String getComboItemNameFromId(String id) {
+ for (Entry<String, String> entry : comboItems.entrySet()) {
+ if (id.equals(entry.getValue())) {
+ return entry.getKey();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get index of specific name in the combo items list
+ *
+ * @param name name of item
+ * @return index of given name, -1 if it not found
+ */
+ private int getItemIndex(String name) {
+ int itemCount = providerCombo.getItemCount();
+ for (int i = 0; i < itemCount; i++) {
+ if (providerCombo.getItem(i).equals(name)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Get index of specific id in the combo items list
+ *
+ * @param id
+ * @return index of given id in combo items list, -1 if it not found.
+ */
+ private int getComboItemIndexFromId(String id) {
+ String providerName = getComboItemNameFromId(id);
+ return getItemIndex(providerName);
+ }
+
+ /**
+ * Get profiling type of this plug-in.
+ *
+ * @return String profiling type this plug-in supports.
+ */
+ protected abstract String getProfilingType();
+}
diff --git a/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/ProviderPreferencesPage.java b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/ProviderPreferencesPage.java
new file mode 100644
index 0000000..eabb1dc
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/ProviderPreferencesPage.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.profiling.provider;
+
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.linuxtools.internal.profiling.provider.launch.Messages;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+public class ProviderPreferencesPage extends FieldEditorPreferencePage
+ implements IWorkbenchPreferencePage {
+
+ public void init(IWorkbench workbench) {
+ setDescription(Messages.ProviderPreferencesPage_0);
+ }
+
+ @Override
+ protected void createFieldEditors() {
+ // Content for global profiling provider preferences.
+ }
+
+} \ No newline at end of file
diff --git a/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/Messages.java b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/Messages.java
new file mode 100644
index 0000000..b816846
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/Messages.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.profiling.provider.launch;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.profiling.provider.launch.messages"; //$NON-NLS-1$
+ public static String ProviderLaunchShortcut_0;
+ public static String ProviderPreferencesPage_0;
+ public static String ProviderPreferencesPage_1;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/ProviderLaunchConfigurationDelegate.java b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/ProviderLaunchConfigurationDelegate.java
new file mode 100644
index 0000000..166e044
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/ProviderLaunchConfigurationDelegate.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.profiling.provider.launch;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.preferences.ConfigurationScope;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.linuxtools.internal.profiling.provider.AbstractProviderPreferencesPage;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationDelegate;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTabGroup;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchShortcut;
+
+public abstract class ProviderLaunchConfigurationDelegate extends
+ ProfileLaunchConfigurationDelegate {
+
+ @Override
+ public void launch(ILaunchConfiguration config, String mode,
+ ILaunch launch, IProgressMonitor monitor) {
+ try {
+
+ if (config != null) {
+ // get provider id from configuration.
+ String providerId = config.getAttribute(
+ AbstractProviderPreferencesPage.PREFS_KEY, "");
+ if (providerId.equals("")) {
+ providerId = getProviderIdToRun();
+ }
+ // get configuration delegate associated with provider id.
+ ProfileLaunchConfigurationDelegate delegate = getConfigurationDelegateFromId(providerId);
+ if (delegate != null) {
+ delegate.launch(config, mode, launch, monitor);
+ }
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ return;
+ }
+
+ private String getProviderIdToRun() {
+ // Get self assigned default
+ String providerId = ConfigurationScope.INSTANCE.getNode(
+ getProfilingType()).get(
+ AbstractProviderPreferencesPage.PREFS_KEY, "");
+ if (providerId.equals("")) {
+ providerId = ProfileLaunchConfigurationTabGroup
+ .getHighestProviderId(getProfilingType());
+ if (providerId.equals("")) {
+ // Get highest priority provider
+ providerId = ProfileLaunchShortcut
+ .getDefaultLaunchShortcutProviderId(getProfilingType());
+ }
+ }
+ return providerId;
+ }
+
+ @Override
+ public String generateCommand(ILaunchConfiguration config) {
+ return null;
+ }
+
+ public abstract String getProfilingType();
+
+}
diff --git a/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/ProviderLaunchShortcut.java b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/ProviderLaunchShortcut.java
new file mode 100644
index 0000000..42b6d8d
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/ProviderLaunchShortcut.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.profiling.provider.launch;
+
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchShortcut;
+
+public abstract class ProviderLaunchShortcut extends ProfileLaunchShortcut {
+
+ @Override
+ protected ILaunchConfigurationType getLaunchConfigType() {
+ return getLaunchManager().getLaunchConfigurationType(getLaunchConfigID());
+ }
+
+ @Override
+ protected void setDefaultProfileAttributes(
+ ILaunchConfigurationWorkingCopy wc) {
+ wc.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, false);
+ wc.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, true);
+ }
+
+ /**
+ * Get profiling type of this plug-in.
+ *
+ * @return String profiling type this plug-in supports.
+ */
+ protected abstract String getLaunchConfigID();
+
+}
diff --git a/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/messages.properties b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/messages.properties
new file mode 100644
index 0000000..a64b428
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/messages.properties
@@ -0,0 +1,4 @@
+ProviderLaunchShortcut_0=Could not find a provider for profiling type :
+ProviderPreferencesPage_0=Profiling Preferences
+ProviderPreferencesPage_1=Choose default launch provider
+