diff options
author | Jonah Graham | 2018-11-20 21:20:39 +0000 |
---|---|---|
committer | Jonah Graham | 2018-11-20 21:20:39 +0000 |
commit | 48d2271a58a68743e428d3096d2bca054d04e310 (patch) | |
tree | 235ba23e71c393ad22d1d57fc8fdfec14754c4ee /debug | |
parent | 3cf0297769e5cfb91823e93ce570120a75fe01ce (diff) | |
download | org.eclipse.cdt-48d2271a58a68743e428d3096d2bca054d04e310.tar.gz org.eclipse.cdt-48d2271a58a68743e428d3096d2bca054d04e310.tar.xz org.eclipse.cdt-48d2271a58a68743e428d3096d2bca054d04e310.zip |
Bug 540373: Normalize newlines with .gitattributes
There is also a new script to verify completeness of .gitattributes:
releng/scripts/verify_gitattributes.sh
Change-Id: I2ce270852ab54b66b6c474a6ec94203fe5bba78b
Diffstat (limited to 'debug')
26 files changed, 2343 insertions, 2343 deletions
diff --git a/debug/org.eclipse.cdt.debug.application.doc/customBuildCallbacks.xml b/debug/org.eclipse.cdt.debug.application.doc/customBuildCallbacks.xml index e0a92a65f0f..53a5bbd0435 100644 --- a/debug/org.eclipse.cdt.debug.application.doc/customBuildCallbacks.xml +++ b/debug/org.eclipse.cdt.debug.application.doc/customBuildCallbacks.xml @@ -1,163 +1,163 @@ -<!-- ===================================================================== -->
-<!-- Custom targets called from a project's generated build.xml -->
-<!-- Set customBuildCallbacks=<path/to/this/file> in your build.properties.-->
-<!-- ===================================================================== -->
-<project name="Build specific targets and properties" default="noDefault">
-
- <!-- ===================================================================== -->
- <!-- Default target -->
- <!-- ===================================================================== -->
- <target name="noDefault">
- <echo message="This file must be called with explicit targets" />
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do before the target build.jars -->
- <!-- Available parameters : -->
- <!-- build.result.folder - folder to contain the build results -->
- <!-- ===================================================================== -->
- <target name="pre.build.jars">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do after the target build.jars -->
- <!-- Available parameters : -->
- <!-- build.result.folder - folder to contain the build results -->
- <!-- ===================================================================== -->
- <target name="post.build.jars">
- <antcall target="build.index"/>
- </target>
-
- <target name="build.index" description="Builds search index for the plug-in: org.eclipse.rse.doc.user." if="eclipse.running">
- <help.buildHelpIndex manifest="plugin.xml" destination="."/>
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do before the target build.sources -->
- <!-- Available parameters : -->
- <!-- build.result.folder - folder to contain the build results -->
- <!-- ===================================================================== -->
- <target name="pre.build.sources">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do after the target build.sources -->
- <!-- Available parameters : -->
- <!-- build.result.folder - folder to contain the build results -->
- <!-- ===================================================================== -->
- <target name="post.build.sources">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do before the compilation target <name> -->
- <!-- Substitute "name" with the name of the compilation target, eg @dot -->
- <!-- Available parameters : -->
- <!-- source.foldern : n = 1 ... N, the source folders -->
- <!-- target.folder : where the results of the compilation go -->
- <!-- <name>.classpath : name = name of the compilation target. A -->
- <!-- reference to the classpath structure. -->
- <!-- ===================================================================== -->
- <target name="pre.name">
- </target>
-
- <target name="pre.@dot">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do during the compilation target <name>, after the compile -->
- <!-- but before jaring. Substitute "name" with the name of the compilation-->
- <!-- target, eg @dot -->
- <!-- Available parameters : -->
- <!-- source.foldern : n = 1 ... N, the source folders -->
- <!-- target.folder : where the results of the compilation go -->
- <!-- <name>.classpath : name = name of the compilation target. A -->
- <!-- reference to the classpath structure. -->
- <!-- ===================================================================== -->
- <target name="post.compile.name">
- </target>
-
- <target name="post.compile.@dot">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do after the compilation target <name> -->
- <!-- Substitute "name" with the name of the compilation target, eg @dot -->
- <!-- Available parameters : -->
- <!-- jar.Location - the location of the compilation results -->
- <!-- <name>.classpath : name = name of the compilation target. A -->
- <!-- reference to the classpath structure. -->
- <!-- ===================================================================== -->
- <target name="post.name">
- </target>
-
- <target name="post.@dot">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do before the target gather.bin.parts -->
- <!-- Available parameters : -->
- <!-- build.result.folder - folder containing the build results -->
- <!-- target.folder - destination folder -->
- <!-- ===================================================================== -->
- <target name="pre.gather.bin.parts">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do after the target gather.bin.parts -->
- <!-- Available parameters : -->
- <!-- build.result.folder - folder containing the build results -->
- <!-- target.folder - destination folder -->
- <!-- ===================================================================== -->
- <target name="post.gather.bin.parts">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do before the target gather.sources -->
- <!-- Available parameters : -->
- <!-- destination.temp.folder - destination folder -->
- <!-- ===================================================================== -->
- <target name="pre.gather.sources">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do after the target gather.sources -->
- <!-- Available parameters : -->
- <!-- destination.temp.folder - destination folder -->
- <!-- ===================================================================== -->
- <target name="post.gather.sources">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do before the target gather.logs -->
- <!-- Available parameters : -->
- <!-- destination.temp.folder - destination folder -->
- <!-- ===================================================================== -->
- <target name="pre.gather.logs">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do after the target gather.logs -->
- <!-- Available parameters : -->
- <!-- destination.temp.folder - destination folder -->
- <!-- ===================================================================== -->
- <target name="post.gather.logs">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do before the target clean -->
- <!-- Available parameters : -->
- <!-- destination.temp.folder - destination folder -->
- <!-- ===================================================================== -->
- <target name="pre.clean">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do after the target clean -->
- <!-- Available parameters : -->
- <!-- plugin.destination - final destination of the build -->
- <!-- build.result.folder - results of the compilation -->
- <!-- temp.folder - temporary folder -->
- <!-- ===================================================================== -->
- <target name="post.clean">
- </target>
-</project>
+<!-- ===================================================================== --> +<!-- Custom targets called from a project's generated build.xml --> +<!-- Set customBuildCallbacks=<path/to/this/file> in your build.properties.--> +<!-- ===================================================================== --> +<project name="Build specific targets and properties" default="noDefault"> + + <!-- ===================================================================== --> + <!-- Default target --> + <!-- ===================================================================== --> + <target name="noDefault"> + <echo message="This file must be called with explicit targets" /> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do before the target build.jars --> + <!-- Available parameters : --> + <!-- build.result.folder - folder to contain the build results --> + <!-- ===================================================================== --> + <target name="pre.build.jars"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do after the target build.jars --> + <!-- Available parameters : --> + <!-- build.result.folder - folder to contain the build results --> + <!-- ===================================================================== --> + <target name="post.build.jars"> + <antcall target="build.index"/> + </target> + + <target name="build.index" description="Builds search index for the plug-in: org.eclipse.rse.doc.user." if="eclipse.running"> + <help.buildHelpIndex manifest="plugin.xml" destination="."/> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do before the target build.sources --> + <!-- Available parameters : --> + <!-- build.result.folder - folder to contain the build results --> + <!-- ===================================================================== --> + <target name="pre.build.sources"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do after the target build.sources --> + <!-- Available parameters : --> + <!-- build.result.folder - folder to contain the build results --> + <!-- ===================================================================== --> + <target name="post.build.sources"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do before the compilation target <name> --> + <!-- Substitute "name" with the name of the compilation target, eg @dot --> + <!-- Available parameters : --> + <!-- source.foldern : n = 1 ... N, the source folders --> + <!-- target.folder : where the results of the compilation go --> + <!-- <name>.classpath : name = name of the compilation target. A --> + <!-- reference to the classpath structure. --> + <!-- ===================================================================== --> + <target name="pre.name"> + </target> + + <target name="pre.@dot"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do during the compilation target <name>, after the compile --> + <!-- but before jaring. Substitute "name" with the name of the compilation--> + <!-- target, eg @dot --> + <!-- Available parameters : --> + <!-- source.foldern : n = 1 ... N, the source folders --> + <!-- target.folder : where the results of the compilation go --> + <!-- <name>.classpath : name = name of the compilation target. A --> + <!-- reference to the classpath structure. --> + <!-- ===================================================================== --> + <target name="post.compile.name"> + </target> + + <target name="post.compile.@dot"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do after the compilation target <name> --> + <!-- Substitute "name" with the name of the compilation target, eg @dot --> + <!-- Available parameters : --> + <!-- jar.Location - the location of the compilation results --> + <!-- <name>.classpath : name = name of the compilation target. A --> + <!-- reference to the classpath structure. --> + <!-- ===================================================================== --> + <target name="post.name"> + </target> + + <target name="post.@dot"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do before the target gather.bin.parts --> + <!-- Available parameters : --> + <!-- build.result.folder - folder containing the build results --> + <!-- target.folder - destination folder --> + <!-- ===================================================================== --> + <target name="pre.gather.bin.parts"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do after the target gather.bin.parts --> + <!-- Available parameters : --> + <!-- build.result.folder - folder containing the build results --> + <!-- target.folder - destination folder --> + <!-- ===================================================================== --> + <target name="post.gather.bin.parts"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do before the target gather.sources --> + <!-- Available parameters : --> + <!-- destination.temp.folder - destination folder --> + <!-- ===================================================================== --> + <target name="pre.gather.sources"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do after the target gather.sources --> + <!-- Available parameters : --> + <!-- destination.temp.folder - destination folder --> + <!-- ===================================================================== --> + <target name="post.gather.sources"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do before the target gather.logs --> + <!-- Available parameters : --> + <!-- destination.temp.folder - destination folder --> + <!-- ===================================================================== --> + <target name="pre.gather.logs"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do after the target gather.logs --> + <!-- Available parameters : --> + <!-- destination.temp.folder - destination folder --> + <!-- ===================================================================== --> + <target name="post.gather.logs"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do before the target clean --> + <!-- Available parameters : --> + <!-- destination.temp.folder - destination folder --> + <!-- ===================================================================== --> + <target name="pre.clean"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do after the target clean --> + <!-- Available parameters : --> + <!-- plugin.destination - final destination of the build --> + <!-- build.result.folder - results of the compilation --> + <!-- temp.folder - temporary folder --> + <!-- ===================================================================== --> + <target name="post.clean"> + </target> +</project> diff --git a/debug/org.eclipse.cdt.debug.application/configGenerator.xml b/debug/org.eclipse.cdt.debug.application/configGenerator.xml index 6f5e41896b0..5a9f107ead5 100644 --- a/debug/org.eclipse.cdt.debug.application/configGenerator.xml +++ b/debug/org.eclipse.cdt.debug.application/configGenerator.xml @@ -1,15 +1,15 @@ -<!-- This generates the config.ini file, based on the debug.product -->
-<project name="Build specific targets and properties" default="generate.configuration">
- <target name="generate.configuration" description="Generates config.ini file">
- <java classname="org.eclipse.cdt.debug.application.ConfigGenerator" failonerror="true">
- <arg value="-product"/>
- <arg value="${product_path}"/>
- <arg value="-out"/>
- <arg value="${config_path}"/>
- <classpath>
- <pathelement path="bin"/>
- <pathelement path="target/classes"/>
- </classpath>
- </java>
- </target>
-</project>
+<!-- This generates the config.ini file, based on the debug.product --> +<project name="Build specific targets and properties" default="generate.configuration"> + <target name="generate.configuration" description="Generates config.ini file"> + <java classname="org.eclipse.cdt.debug.application.ConfigGenerator" failonerror="true"> + <arg value="-product"/> + <arg value="${product_path}"/> + <arg value="-out"/> + <arg value="${config_path}"/> + <classpath> + <pathelement path="bin"/> + <pathelement path="target/classes"/> + </classpath> + </java> + </target> +</project> diff --git a/debug/org.eclipse.cdt.debug.core/schema/BreakpointAction.exsd b/debug/org.eclipse.cdt.debug.core/schema/BreakpointAction.exsd index 7c5b6bac2b1..992cad8e211 100644 --- a/debug/org.eclipse.cdt.debug.core/schema/BreakpointAction.exsd +++ b/debug/org.eclipse.cdt.debug.core/schema/BreakpointAction.exsd @@ -1,106 +1,106 @@ -<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.cdt.debug.core">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.cdt.debug.core" id="BreakpointActionType" name="BreakpointActionType"/>
- </appInfo>
- <documentation>
- Extension to provide additional actions to execute when a breakpoint is hit.
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="actionType"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="actionType">
- <complexType>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="class" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- [Enter the first release in which this extension point appears.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- Copyright (c) 2007 Nokia and others.
-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
- </documentation>
- </annotation>
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.cdt.debug.core"> +<annotation> + <appInfo> + <meta.schema plugin="org.eclipse.cdt.debug.core" id="BreakpointActionType" name="BreakpointActionType"/> + </appInfo> + <documentation> + Extension to provide additional actions to execute when a breakpoint is hit. + </documentation> + </annotation> + + <element name="extension"> + <complexType> + <sequence> + <element ref="actionType"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <element name="actionType"> + <complexType> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + <attribute name="class" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appInfo> + <meta.section type="since"/> + </appInfo> + <documentation> + [Enter the first release in which this extension point appears.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="examples"/> + </appInfo> + <documentation> + [Enter extension point usage example here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="apiInfo"/> + </appInfo> + <documentation> + [Enter API information here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="implementation"/> + </appInfo> + <documentation> + [Enter information about supplied implementation of this extension point.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="copyright"/> + </appInfo> + <documentation> + Copyright (c) 2007 Nokia and others. +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 + </documentation> + </annotation> + +</schema> diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigDelegate.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigDelegate.java index 217c6dced4f..b3909f12d61 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigDelegate.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigDelegate.java @@ -1,88 +1,88 @@ -/*******************************************************************************
- * Copyright (c) 2017 QNX Software Systems and others.
- * 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
- *******************************************************************************/
-package org.eclipse.cdt.debug.core.launch;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.cdt.debug.core.CDebugCorePlugin;
-import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
-import org.eclipse.cdt.debug.internal.core.Messages;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.variables.IStringVariableManager;
-import org.eclipse.core.variables.VariablesPlugin;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-
-/**
- * Delegate for Generic Launches over the Generic Launch Target. Can be
- * overriden to support launch customization for similar targets.
- *
- * @since 8.3
- */
-public class CoreBuildGenericLaunchConfigDelegate extends CoreBuildLaunchConfigDelegate {
-
- public static final String TYPE_ID = "org.eclipse.cdt.debug.core.genericLaunchConfigType"; //$NON-NLS-1$
-
- @Override
- public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
- throws CoreException {
- IStringVariableManager varManager = VariablesPlugin.getDefault().getStringVariableManager();
-
- String location = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_LOCATION, ""); //$NON-NLS-1$
- if (location.isEmpty()) {
- launch.addProcess(new NullProcess(launch, Messages.CoreBuildGenericLaunchConfigDelegate_NoAction));
- return;
- } else {
- String substLocation = varManager.performStringSubstitution(location);
- if (substLocation.isEmpty()) {
- throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID,
- String.format(Messages.CoreBuildGenericLaunchConfigDelegate_SubstitutionFailed, location)));
- }
- location = substLocation;
- }
-
- if (!new File(location).canExecute()) {
- throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID,
- String.format(Messages.CoreBuildGenericLaunchConfigDelegate_CommandNotValid, location)));
- }
-
- List<String> commands = new ArrayList<>();
- commands.add(location);
-
- String arguments = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_TOOL_ARGUMENTS, ""); //$NON-NLS-1$
- if (!arguments.isEmpty()) {
- commands.addAll(Arrays.asList(varManager.performStringSubstitution(arguments).split(" "))); //$NON-NLS-1$
- }
-
- String workingDirectory = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
- ""); //$NON-NLS-1$
- File workingDir;
- if (workingDirectory.isEmpty()) {
- workingDir = new File(getProject(configuration).getLocationURI());
- } else {
- workingDir = new File(varManager.performStringSubstitution(workingDirectory));
- if (!workingDir.isDirectory()) {
- throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID,
- String.format(Messages.CoreBuildGenericLaunchConfigDelegate_WorkingDirNotExists, location)));
- }
- }
-
- String[] envp = DebugPlugin.getDefault().getLaunchManager().getEnvironment(configuration);
-
- Process p = DebugPlugin.exec(commands.toArray(new String[0]), workingDir, envp);
- DebugPlugin.newProcess(launch, p, String.join(" ", commands)); //$NON-NLS-1$
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2017 QNX Software Systems and others. + * 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 + *******************************************************************************/ +package org.eclipse.cdt.debug.core.launch; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.eclipse.cdt.debug.core.CDebugCorePlugin; +import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; +import org.eclipse.cdt.debug.internal.core.Messages; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.variables.IStringVariableManager; +import org.eclipse.core.variables.VariablesPlugin; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; + +/** + * Delegate for Generic Launches over the Generic Launch Target. Can be + * overriden to support launch customization for similar targets. + * + * @since 8.3 + */ +public class CoreBuildGenericLaunchConfigDelegate extends CoreBuildLaunchConfigDelegate { + + public static final String TYPE_ID = "org.eclipse.cdt.debug.core.genericLaunchConfigType"; //$NON-NLS-1$ + + @Override + public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) + throws CoreException { + IStringVariableManager varManager = VariablesPlugin.getDefault().getStringVariableManager(); + + String location = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_LOCATION, ""); //$NON-NLS-1$ + if (location.isEmpty()) { + launch.addProcess(new NullProcess(launch, Messages.CoreBuildGenericLaunchConfigDelegate_NoAction)); + return; + } else { + String substLocation = varManager.performStringSubstitution(location); + if (substLocation.isEmpty()) { + throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, + String.format(Messages.CoreBuildGenericLaunchConfigDelegate_SubstitutionFailed, location))); + } + location = substLocation; + } + + if (!new File(location).canExecute()) { + throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, + String.format(Messages.CoreBuildGenericLaunchConfigDelegate_CommandNotValid, location))); + } + + List<String> commands = new ArrayList<>(); + commands.add(location); + + String arguments = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_TOOL_ARGUMENTS, ""); //$NON-NLS-1$ + if (!arguments.isEmpty()) { + commands.addAll(Arrays.asList(varManager.performStringSubstitution(arguments).split(" "))); //$NON-NLS-1$ + } + + String workingDirectory = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, + ""); //$NON-NLS-1$ + File workingDir; + if (workingDirectory.isEmpty()) { + workingDir = new File(getProject(configuration).getLocationURI()); + } else { + workingDir = new File(varManager.performStringSubstitution(workingDirectory)); + if (!workingDir.isDirectory()) { + throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, + String.format(Messages.CoreBuildGenericLaunchConfigDelegate_WorkingDirNotExists, location))); + } + } + + String[] envp = DebugPlugin.getDefault().getLaunchManager().getEnvironment(configuration); + + Process p = DebugPlugin.exec(commands.toArray(new String[0]), workingDir, envp); + DebugPlugin.newProcess(launch, p, String.join(" ", commands)); //$NON-NLS-1$ + } + +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigProvider.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigProvider.java index 7cc54a1260b..24439e69d5d 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigProvider.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigProvider.java @@ -1,165 +1,165 @@ -package org.eclipse.cdt.debug.core.launch;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.cdt.debug.core.CDebugCorePlugin;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-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.launchbar.core.AbstractLaunchConfigProvider;
-import org.eclipse.launchbar.core.ILaunchDescriptor;
-import org.eclipse.launchbar.core.target.ILaunchTarget;
-import org.eclipse.launchbar.core.target.ILaunchTargetManager;
-
-/**
- * Core launch configuration provider used by generic target types.
- *
- * @since 8.3
- */
-public class CoreBuildGenericLaunchConfigProvider extends AbstractLaunchConfigProvider {
-
- private static final String ATTR_OS = CDebugCorePlugin.PLUGIN_ID + ".target_os"; //$NON-NLS-1$
- private static final String ATTR_ARCH = CDebugCorePlugin.PLUGIN_ID + ".target_arch"; //$NON-NLS-1$
- private static final String EMPTY = ""; //$NON-NLS-1$
-
- private Map<IProject, Map<String, ILaunchConfiguration>> configs = new HashMap<>();
-
- @Override
- public boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException {
- return target.getTypeId().equals(GenericTargetTypeProvider.TYPE_ID);
- }
-
- @Override
- public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target)
- throws CoreException {
- return DebugPlugin.getDefault().getLaunchManager()
- .getLaunchConfigurationType(CoreBuildGenericLaunchConfigDelegate.TYPE_ID);
- }
-
- @Override
- public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target)
- throws CoreException {
- ILaunchConfiguration config = null;
- IProject project = descriptor.getAdapter(IProject.class);
- if (project != null) {
- Map<String, ILaunchConfiguration> projectConfigs = configs.get(project);
- if (projectConfigs == null) {
- projectConfigs = new HashMap<>();
- configs.put(project, projectConfigs);
- }
-
- String os = target.getAttribute(ILaunchTarget.ATTR_OS, EMPTY);
- String arch = target.getAttribute(ILaunchTarget.ATTR_ARCH, EMPTY);
- String targetConfig = os + '.' + arch;
- config = projectConfigs.get(targetConfig);
- if (config == null) {
- config = createLaunchConfiguration(descriptor, target);
- }
- }
- return config;
- }
-
- @Override
- protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target,
- ILaunchConfigurationWorkingCopy workingCopy) throws CoreException {
- super.populateLaunchConfiguration(descriptor, target, workingCopy);
-
- // Set the project
- IProject project = descriptor.getAdapter(IProject.class);
- workingCopy.setMappedResources(new IResource[] { project });
-
- // set the OS and ARCH
- String os = target.getAttribute(ILaunchTarget.ATTR_OS, EMPTY);
- workingCopy.setAttribute(ATTR_OS, os);
-
- String arch = target.getAttribute(ILaunchTarget.ATTR_ARCH, EMPTY);
- workingCopy.setAttribute(ATTR_ARCH, arch);
- }
-
- @Override
- public boolean launchConfigurationAdded(ILaunchConfiguration configuration) throws CoreException {
- // TODO make sure it's the correct type
- if (ownsLaunchConfiguration(configuration)) {
- IProject project = configuration.getMappedResources()[0].getProject();
- Map<String, ILaunchConfiguration> projectConfigs = configs.get(project);
- if (projectConfigs == null) {
- projectConfigs = new HashMap<>();
- configs.put(project, projectConfigs);
- }
-
- String os = configuration.getAttribute(ATTR_OS, EMPTY);
- String arch = configuration.getAttribute(ATTR_ARCH, EMPTY);
- String targetConfig = os + '.' + arch;
- projectConfigs.put(targetConfig, configuration);
- return true;
- }
- return false;
- }
-
- @Override
- public boolean launchConfigurationRemoved(ILaunchConfiguration configuration) throws CoreException {
- for (Entry<IProject, Map<String, ILaunchConfiguration>> projectEntry : configs.entrySet()) {
- Map<String, ILaunchConfiguration> projectConfigs = projectEntry.getValue();
- for (Entry<String, ILaunchConfiguration> entry : projectConfigs.entrySet()) {
- if (configuration.equals(entry.getValue())) {
- projectConfigs.remove(entry.getKey());
- if (projectConfigs.isEmpty()) {
- configs.remove(projectEntry.getKey());
- }
- return true;
- }
- }
- }
- return false;
- }
-
- @Override
- public boolean launchConfigurationChanged(ILaunchConfiguration configuration) throws CoreException {
- // nothing to do
- return false;
- }
-
- @Override
- public void launchDescriptorRemoved(ILaunchDescriptor descriptor) throws CoreException {
- IProject project = descriptor.getAdapter(IProject.class);
- if (project != null) {
- Map<String, ILaunchConfiguration> projectConfigs = configs.get(project);
- if (projectConfigs != null) {
- for (ILaunchConfiguration config : projectConfigs.values()) {
- config.delete();
- }
- }
- }
- }
-
- @Override
- public void launchTargetRemoved(ILaunchTarget target) throws CoreException {
- // Any other targets have the same OS and ARCH?
- String os = target.getAttribute(ILaunchTarget.ATTR_OS, EMPTY);
- String arch = target.getAttribute(ILaunchTarget.ATTR_ARCH, EMPTY);
-
- ILaunchTargetManager targetManager = CDebugCorePlugin.getService(ILaunchTargetManager.class);
- for (ILaunchTarget t : targetManager.getLaunchTargets()) {
- if (!target.equals(t) && os.equals(t.getAttribute(ILaunchTarget.ATTR_OS, EMPTY))
- && arch.equals(t.getAttribute(ILaunchTarget.ATTR_ARCH, EMPTY))) {
- // Yup, nothing to do then
- return;
- }
- }
-
- for (Entry<IProject, Map<String, ILaunchConfiguration>> projectEntry : configs.entrySet()) {
- Map<String, ILaunchConfiguration> projectConfigs = projectEntry.getValue();
- ILaunchConfiguration config = projectConfigs.get(os);
- if (config != null) {
- config.delete();
- }
- }
- }
-
-}
+package org.eclipse.cdt.debug.core.launch; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +import org.eclipse.cdt.debug.core.CDebugCorePlugin; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +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.launchbar.core.AbstractLaunchConfigProvider; +import org.eclipse.launchbar.core.ILaunchDescriptor; +import org.eclipse.launchbar.core.target.ILaunchTarget; +import org.eclipse.launchbar.core.target.ILaunchTargetManager; + +/** + * Core launch configuration provider used by generic target types. + * + * @since 8.3 + */ +public class CoreBuildGenericLaunchConfigProvider extends AbstractLaunchConfigProvider { + + private static final String ATTR_OS = CDebugCorePlugin.PLUGIN_ID + ".target_os"; //$NON-NLS-1$ + private static final String ATTR_ARCH = CDebugCorePlugin.PLUGIN_ID + ".target_arch"; //$NON-NLS-1$ + private static final String EMPTY = ""; //$NON-NLS-1$ + + private Map<IProject, Map<String, ILaunchConfiguration>> configs = new HashMap<>(); + + @Override + public boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException { + return target.getTypeId().equals(GenericTargetTypeProvider.TYPE_ID); + } + + @Override + public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target) + throws CoreException { + return DebugPlugin.getDefault().getLaunchManager() + .getLaunchConfigurationType(CoreBuildGenericLaunchConfigDelegate.TYPE_ID); + } + + @Override + public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target) + throws CoreException { + ILaunchConfiguration config = null; + IProject project = descriptor.getAdapter(IProject.class); + if (project != null) { + Map<String, ILaunchConfiguration> projectConfigs = configs.get(project); + if (projectConfigs == null) { + projectConfigs = new HashMap<>(); + configs.put(project, projectConfigs); + } + + String os = target.getAttribute(ILaunchTarget.ATTR_OS, EMPTY); + String arch = target.getAttribute(ILaunchTarget.ATTR_ARCH, EMPTY); + String targetConfig = os + '.' + arch; + config = projectConfigs.get(targetConfig); + if (config == null) { + config = createLaunchConfiguration(descriptor, target); + } + } + return config; + } + + @Override + protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target, + ILaunchConfigurationWorkingCopy workingCopy) throws CoreException { + super.populateLaunchConfiguration(descriptor, target, workingCopy); + + // Set the project + IProject project = descriptor.getAdapter(IProject.class); + workingCopy.setMappedResources(new IResource[] { project }); + + // set the OS and ARCH + String os = target.getAttribute(ILaunchTarget.ATTR_OS, EMPTY); + workingCopy.setAttribute(ATTR_OS, os); + + String arch = target.getAttribute(ILaunchTarget.ATTR_ARCH, EMPTY); + workingCopy.setAttribute(ATTR_ARCH, arch); + } + + @Override + public boolean launchConfigurationAdded(ILaunchConfiguration configuration) throws CoreException { + // TODO make sure it's the correct type + if (ownsLaunchConfiguration(configuration)) { + IProject project = configuration.getMappedResources()[0].getProject(); + Map<String, ILaunchConfiguration> projectConfigs = configs.get(project); + if (projectConfigs == null) { + projectConfigs = new HashMap<>(); + configs.put(project, projectConfigs); + } + + String os = configuration.getAttribute(ATTR_OS, EMPTY); + String arch = configuration.getAttribute(ATTR_ARCH, EMPTY); + String targetConfig = os + '.' + arch; + projectConfigs.put(targetConfig, configuration); + return true; + } + return false; + } + + @Override + public boolean launchConfigurationRemoved(ILaunchConfiguration configuration) throws CoreException { + for (Entry<IProject, Map<String, ILaunchConfiguration>> projectEntry : configs.entrySet()) { + Map<String, ILaunchConfiguration> projectConfigs = projectEntry.getValue(); + for (Entry<String, ILaunchConfiguration> entry : projectConfigs.entrySet()) { + if (configuration.equals(entry.getValue())) { + projectConfigs.remove(entry.getKey()); + if (projectConfigs.isEmpty()) { + configs.remove(projectEntry.getKey()); + } + return true; + } + } + } + return false; + } + + @Override + public boolean launchConfigurationChanged(ILaunchConfiguration configuration) throws CoreException { + // nothing to do + return false; + } + + @Override + public void launchDescriptorRemoved(ILaunchDescriptor descriptor) throws CoreException { + IProject project = descriptor.getAdapter(IProject.class); + if (project != null) { + Map<String, ILaunchConfiguration> projectConfigs = configs.get(project); + if (projectConfigs != null) { + for (ILaunchConfiguration config : projectConfigs.values()) { + config.delete(); + } + } + } + } + + @Override + public void launchTargetRemoved(ILaunchTarget target) throws CoreException { + // Any other targets have the same OS and ARCH? + String os = target.getAttribute(ILaunchTarget.ATTR_OS, EMPTY); + String arch = target.getAttribute(ILaunchTarget.ATTR_ARCH, EMPTY); + + ILaunchTargetManager targetManager = CDebugCorePlugin.getService(ILaunchTargetManager.class); + for (ILaunchTarget t : targetManager.getLaunchTargets()) { + if (!target.equals(t) && os.equals(t.getAttribute(ILaunchTarget.ATTR_OS, EMPTY)) + && arch.equals(t.getAttribute(ILaunchTarget.ATTR_ARCH, EMPTY))) { + // Yup, nothing to do then + return; + } + } + + for (Entry<IProject, Map<String, ILaunchConfiguration>> projectEntry : configs.entrySet()) { + Map<String, ILaunchConfiguration> projectConfigs = projectEntry.getValue(); + ILaunchConfiguration config = projectConfigs.get(os); + if (config != null) { + config.delete(); + } + } + } + +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/NullProcess.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/NullProcess.java index ca62c059340..bab959fbcd3 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/NullProcess.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/NullProcess.java @@ -1,107 +1,107 @@ -/*******************************************************************************
- * Copyright (c) 2017 QNX Software Systems and others.
- * 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
- *******************************************************************************/
-package org.eclipse.cdt.debug.core.launch;
-
-import java.io.IOException;
-
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.IStreamListener;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.debug.core.model.IStreamMonitor;
-import org.eclipse.debug.core.model.IStreamsProxy;
-
-/**
- * A simple process that only spits out a message then terminates.
- *
- * @since 8.3
- */
-public class NullProcess extends PlatformObject implements IProcess {
-
- private final String message;
- private final ILaunch launch;
-
- public NullProcess(ILaunch launch, String message) {
- this.launch = launch;
- this.message = message;
- }
-
- @Override
- public boolean canTerminate() {
- return true;
- }
-
- @Override
- public boolean isTerminated() {
- return true;
- }
-
- @Override
- public void terminate() throws DebugException {
- }
-
- @Override
- public String getLabel() {
- return launch.getLaunchConfiguration().getName();
- }
-
- @Override
- public ILaunch getLaunch() {
- return launch;
- }
-
- @Override
- public IStreamsProxy getStreamsProxy() {
- return new IStreamsProxy() {
- @Override
- public void write(String input) throws IOException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public IStreamMonitor getOutputStreamMonitor() {
- return new IStreamMonitor() {
- @Override
- public void removeListener(IStreamListener listener) {
- }
-
- @Override
- public String getContents() {
- return message;
- }
-
- @Override
- public void addListener(IStreamListener listener) {
- }
- };
- }
-
- @Override
- public IStreamMonitor getErrorStreamMonitor() {
- return null;
- }
- };
- }
-
- @Override
- public void setAttribute(String key, String value) {
- }
-
- @Override
- public String getAttribute(String key) {
- return null;
- }
-
- @Override
- public int getExitValue() throws DebugException {
- return 0;
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2017 QNX Software Systems and others. + * 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 + *******************************************************************************/ +package org.eclipse.cdt.debug.core.launch; + +import java.io.IOException; + +import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.IStreamListener; +import org.eclipse.debug.core.model.IProcess; +import org.eclipse.debug.core.model.IStreamMonitor; +import org.eclipse.debug.core.model.IStreamsProxy; + +/** + * A simple process that only spits out a message then terminates. + * + * @since 8.3 + */ +public class NullProcess extends PlatformObject implements IProcess { + + private final String message; + private final ILaunch launch; + + public NullProcess(ILaunch launch, String message) { + this.launch = launch; + this.message = message; + } + + @Override + public boolean canTerminate() { + return true; + } + + @Override + public boolean isTerminated() { + return true; + } + + @Override + public void terminate() throws DebugException { + } + + @Override + public String getLabel() { + return launch.getLaunchConfiguration().getName(); + } + + @Override + public ILaunch getLaunch() { + return launch; + } + + @Override + public IStreamsProxy getStreamsProxy() { + return new IStreamsProxy() { + @Override + public void write(String input) throws IOException { + // TODO Auto-generated method stub + + } + + @Override + public IStreamMonitor getOutputStreamMonitor() { + return new IStreamMonitor() { + @Override + public void removeListener(IStreamListener listener) { + } + + @Override + public String getContents() { + return message; + } + + @Override + public void addListener(IStreamListener listener) { + } + }; + } + + @Override + public IStreamMonitor getErrorStreamMonitor() { + return null; + } + }; + } + + @Override + public void setAttribute(String key, String value) { + } + + @Override + public String getAttribute(String key) { + return null; + } + + @Override + public int getExitValue() throws DebugException { + return 0; + } + +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/Messages.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/Messages.java index 7de4c1786fe..e72f4cb2ee7 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/Messages.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/Messages.java @@ -1,25 +1,25 @@ -/*******************************************************************************
- * Copyright (c) 2017 QNX Software Systems and others.
- * 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
- *******************************************************************************/
-package org.eclipse.cdt.debug.internal.core;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.core.messages"; //$NON-NLS-1$
- public static String CoreBuildGenericLaunchConfigDelegate_CommandNotValid;
- public static String CoreBuildGenericLaunchConfigDelegate_NoAction;
- public static String CoreBuildGenericLaunchConfigDelegate_SubstitutionFailed;
- public static String CoreBuildGenericLaunchConfigDelegate_WorkingDirNotExists;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
+/******************************************************************************* + * Copyright (c) 2017 QNX Software Systems and others. + * 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 + *******************************************************************************/ +package org.eclipse.cdt.debug.internal.core; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.core.messages"; //$NON-NLS-1$ + public static String CoreBuildGenericLaunchConfigDelegate_CommandNotValid; + public static String CoreBuildGenericLaunchConfigDelegate_NoAction; + public static String CoreBuildGenericLaunchConfigDelegate_SubstitutionFailed; + public static String CoreBuildGenericLaunchConfigDelegate_WorkingDirNotExists; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpointImportParticipant.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpointImportParticipant.java index 6d9037fef4d..995eb38c6f9 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpointImportParticipant.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpointImportParticipant.java @@ -1,164 +1,164 @@ -/*******************************************************************************
- * Copyright (c) 2015 Freescale Semiconductors and others.
- * 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:
- * Dan Ungureanu (Freescale Semiconductors) - Initial implementation
- *******************************************************************************/
-package org.eclipse.cdt.debug.internal.core.breakpoints;
-
-import java.util.Map;
-
-import org.eclipse.cdt.debug.core.model.ICBreakpoint;
-import org.eclipse.cdt.debug.core.model.ICEventBreakpoint;
-import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.model.IBreakpoint;
-import org.eclipse.debug.core.model.IBreakpointImportParticipant;
-
-/**
- * Initial implementation covering matching breakpoints at import for all platform C/C++ breakpoints
- */
-public class CBreakpointImportParticipant implements IBreakpointImportParticipant {
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.debug.core.model.IBreakpointImportParticipant#matches(java
- * .util.Map, org.eclipse.debug.core.model.IBreakpoint)
- */
- public boolean matches(Map<String, Object> attributes, IBreakpoint breakpoint)
- throws CoreException {
- if (attributes == null || breakpoint == null) {
- return false;
- }
- String type = (String) attributes.get("type"); //$NON-NLS-1$
- if (type == null) {
- return false;
- }
- if (!breakpoint.getMarker().getType().equals(type)) {
- return false;
- }
- if (breakpoint instanceof AbstractLineBreakpoint) {
- return matchesLineBreakpoint(attributes,
- (AbstractLineBreakpoint) breakpoint);
- }
- if (breakpoint instanceof AbstractTracepoint) {
- return matchesTracepoint(attributes,
- (AbstractTracepoint) breakpoint);
- }
- if (breakpoint instanceof CEventBreakpoint) {
- return matchesEventBreakpoint(attributes, (CEventBreakpoint) breakpoint);
- }
- if (breakpoint instanceof CWatchpoint) {
- return matchesWatchpoint(attributes, (CWatchpoint) breakpoint);
- }
- return false;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.debug.core.model.IBreakpointImportParticipant#verify(org.eclipse.debug.core.model.IBreakpoint)
- */
- @Override
- public void verify(IBreakpoint breakpoint) throws CoreException {}
-
-
- /**
- * Compares two attributes in a <code>null</code> safe way
- *
- * @param attr1
- * the first attribute
- * @param attr2
- * the second attribute
- * @return true if the attributes are equal, false otherwise. If both
- * attributes are <code>null</code> they are considered to be equal
- */
- private boolean attributesEqual(Object attr1, Object attr2) {
- if (attr1 == null) {
- return attr2 == null;
- }
- return attr1.equals(attr2);
- }
-
- /**
- * Returns if the given map of attributes matches the given breakpoint
- * Works for any breakpoint class that extends AbstractLineBreakpoint
- *
- * @param attributes
- * @param breakpoint
- * @return true if the attributes match the breakpoint's attributes, false
- * otherwise
- * @throws CoreException
- */
- private boolean matchesLineBreakpoint(Map<String, Object> attributes, AbstractLineBreakpoint breakpoint)
- throws CoreException {
- Integer line = (Integer) attributes.get(IMarker.LINE_NUMBER);
- int lineNumber = (line == null ? -1 : line.intValue());
- return breakpoint.getLineNumber() == lineNumber
- && attributesEqual(breakpoint.getType(), attributes.get(CBreakpoint.TYPE))
- && attributesEqual(breakpoint.getSourceHandle(), attributes.get(ICBreakpoint.SOURCE_HANDLE))
- && attributesEqual(breakpoint.getMarker().getAttribute(ICLineBreakpoint.ADDRESS), attributes.get(ICLineBreakpoint.ADDRESS))
- && attributesEqual(breakpoint.getMarker().getAttribute(ICLineBreakpoint.FUNCTION), attributes.get(ICLineBreakpoint.FUNCTION));
- }
-
- /**
- * Returns if the given map of attributes matches the given tracepoint
- * Works for any breakpoint class that extends AbstractTracepoint
- *
- * @param attributes
- * @param tracepoint
- * @return true if the attributes match the tracepoint's attributes, false
- * otherwise
- * @throws CoreException
- */
- private boolean matchesTracepoint(Map<String, Object> attributes, AbstractTracepoint tracepoint)
- throws CoreException {
- Integer line = (Integer) attributes.get(IMarker.LINE_NUMBER);
- int lineNumber = (line == null ? -1 : line.intValue());
- return tracepoint.getLineNumber() == lineNumber
- && attributesEqual(tracepoint.getType(), attributes.get(CBreakpoint.TYPE))
- && attributesEqual(tracepoint.getSourceHandle(), attributes.get(ICBreakpoint.SOURCE_HANDLE))
- && attributesEqual(tracepoint.getMarker().getAttribute(ICLineBreakpoint.ADDRESS), attributes.get(ICLineBreakpoint.ADDRESS))
- && attributesEqual(tracepoint.getMarker().getAttribute(ICLineBreakpoint.FUNCTION), attributes.get(ICLineBreakpoint.FUNCTION));
- }
-
- /**
- * Returns if the given map of attributes matches the given event breakpoint
- *
- * @param attributes
- * @param breakpoint
- * @return true if the attributes match the event breakpoint's attributes, false
- * otherwise
- * @throws CoreException
- */
- private boolean matchesEventBreakpoint(Map<String, Object> attributes, CEventBreakpoint breakpoint)
- throws CoreException {
- return breakpoint.getEventArgument().equals(
- attributes.get(ICEventBreakpoint.EVENT_ARG))
- && attributesEqual(breakpoint.getEventType(),
- attributes.get(ICEventBreakpoint.EVENT_TYPE_ID));
- }
-
- /**
- * Returns if the given map of attributes matches the given watchpoint
- *
- * @param attributes
- * @param breakpoint
- * @return true if the attributes match the watchpoint's attributes, false
- * otherwise
- * @throws CoreException
- */
- private boolean matchesWatchpoint(Map<String, Object> attributes, CWatchpoint watchpoint)
- throws CoreException {
- return watchpoint.getExpression().equals(
- attributes.get(CWatchpoint.EXPRESSION))
- && attributesEqual(watchpoint.getType(),
- attributes.get(CBreakpoint.TYPE));
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2015 Freescale Semiconductors and others. + * 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: + * Dan Ungureanu (Freescale Semiconductors) - Initial implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.internal.core.breakpoints; + +import java.util.Map; + +import org.eclipse.cdt.debug.core.model.ICBreakpoint; +import org.eclipse.cdt.debug.core.model.ICEventBreakpoint; +import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.model.IBreakpoint; +import org.eclipse.debug.core.model.IBreakpointImportParticipant; + +/** + * Initial implementation covering matching breakpoints at import for all platform C/C++ breakpoints + */ +public class CBreakpointImportParticipant implements IBreakpointImportParticipant { + /* + * (non-Javadoc) + * + * @see + * org.eclipse.debug.core.model.IBreakpointImportParticipant#matches(java + * .util.Map, org.eclipse.debug.core.model.IBreakpoint) + */ + public boolean matches(Map<String, Object> attributes, IBreakpoint breakpoint) + throws CoreException { + if (attributes == null || breakpoint == null) { + return false; + } + String type = (String) attributes.get("type"); //$NON-NLS-1$ + if (type == null) { + return false; + } + if (!breakpoint.getMarker().getType().equals(type)) { + return false; + } + if (breakpoint instanceof AbstractLineBreakpoint) { + return matchesLineBreakpoint(attributes, + (AbstractLineBreakpoint) breakpoint); + } + if (breakpoint instanceof AbstractTracepoint) { + return matchesTracepoint(attributes, + (AbstractTracepoint) breakpoint); + } + if (breakpoint instanceof CEventBreakpoint) { + return matchesEventBreakpoint(attributes, (CEventBreakpoint) breakpoint); + } + if (breakpoint instanceof CWatchpoint) { + return matchesWatchpoint(attributes, (CWatchpoint) breakpoint); + } + return false; + } + + /* + * (non-Javadoc) + * @see org.eclipse.debug.core.model.IBreakpointImportParticipant#verify(org.eclipse.debug.core.model.IBreakpoint) + */ + @Override + public void verify(IBreakpoint breakpoint) throws CoreException {} + + + /** + * Compares two attributes in a <code>null</code> safe way + * + * @param attr1 + * the first attribute + * @param attr2 + * the second attribute + * @return true if the attributes are equal, false otherwise. If both + * attributes are <code>null</code> they are considered to be equal + */ + private boolean attributesEqual(Object attr1, Object attr2) { + if (attr1 == null) { + return attr2 == null; + } + return attr1.equals(attr2); + } + + /** + * Returns if the given map of attributes matches the given breakpoint + * Works for any breakpoint class that extends AbstractLineBreakpoint + * + * @param attributes + * @param breakpoint + * @return true if the attributes match the breakpoint's attributes, false + * otherwise + * @throws CoreException + */ + private boolean matchesLineBreakpoint(Map<String, Object> attributes, AbstractLineBreakpoint breakpoint) + throws CoreException { + Integer line = (Integer) attributes.get(IMarker.LINE_NUMBER); + int lineNumber = (line == null ? -1 : line.intValue()); + return breakpoint.getLineNumber() == lineNumber + && attributesEqual(breakpoint.getType(), attributes.get(CBreakpoint.TYPE)) + && attributesEqual(breakpoint.getSourceHandle(), attributes.get(ICBreakpoint.SOURCE_HANDLE)) + && attributesEqual(breakpoint.getMarker().getAttribute(ICLineBreakpoint.ADDRESS), attributes.get(ICLineBreakpoint.ADDRESS)) + && attributesEqual(breakpoint.getMarker().getAttribute(ICLineBreakpoint.FUNCTION), attributes.get(ICLineBreakpoint.FUNCTION)); + } + + /** + * Returns if the given map of attributes matches the given tracepoint + * Works for any breakpoint class that extends AbstractTracepoint + * + * @param attributes + * @param tracepoint + * @return true if the attributes match the tracepoint's attributes, false + * otherwise + * @throws CoreException + */ + private boolean matchesTracepoint(Map<String, Object> attributes, AbstractTracepoint tracepoint) + throws CoreException { + Integer line = (Integer) attributes.get(IMarker.LINE_NUMBER); + int lineNumber = (line == null ? -1 : line.intValue()); + return tracepoint.getLineNumber() == lineNumber + && attributesEqual(tracepoint.getType(), attributes.get(CBreakpoint.TYPE)) + && attributesEqual(tracepoint.getSourceHandle(), attributes.get(ICBreakpoint.SOURCE_HANDLE)) + && attributesEqual(tracepoint.getMarker().getAttribute(ICLineBreakpoint.ADDRESS), attributes.get(ICLineBreakpoint.ADDRESS)) + && attributesEqual(tracepoint.getMarker().getAttribute(ICLineBreakpoint.FUNCTION), attributes.get(ICLineBreakpoint.FUNCTION)); + } + + /** + * Returns if the given map of attributes matches the given event breakpoint + * + * @param attributes + * @param breakpoint + * @return true if the attributes match the event breakpoint's attributes, false + * otherwise + * @throws CoreException + */ + private boolean matchesEventBreakpoint(Map<String, Object> attributes, CEventBreakpoint breakpoint) + throws CoreException { + return breakpoint.getEventArgument().equals( + attributes.get(ICEventBreakpoint.EVENT_ARG)) + && attributesEqual(breakpoint.getEventType(), + attributes.get(ICEventBreakpoint.EVENT_TYPE_ID)); + } + + /** + * Returns if the given map of attributes matches the given watchpoint + * + * @param attributes + * @param breakpoint + * @return true if the attributes match the watchpoint's attributes, false + * otherwise + * @throws CoreException + */ + private boolean matchesWatchpoint(Map<String, Object> attributes, CWatchpoint watchpoint) + throws CoreException { + return watchpoint.getExpression().equals( + attributes.get(CWatchpoint.EXPRESSION)) + && attributesEqual(watchpoint.getType(), + attributes.get(CBreakpoint.TYPE)); + } + +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/messages.properties b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/messages.properties index c00aff78954..387004aeef9 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/messages.properties +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/messages.properties @@ -1,11 +1,11 @@ -###############################################################################
-# Copyright (c) 2003, 2010 QNX Software Systems and others.
-# 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
-###############################################################################
-CoreBuildGenericLaunchConfigDelegate_CommandNotValid=Not a valid command "%s"
-CoreBuildGenericLaunchConfigDelegate_NoAction=No action specified. Skipping.
-CoreBuildGenericLaunchConfigDelegate_SubstitutionFailed=Variable substitution failed "%s"
-CoreBuildGenericLaunchConfigDelegate_WorkingDirNotExists=Working directory %s does not exist
+############################################################################### +# Copyright (c) 2003, 2010 QNX Software Systems and others. +# 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 +############################################################################### +CoreBuildGenericLaunchConfigDelegate_CommandNotValid=Not a valid command "%s" +CoreBuildGenericLaunchConfigDelegate_NoAction=No action specified. Skipping. +CoreBuildGenericLaunchConfigDelegate_SubstitutionFailed=Variable substitution failed "%s" +CoreBuildGenericLaunchConfigDelegate_WorkingDirNotExists=Working directory %s does not exist diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/StringSetSerializer.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/StringSetSerializer.java index fd8c60fea3e..42da492c9ba 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/StringSetSerializer.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/StringSetSerializer.java @@ -1,55 +1,55 @@ -/*******************************************************************************
- * Copyright (c) 2006, 2016 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
+/******************************************************************************* + * Copyright (c) 2006, 2016 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.preferences;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.Assert;
-
-public final class StringSetSerializer {
- private static final String DELIM= "\0"; //$NON-NLS-1$
- private StringSetSerializer() {
- }
-
- public static String serialize(Set<String> strings) {
- Assert.isLegal(strings != null);
- StringBuilder buf= new StringBuilder(strings.size() * 20);
- for (Iterator<String> it= strings.iterator(); it.hasNext();) {
- buf.append(it.next());
- if (it.hasNext())
- buf.append(DELIM);
- }
- return buf.toString();
- }
-
- public static Set<String> deserialize(String serialized) {
- Assert.isLegal(serialized != null);
- Set<String> marked= new HashSet<String>();
- StringTokenizer tok= new StringTokenizer(serialized, DELIM);
- while (tok.hasMoreTokens())
- marked.add(tok.nextToken());
- return marked;
- }
-
- public static String[] getDifference(String oldValue, String newValue) {
- Set<String> oldSet= deserialize(oldValue);
- Set<String> newSet= deserialize(newValue);
- Set<String> intersection= new HashSet<String>(oldSet);
- intersection.retainAll(newSet);
- oldSet.removeAll(intersection);
- newSet.removeAll(intersection);
- oldSet.addAll(newSet);
- return oldSet.toArray(new String[oldSet.size()]);
- }
-}
+package org.eclipse.cdt.debug.internal.ui.preferences; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import java.util.StringTokenizer; + +import org.eclipse.core.runtime.Assert; + +public final class StringSetSerializer { + private static final String DELIM= "\0"; //$NON-NLS-1$ + private StringSetSerializer() { + } + + public static String serialize(Set<String> strings) { + Assert.isLegal(strings != null); + StringBuilder buf= new StringBuilder(strings.size() * 20); + for (Iterator<String> it= strings.iterator(); it.hasNext();) { + buf.append(it.next()); + if (it.hasNext()) + buf.append(DELIM); + } + return buf.toString(); + } + + public static Set<String> deserialize(String serialized) { + Assert.isLegal(serialized != null); + Set<String> marked= new HashSet<String>(); + StringTokenizer tok= new StringTokenizer(serialized, DELIM); + while (tok.hasMoreTokens()) + marked.add(tok.nextToken()); + return marked; + } + + public static String[] getDifference(String oldValue, String newValue) { + Set<String> oldSet= deserialize(oldValue); + Set<String> newSet= deserialize(newValue); + Set<String> intersection= new HashSet<String>(oldSet); + intersection.retainAll(newSet); + oldSet.removeAll(intersection); + newSet.removeAll(intersection); + oldSet.addAll(newSet); + return oldSet.toArray(new String[oldSet.size()]); + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandAction.java index f5b11815764..3fed228efb2 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandAction.java @@ -1,124 +1,124 @@ -/*******************************************************************************
- * Copyright (c) 2016 QNX Software Systems and others.
- * 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:
- * Alena Laskavaia (QNX)- Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.debug.ui.breakpointactions;
-
-import java.text.MessageFormat;
-
-import org.eclipse.cdt.debug.core.CDIDebugModel;
-import org.eclipse.cdt.debug.core.breakpointactions.AbstractBreakpointAction;
-import org.eclipse.cdt.debug.core.breakpointactions.ICLIDebugActionEnabler;
-import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
-import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
-import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.model.IBreakpoint;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * This breakpoint action allows to pass arbitrary command line command to debugger backend.
- * For example in case of gdb it would be something like
- * p myGlobal
- * cont
- * @since 8.0
- */
-public class CLICommandAction extends AbstractBreakpointAction {
- private static final String COMMAND_ATT = "command"; //$NON-NLS-1$
- private String command = ""; //$NON-NLS-1$
-
- @Override
- public IStatus execute(IBreakpoint breakpoint, IAdaptable context, IProgressMonitor monitor) {
- ICLIDebugActionEnabler enabler = context.getAdapter(ICLIDebugActionEnabler.class);
- if (enabler != null) {
- try {
- enabler.execute(getCommand());
- } catch (Exception e) {
- return errorStatus(e);
- }
- } else
- return new Status(IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(),
- IInternalCDebugUIConstants.INTERNAL_ERROR,
- Messages.getString("CLICommandAction.NoSupport"), null); //$NON-NLS-1$
- return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
- }
-
- private IStatus errorStatus(Exception ex) {
- String errorMsg = MessageFormat.format(Messages.getString("CLICommandAction.error.0"), //$NON-NLS-1$
- new Object[] { getSummary() });
- return new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(),
- ICDebugInternalConstants.STATUS_CODE_ERROR, errorMsg, ex);
- }
-
- @Override
- public String getDefaultName() {
- return Messages.getString("CLICommandAction.UntitledName"); //$NON-NLS-1$
- }
-
- @Override
- public String getIdentifier() {
- return "org.eclipse.cdt.debug.ui.breakpointactions.CLICommandAction"; //$NON-NLS-1$
- }
-
- @Override
- public String getMemento() {
- try {
- Document doc = DebugPlugin.newDocument();
- Element rootElement = doc.createElement(COMMAND_ATT);
- rootElement.setAttribute(COMMAND_ATT, command);
- doc.appendChild(rootElement);
- return DebugPlugin.serializeDocument(doc);
- } catch (DOMException | CoreException e) {
- CDebugUIPlugin.log(e);
-
- }
- return ""; //$NON-NLS-1$
- }
-
- public String getCommand() {
- return command;
- }
-
- public void setCommand(String command) {
- this.command = command;
- }
-
- @Override
- public String getSummary() {
- String summary = getCommand();
- if (summary.length() > 32)
- summary = summary.substring(0, 32);
- return summary;
- }
-
- @Override
- public String getTypeName() {
- return Messages.getString("CLICommandAction.TypeName"); //$NON-NLS-1$
- }
-
- @Override
- public void initializeFromMemento(String data) {
- try {
- Element root = DebugPlugin.parseDocument(data);
- String value = root.getAttribute(COMMAND_ATT);
- if (value == null)
- value = ""; //$NON-NLS-1$
- command = value;
- } catch (Exception e) {
- CDebugUIPlugin.log(e);
- }
- }
-}
+/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. + * 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: + * Alena Laskavaia (QNX)- Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +import java.text.MessageFormat; + +import org.eclipse.cdt.debug.core.CDIDebugModel; +import org.eclipse.cdt.debug.core.breakpointactions.AbstractBreakpointAction; +import org.eclipse.cdt.debug.core.breakpointactions.ICLIDebugActionEnabler; +import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants; +import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants; +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.model.IBreakpoint; +import org.w3c.dom.DOMException; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +/** + * This breakpoint action allows to pass arbitrary command line command to debugger backend. + * For example in case of gdb it would be something like + * p myGlobal + * cont + * @since 8.0 + */ +public class CLICommandAction extends AbstractBreakpointAction { + private static final String COMMAND_ATT = "command"; //$NON-NLS-1$ + private String command = ""; //$NON-NLS-1$ + + @Override + public IStatus execute(IBreakpoint breakpoint, IAdaptable context, IProgressMonitor monitor) { + ICLIDebugActionEnabler enabler = context.getAdapter(ICLIDebugActionEnabler.class); + if (enabler != null) { + try { + enabler.execute(getCommand()); + } catch (Exception e) { + return errorStatus(e); + } + } else + return new Status(IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), + IInternalCDebugUIConstants.INTERNAL_ERROR, + Messages.getString("CLICommandAction.NoSupport"), null); //$NON-NLS-1$ + return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS; + } + + private IStatus errorStatus(Exception ex) { + String errorMsg = MessageFormat.format(Messages.getString("CLICommandAction.error.0"), //$NON-NLS-1$ + new Object[] { getSummary() }); + return new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, errorMsg, ex); + } + + @Override + public String getDefaultName() { + return Messages.getString("CLICommandAction.UntitledName"); //$NON-NLS-1$ + } + + @Override + public String getIdentifier() { + return "org.eclipse.cdt.debug.ui.breakpointactions.CLICommandAction"; //$NON-NLS-1$ + } + + @Override + public String getMemento() { + try { + Document doc = DebugPlugin.newDocument(); + Element rootElement = doc.createElement(COMMAND_ATT); + rootElement.setAttribute(COMMAND_ATT, command); + doc.appendChild(rootElement); + return DebugPlugin.serializeDocument(doc); + } catch (DOMException | CoreException e) { + CDebugUIPlugin.log(e); + + } + return ""; //$NON-NLS-1$ + } + + public String getCommand() { + return command; + } + + public void setCommand(String command) { + this.command = command; + } + + @Override + public String getSummary() { + String summary = getCommand(); + if (summary.length() > 32) + summary = summary.substring(0, 32); + return summary; + } + + @Override + public String getTypeName() { + return Messages.getString("CLICommandAction.TypeName"); //$NON-NLS-1$ + } + + @Override + public void initializeFromMemento(String data) { + try { + Element root = DebugPlugin.parseDocument(data); + String value = root.getAttribute(COMMAND_ATT); + if (value == null) + value = ""; //$NON-NLS-1$ + command = value; + } catch (Exception e) { + CDebugUIPlugin.log(e); + } + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandActionComposite.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandActionComposite.java index 2ee432bc6ba..663a233cfa3 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandActionComposite.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandActionComposite.java @@ -1,43 +1,43 @@ -/*******************************************************************************
- * Copyright (c) 2016 QNX Software Systems and others.
- * 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:
- * Alena Laskavaia (QNX)- Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.debug.ui.breakpointactions;
-
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * This composite show a little text field (multi-line) that allow to enter to enter debugger commands.
- * Interpretation of that depends on the backend
- *
- * @since 8.0
- */
-public class CLICommandActionComposite extends Composite {
- private Text command;
-
- public CLICommandActionComposite(Composite parent, int style, CLICommandActionPage commandActionPage) {
- super(parent, style);
- setLayout(GridLayoutFactory.fillDefaults().create());
- Label messageToLogLabel = new Label(this, SWT.NONE);
- messageToLogLabel.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
- messageToLogLabel.setText(Messages.getString("CLICommandActionComposite.0")); //$NON-NLS-1$
- command = new Text(this, SWT.BORDER | SWT.WRAP);
- command.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
- command.setText(commandActionPage.getCLICommandAction().getCommand());
- }
-
- public String getCommand() {
- return command.getText();
- }
-}
+/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. + * 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: + * Alena Laskavaia (QNX)- Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.layout.GridLayoutFactory; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +/** + * This composite show a little text field (multi-line) that allow to enter to enter debugger commands. + * Interpretation of that depends on the backend + * + * @since 8.0 + */ +public class CLICommandActionComposite extends Composite { + private Text command; + + public CLICommandActionComposite(Composite parent, int style, CLICommandActionPage commandActionPage) { + super(parent, style); + setLayout(GridLayoutFactory.fillDefaults().create()); + Label messageToLogLabel = new Label(this, SWT.NONE); + messageToLogLabel.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); + messageToLogLabel.setText(Messages.getString("CLICommandActionComposite.0")); //$NON-NLS-1$ + command = new Text(this, SWT.BORDER | SWT.WRAP); + command.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); + command.setText(commandActionPage.getCLICommandAction().getCommand()); + } + + public String getCommand() { + return command.getText(); + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandActionPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandActionPage.java index 7b6d606a89a..0979ac5cfa8 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandActionPage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandActionPage.java @@ -1,45 +1,45 @@ -/*******************************************************************************
- * Copyright (c) 2016 QNX Software Systems and others.
- * 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:
- * Alena Laskavaia (QNX)- Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.debug.ui.breakpointactions;
-
-import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction;
-import org.eclipse.cdt.debug.ui.breakpointactions.IBreakpointActionPage;
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @since 8.0
- */
-public class CLICommandActionPage extends PlatformObject implements
- IBreakpointActionPage {
- private CLICommandAction cliCommandAction;
- private CLICommandActionComposite editor;
-
- public CLICommandAction getCLICommandAction() {
- return cliCommandAction;
- }
-
- @Override
- public void actionDialogCanceled() {
- }
-
- @Override
- public void actionDialogOK() {
- cliCommandAction.setCommand(editor.getCommand());
- }
-
- @Override
- public Composite createComposite(IBreakpointAction action, Composite composite, int style) {
- cliCommandAction = (CLICommandAction) action;
- editor = new CLICommandActionComposite(composite, style, this);
- return editor;
- }
-}
+/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. + * 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: + * Alena Laskavaia (QNX)- Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction; +import org.eclipse.cdt.debug.ui.breakpointactions.IBreakpointActionPage; +import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.swt.widgets.Composite; + +/** + * @since 8.0 + */ +public class CLICommandActionPage extends PlatformObject implements + IBreakpointActionPage { + private CLICommandAction cliCommandAction; + private CLICommandActionComposite editor; + + public CLICommandAction getCLICommandAction() { + return cliCommandAction; + } + + @Override + public void actionDialogCanceled() { + } + + @Override + public void actionDialogOK() { + cliCommandAction.setCommand(editor.getCommand()); + } + + @Override + public Composite createComposite(IBreakpointAction action, Composite composite, int style) { + cliCommandAction = (CLICommandAction) action; + editor = new CLICommandActionComposite(composite, style, this); + return editor; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/IBreakpointActionPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/IBreakpointActionPage.java index f89419a0a6b..3bf7ffdd881 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/IBreakpointActionPage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/IBreakpointActionPage.java @@ -1,32 +1,32 @@ -/*******************************************************************************
- * Copyright (c) 2007 Nokia and others.
- * 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:
- * Nokia - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.debug.ui.breakpointactions;
-
-import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- *
- * THIS INTERFACE IS PROVISIONAL AND WILL CHANGE IN THE FUTURE
- * PLUG-INS USING THIS INTERFACE WILL NEED
- * TO BE REVISED TO WORK WITH FUTURE VERSIONS OF CDT.
- *
- */
-
-public interface IBreakpointActionPage {
-
- public void actionDialogCanceled();
-
- public void actionDialogOK();
-
- public Composite createComposite(IBreakpointAction action, Composite composite, int style);
-
-}
+/******************************************************************************* + * Copyright (c) 2007 Nokia and others. + * 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: + * Nokia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction; +import org.eclipse.swt.widgets.Composite; + +/** + * + * THIS INTERFACE IS PROVISIONAL AND WILL CHANGE IN THE FUTURE + * PLUG-INS USING THIS INTERFACE WILL NEED + * TO BE REVISED TO WORK WITH FUTURE VERSIONS OF CDT. + * + */ + +public interface IBreakpointActionPage { + + public void actionDialogCanceled(); + + public void actionDialogOK(); + + public Composite createComposite(IBreakpointAction action, Composite composite, int style); + +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogActionComposite.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogActionComposite.java index 031b30979e7..63d922cc8db 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogActionComposite.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogActionComposite.java @@ -1,75 +1,75 @@ -/*******************************************************************************
- * Copyright (c) 2007, 2012 Nokia and others.
- * 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:
- * Nokia - initial API and implementation
+/******************************************************************************* + * Copyright (c) 2007, 2012 Nokia and others. + * 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: + * Nokia - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.ui.breakpointactions;
-
-import org.eclipse.swt.SWT;
-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.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-public class LogActionComposite extends Composite {
-
- private Button expressionButton;
- private LogActionPage logActionPage;
- private Text message;
-
- public LogActionComposite(Composite parent, int style, LogActionPage logActionPage) {
- super(parent, style);
- final GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 2;
- setLayout(gridLayout);
-
- this.logActionPage = logActionPage;
-
- final Label messageToLogLabel = new Label(this, SWT.NONE);
- messageToLogLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 2, 1));
- messageToLogLabel.setText(Messages.getString("LogActionComposite.0")); //$NON-NLS-1$
-
- message = new Text(this, SWT.BORDER | SWT.WRAP);
- message.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1));
-
- expressionButton = new Button(this, SWT.CHECK);
- expressionButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(final SelectionEvent e) {
- }
- });
- expressionButton.setText(Messages.getString("LogActionComposite.1")); //$NON-NLS-1$
- //
-
- message.setText(this.logActionPage.getLogAction().getMessage());
- expressionButton.setSelection(this.logActionPage.getLogAction().isEvaluateExpression());
- }
-
- @Override
- protected void checkSubclass() {
- // Disable the check that prevents subclassing of SWT components
- }
-
- @Override
- public void dispose() {
- super.dispose();
- }
-
- public boolean getIsExpression() {
- return expressionButton.getSelection();
- }
-
- public String getMessage() {
- return message.getText();
- }
-
-}
+package org.eclipse.cdt.debug.ui.breakpointactions; + +import org.eclipse.swt.SWT; +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.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +public class LogActionComposite extends Composite { + + private Button expressionButton; + private LogActionPage logActionPage; + private Text message; + + public LogActionComposite(Composite parent, int style, LogActionPage logActionPage) { + super(parent, style); + final GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 2; + setLayout(gridLayout); + + this.logActionPage = logActionPage; + + final Label messageToLogLabel = new Label(this, SWT.NONE); + messageToLogLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 2, 1)); + messageToLogLabel.setText(Messages.getString("LogActionComposite.0")); //$NON-NLS-1$ + + message = new Text(this, SWT.BORDER | SWT.WRAP); + message.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1)); + + expressionButton = new Button(this, SWT.CHECK); + expressionButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(final SelectionEvent e) { + } + }); + expressionButton.setText(Messages.getString("LogActionComposite.1")); //$NON-NLS-1$ + // + + message.setText(this.logActionPage.getLogAction().getMessage()); + expressionButton.setSelection(this.logActionPage.getLogAction().isEvaluateExpression()); + } + + @Override + protected void checkSubclass() { + // Disable the check that prevents subclassing of SWT components + } + + @Override + public void dispose() { + super.dispose(); + } + + public boolean getIsExpression() { + return expressionButton.getSelection(); + } + + public String getMessage() { + return message.getText(); + } + +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/Messages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/Messages.java index 13dc00cafd6..24261cf6841 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/Messages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/Messages.java @@ -1,32 +1,32 @@ -/*******************************************************************************
- * Copyright (c) 2007 Nokia and others.
- * 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:
- * Nokia - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.debug.ui.breakpointactions;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class Messages {
- private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.ui.breakpointactions.messages"; //$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
-
- private Messages() {
- }
-
- public static String getString(String key) {
- // TODO Auto-generated method stub
- try {
- return RESOURCE_BUNDLE.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-}
+/******************************************************************************* + * Copyright (c) 2007 Nokia and others. + * 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: + * Nokia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class Messages { + private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.ui.breakpointactions.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); + + private Messages() { + } + + public static String getString(String key) { + // TODO Auto-generated method stub + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceConstants.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceConstants.java index 96a77c8e18f..e77ec1105dc 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceConstants.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceConstants.java @@ -1,26 +1,26 @@ -/*******************************************************************************
- * Copyright (c) 2007 Nokia and others.
- * 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:
- * Nokia - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.debug.ui.breakpointactions;
-
-/**
- * Constant definitions for plug-in preferences
- */
-public class PreferenceConstants {
-
- public static final String P_PATH = "pathPreference"; //$NON-NLS-1$
-
- public static final String P_BOOLEAN = "booleanPreference"; //$NON-NLS-1$
-
- public static final String P_CHOICE = "choicePreference"; //$NON-NLS-1$
-
- public static final String P_STRING = "stringPreference"; //$NON-NLS-1$
-
-}
+/******************************************************************************* + * Copyright (c) 2007 Nokia and others. + * 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: + * Nokia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +/** + * Constant definitions for plug-in preferences + */ +public class PreferenceConstants { + + public static final String P_PATH = "pathPreference"; //$NON-NLS-1$ + + public static final String P_BOOLEAN = "booleanPreference"; //$NON-NLS-1$ + + public static final String P_CHOICE = "choicePreference"; //$NON-NLS-1$ + + public static final String P_STRING = "stringPreference"; //$NON-NLS-1$ + +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceInitializer.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceInitializer.java index a87093be472..d6a717a5e3e 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceInitializer.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceInitializer.java @@ -1,35 +1,35 @@ -/*******************************************************************************
- * Copyright (c) 2007, 2012 Nokia and others.
- * 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:
- * Nokia - initial API and implementation
+/******************************************************************************* + * Copyright (c) 2007, 2012 Nokia and others. + * 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: + * Nokia - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.ui.breakpointactions;
-
-import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
-import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
-import org.eclipse.jface.preference.IPreferenceStore;
-
-/**
- * Class used to initialize default preference values.
- */
-public class PreferenceInitializer extends AbstractPreferenceInitializer {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
- */
- @Override
- public void initializeDefaultPreferences() {
- IPreferenceStore store = CDebugUIPlugin.getDefault().getPreferenceStore();
- store.setDefault(PreferenceConstants.P_BOOLEAN, true);
- store.setDefault(PreferenceConstants.P_CHOICE, "choice2"); //$NON-NLS-1$
- store.setDefault(PreferenceConstants.P_STRING, Messages.getString("PreferenceInitializer.1")); //$NON-NLS-1$
- }
-
-}
+package org.eclipse.cdt.debug.ui.breakpointactions; + +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; + +/** + * Class used to initialize default preference values. + */ +public class PreferenceInitializer extends AbstractPreferenceInitializer { + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() + */ + @Override + public void initializeDefaultPreferences() { + IPreferenceStore store = CDebugUIPlugin.getDefault().getPreferenceStore(); + store.setDefault(PreferenceConstants.P_BOOLEAN, true); + store.setDefault(PreferenceConstants.P_CHOICE, "choice2"); //$NON-NLS-1$ + store.setDefault(PreferenceConstants.P_STRING, Messages.getString("PreferenceInitializer.1")); //$NON-NLS-1$ + } + +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionComposite.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionComposite.java index 5c44796655e..59685c2b9a5 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionComposite.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionComposite.java @@ -1,178 +1,178 @@ -/*******************************************************************************
- * Copyright (c) 2007, 2012 Nokia and others.
- * 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:
- * Nokia - initial API and implementation
+/******************************************************************************* + * Copyright (c) 2007, 2012 Nokia and others. + * 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: + * Nokia - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.ui.breakpointactions;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-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.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-
-public class SoundActionComposite extends Composite {
-
- private static final String[] soundFileExtensions = new String[] { "*.wav", "*.mid", "*.au", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "*.aiff" }; //$NON-NLS-1$
-
- private Combo combo_1;
- private ModifyListener comboModifyListener = null;
- private File selectedSoundFile = null;
- private SoundActionPage soundActionPage;
- private Label soundFilePathLabel;
- private Button tryItButton;
-
- /**
- * Create the composite
- *
- * @param parent
- * @param style
- * @param page
- */
- public SoundActionComposite(Composite parent, int style, SoundActionPage page) {
- super(parent, style);
- soundActionPage = page;
- final GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 2;
- setLayout(gridLayout);
-
- final Label playSoundLabel = new Label(this, SWT.NONE);
- playSoundLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
- playSoundLabel.setText(Messages.getString("SoundActionComposite.4")); //$NON-NLS-1$
-
- combo_1 = new Combo(this, SWT.READ_ONLY);
- final GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
- combo_1.setLayoutData(gridData);
-
- comboModifyListener = new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- if (combo_1.getText().length() > 0) {
- String filePath = combo_1.getText();
- File soundFile = new File(filePath);
- if (soundFile.exists()) {
- soundFilePathLabel.setText(filePath);
- tryItButton.setEnabled(true);
- selectedSoundFile = soundFile;
- } else {
- soundFilePathLabel.setText(Messages.getString("SoundActionComposite.9")); //$NON-NLS-1$
- tryItButton.setEnabled(false);
- }
- }
- }
- };
- rebuildRecentSoundsCombo();
- combo_1.addModifyListener(comboModifyListener);
-
- final String mediaPath = page.getMediaPath();
-
- final Button browseButton = new Button(this, SWT.NONE);
- browseButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
- dialog.setText(Messages.getString("SoundActionComposite.5")); //$NON-NLS-1$
- dialog.setFilterExtensions(soundFileExtensions);
- if (mediaPath.length() > 0)
- dialog.setFilterPath(mediaPath);
-
- String res = dialog.open();
- if (res != null) {
- setSoundFile(res);
- }
- }
- });
- browseButton.setText(Messages.getString("SoundActionComposite.6")); //$NON-NLS-1$
-
- tryItButton = new Button(this, SWT.NONE);
- tryItButton.setLayoutData(new GridData());
- tryItButton.setText(Messages.getString("SoundActionComposite.7")); //$NON-NLS-1$
- tryItButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- File soundFile = new File(soundFilePathLabel.getText());
- playSoundFile(soundFile);
- }
- });
-
- soundFilePathLabel = new Label(this, SWT.NONE);
- final GridData gridData_1 = new GridData(GridData.FILL_HORIZONTAL);
- gridData_1.horizontalSpan = 2;
- soundFilePathLabel.setLayoutData(gridData_1);
- soundFilePathLabel.setText(""); //$NON-NLS-1$
-
- //
- if (soundActionPage.getSoundAction().getSoundFile() != null)
- setSoundFile(soundActionPage.getSoundAction().getSoundFile().getAbsolutePath());
- }
-
- private void addRecentSound(File soundFile) {
- soundActionPage.addRecentSound(soundFile);
- rebuildRecentSoundsCombo();
- }
-
- @Override
- protected void checkSubclass() {
- // Disable the check that prevents subclassing of SWT components
- }
-
- @Override
- public void dispose() {
- super.dispose();
- }
-
- public File getSoundFile() {
- return selectedSoundFile;
- }
-
- protected void playSoundFile(File soundFile) {
- SoundAction.playSoundFile(soundFile);
- }
-
- private void rebuildRecentSoundsCombo() {
- combo_1.removeAll();
-
- ArrayList<File> sortedSounds = new ArrayList<File>(soundActionPage.getRecentSounds());
- Collections.sort(sortedSounds);
-
- for (Iterator<File> iter = sortedSounds.iterator(); iter.hasNext();) {
- File element = iter.next();
- combo_1.add(element.getAbsolutePath());
- }
- }
-
- private void setSoundFile(String filePath) {
- combo_1.removeModifyListener(comboModifyListener);
- File soundFile = new File(filePath);
- if (soundFile.exists()) {
- addRecentSound(soundFile);
- combo_1.setText(soundFile.getAbsolutePath());
- soundFilePathLabel.setText(filePath);
- tryItButton.setEnabled(true);
- selectedSoundFile = soundFile;
- } else {
- soundFilePathLabel.setText(Messages.getString("SoundActionComposite.9")); //$NON-NLS-1$
- tryItButton.setEnabled(false);
- }
- combo_1.addModifyListener(comboModifyListener);
- }
-
-}
+package org.eclipse.cdt.debug.ui.breakpointactions; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +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.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; + +public class SoundActionComposite extends Composite { + + private static final String[] soundFileExtensions = new String[] { "*.wav", "*.mid", "*.au", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + "*.aiff" }; //$NON-NLS-1$ + + private Combo combo_1; + private ModifyListener comboModifyListener = null; + private File selectedSoundFile = null; + private SoundActionPage soundActionPage; + private Label soundFilePathLabel; + private Button tryItButton; + + /** + * Create the composite + * + * @param parent + * @param style + * @param page + */ + public SoundActionComposite(Composite parent, int style, SoundActionPage page) { + super(parent, style); + soundActionPage = page; + final GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 2; + setLayout(gridLayout); + + final Label playSoundLabel = new Label(this, SWT.NONE); + playSoundLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); + playSoundLabel.setText(Messages.getString("SoundActionComposite.4")); //$NON-NLS-1$ + + combo_1 = new Combo(this, SWT.READ_ONLY); + final GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); + combo_1.setLayoutData(gridData); + + comboModifyListener = new ModifyListener() { + @Override + public void modifyText(ModifyEvent e) { + if (combo_1.getText().length() > 0) { + String filePath = combo_1.getText(); + File soundFile = new File(filePath); + if (soundFile.exists()) { + soundFilePathLabel.setText(filePath); + tryItButton.setEnabled(true); + selectedSoundFile = soundFile; + } else { + soundFilePathLabel.setText(Messages.getString("SoundActionComposite.9")); //$NON-NLS-1$ + tryItButton.setEnabled(false); + } + } + } + }; + rebuildRecentSoundsCombo(); + combo_1.addModifyListener(comboModifyListener); + + final String mediaPath = page.getMediaPath(); + + final Button browseButton = new Button(this, SWT.NONE); + browseButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(getShell(), SWT.NONE); + dialog.setText(Messages.getString("SoundActionComposite.5")); //$NON-NLS-1$ + dialog.setFilterExtensions(soundFileExtensions); + if (mediaPath.length() > 0) + dialog.setFilterPath(mediaPath); + + String res = dialog.open(); + if (res != null) { + setSoundFile(res); + } + } + }); + browseButton.setText(Messages.getString("SoundActionComposite.6")); //$NON-NLS-1$ + + tryItButton = new Button(this, SWT.NONE); + tryItButton.setLayoutData(new GridData()); + tryItButton.setText(Messages.getString("SoundActionComposite.7")); //$NON-NLS-1$ + tryItButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + File soundFile = new File(soundFilePathLabel.getText()); + playSoundFile(soundFile); + } + }); + + soundFilePathLabel = new Label(this, SWT.NONE); + final GridData gridData_1 = new GridData(GridData.FILL_HORIZONTAL); + gridData_1.horizontalSpan = 2; + soundFilePathLabel.setLayoutData(gridData_1); + soundFilePathLabel.setText(""); //$NON-NLS-1$ + + // + if (soundActionPage.getSoundAction().getSoundFile() != null) + setSoundFile(soundActionPage.getSoundAction().getSoundFile().getAbsolutePath()); + } + + private void addRecentSound(File soundFile) { + soundActionPage.addRecentSound(soundFile); + rebuildRecentSoundsCombo(); + } + + @Override + protected void checkSubclass() { + // Disable the check that prevents subclassing of SWT components + } + + @Override + public void dispose() { + super.dispose(); + } + + public File getSoundFile() { + return selectedSoundFile; + } + + protected void playSoundFile(File soundFile) { + SoundAction.playSoundFile(soundFile); + } + + private void rebuildRecentSoundsCombo() { + combo_1.removeAll(); + + ArrayList<File> sortedSounds = new ArrayList<File>(soundActionPage.getRecentSounds()); + Collections.sort(sortedSounds); + + for (Iterator<File> iter = sortedSounds.iterator(); iter.hasNext();) { + File element = iter.next(); + combo_1.add(element.getAbsolutePath()); + } + } + + private void setSoundFile(String filePath) { + combo_1.removeModifyListener(comboModifyListener); + File soundFile = new File(filePath); + if (soundFile.exists()) { + addRecentSound(soundFile); + combo_1.setText(soundFile.getAbsolutePath()); + soundFilePathLabel.setText(filePath); + tryItButton.setEnabled(true); + selectedSoundFile = soundFile; + } else { + soundFilePathLabel.setText(Messages.getString("SoundActionComposite.9")); //$NON-NLS-1$ + tryItButton.setEnabled(false); + } + combo_1.addModifyListener(comboModifyListener); + } + +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/AbstractContributedRulerColumn.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/AbstractContributedRulerColumn.java index a46aaf45a49..b32434c71ea 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/AbstractContributedRulerColumn.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/AbstractContributedRulerColumn.java @@ -1,66 +1,66 @@ -/*******************************************************************************
- * Copyright (c) 2006, 2011 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- * Wind River Systems, Inc. - adapted for for disassembly parts
- *******************************************************************************/
-package org.eclipse.cdt.debug.ui.disassembly.rulers;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IConfigurationElement;
-
-import org.eclipse.ui.IWorkbenchPart;
-
-
-/**
- * Helper class for contributions to the
- * <code>org.eclipse.cdt.debug.ui.disassemblyRulerColumns</code> extension point.
- * <p>
- * Subclasses must have a zero-argument constructor so that they can be created by
- * {@link IConfigurationElement#createExecutableExtension(String)}.</p>
- *
- * @since 7.2
- */
-public abstract class AbstractContributedRulerColumn implements IContributedRulerColumn {
- /** The contribution descriptor. */
- private RulerColumnDescriptor fDescriptor;
- /** The target disassembly part. */
- private IWorkbenchPart fDisassembly;
-
- @Override
- public final RulerColumnDescriptor getDescriptor() {
- return fDescriptor;
- }
-
- @Override
- public final void setDescriptor(RulerColumnDescriptor descriptor) {
- Assert.isLegal(descriptor != null);
- Assert.isTrue(fDescriptor == null);
- fDescriptor= descriptor;
- }
-
- @Override
- public final void setDisassemblyPart(IWorkbenchPart disassembly) {
- Assert.isLegal(disassembly != null);
- Assert.isTrue(fDisassembly == null);
- fDisassembly= disassembly;
- }
-
- @Override
- public final IWorkbenchPart getDisassemblyPart() {
- return fDisassembly;
- }
-
- @Override
- public void columnCreated() {
- }
-
- @Override
- public void columnRemoved() {
- }
-}
+/******************************************************************************* + * Copyright (c) 2006, 2011 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + * Wind River Systems, Inc. - adapted for for disassembly parts + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.disassembly.rulers; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IConfigurationElement; + +import org.eclipse.ui.IWorkbenchPart; + + +/** + * Helper class for contributions to the + * <code>org.eclipse.cdt.debug.ui.disassemblyRulerColumns</code> extension point. + * <p> + * Subclasses must have a zero-argument constructor so that they can be created by + * {@link IConfigurationElement#createExecutableExtension(String)}.</p> + * + * @since 7.2 + */ +public abstract class AbstractContributedRulerColumn implements IContributedRulerColumn { + /** The contribution descriptor. */ + private RulerColumnDescriptor fDescriptor; + /** The target disassembly part. */ + private IWorkbenchPart fDisassembly; + + @Override + public final RulerColumnDescriptor getDescriptor() { + return fDescriptor; + } + + @Override + public final void setDescriptor(RulerColumnDescriptor descriptor) { + Assert.isLegal(descriptor != null); + Assert.isTrue(fDescriptor == null); + fDescriptor= descriptor; + } + + @Override + public final void setDisassemblyPart(IWorkbenchPart disassembly) { + Assert.isLegal(disassembly != null); + Assert.isTrue(fDisassembly == null); + fDisassembly= disassembly; + } + + @Override + public final IWorkbenchPart getDisassemblyPart() { + return fDisassembly; + } + + @Override + public void columnCreated() { + } + + @Override + public void columnRemoved() { + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IColumnSupport.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IColumnSupport.java index ea21e15a4b7..1a6f316f961 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IColumnSupport.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IColumnSupport.java @@ -1,62 +1,62 @@ -/*******************************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- * Wind River Systems, Inc. - adapted for for disassembly parts
- *******************************************************************************/
-package org.eclipse.cdt.debug.ui.disassembly.rulers;
-
-
-/**
- * Provides support to modify and query the visibility of
- * ruler columns and test whether a ruler column is supported.
- * <p>
- * This interface must not be implemented by clients.
- * </p>
- *
- * @since 7.2
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
- */
-public interface IColumnSupport {
-
- /**
- * Returns <code>true</code> if the column described by <code>descriptor</code> is
- * currently showing, <code>false</code> if not.
- *
- * @param descriptor the column descriptor
- * @return <code>true</code> if the specified column is currently visible
- */
- boolean isColumnVisible(RulerColumnDescriptor descriptor);
-
- /**
- * Attempts to set the visibility of the column described by <code>descriptor</code>. Nothing
- * happens if the visibility is already as requested, or if the column is not supported by the
- * editor.
- *
- * @param descriptor the column descriptor
- * @param visible <code>true</code> to show the column, <code>false</code> to hide it
- */
- void setColumnVisible(RulerColumnDescriptor descriptor, boolean visible);
-
- /**
- * Returns <code>true</code> if the column described by <code>descriptor</code> is
- * supported by the receiver's editor, <code>false</code> if <code>id</code> is not the
- * identifier of a known column contribution, if the column does not target the editor, or if
- * the editor does not support contributed columns.
- *
- * @param descriptor the column descriptor
- * @return <code>true</code> if the specified column is supported
- */
- boolean isColumnSupported(RulerColumnDescriptor descriptor);
-
- /**
- * Removes and disposes all currently visible ruler columns.
- */
- void dispose();
+/******************************************************************************* + * Copyright (c) 2007, 2011 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + * Wind River Systems, Inc. - adapted for for disassembly parts + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.disassembly.rulers; + + +/** + * Provides support to modify and query the visibility of + * ruler columns and test whether a ruler column is supported. + * <p> + * This interface must not be implemented by clients. + * </p> + * + * @since 7.2 + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. + */ +public interface IColumnSupport { + + /** + * Returns <code>true</code> if the column described by <code>descriptor</code> is + * currently showing, <code>false</code> if not. + * + * @param descriptor the column descriptor + * @return <code>true</code> if the specified column is currently visible + */ + boolean isColumnVisible(RulerColumnDescriptor descriptor); + + /** + * Attempts to set the visibility of the column described by <code>descriptor</code>. Nothing + * happens if the visibility is already as requested, or if the column is not supported by the + * editor. + * + * @param descriptor the column descriptor + * @param visible <code>true</code> to show the column, <code>false</code> to hide it + */ + void setColumnVisible(RulerColumnDescriptor descriptor, boolean visible); + + /** + * Returns <code>true</code> if the column described by <code>descriptor</code> is + * supported by the receiver's editor, <code>false</code> if <code>id</code> is not the + * identifier of a known column contribution, if the column does not target the editor, or if + * the editor does not support contributed columns. + * + * @param descriptor the column descriptor + * @return <code>true</code> if the specified column is supported + */ + boolean isColumnSupported(RulerColumnDescriptor descriptor); + + /** + * Removes and disposes all currently visible ruler columns. + */ + void dispose(); }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IContributedRulerColumn.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IContributedRulerColumn.java index 4c2e7c616ba..20d4fbca9af 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IContributedRulerColumn.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IContributedRulerColumn.java @@ -1,99 +1,99 @@ -/*******************************************************************************
- * Copyright (c) 2006, 2011 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- * Wind River Systems, Inc. - adapted for for disassembly parts
- *******************************************************************************/
-package org.eclipse.cdt.debug.ui.disassembly.rulers;
-
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.jface.text.source.IVerticalRulerColumn;
-import org.eclipse.ui.IWorkbenchPart;
-
-
-/**
- * Interface that has to be implemented by contributions to the
- * <code>org.eclipse.cdt.debug.ui.disassembly.rulerColumns</code> extension point.
- * <p>
- * Implementors must have a zero-argument constructor so that they can be created
- * by {@link IConfigurationElement#createExecutableExtension(String)}.</p>
- *
- * @since 7.2
- */
-public interface IContributedRulerColumn extends IVerticalRulerColumn {
-
- /**
- * Returns the extension point descriptor of this ruler.
- *
- * @return descriptor the extension point descriptor of this ruler or <code>null</code> if called before {@link #columnCreated()}
- */
- RulerColumnDescriptor getDescriptor();
-
- /**
- * Sets the extension point descriptor of this ruler.
- * <p>
- * <em>This method will be called by the framework and must not
- * be called by clients.</em></p>
- *
- * @param descriptor the extension point descriptor
- */
- void setDescriptor(RulerColumnDescriptor descriptor);
-
- /**
- * Sets the disassembly part (called right after the extension was instantiated).
- * <p>
- * <em>This method will be called by the framework and must not
- * be called by clients.</em></p>
- *
- * @param disassembly the disassembly part targeted by this ruler instance
- */
- void setDisassemblyPart(IWorkbenchPart disassembly);
-
- /**
- * Returns the disassembly part targeted by this ruler instance.
- *
- * @return the disassembly part targeted by this ruler instance or <code>null</code> if called before {@link #columnCreated()}
- */
- IWorkbenchPart getDisassemblyPart();
-
- /**
- * Hook method called after a column has been instantiated, but before it is
- * added to a {@link org.eclipse.jface.text.source.CompositeRuler} and before
- * {@linkplain org.eclipse.jface.text.source.IVerticalRulerColumn#createControl(org.eclipse.jface.text.source.CompositeRuler, org.eclipse.swt.widgets.Composite) createControl}
- * is called.
- * <p>
- * This happens when
- * <ul>
- * <li>the column is set visible by the user or programmatically</li>
- * <li>the disassembly part is created, if this ruler targets the disassembly part and is enabled by default</li>
- * <li>the disassembly part input changes and the column now targets the new disassembly part contents.</li>
- * </ul></p>
- */
- void columnCreated();
-
- /**
- * Hook method called after a column has been removed from the {@link org.eclipse.jface.text.source.CompositeRuler}.
- * <p>
- * This happens when
- * <ul>
- * <li>the column is hidden by the user or programmatically</li>
- * <li>the disassembly part is closed</li>
- * <li>the disassembly part input changes and the column no longer targets the disassembly part
- * contents.</li>
- * </ul>
- * </p>
- * <p>
- * The column will not be used after this method has been called. A new
- * column will be instantiated if the same column type should be shown for
- * the same disassembly part.
- * </p>
- */
- void columnRemoved();
-
-}
+/******************************************************************************* + * Copyright (c) 2006, 2011 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + * Wind River Systems, Inc. - adapted for for disassembly parts + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.disassembly.rulers; + + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.jface.text.source.IVerticalRulerColumn; +import org.eclipse.ui.IWorkbenchPart; + + +/** + * Interface that has to be implemented by contributions to the + * <code>org.eclipse.cdt.debug.ui.disassembly.rulerColumns</code> extension point. + * <p> + * Implementors must have a zero-argument constructor so that they can be created + * by {@link IConfigurationElement#createExecutableExtension(String)}.</p> + * + * @since 7.2 + */ +public interface IContributedRulerColumn extends IVerticalRulerColumn { + + /** + * Returns the extension point descriptor of this ruler. + * + * @return descriptor the extension point descriptor of this ruler or <code>null</code> if called before {@link #columnCreated()} + */ + RulerColumnDescriptor getDescriptor(); + + /** + * Sets the extension point descriptor of this ruler. + * <p> + * <em>This method will be called by the framework and must not + * be called by clients.</em></p> + * + * @param descriptor the extension point descriptor + */ + void setDescriptor(RulerColumnDescriptor descriptor); + + /** + * Sets the disassembly part (called right after the extension was instantiated). + * <p> + * <em>This method will be called by the framework and must not + * be called by clients.</em></p> + * + * @param disassembly the disassembly part targeted by this ruler instance + */ + void setDisassemblyPart(IWorkbenchPart disassembly); + + /** + * Returns the disassembly part targeted by this ruler instance. + * + * @return the disassembly part targeted by this ruler instance or <code>null</code> if called before {@link #columnCreated()} + */ + IWorkbenchPart getDisassemblyPart(); + + /** + * Hook method called after a column has been instantiated, but before it is + * added to a {@link org.eclipse.jface.text.source.CompositeRuler} and before + * {@linkplain org.eclipse.jface.text.source.IVerticalRulerColumn#createControl(org.eclipse.jface.text.source.CompositeRuler, org.eclipse.swt.widgets.Composite) createControl} + * is called. + * <p> + * This happens when + * <ul> + * <li>the column is set visible by the user or programmatically</li> + * <li>the disassembly part is created, if this ruler targets the disassembly part and is enabled by default</li> + * <li>the disassembly part input changes and the column now targets the new disassembly part contents.</li> + * </ul></p> + */ + void columnCreated(); + + /** + * Hook method called after a column has been removed from the {@link org.eclipse.jface.text.source.CompositeRuler}. + * <p> + * This happens when + * <ul> + * <li>the column is hidden by the user or programmatically</li> + * <li>the disassembly part is closed</li> + * <li>the disassembly part input changes and the column no longer targets the disassembly part + * contents.</li> + * </ul> + * </p> + * <p> + * The column will not be used after this method has been called. A new + * column will be instantiated if the same column type should be shown for + * the same disassembly part. + * </p> + */ + void columnRemoved(); + +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnDescriptor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnDescriptor.java index 1154a9e94d4..6a89a44d8d0 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnDescriptor.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnDescriptor.java @@ -1,307 +1,307 @@ -/*******************************************************************************
- * Copyright (c) 2005, 2015 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- * Wind River Systems, Inc. - adapted for for disassembly parts
+/******************************************************************************* + * Copyright (c) 2005, 2015 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + * Wind River Systems, Inc. - adapted for for disassembly parts *******************************************************************************/ -package org.eclipse.cdt.debug.ui.disassembly.rulers;
-
-import java.net.URL;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.InvalidRegistryObjectException;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.internal.texteditor.rulers.ExtensionPointHelper;
-import org.eclipse.ui.internal.texteditor.rulers.RulerColumnMessages;
-import org.eclipse.ui.internal.texteditor.rulers.RulerColumnPlacement;
-import org.eclipse.ui.internal.texteditor.rulers.RulerColumnTarget;
-
-
-/**
- * The description of an extension to the
- * <code>org.eclipse.ui.workbench.texteditor.rulerColumns</code> extension point. Instances are
- * immutable. Instances can be obtained from a {@link RulerColumnRegistry}.
- *
- * @since 7.2
- * @noinstantiate This class is not intended to be instantiated by clients.
- */
-public final class RulerColumnDescriptor {
- /** The extension schema name of the class attribute. */
- private static final String CLASS= "class"; //$NON-NLS-1$
- /** The extension schema name of the id attribute. */
- private static final String ID= "id"; //$NON-NLS-1$
- /** The extension schema name of the optional name attribute. */
- private static final String NAME= "name"; //$NON-NLS-1$
- /** The extension schema name of the optional enabled attribute. */
- private static final String ENABLED= "enabled"; //$NON-NLS-1$
- /** The extension schema name of the optional icon attribute. */
- private static final String ICON= "icon"; //$NON-NLS-1$
- /** The extension schema name of the optional global attribute. */
- private static final String GLOBAL= "global"; //$NON-NLS-1$
- /** The extension schema name of the optional menu inclusion attribute. */
- private static final String INCLUDE_IN_MENU= "includeInMenu"; //$NON-NLS-1$
- /** The extension schema name of the targetEditor element. */
- private static final String TARGET_ID= "targetId"; //$NON-NLS-1$
- /** The extension schema name of the targetClass element. */
- private static final String TARGET_CLASS= "targetClass"; //$NON-NLS-1$
- /** The extension schema name of the placement element. */
- private static final String PLACEMENT= "placement"; //$NON-NLS-1$
-
- /** The identifier of the extension. */
- private final String fId;
- /** The name of the extension, equal to the id if no name is given. */
- private final String fName;
- /** The icon descriptor. */
- private final ImageDescriptor fIcon;
- /** The configuration element of this extension. */
- private final IConfigurationElement fElement;
- /** The target specification of the ruler column contribution. */
- private final RulerColumnTarget fTarget;
- /** The placement specification of the ruler column contribution. */
- private final RulerColumnPlacement fRulerColumnPlacement;
- /** The default enablement setting of the ruler column contribution. */
- private final boolean fDefaultEnablement;
- /** The global setting of the ruler column contribution. */
- private final boolean fIsGlobal;
- /** The menu inclusion setting of the ruler column contribution. */
- private final boolean fIncludeInMenu;
-
- /**
- * Creates a new descriptor.
- *
- * @param element the configuration element to read
- * @param registry the computer registry creating this descriptor
- * @throws InvalidRegistryObjectException if the configuration element is no longer valid
- * @throws CoreException if the configuration element does not conform to the extension point spec
- */
- RulerColumnDescriptor(IConfigurationElement element, RulerColumnRegistry registry) throws InvalidRegistryObjectException, CoreException {
- Assert.isLegal(registry != null);
- Assert.isLegal(element != null);
- fElement= element;
-
- ExtensionPointHelper helper= new ExtensionPointHelper(element);
-
- fId= helper.getNonNullAttribute(ID);
- fName= helper.getDefaultAttribute(NAME, fId);
- helper.getNonNullAttribute(CLASS); // just check validity
- URL iconURL= helper.getDefaultResourceURL(ICON, null);
- fIcon= iconURL == null ? null : ImageDescriptor.createFromURL(iconURL);
- fDefaultEnablement= helper.getDefaultAttribute(ENABLED, true);
- fIsGlobal= helper.getDefaultAttribute(GLOBAL, true);
- fIncludeInMenu= helper.getDefaultAttribute(INCLUDE_IN_MENU, true);
-
- IConfigurationElement[] targetEditors= element.getChildren(TARGET_ID);
- IConfigurationElement[] targetClasses= element.getChildren(TARGET_CLASS);
-
- RulerColumnTarget combined= null;
- for (int i= 0; i < targetEditors.length; i++) {
- IConfigurationElement targetEditor= targetEditors[i];
- RulerColumnTarget target= RulerColumnTarget.createEditorIdTarget(new ExtensionPointHelper(targetEditor).getNonNullAttribute(ID));
- combined= RulerColumnTarget.createOrTarget(combined, target);
- }
- for (int i= 0; i < targetClasses.length; i++) {
- IConfigurationElement targetClass= targetClasses[i];
- RulerColumnTarget target= RulerColumnTarget.createClassTarget(new ExtensionPointHelper(targetClass).getNonNullAttribute(CLASS));
- combined= RulerColumnTarget.createOrTarget(combined, target);
- }
- fTarget= combined;
-
- IConfigurationElement[] placements= element.getChildren(PLACEMENT);
- switch (placements.length) {
- case 0:
- fRulerColumnPlacement= new RulerColumnPlacement();
- break;
- case 1:
- fRulerColumnPlacement= new RulerColumnPlacement(placements[0]);
- break;
- default:
- helper.fail(RulerColumnMessages.RulerColumnDescriptor_invalid_placement_msg);
- fRulerColumnPlacement= null; // dummy
- break;
- }
-
- Assert.isTrue(fTarget != null);
- Assert.isTrue(fRulerColumnPlacement != null);
- }
-
- /**
- * Returns the identifier of the described extension.
- *
- * @return the identifier of the described extension
- */
- public String getId() {
- return fId;
- }
-
- /**
- * Returns the name of the described extension.
- *
- * @return the name of the described extension
- */
- public String getName() {
- return fName;
- }
-
- /**
- * Returns the image descriptor of the described extension, <code>null</code> if it does not
- * have an image.
- *
- * @return the image descriptor of the described extension or <code>null</code> for no image
- */
- public ImageDescriptor getIcon() {
- return fIcon;
- }
-
- RulerColumnTarget getTarget() {
- return fTarget;
- }
-
- RulerColumnPlacement getPlacement() {
- return fRulerColumnPlacement;
- }
-
- /**
- * Returns the default enablement of the described extension. Editors that support this
- * contribution should typically enable the column by default.
- *
- * @return the default enablement of the described extension
- */
- public boolean getDefaultEnablement() {
- return fDefaultEnablement;
- }
-
- /**
- * Returns the global property of the described extension. Changing the visibility of a column
- * with the global property set to <code>true</code> should typically affect all matching
- * editors. Changing the visibility of a column with the global property set to
- * <code>false</code> should only affect the current disassembly part.
- *
- * @return the global property of the described extension
- */
- public boolean isGlobal() {
- return fIsGlobal;
- }
-
- /**
- * Returns the menu inclusion property of the described extension. A toggle menu entry should be
- * inluded in the ruler context menu for columns with this property set to <code>true</code>.
- *
- * @return the menu inclusion property of the described extension
- */
- public boolean isIncludedInMenu() {
- return fIncludeInMenu;
- }
-
- /**
- * Returns <code>true</code> if this contribution matches the passed disassembly part , <code>false</code> if not.
- *
- * @param disassembly the disassembly part to check
- * @return <code>true</code> if this contribution targets the passed disassembly part
- */
- public boolean matchesPart(IWorkbenchPart disassembly) {
- Assert.isLegal(disassembly != null);
- RulerColumnTarget target= getTarget();
-
- IWorkbenchPartSite site= disassembly.getSite();
- if (site != null && target.matchesEditorId(site.getId()))
- return true;
-
- if (target.matchesClass(disassembly.getClass()))
- return true;
-
- IContentType contentType= getContentType(disassembly);
- return contentType != null && target.matchesContentType(contentType);
-
- }
-
- /**
- * Creates a {@link IContributedRulerColumn} instance as described by the receiver. This may load the contributing plug-in.
- *
- * @param disassembly the disassembly part that loads the contributed column
- * @return the instantiated column
- * @throws CoreException as thrown by {@link IConfigurationElement#createExecutableExtension(String)}
- * @throws InvalidRegistryObjectException as thrown by {@link IConfigurationElement#createExecutableExtension(String)}
- */
- public IContributedRulerColumn createColumn(IWorkbenchPart disassembly) throws CoreException, InvalidRegistryObjectException {
- Assert.isLegal(disassembly != null);
- IContributedRulerColumn column= (IContributedRulerColumn)fElement.createExecutableExtension(CLASS);
- column.setDescriptor(this);
- column.setDisassemblyPart(disassembly);
- column.columnCreated();
- return column;
- }
-
- /*
- * @see java.lang.Object#toString()
- * @since 3.3
- */
- @Override
- public String toString() {
- return "RulerColumnDescriptor[name=" + getName() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- IConfigurationElement getConfigurationElement() {
- return fElement;
- }
-
- /*
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime= 31;
- int result= 1;
- result= prime * result + ((fId == null) ? 0 : fId.hashCode());
- return result;
- }
-
- /*
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final RulerColumnDescriptor other= (RulerColumnDescriptor) obj;
- if (fId == null) {
- if (other.fId != null)
- return false;
- } else if (!fId.equals(other.fId))
- return false;
- return true;
- }
-
- /**
- * Returns the content type of the disassembly part's input, <code>null</code> if the disassembly part input or
- * the document provider is <code>null</code> or the content type cannot be determined.
- *
- * @param disassembly part the disassembly part to get the content type from
- * @return the content type of the disassembly part's input, <code>null</code> if it cannot be
- * determined
- */
- private IContentType getContentType(IWorkbenchPart disassembly) {
- return null;
- }
-
- String getContributor() {
- try {
- return fElement.getContributor().getName();
- } catch (InvalidRegistryObjectException e) {
- return "unknown"; //$NON-NLS-1$
- }
- }
-}
+package org.eclipse.cdt.debug.ui.disassembly.rulers; + +import java.net.URL; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.InvalidRegistryObjectException; +import org.eclipse.core.runtime.content.IContentType; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchPartSite; +import org.eclipse.ui.internal.texteditor.rulers.ExtensionPointHelper; +import org.eclipse.ui.internal.texteditor.rulers.RulerColumnMessages; +import org.eclipse.ui.internal.texteditor.rulers.RulerColumnPlacement; +import org.eclipse.ui.internal.texteditor.rulers.RulerColumnTarget; + + +/** + * The description of an extension to the + * <code>org.eclipse.ui.workbench.texteditor.rulerColumns</code> extension point. Instances are + * immutable. Instances can be obtained from a {@link RulerColumnRegistry}. + * + * @since 7.2 + * @noinstantiate This class is not intended to be instantiated by clients. + */ +public final class RulerColumnDescriptor { + /** The extension schema name of the class attribute. */ + private static final String CLASS= "class"; //$NON-NLS-1$ + /** The extension schema name of the id attribute. */ + private static final String ID= "id"; //$NON-NLS-1$ + /** The extension schema name of the optional name attribute. */ + private static final String NAME= "name"; //$NON-NLS-1$ + /** The extension schema name of the optional enabled attribute. */ + private static final String ENABLED= "enabled"; //$NON-NLS-1$ + /** The extension schema name of the optional icon attribute. */ + private static final String ICON= "icon"; //$NON-NLS-1$ + /** The extension schema name of the optional global attribute. */ + private static final String GLOBAL= "global"; //$NON-NLS-1$ + /** The extension schema name of the optional menu inclusion attribute. */ + private static final String INCLUDE_IN_MENU= "includeInMenu"; //$NON-NLS-1$ + /** The extension schema name of the targetEditor element. */ + private static final String TARGET_ID= "targetId"; //$NON-NLS-1$ + /** The extension schema name of the targetClass element. */ + private static final String TARGET_CLASS= "targetClass"; //$NON-NLS-1$ + /** The extension schema name of the placement element. */ + private static final String PLACEMENT= "placement"; //$NON-NLS-1$ + + /** The identifier of the extension. */ + private final String fId; + /** The name of the extension, equal to the id if no name is given. */ + private final String fName; + /** The icon descriptor. */ + private final ImageDescriptor fIcon; + /** The configuration element of this extension. */ + private final IConfigurationElement fElement; + /** The target specification of the ruler column contribution. */ + private final RulerColumnTarget fTarget; + /** The placement specification of the ruler column contribution. */ + private final RulerColumnPlacement fRulerColumnPlacement; + /** The default enablement setting of the ruler column contribution. */ + private final boolean fDefaultEnablement; + /** The global setting of the ruler column contribution. */ + private final boolean fIsGlobal; + /** The menu inclusion setting of the ruler column contribution. */ + private final boolean fIncludeInMenu; + + /** + * Creates a new descriptor. + * + * @param element the configuration element to read + * @param registry the computer registry creating this descriptor + * @throws InvalidRegistryObjectException if the configuration element is no longer valid + * @throws CoreException if the configuration element does not conform to the extension point spec + */ + RulerColumnDescriptor(IConfigurationElement element, RulerColumnRegistry registry) throws InvalidRegistryObjectException, CoreException { + Assert.isLegal(registry != null); + Assert.isLegal(element != null); + fElement= element; + + ExtensionPointHelper helper= new ExtensionPointHelper(element); + + fId= helper.getNonNullAttribute(ID); + fName= helper.getDefaultAttribute(NAME, fId); + helper.getNonNullAttribute(CLASS); // just check validity + URL iconURL= helper.getDefaultResourceURL(ICON, null); + fIcon= iconURL == null ? null : ImageDescriptor.createFromURL(iconURL); + fDefaultEnablement= helper.getDefaultAttribute(ENABLED, true); + fIsGlobal= helper.getDefaultAttribute(GLOBAL, true); + fIncludeInMenu= helper.getDefaultAttribute(INCLUDE_IN_MENU, true); + + IConfigurationElement[] targetEditors= element.getChildren(TARGET_ID); + IConfigurationElement[] targetClasses= element.getChildren(TARGET_CLASS); + + RulerColumnTarget combined= null; + for (int i= 0; i < targetEditors.length; i++) { + IConfigurationElement targetEditor= targetEditors[i]; + RulerColumnTarget target= RulerColumnTarget.createEditorIdTarget(new ExtensionPointHelper(targetEditor).getNonNullAttribute(ID)); + combined= RulerColumnTarget.createOrTarget(combined, target); + } + for (int i= 0; i < targetClasses.length; i++) { + IConfigurationElement targetClass= targetClasses[i]; + RulerColumnTarget target= RulerColumnTarget.createClassTarget(new ExtensionPointHelper(targetClass).getNonNullAttribute(CLASS)); + combined= RulerColumnTarget.createOrTarget(combined, target); + } + fTarget= combined; + + IConfigurationElement[] placements= element.getChildren(PLACEMENT); + switch (placements.length) { + case 0: + fRulerColumnPlacement= new RulerColumnPlacement(); + break; + case 1: + fRulerColumnPlacement= new RulerColumnPlacement(placements[0]); + break; + default: + helper.fail(RulerColumnMessages.RulerColumnDescriptor_invalid_placement_msg); + fRulerColumnPlacement= null; // dummy + break; + } + + Assert.isTrue(fTarget != null); + Assert.isTrue(fRulerColumnPlacement != null); + } + + /** + * Returns the identifier of the described extension. + * + * @return the identifier of the described extension + */ + public String getId() { + return fId; + } + + /** + * Returns the name of the described extension. + * + * @return the name of the described extension + */ + public String getName() { + return fName; + } + + /** + * Returns the image descriptor of the described extension, <code>null</code> if it does not + * have an image. + * + * @return the image descriptor of the described extension or <code>null</code> for no image + */ + public ImageDescriptor getIcon() { + return fIcon; + } + + RulerColumnTarget getTarget() { + return fTarget; + } + + RulerColumnPlacement getPlacement() { + return fRulerColumnPlacement; + } + + /** + * Returns the default enablement of the described extension. Editors that support this + * contribution should typically enable the column by default. + * + * @return the default enablement of the described extension + */ + public boolean getDefaultEnablement() { + return fDefaultEnablement; + } + + /** + * Returns the global property of the described extension. Changing the visibility of a column + * with the global property set to <code>true</code> should typically affect all matching + * editors. Changing the visibility of a column with the global property set to + * <code>false</code> should only affect the current disassembly part. + * + * @return the global property of the described extension + */ + public boolean isGlobal() { + return fIsGlobal; + } + + /** + * Returns the menu inclusion property of the described extension. A toggle menu entry should be + * inluded in the ruler context menu for columns with this property set to <code>true</code>. + * + * @return the menu inclusion property of the described extension + */ + public boolean isIncludedInMenu() { + return fIncludeInMenu; + } + + /** + * Returns <code>true</code> if this contribution matches the passed disassembly part , <code>false</code> if not. + * + * @param disassembly the disassembly part to check + * @return <code>true</code> if this contribution targets the passed disassembly part + */ + public boolean matchesPart(IWorkbenchPart disassembly) { + Assert.isLegal(disassembly != null); + RulerColumnTarget target= getTarget(); + + IWorkbenchPartSite site= disassembly.getSite(); + if (site != null && target.matchesEditorId(site.getId())) + return true; + + if (target.matchesClass(disassembly.getClass())) + return true; + + IContentType contentType= getContentType(disassembly); + return contentType != null && target.matchesContentType(contentType); + + } + + /** + * Creates a {@link IContributedRulerColumn} instance as described by the receiver. This may load the contributing plug-in. + * + * @param disassembly the disassembly part that loads the contributed column + * @return the instantiated column + * @throws CoreException as thrown by {@link IConfigurationElement#createExecutableExtension(String)} + * @throws InvalidRegistryObjectException as thrown by {@link IConfigurationElement#createExecutableExtension(String)} + */ + public IContributedRulerColumn createColumn(IWorkbenchPart disassembly) throws CoreException, InvalidRegistryObjectException { + Assert.isLegal(disassembly != null); + IContributedRulerColumn column= (IContributedRulerColumn)fElement.createExecutableExtension(CLASS); + column.setDescriptor(this); + column.setDisassemblyPart(disassembly); + column.columnCreated(); + return column; + } + + /* + * @see java.lang.Object#toString() + * @since 3.3 + */ + @Override + public String toString() { + return "RulerColumnDescriptor[name=" + getName() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ + } + + IConfigurationElement getConfigurationElement() { + return fElement; + } + + /* + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime= 31; + int result= 1; + result= prime * result + ((fId == null) ? 0 : fId.hashCode()); + return result; + } + + /* + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final RulerColumnDescriptor other= (RulerColumnDescriptor) obj; + if (fId == null) { + if (other.fId != null) + return false; + } else if (!fId.equals(other.fId)) + return false; + return true; + } + + /** + * Returns the content type of the disassembly part's input, <code>null</code> if the disassembly part input or + * the document provider is <code>null</code> or the content type cannot be determined. + * + * @param disassembly part the disassembly part to get the content type from + * @return the content type of the disassembly part's input, <code>null</code> if it cannot be + * determined + */ + private IContentType getContentType(IWorkbenchPart disassembly) { + return null; + } + + String getContributor() { + try { + return fElement.getContributor().getName(); + } catch (InvalidRegistryObjectException e) { + return "unknown"; //$NON-NLS-1$ + } + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnRegistry.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnRegistry.java index 024d07e97b0..1fb7f1229f3 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnRegistry.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnRegistry.java @@ -1,294 +1,294 @@ -/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- * Wind River Systems, Inc. - adapted for for disassembly parts
- *******************************************************************************/
-package org.eclipse.cdt.debug.ui.disassembly.rulers;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.InvalidRegistryObjectException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.ui.internal.texteditor.TextEditorPlugin;
-import org.eclipse.ui.internal.texteditor.rulers.DAG;
-import org.eclipse.ui.internal.texteditor.rulers.ExtensionPointHelper;
-import org.eclipse.ui.internal.texteditor.rulers.RulerColumnMessages;
-import org.eclipse.ui.internal.texteditor.rulers.RulerColumnPlacementConstraint;
-import org.eclipse.ui.texteditor.ConfigurationElementSorter;
-
-import com.ibm.icu.text.MessageFormat;
-
-
-/**
- * A registry for all extensions to the
- * <code>rulerColumns</code> extension point.
- *
- * @since 7.2
- * @noinstantiate This class is not intended to be instantiated by clients.
- */
-public final class RulerColumnRegistry {
-
- private static final String EXTENSION_POINT= "disassemblyRulerColumns"; //$NON-NLS-1$
- private static final String QUALIFIED_EXTENSION_POINT= CDebugUIPlugin.PLUGIN_ID + '.' + EXTENSION_POINT;
-
- /** The singleton instance. */
- private static RulerColumnRegistry fgSingleton= null;
-
- /**
- * Returns the default computer registry.
- *
- * @return the singleton instance
- */
- public static synchronized RulerColumnRegistry getDefault() {
- if (fgSingleton == null) {
- fgSingleton= new RulerColumnRegistry();
- }
-
- return fgSingleton;
- }
-
- /**
- * All descriptors (element type:
- * {@link RulerColumnDescriptor}).
- */
- private List<RulerColumnDescriptor> fDescriptors= null;
- /**
- * All descriptors by id (element type: {@link RulerColumnDescriptor}).
- */
- private Map<String, RulerColumnDescriptor> fDescriptorMap= null;
-
- /**
- * <code>true</code> if this registry has been loaded.
- */
- private boolean fLoaded= false;
-
- /**
- * Creates a new instance.
- */
- RulerColumnRegistry() {
- }
-
- /**
- * Returns the list of {@link RulerColumnDescriptor}s describing all extensions to the
- * <code>rulerColumns</code> extension point. The list's iterator traverses the descriptors in
- * the ordering implied by the placement specifications of the contributions.
- * <p>
- * The returned list is unmodifiable and guaranteed to never change. Note that the set of
- * descriptors may change over time due to dynamic plug-in removal or addition.
- * </p>
- *
- * @return the sorted list of extensions to the <code>rulerColumns</code> extension point
- * (element type: {@link RulerColumnDescriptor})
- */
- public List<RulerColumnDescriptor> getColumnDescriptors() {
- ensureExtensionPointRead();
- return fDescriptors;
- }
-
- /**
- * Returns the {@link RulerColumnDescriptor} with the given identity, <code>null</code> if no
- * such descriptor exists.
- *
- * @param id the identity of the ruler contribution as given in the extension point xml.
- * @return the {@link RulerColumnDescriptor} with the given identity, <code>null</code> if no
- * such descriptor exists
- */
- public RulerColumnDescriptor getColumnDescriptor(String id) {
- Assert.isLegal(id != null);
- ensureExtensionPointRead();
- return fDescriptorMap.get(id);
- }
-
- /**
- * Ensures that the extensions are read and stored in
- * <code>fDescriptorsByPartition</code>.
- */
- private void ensureExtensionPointRead() {
- boolean reload;
- synchronized (this) {
- reload= !fLoaded;
- fLoaded= true;
- }
- if (reload)
- reload();
- }
-
- /**
- * Reloads the extensions to the extension point.
- * <p>
- * This method can be called more than once in order to reload from
- * a changed extension registry.
- * </p>
- */
- public void reload() {
- IExtensionRegistry registry= Platform.getExtensionRegistry();
- List<IConfigurationElement> elements= new ArrayList<IConfigurationElement>(Arrays.asList(registry.getConfigurationElementsFor(CDebugUIPlugin.PLUGIN_ID, EXTENSION_POINT)));
-
- List<RulerColumnDescriptor> descriptors= new ArrayList<RulerColumnDescriptor>();
- Map<String, RulerColumnDescriptor> descriptorMap= new HashMap<String, RulerColumnDescriptor>();
-
- for (Iterator<IConfigurationElement> iter= elements.iterator(); iter.hasNext();) {
- IConfigurationElement element= iter.next();
- try {
- RulerColumnDescriptor desc= new RulerColumnDescriptor(element, this);
- String id= desc.getId();
- if (descriptorMap.containsKey(id)) {
- noteDuplicateId(desc);
- continue;
- }
-
- descriptors.add(desc);
- descriptorMap.put(id, desc);
- } catch (InvalidRegistryObjectException x) {
- /*
- * Element is not valid any longer as the contributing plug-in was unloaded or for
- * some other reason. Do not include the extension in the list and inform the user
- * about it.
- */
- noteInvalidExtension(element, x);
- } catch (CoreException x) {
- warnUser(x.getStatus());
- }
- }
-
- sort(descriptors);
-
- synchronized (this) {
- fDescriptors= Collections.unmodifiableList(descriptors);
- fDescriptorMap= Collections.unmodifiableMap(descriptorMap);
- }
- }
-
- /**
- * Sorts the column contributions.
- *
- * @param descriptors the descriptors to sort
- */
- @SuppressWarnings("unchecked")
- private void sort(List<RulerColumnDescriptor> descriptors) {
- /*
- * Topological sort of the DAG defined by the plug-in dependencies
- * 1. TopoSort descriptors by plug-in dependency
- * 2. Insert into Directed Acyclic Graph
- * 3. TopoSort DAG: pick the source with the lowest gravity and remove from DAG
- */
- ConfigurationElementSorter sorter= new ConfigurationElementSorter() {
- @Override
- public IConfigurationElement getConfigurationElement(Object object) {
- return ((RulerColumnDescriptor) object).getConfigurationElement();
- }
- };
- RulerColumnDescriptor[] array= new RulerColumnDescriptor[descriptors.size()];
- descriptors.toArray(array);
- sorter.sort(array);
-
- Map<String, RulerColumnDescriptor> descriptorsById= new HashMap<String, RulerColumnDescriptor>();
- for (RulerColumnDescriptor desc : array) {
- descriptorsById.put(desc.getId(), desc);
- }
-
- DAG dag= new DAG();
- for (RulerColumnDescriptor desc : array) {
- dag.addVertex(desc);
-
- Set<?> before= desc.getPlacement().getConstraints();
- for (Iterator<?> it= before.iterator(); it.hasNext();) {
- RulerColumnPlacementConstraint constraint= (RulerColumnPlacementConstraint) it.next();
- String id= constraint.getId();
- RulerColumnDescriptor target= descriptorsById.get(id);
- if (target == null) {
- noteUnknownTarget(desc, id);
- } else {
- boolean success;
- if (constraint.isBefore())
- success= dag.addEdge(desc, target);
- else
- success= dag.addEdge(target, desc);
- if (!success)
- noteCycle(desc, target);
- }
- }
- }
-
- Comparator<RulerColumnDescriptor> gravityComp= new Comparator<RulerColumnDescriptor>() {
- @Override
- public int compare(RulerColumnDescriptor o1, RulerColumnDescriptor o2) {
- float diff= o1.getPlacement().getGravity() - o2.getPlacement().getGravity();
- if (diff == 0)
- return 0;
- if (diff < 0)
- return -1;
- return 1;
- }
- };
-
- /* Topological sort - always select the source with the least gravity */
- Set<RulerColumnDescriptor> toProcess= dag.getSources();
- int index= 0;
- while (!toProcess.isEmpty()) {
- RulerColumnDescriptor next= Collections.min(toProcess, gravityComp);
- array[index]= next;
- index++;
- dag.removeVertex(next);
- toProcess= dag.getSources();
- }
- Assert.isTrue(index == array.length);
-
- ListIterator<RulerColumnDescriptor> it= descriptors.listIterator();
- for (int i= 0; i < index; i++) {
- it.next();
- it.set(array[i]);
- }
- }
-
- private void noteInvalidExtension(IConfigurationElement element, InvalidRegistryObjectException x) {
- String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_invalid_msg, new Object[] {ExtensionPointHelper.findId(element)});
- warnUser(message, x);
- }
-
- private void noteUnknownTarget(RulerColumnDescriptor desc, String referencedId) {
- String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_unresolved_placement_msg, new Object[] {QUALIFIED_EXTENSION_POINT, referencedId, desc.getName(), desc.getContributor()});
- warnUser(message, null);
- }
-
- private void noteCycle(RulerColumnDescriptor desc, RulerColumnDescriptor target) {
- String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_cyclic_placement_msg, new Object[] {QUALIFIED_EXTENSION_POINT, target.getName(), desc.getName(), desc.getContributor()});
- warnUser(message, null);
- }
-
- private void noteDuplicateId(RulerColumnDescriptor desc) {
- String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_duplicate_id_msg, new Object[] {QUALIFIED_EXTENSION_POINT, desc.getId(), desc.getContributor()});
- warnUser(message, null);
- }
-
- private void warnUser(String message, Exception exception) {
- IStatus status= new Status(IStatus.WARNING, TextEditorPlugin.PLUGIN_ID, IStatus.OK, message, exception);
- warnUser(status);
- }
-
- private void warnUser(IStatus status) {
- TextEditorPlugin.getDefault().getLog().log(status);
- }
-}
+/******************************************************************************* + * Copyright (c) 2000, 2011 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + * Wind River Systems, Inc. - adapted for for disassembly parts + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.disassembly.rulers; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Set; + +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.InvalidRegistryObjectException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.ui.internal.texteditor.TextEditorPlugin; +import org.eclipse.ui.internal.texteditor.rulers.DAG; +import org.eclipse.ui.internal.texteditor.rulers.ExtensionPointHelper; +import org.eclipse.ui.internal.texteditor.rulers.RulerColumnMessages; +import org.eclipse.ui.internal.texteditor.rulers.RulerColumnPlacementConstraint; +import org.eclipse.ui.texteditor.ConfigurationElementSorter; + +import com.ibm.icu.text.MessageFormat; + + +/** + * A registry for all extensions to the + * <code>rulerColumns</code> extension point. + * + * @since 7.2 + * @noinstantiate This class is not intended to be instantiated by clients. + */ +public final class RulerColumnRegistry { + + private static final String EXTENSION_POINT= "disassemblyRulerColumns"; //$NON-NLS-1$ + private static final String QUALIFIED_EXTENSION_POINT= CDebugUIPlugin.PLUGIN_ID + '.' + EXTENSION_POINT; + + /** The singleton instance. */ + private static RulerColumnRegistry fgSingleton= null; + + /** + * Returns the default computer registry. + * + * @return the singleton instance + */ + public static synchronized RulerColumnRegistry getDefault() { + if (fgSingleton == null) { + fgSingleton= new RulerColumnRegistry(); + } + + return fgSingleton; + } + + /** + * All descriptors (element type: + * {@link RulerColumnDescriptor}). + */ + private List<RulerColumnDescriptor> fDescriptors= null; + /** + * All descriptors by id (element type: {@link RulerColumnDescriptor}). + */ + private Map<String, RulerColumnDescriptor> fDescriptorMap= null; + + /** + * <code>true</code> if this registry has been loaded. + */ + private boolean fLoaded= false; + + /** + * Creates a new instance. + */ + RulerColumnRegistry() { + } + + /** + * Returns the list of {@link RulerColumnDescriptor}s describing all extensions to the + * <code>rulerColumns</code> extension point. The list's iterator traverses the descriptors in + * the ordering implied by the placement specifications of the contributions. + * <p> + * The returned list is unmodifiable and guaranteed to never change. Note that the set of + * descriptors may change over time due to dynamic plug-in removal or addition. + * </p> + * + * @return the sorted list of extensions to the <code>rulerColumns</code> extension point + * (element type: {@link RulerColumnDescriptor}) + */ + public List<RulerColumnDescriptor> getColumnDescriptors() { + ensureExtensionPointRead(); + return fDescriptors; + } + + /** + * Returns the {@link RulerColumnDescriptor} with the given identity, <code>null</code> if no + * such descriptor exists. + * + * @param id the identity of the ruler contribution as given in the extension point xml. + * @return the {@link RulerColumnDescriptor} with the given identity, <code>null</code> if no + * such descriptor exists + */ + public RulerColumnDescriptor getColumnDescriptor(String id) { + Assert.isLegal(id != null); + ensureExtensionPointRead(); + return fDescriptorMap.get(id); + } + + /** + * Ensures that the extensions are read and stored in + * <code>fDescriptorsByPartition</code>. + */ + private void ensureExtensionPointRead() { + boolean reload; + synchronized (this) { + reload= !fLoaded; + fLoaded= true; + } + if (reload) + reload(); + } + + /** + * Reloads the extensions to the extension point. + * <p> + * This method can be called more than once in order to reload from + * a changed extension registry. + * </p> + */ + public void reload() { + IExtensionRegistry registry= Platform.getExtensionRegistry(); + List<IConfigurationElement> elements= new ArrayList<IConfigurationElement>(Arrays.asList(registry.getConfigurationElementsFor(CDebugUIPlugin.PLUGIN_ID, EXTENSION_POINT))); + + List<RulerColumnDescriptor> descriptors= new ArrayList<RulerColumnDescriptor>(); + Map<String, RulerColumnDescriptor> descriptorMap= new HashMap<String, RulerColumnDescriptor>(); + + for (Iterator<IConfigurationElement> iter= elements.iterator(); iter.hasNext();) { + IConfigurationElement element= iter.next(); + try { + RulerColumnDescriptor desc= new RulerColumnDescriptor(element, this); + String id= desc.getId(); + if (descriptorMap.containsKey(id)) { + noteDuplicateId(desc); + continue; + } + + descriptors.add(desc); + descriptorMap.put(id, desc); + } catch (InvalidRegistryObjectException x) { + /* + * Element is not valid any longer as the contributing plug-in was unloaded or for + * some other reason. Do not include the extension in the list and inform the user + * about it. + */ + noteInvalidExtension(element, x); + } catch (CoreException x) { + warnUser(x.getStatus()); + } + } + + sort(descriptors); + + synchronized (this) { + fDescriptors= Collections.unmodifiableList(descriptors); + fDescriptorMap= Collections.unmodifiableMap(descriptorMap); + } + } + + /** + * Sorts the column contributions. + * + * @param descriptors the descriptors to sort + */ + @SuppressWarnings("unchecked") + private void sort(List<RulerColumnDescriptor> descriptors) { + /* + * Topological sort of the DAG defined by the plug-in dependencies + * 1. TopoSort descriptors by plug-in dependency + * 2. Insert into Directed Acyclic Graph + * 3. TopoSort DAG: pick the source with the lowest gravity and remove from DAG + */ + ConfigurationElementSorter sorter= new ConfigurationElementSorter() { + @Override + public IConfigurationElement getConfigurationElement(Object object) { + return ((RulerColumnDescriptor) object).getConfigurationElement(); + } + }; + RulerColumnDescriptor[] array= new RulerColumnDescriptor[descriptors.size()]; + descriptors.toArray(array); + sorter.sort(array); + + Map<String, RulerColumnDescriptor> descriptorsById= new HashMap<String, RulerColumnDescriptor>(); + for (RulerColumnDescriptor desc : array) { + descriptorsById.put(desc.getId(), desc); + } + + DAG dag= new DAG(); + for (RulerColumnDescriptor desc : array) { + dag.addVertex(desc); + + Set<?> before= desc.getPlacement().getConstraints(); + for (Iterator<?> it= before.iterator(); it.hasNext();) { + RulerColumnPlacementConstraint constraint= (RulerColumnPlacementConstraint) it.next(); + String id= constraint.getId(); + RulerColumnDescriptor target= descriptorsById.get(id); + if (target == null) { + noteUnknownTarget(desc, id); + } else { + boolean success; + if (constraint.isBefore()) + success= dag.addEdge(desc, target); + else + success= dag.addEdge(target, desc); + if (!success) + noteCycle(desc, target); + } + } + } + + Comparator<RulerColumnDescriptor> gravityComp= new Comparator<RulerColumnDescriptor>() { + @Override + public int compare(RulerColumnDescriptor o1, RulerColumnDescriptor o2) { + float diff= o1.getPlacement().getGravity() - o2.getPlacement().getGravity(); + if (diff == 0) + return 0; + if (diff < 0) + return -1; + return 1; + } + }; + + /* Topological sort - always select the source with the least gravity */ + Set<RulerColumnDescriptor> toProcess= dag.getSources(); + int index= 0; + while (!toProcess.isEmpty()) { + RulerColumnDescriptor next= Collections.min(toProcess, gravityComp); + array[index]= next; + index++; + dag.removeVertex(next); + toProcess= dag.getSources(); + } + Assert.isTrue(index == array.length); + + ListIterator<RulerColumnDescriptor> it= descriptors.listIterator(); + for (int i= 0; i < index; i++) { + it.next(); + it.set(array[i]); + } + } + + private void noteInvalidExtension(IConfigurationElement element, InvalidRegistryObjectException x) { + String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_invalid_msg, new Object[] {ExtensionPointHelper.findId(element)}); + warnUser(message, x); + } + + private void noteUnknownTarget(RulerColumnDescriptor desc, String referencedId) { + String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_unresolved_placement_msg, new Object[] {QUALIFIED_EXTENSION_POINT, referencedId, desc.getName(), desc.getContributor()}); + warnUser(message, null); + } + + private void noteCycle(RulerColumnDescriptor desc, RulerColumnDescriptor target) { + String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_cyclic_placement_msg, new Object[] {QUALIFIED_EXTENSION_POINT, target.getName(), desc.getName(), desc.getContributor()}); + warnUser(message, null); + } + + private void noteDuplicateId(RulerColumnDescriptor desc) { + String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_duplicate_id_msg, new Object[] {QUALIFIED_EXTENSION_POINT, desc.getId(), desc.getContributor()}); + warnUser(message, null); + } + + private void warnUser(String message, Exception exception) { + IStatus status= new Status(IStatus.WARNING, TextEditorPlugin.PLUGIN_ID, IStatus.OK, message, exception); + warnUser(status); + } + + private void warnUser(IStatus status) { + TextEditorPlugin.getDefault().getLog().log(status); + } +} diff --git a/debug/org.eclipse.cdt.gdb/about.ini b/debug/org.eclipse.cdt.gdb/about.ini index 2411cc21096..e07a7bb377e 100644 --- a/debug/org.eclipse.cdt.gdb/about.ini +++ b/debug/org.eclipse.cdt.gdb/about.ini @@ -1,24 +1,24 @@ -# about.ini
-# contains information about a feature
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# "%key" are externalized strings defined in about.properties
-# This file does not need to be translated.
-
-# Property "aboutText" contains blurb for "About" dialog (translated)
-aboutText=%blurb
-
-# Property "windowImage" contains path to window icon (16x16)
-# needed for primary features only
-
-# Property "featureImage" contains path to feature image (32x32)
-featureImage=cdt_logo_icon32.png
-
-# Property "aboutImage" contains path to product image (500x330 or 115x164)
-# needed for primary features only
-
-# Property "appName" contains name of the application (translated)
-# needed for primary features only
-
-# Property "welcomePerspective" contains the id of the perspective in which the
-# welcome page is to be opened.
-# optional
+# about.ini +# contains information about a feature +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# "%key" are externalized strings defined in about.properties +# This file does not need to be translated. + +# Property "aboutText" contains blurb for "About" dialog (translated) +aboutText=%blurb + +# Property "windowImage" contains path to window icon (16x16) +# needed for primary features only + +# Property "featureImage" contains path to feature image (32x32) +featureImage=cdt_logo_icon32.png + +# Property "aboutImage" contains path to product image (500x330 or 115x164) +# needed for primary features only + +# Property "appName" contains name of the application (translated) +# needed for primary features only + +# Property "welcomePerspective" contains the id of the perspective in which the +# welcome page is to be opened. +# optional diff --git a/debug/org.eclipse.cdt.gdb/about.mappings b/debug/org.eclipse.cdt.gdb/about.mappings index c39de2d7fe5..0824105e69d 100644 --- a/debug/org.eclipse.cdt.gdb/about.mappings +++ b/debug/org.eclipse.cdt.gdb/about.mappings @@ -1,9 +1,9 @@ -# about.mappings
-# contains fill-ins for about.properties
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# This file does not need to be translated.
-
-# The following should contain the build version.
-# e.g. "0=20020612"
-# This value will be added automaticaly via the build scripts
+# about.mappings +# contains fill-ins for about.properties +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# This file does not need to be translated. + +# The following should contain the build version. +# e.g. "0=20020612" +# This value will be added automaticaly via the build scripts 0=@build@
\ No newline at end of file |