Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF1
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.properties3
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.xml1
-rw-r--r--debug/org.eclipse.cdt.debug.ui/schema/disassemblyRulerColumns.exsd269
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/StringSetSerializer.java56
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/AbstractContributedRulerColumn.java66
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IColumnSupport.java62
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IContributedRulerColumn.java99
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnDescriptor.java309
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnPreferenceAdapter.java89
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnRegistry.java294
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/.settings/.api_filters8
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/plugin.properties7
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/plugin.xml55
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/AddressRulerColumn.java68
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyColumnSupport.java209
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java4
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties12
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java468
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/FunctionOffsetRulerColumn.java21
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/OpcodeRulerColumn.java27
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/model/DisassemblyDocument.java11
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferenceConstants.java6
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferencePage.java71
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyRulerColumn.java (renamed from dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyRulerColumn.java)66
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyViewer.java (renamed from dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyViewer.java)55
26 files changed, 1914 insertions, 423 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF b/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF
index e353bd2dc76..934302b9c8d 100644
--- a/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF
+++ b/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF
@@ -33,6 +33,7 @@ Export-Package:
org.eclipse.cdt.debug.ui.breakpointactions,
org.eclipse.cdt.debug.ui.breakpoints,
org.eclipse.cdt.debug.ui.disassembly,
+ org.eclipse.cdt.debug.ui.disassembly.rulers,
org.eclipse.cdt.debug.ui.editors,
org.eclipse.cdt.debug.ui.importexecutable,
org.eclipse.cdt.debug.ui.preferences,
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties
index 719707c823f..c60a7ff9ee3 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.properties
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties
@@ -226,3 +226,6 @@ CastingCategory.name = Cast to Type or Array
# Pin & Clone
PinView.name = Pin to Debug Context
OpenNewView.name = Open New View
+
+# Disassembly Ruler Column extension point
+extPoint.disassemblyRulerColumn=Disassembly Ruler Column
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml
index 7bb1df689ba..bcff9995a95 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml
@@ -5,6 +5,7 @@
<extension-point id="CDebuggerPage" name="%CDebuggerPage" schema="schema/CDebuggerPage.exsd"/>
<extension-point id="BreakpointActionPage" name="%BreakpointActionPage" schema="schema/BreakpointActionPage.exsd"/>
<extension-point id="breakpointContribution" name="%breakpointContribution" schema="schema/BreakpointUIContribution.exsd"/>
+ <extension-point id="disassemblyRulerColumns" name="%extPoint.disassemblyRulerColumn" schema="schema/disassemblyRulerColumns.exsd"/>
<!-- Extensions -->
<extension
diff --git a/debug/org.eclipse.cdt.debug.ui/schema/disassemblyRulerColumns.exsd b/debug/org.eclipse.cdt.debug.ui/schema/disassemblyRulerColumns.exsd
new file mode 100644
index 00000000000..5a8315aaaa8
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/schema/disassemblyRulerColumns.exsd
@@ -0,0 +1,269 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.debug.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.debug.ui" id="disassemblyRulerColumns" name="Disassembly Ruler Column"/>
+ </appInfo>
+ <documentation>
+ Ruler column contributions are line based information areas that are normally shown in the vertical ruler area of the disassembly.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="column" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully qualified identifier of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional identifier of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name of the extension instance
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="column">
+ <annotation>
+ <appInfo>
+ <meta.element labelAttribute="name" icon="icon"/>
+ </appInfo>
+ <documentation>
+ The specification of a ruler column contribution.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <choice minOccurs="1" maxOccurs="unbounded">
+ <element ref="targetId"/>
+ <element ref="targetClass"/>
+ </choice>
+ <element ref="placement"/>
+ </sequence>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ the unique id of this column
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name of the column, may be used in the user interface (e.g. in preference pages)
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="icon" type="string">
+ <annotation>
+ <documentation>
+ an optional icon for the column. May be used in the user interface, for example on preference pages.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="resource"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ the class implementing the column; must implement &lt;code&gt;org.eclipse.cdt.debug.ui.disassembly.rulers.IContributedRulerColumn&lt;/code&gt;
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.cdt.debug.ui.disassembly.rulers.IContributedRulerColumn"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="enabled" type="boolean" use="default" value="true">
+ <annotation>
+ <documentation>
+ the default enablement state of this column
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="global" type="boolean" use="default" value="true">
+ <annotation>
+ <documentation>
+ controls whether toggling the visibility of this column operates on all targeted disassembly parts, or only the active disassembly part. If true, the ruler is added to all applicable parts when the user enables the column; if false, the ruler is only added to the active disassembly part.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="includeInMenu" type="boolean" use="default" value="true">
+ <annotation>
+ <documentation>
+ whether to include a &quot;Show/Hide&quot; menu entry for this column in the ruler context menu
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="targetId">
+ <annotation>
+ <documentation>
+ Describes a disassembly part that the column is contributed to.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ the part id of the target disassembly part
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.ui.editors/editor/@id"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="targetClass">
+ <annotation>
+ <documentation>
+ Describes a disassembly part class that the column is contributed to. Subclasses of the specified class are also targeted by this colum contribution.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ the fully qualified name of a class implementing IWorkbenchPart. The class does not need to be instantiatable.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.ui.IWorkbenchPart"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="placement">
+ <annotation>
+ <documentation>
+ Describes the placement of this ruler column relative to other contributed columns. A column may request to be placed &lt;em&gt;before&lt;/em&gt; or &lt;em&gt;after&lt;/em&gt; other known columns (identified by their &lt;tt&gt;id&lt;/tt&gt;). Columns that would end up at the same position are ordered by &lt;em&gt;gravity&lt;/em&gt; (see below). If the ordering is contradicting or no ordering can be found that fulfills all placement requests, some placement requirements are dropped until the placement can be achieved. If a column does not fully specify its placement it will be placed at an arbitrary but consistent location.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <choice>
+ <element ref="before"/>
+ <element ref="after"/>
+ </choice>
+ </sequence>
+ <attribute name="gravity" type="string" use="default" value="1.0">
+ <annotation>
+ <documentation>
+ a float number between 0.0 and 1.0 that tells how close the column wants to be to the editor, where 0.0 means as far away as possible and 1.0 means as close as possible. After all &lt;i&gt;before&lt;/i&gt; and &lt;i&gt;after&lt;/i&gt; constraints are evaluated, columns that would end up at the same position are ordered by their &lt;i&gt;gravity&lt;/i&gt; value.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="before">
+ <annotation>
+ <documentation>
+ Requests placement before another column. The meaning of &lt;i&gt;before&lt;/i&gt; is similar to the SWT.LEAD flag: In left-to-right environments, &lt;i&gt;before&lt;/i&gt; means &lt;i&gt;to the left of&lt;/i&gt;, in right-to-left environments, it means &lt;i&gt;to the right of&lt;/i&gt;.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ the id of another &lt;tt&gt;rulerColumns&lt;/tt&gt; contribution
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.cdt.debug.ui.disassemblyRulerColumns/column/@id"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="after">
+ <annotation>
+ <documentation>
+ Requests placement after another column. The meaning of &lt;i&gt;after&lt;/i&gt; is similar to the SWT.TRAIL flag: In left-to-right environments, &lt;i&gt;after&lt;/i&gt; means &lt;i&gt;to the right of&lt;/i&gt;, in right-to-left environments, it means &lt;i&gt;to the left of&lt;/i&gt;.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ the id of another &lt;tt&gt;rulerColumns&lt;/tt&gt; contribution
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.cdt.debug.ui.disassemblyRulerColumns/column/@id"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 7.2
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ The extension point is supported by the &lt;tt&gt;org.eclipse.cdt.debug.ui.disassembly.rulers&lt;/tt&gt; package. &lt;code&gt;RulerColumnRegistry&lt;/code&gt; gives access to all contributions, which in turn are described by &lt;code&gt;RulerColumnDescriptor&lt;/code&gt; instances.
+ </documentation>
+ </annotation>
+
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ All ruler column contributions must implement &lt;code&gt;org.eclipse.cdt.debug.ui.disassembly.rulers.IContributedRulerColumn&lt;/code&gt;. Many contributors will find the supplied &lt;code&gt;org.eclipse.cdt.debug.ui.disassembly.rulers.AbstractContributedRulerColumn&lt;/code&gt; useful which serves as super class for contributed ruler columns. Others might start off &lt;code&gt;org.eclipse.jface.text.source.AbstractRulerColumn&lt;/code&gt; which takes over most painting and scrolling aspects of a line based column and can be extended at various granularity levels. Those subclassing the latter class will have to implement &lt;code&gt;org.eclipse.cdt.debug.ui.disassembly.rulers.IContributedRulerColumn&lt;/code&gt; on their own by using &lt;code&gt;org.eclipse.cdt.debug.ui.disassembly.rulers.AbstractContributedRulerColumn&lt;/code&gt; as template.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2006, 20011 IBM Corporation and others.&lt;br&gt;
+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 &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+ </documentation>
+ </annotation>
+
+</schema>
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
new file mode 100644
index 00000000000..68f71ebed2f
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/StringSetSerializer.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 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);
+ @SuppressWarnings("null")
+ StringBuffer buf= new StringBuffer(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/disassembly/rulers/AbstractContributedRulerColumn.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/AbstractContributedRulerColumn.java
new file mode 100644
index 00000000000..a46aaf45a49
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/AbstractContributedRulerColumn.java
@@ -0,0 +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() {
+ }
+}
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
new file mode 100644
index 00000000000..ea21e15a4b7
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IColumnSupport.java
@@ -0,0 +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();
+} \ 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
new file mode 100644
index 00000000000..4c2e7c616ba
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IContributedRulerColumn.java
@@ -0,0 +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();
+
+}
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
new file mode 100644
index 00000000000..48dfaef455f
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnDescriptor.java
@@ -0,0 +1,309 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 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.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);
+
+ @SuppressWarnings("null")
+ 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();
+
+ @SuppressWarnings("null")
+ 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/RulerColumnPreferenceAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnPreferenceAdapter.java
new file mode 100644
index 00000000000..b924ec41782
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnPreferenceAdapter.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 201 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.Set;
+
+import org.eclipse.cdt.debug.internal.ui.preferences.StringSetSerializer;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+/**
+ * Manages the preferences for ruler contributions stored in a preference store.
+ *
+ * @since 7.2
+ */
+public final class RulerColumnPreferenceAdapter {
+ private final IPreferenceStore fStore;
+ private final String fKey;
+
+ /**
+ * Creates a new preference adapter that will read and write under the specified key in the
+ * given preference store.
+ *
+ * @param store the preference store
+ * @param key the key
+ */
+ public RulerColumnPreferenceAdapter(IPreferenceStore store, String key) {
+ Assert.isLegal(store != null);
+ Assert.isLegal(key != null);
+ fStore= store;
+ fKey= key;
+ }
+
+ /**
+ * Returns the enablement state of the given ruler contribution.
+ *
+ * @param descriptor a ruler contribution descriptor
+ * @return <code>true</code> if the ruler is enabled, <code>false</code> otherwise
+ */
+ @SuppressWarnings("null")
+ public boolean isEnabled(RulerColumnDescriptor descriptor) {
+ Assert.isLegal(descriptor != null);
+ String preference= fStore.getString(fKey);
+ return StringSetSerializer.deserialize(preference).contains(descriptor.getId()) ^ descriptor.getDefaultEnablement();
+ }
+
+ /**
+ * Sets the enablement state of the given ruler contribution.
+ *
+ * @param descriptor a ruler contribution descriptor
+ * @param enabled <code>true</code> to enable the contribution, <code>false</code> to
+ * disable it
+ */
+ public void setEnabled(RulerColumnDescriptor descriptor, boolean enabled) {
+ Assert.isLegal(descriptor != null);
+ @SuppressWarnings("null")
+ String id= descriptor.getId();
+ String preference= fStore.getString(fKey);
+ Set<String> marked= StringSetSerializer.deserialize(preference);
+ boolean shouldMark= enabled ^ descriptor.getDefaultEnablement();
+ boolean isMarked= marked.contains(id);
+ if (isMarked != shouldMark) {
+ if (shouldMark)
+ marked.add(id);
+ else
+ marked.remove(id);
+ fStore.setValue(fKey, StringSetSerializer.serialize(marked));
+ }
+ }
+
+ /**
+ * Toggles the enablement state of given the ruler contribution.
+ *
+ * @param descriptor a ruler contribution descriptor
+ */
+ public void toggle(RulerColumnDescriptor descriptor) {
+ Assert.isLegal(descriptor != null);
+ setEnabled(descriptor, !isEnabled(descriptor));
+ }
+}
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
new file mode 100644
index 00000000000..024d07e97b0
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnRegistry.java
@@ -0,0 +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);
+ }
+}
diff --git a/dsf/org.eclipse.cdt.dsf.ui/.settings/.api_filters b/dsf/org.eclipse.cdt.dsf.ui/.settings/.api_filters
index 6dfc9ce04a6..d89b3e85b34 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/.settings/.api_filters
+++ b/dsf/org.eclipse.cdt.dsf.ui/.settings/.api_filters
@@ -1,5 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.cdt.dsf.ui" version="2">
+ <resource path="src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyColumnSupport.java" type="org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyColumnSupport">
+ <filter comment="Bug 366942 - [disassembly] Extension point for contributing ruler columns" id="574619656">
+ <message_arguments>
+ <message_argument value="IColumnSupport"/>
+ <message_argument value="DisassemblyColumnSupport"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java" type="org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyPart">
<filter id="571473929">
<message_arguments>
diff --git a/dsf/org.eclipse.cdt.dsf.ui/plugin.properties b/dsf/org.eclipse.cdt.dsf.ui/plugin.properties
index b88d2ccf30c..fa604141f8f 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/plugin.properties
+++ b/dsf/org.eclipse.cdt.dsf.ui/plugin.properties
@@ -66,4 +66,9 @@ debugUpdateModes.label = Debug Update Modes
# Pin & Clone
PinView.name = Pin to Debug Context
-OpenNewView.name = Open New View \ No newline at end of file
+OpenNewView.name = Open New View
+
+# Disassembly ruler columns
+disassemblyRulerColumn.addresses=Addresses
+disassemblyRulerColumn.functionOffsets=Function Offsets
+disassemblyRulerColumn.opcodes=Opcodes
diff --git a/dsf/org.eclipse.cdt.dsf.ui/plugin.xml b/dsf/org.eclipse.cdt.dsf.ui/plugin.xml
index 6fbd3346834..95ad92131b9 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/plugin.xml
+++ b/dsf/org.eclipse.cdt.dsf.ui/plugin.xml
@@ -789,6 +789,59 @@
name="%disassemblyView.name">
</editor>
</extension>
-
+ <extension
+ point="org.eclipse.cdt.debug.ui.disassemblyRulerColumns">
+ <column
+ class="org.eclipse.cdt.dsf.debug.internal.ui.disassembly.AddressRulerColumn"
+ enabled="true"
+ global="false"
+ id="org.eclipse.cdt.dsf.ui.disassemblyColumn.address"
+ includeInMenu="true"
+ name="%disassemblyRulerColumn.addresses">
+ <placement
+ gravity="0.9">
+ </placement>
+ <targetClass
+ class="org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyPart">
+ </targetClass>
+ </column>
+ <column
+ class="org.eclipse.cdt.dsf.debug.internal.ui.disassembly.FunctionOffsetRulerColumn"
+ enabled="false"
+ global="true"
+ id="org.eclipse.cdt.dsf.ui.disassemblyColumn.functionOffsets"
+ includeInMenu="true"
+ name="%disassemblyRulerColumn.functionOffsets">
+ <placement
+ gravity="0.9">
+ <after
+ id="org.eclipse.cdt.dsf.ui.disassemblyColumn.address">
+ </after>
+ <after
+ id="org.eclipse.cdt.dsf.ui.disassemblyColumn.opcodes">
+ </after>
+ </placement>
+ <targetClass
+ class="org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyPart">
+ </targetClass>
+ </column>
+ <column
+ class="org.eclipse.cdt.dsf.debug.internal.ui.disassembly.OpcodeRulerColumn"
+ enabled="false"
+ global="true"
+ id="org.eclipse.cdt.dsf.ui.disassemblyColumn.opcodes"
+ includeInMenu="true"
+ name="%disassemblyRulerColumn.opcodes">
+ <placement
+ gravity="0.9">
+ <after
+ id="org.eclipse.cdt.dsf.ui.disassemblyColumn.address">
+ </after>
+ </placement>
+ <targetClass
+ class="org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyPart">
+ </targetClass>
+ </column>
+ </extension>
</plugin>
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/AddressRulerColumn.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/AddressRulerColumn.java
index d5cfa50889a..00dee41f8b6 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/AddressRulerColumn.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/AddressRulerColumn.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Wind River Systems and others.
+ * Copyright (c) 2007, 2011 Wind River 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
@@ -15,6 +15,9 @@ import java.math.BigInteger;
import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.DisassemblyDocument;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.SourceFileInfo;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.preferences.DisassemblyPreferenceConstants;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblyRulerColumn;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.source.IAnnotationHover;
import org.eclipse.jface.text.source.IAnnotationModel;
@@ -22,6 +25,7 @@ import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.jface.text.source.IVerticalRulerInfoExtension;
import org.eclipse.jface.text.source.IVerticalRulerListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
/**
@@ -29,6 +33,8 @@ import org.eclipse.swt.SWT;
*/
public class AddressRulerColumn extends DisassemblyRulerColumn implements IVerticalRulerInfo, IVerticalRulerInfoExtension, IAnnotationHover {
+ public static final String ID = "org.eclipse.cdt.dsf.ui.disassemblyColumn.address"; //$NON-NLS-1$
+
private int fRadix;
private boolean fShowRadixPrefix;
private String fRadixPrefix;
@@ -40,9 +46,11 @@ public class AddressRulerColumn extends DisassemblyRulerColumn implements IVerti
*/
public AddressRulerColumn() {
super(SWT.LEFT);
- setShowRadixPrefix(true);
+ IPreferenceStore prefs = getPreferenceStore();
+ setForeground(getColor(DisassemblyPreferenceConstants.ADDRESS_COLOR));
+ setRadix(prefs.getInt(DisassemblyPreferenceConstants.ADDRESS_RADIX));
+ setShowRadixPrefix(prefs.getBoolean(DisassemblyPreferenceConstants.SHOW_ADDRESS_RADIX));
setAddressSize(32);
- setRadix(16);
}
@Override
@@ -128,49 +136,35 @@ public class AddressRulerColumn extends DisassemblyRulerColumn implements IVerti
return buf.toString();
}
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfo#getLineOfLastMouseButtonActivity()
- */
+ @Override
public int getLineOfLastMouseButtonActivity() {
return getParentRuler().getLineOfLastMouseButtonActivity();
}
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfo#toDocumentLineNumber(int)
- */
+ @Override
public int toDocumentLineNumber(int y_coordinate) {
return getParentRuler().toDocumentLineNumber(y_coordinate);
}
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#getHover()
- */
+ @Override
public IAnnotationHover getHover() {
return this;
}
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#getModel()
- */
+ @Override
public IAnnotationModel getModel() {
return null;
}
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#addVerticalRulerListener(org.eclipse.jface.text.source.IVerticalRulerListener)
- */
+ @Override
public void addVerticalRulerListener(IVerticalRulerListener listener) {
}
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#removeVerticalRulerListener(org.eclipse.jface.text.source.IVerticalRulerListener)
- */
+ @Override
public void removeVerticalRulerListener(IVerticalRulerListener listener) {
}
- /*
- * @see org.eclipse.jface.text.source.IAnnotationHover#getHoverInfo(org.eclipse.jface.text.source.ISourceViewer, int)
- */
+ @Override
public String getHoverInfo(ISourceViewer sourceViewer, int line) {
DisassemblyDocument doc = (DisassemblyDocument)getParentRuler().getTextViewer().getDocument();
BigInteger address = doc.getAddressOfLine(line);
@@ -181,4 +175,30 @@ public class AddressRulerColumn extends DisassemblyRulerColumn implements IVerti
return null;
}
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ String property = event.getProperty();
+ IPreferenceStore store = getPreferenceStore();
+ boolean needRedraw = false;
+ if (DisassemblyPreferenceConstants.ADDRESS_COLOR.equals(property)) {
+ setForeground(getColor(property));
+ needRedraw = true;
+ } else if (DisassemblyPreferenceConstants.ADDRESS_RADIX.equals(property)) {
+ setRadix(store.getInt(property));
+ updateNumberOfDigits();
+ computeIndentations();
+ layout(false);
+ needRedraw = true;
+ } else if (DisassemblyPreferenceConstants.SHOW_ADDRESS_RADIX.equals(property)) {
+ setShowRadixPrefix(store.getBoolean(property));
+ updateNumberOfDigits();
+ computeIndentations();
+ layout(false);
+ needRedraw = true;
+ }
+ if (needRedraw) {
+ redraw();
+ }
+ }
+
}
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyColumnSupport.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyColumnSupport.java
new file mode 100644
index 00000000000..09f48dbba8c
--- /dev/null
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyColumnSupport.java
@@ -0,0 +1,209 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.dsf.debug.internal.ui.disassembly;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.debug.ui.disassembly.rulers.IColumnSupport;
+import org.eclipse.cdt.debug.ui.disassembly.rulers.IContributedRulerColumn;
+import org.eclipse.cdt.debug.ui.disassembly.rulers.RulerColumnDescriptor;
+import org.eclipse.cdt.debug.ui.disassembly.rulers.RulerColumnRegistry;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.jface.text.source.CompositeRuler;
+import org.eclipse.jface.text.source.IVerticalRulerColumn;
+import org.eclipse.jface.text.source.IVerticalRulerInfo;
+import org.eclipse.jface.util.SafeRunnable;
+
+/**
+ * Implements the ruler column support of for the given disassembly part.
+ * <p>
+ * This is currently only used to support vertical ruler columns.
+ * </p>
+ */
+class DisassemblyColumnSupport implements IColumnSupport {
+ private final DisassemblyPart fDisassembly;
+ private final RulerColumnRegistry fRegistry;
+ private final List<IContributedRulerColumn> fColumns;
+
+ /**
+ * Creates a new column support for the given disassembly part. Only the disassembly part itself should normally
+ * create such an instance.
+ *
+ * @param editor the disassembly part
+ * @param registry the contribution registry to refer to
+ */
+ public DisassemblyColumnSupport(DisassemblyPart disassembly, RulerColumnRegistry registry) {
+ Assert.isLegal(disassembly != null);
+ Assert.isLegal(registry != null);
+ fDisassembly= disassembly;
+ fRegistry= registry;
+ fColumns= new ArrayList<IContributedRulerColumn>();
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.IColumnSupport#setColumnVisible(java.lang.String, boolean)
+ */
+ @Override
+ public final void setColumnVisible(RulerColumnDescriptor descriptor, boolean visible) {
+ Assert.isLegal(descriptor != null);
+
+ final CompositeRuler ruler= getRuler();
+ if (ruler == null)
+ return;
+
+ if (!isColumnSupported(descriptor))
+ visible= false;
+
+ if (isColumnVisible(descriptor)) {
+ if (!visible)
+ removeColumn(ruler, descriptor);
+ } else {
+ if (visible)
+ addColumn(ruler, descriptor);
+ }
+ }
+
+ private void addColumn(final CompositeRuler ruler, final RulerColumnDescriptor descriptor) {
+
+ final int idx= computeIndex(ruler, descriptor);
+
+ SafeRunnable runnable= new SafeRunnable() {
+ @Override
+ public void run() throws Exception {
+ IContributedRulerColumn column= descriptor.createColumn(fDisassembly);
+ fColumns.add(column);
+ initializeColumn(column);
+ ruler.addDecorator(idx, column);
+ }
+ };
+ SafeRunner.run(runnable);
+ }
+
+ /**
+ * Hook to let subclasses initialize a newly created column.
+ * <p>
+ * Subclasses may extend this method.</p>
+ *
+ * @param column the created column
+ */
+ protected void initializeColumn(IContributedRulerColumn column) {
+ }
+
+ private void removeColumn(final CompositeRuler ruler, final RulerColumnDescriptor descriptor) {
+ removeColumn(ruler, getVisibleColumn(ruler, descriptor));
+ }
+
+ private void removeColumn(final CompositeRuler ruler, final IContributedRulerColumn rulerColumn) {
+ if (rulerColumn != null) {
+ SafeRunnable runnable= new SafeRunnable() {
+ @Override
+ public void run() throws Exception {
+ if (ruler != null)
+ ruler.removeDecorator(rulerColumn);
+ rulerColumn.columnRemoved();
+ }
+ };
+ SafeRunner.run(runnable);
+ }
+ }
+
+ /**
+ * Returns the currently visible column matching <code>id</code>, <code>null</code> if
+ * none.
+ *
+ * @param ruler the composite ruler to scan
+ * @param descriptor the descriptor of the column of interest
+ * @return the matching column or <code>null</code>
+ */
+ private IContributedRulerColumn getVisibleColumn(CompositeRuler ruler, RulerColumnDescriptor descriptor) {
+ for (Iterator<?> it= ruler.getDecoratorIterator(); it.hasNext();) {
+ IVerticalRulerColumn column= (IVerticalRulerColumn)it.next();
+ if (column instanceof IContributedRulerColumn) {
+ IContributedRulerColumn rulerColumn= (IContributedRulerColumn)column;
+ RulerColumnDescriptor rcd= rulerColumn.getDescriptor();
+ if (descriptor.equals(rcd))
+ return rulerColumn;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Computes the insertion index for a column contribution into the currently visible columns.
+ *
+ * @param ruler the composite ruler into which to insert the column
+ * @param descriptor the descriptor to compute the index for
+ * @return the insertion index for a new column
+ */
+ private int computeIndex(CompositeRuler ruler, RulerColumnDescriptor descriptor) {
+ int index= 0;
+ List<?> all= fRegistry.getColumnDescriptors();
+ int newPos= all.indexOf(descriptor);
+ for (Iterator<?> it= ruler.getDecoratorIterator(); it.hasNext();) {
+ IVerticalRulerColumn column= (IVerticalRulerColumn) it.next();
+ if (column instanceof IContributedRulerColumn) {
+ RulerColumnDescriptor rcd= ((IContributedRulerColumn)column).getDescriptor();
+ if (rcd != null && all.indexOf(rcd) > newPos)
+ break;
+ }
+ index++;
+ }
+ return index;
+ }
+
+ @Override
+ public final boolean isColumnVisible(RulerColumnDescriptor descriptor) {
+ Assert.isLegal(descriptor != null);
+ CompositeRuler ruler= getRuler();
+ return ruler != null && getVisibleColumn(ruler, descriptor) != null;
+ }
+
+ @Override
+ public final boolean isColumnSupported(RulerColumnDescriptor descriptor) {
+ Assert.isLegal(descriptor != null);
+ if (getRuler() == null)
+ return false;
+
+ if (descriptor == null)
+ return false;
+
+ return descriptor.matchesPart(fDisassembly);
+ }
+
+ /**
+ * Returns the disassembly part's vertical ruler, if it is a {@link CompositeRuler}, <code>null</code>
+ * otherwise.
+ *
+ * @return the disassembly part's {@link CompositeRuler} or <code>null</code>
+ */
+ private CompositeRuler getRuler() {
+ Object ruler= fDisassembly.getAdapter(IVerticalRulerInfo.class);
+ if (ruler instanceof CompositeRuler)
+ return (CompositeRuler) ruler;
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Subclasses may extend this method.</p>
+ *
+ */
+ @Override
+ public void dispose() {
+ for (Iterator<IContributedRulerColumn> iter= new ArrayList<IContributedRulerColumn>(fColumns).iterator(); iter.hasNext();)
+ removeColumn(getRuler(), iter.next());
+ fColumns.clear();
+ }
+}
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java
index 43f06655e32..909f8e9f931 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java
@@ -29,9 +29,6 @@ public final class DisassemblyMessages extends NLS {
return fgBundleForConstructedKeys;
}
- public static String Disassembly_action_ShowAddresses_label;
- public static String Disassembly_action_ShowFunctionOffsets_label;
- public static String Disassembly_action_ShowOpcode_label;
public static String Disassembly_action_ShowSource_label;
public static String Disassembly_action_ShowSymbols_label;
public static String Disassembly_action_GotoPC_label;
@@ -52,6 +49,7 @@ public final class DisassemblyMessages extends NLS {
public static String Disassembly_log_error_expression_eval;
public static String Disassembly_log_error_locateFile;
public static String Disassembly_log_error_readFile;
+ public static String DisassemblyPart_showRulerColumn_label;
public static String DisassemblyPreferencePage_addressFormatTooltip;
public static String DisassemblyPreferencePage_addressRadix;
public static String DisassemblyPreferencePage_showAddressRadix;
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties
index 9ba33204d52..a4098d6aa1b 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties
@@ -11,9 +11,6 @@
# Patrick Chuong (Texas Instruments) - Bug fix (329682)
##########################################################################
-Disassembly_action_ShowAddresses_label=Show Addresses
-Disassembly_action_ShowFunctionOffsets_label=Show Function Offsets
-Disassembly_action_ShowOpcode_label=Show Opcodes
Disassembly_action_ShowSource_label=Show Source
Disassembly_action_ShowSymbols_label=Show Symbols
Disassembly_action_GotoPC_label=Go to Program Counter
@@ -44,9 +41,10 @@ Disassembly_log_error_expression_eval=Expression does not evaluate to an address
Disassembly_log_error_locateFile=Unable to locate file:\
Disassembly_log_error_readFile=Cannot read source file:\
+DisassemblyPart_showRulerColumn_label=Show {0}
DisassemblyPreferencePage_addressFormatTooltip=Use this format for the instruction address
DisassemblyPreferencePage_addressRadix=Address display format:
-DisassemblyPreferencePage_showAddressRadix=Force radix prefixes
+DisassemblyPreferencePage_showAddressRadix=Force radix prefix
DisassemblyPreferencePage_showSource=Show source
DisassemblyPreferencePage_showSourceTooltip=Show source code interleaved with instructions
DisassemblyPreferencePage_showSymbols=Show symbols
@@ -56,14 +54,8 @@ DisassemblyPreferencePage_error_negative_number=Address cannot be negative
DisassemblyPreferencePage_radix_octal=Octal
DisassemblyPreferencePage_radix_decimal=Decimal
DisassemblyPreferencePage_radix_hexadecimal=Hexadecimal
-DisassemblyPreferencePage_showFunctionOffsets=Show function offsets
-DisassemblyPreferencePage_showFunctionOffsetsTooltip=Show offsets of addresses in a function
-DisassemblyPreferencePage_showCodeBytes=Show instruction code bytes
-DisassemblyPreferencePage_showCodeBytesTooltip=Show the value of the address for the instruction code bytes
-DisassemblyPreferencePage_showAddress=Show instruction address
DisassemblyPreferencePage_OpcodeFormatTooltip=Use this format for the instruction value
DisassemblyPreferencePage_OpcodeFormat=Opcode display format:
-DisassemblyPreferencePage_showAddressTooltip=Show the address of each instruction
DisassemblyPreferencePage_showRadixTooltip=Show '0x' with hexadecimal addresses
DisassemblyIPAnnotation_primary=Debug Current Instruction Pointer
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java
index b90e8e99e9a..275588b02d8 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java
@@ -38,6 +38,12 @@ import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyBackend;
import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyDocument;
import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback;
import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.LabelPosition;
+import org.eclipse.cdt.debug.internal.ui.preferences.StringSetSerializer;
+import org.eclipse.cdt.debug.ui.disassembly.rulers.IColumnSupport;
+import org.eclipse.cdt.debug.ui.disassembly.rulers.IContributedRulerColumn;
+import org.eclipse.cdt.debug.ui.disassembly.rulers.RulerColumnDescriptor;
+import org.eclipse.cdt.debug.ui.disassembly.rulers.RulerColumnPreferenceAdapter;
+import org.eclipse.cdt.debug.ui.disassembly.rulers.RulerColumnRegistry;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.AbstractDisassemblyAction;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.ActionGotoAddress;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.ActionGotoProgramCounter;
@@ -50,6 +56,8 @@ import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.DisassemblyDocume
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.SourceFileInfo;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.preferences.DisassemblyPreferenceConstants;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.presentation.DisassemblyIPAnnotation;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblyRulerColumn;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblyViewer;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.util.HSL;
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
@@ -125,6 +133,7 @@ import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.custom.VerifyKeyListener;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DragSource;
import org.eclipse.swt.dnd.DropTarget;
@@ -133,6 +142,7 @@ import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
@@ -171,6 +181,9 @@ import org.eclipse.ui.texteditor.IUpdate;
import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
import org.eclipse.ui.texteditor.SimpleMarkerAnnotation;
import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
+
+import com.ibm.icu.text.MessageFormat;
+
/**
* DisassemblyPart
*/
@@ -206,17 +219,19 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
public static final String KEY_BINDING_CONTEXT_DISASSEMBLY = "org.eclipse.cdt.dsf.debug.ui.disassembly.context"; //$NON-NLS-1$
+ /**
+ * A named preference that controls the visible ruler column contributions.
+ */
+ public static final String PREFERENCE_RULER_CONTRIBUTIONS= "rulerContributions"; //$NON-NLS-1$
+
protected DisassemblyViewer fViewer;
protected AbstractDisassemblyAction fActionGotoPC;
protected AbstractDisassemblyAction fActionGotoAddress;
protected AbstractDisassemblyAction fActionToggleSource;
- private AbstractDisassemblyAction fActionToggleFunctionColumn;
- private AbstractDisassemblyAction fActionToggleOpcodeColumn;
protected AbstractDisassemblyAction fActionToggleSymbols;
protected AbstractDisassemblyAction fActionRefreshView;
protected Action fActionOpenPreferences;
- private AbstractDisassemblyAction fActionToggleAddressColumn;
private AbstractDisassemblyAction fActionToggleBreakpointEnablement;
protected DisassemblyDocument fDocument;
@@ -244,10 +259,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
private TextViewerDragAdapter fDragSourceAdapter;
private DisassemblyDropAdapter fDropTargetAdapter;
- private FunctionOffsetRulerColumn fFunctionOffsetRulerColumn;
- private OpcodeRulerColumn fOpcodeRulerColumn;
- private AddressRulerColumn fAddressRulerColumn;
-
private BigInteger fStartAddress;
private BigInteger fEndAddress;
private int fAddressSize= 32;
@@ -272,8 +283,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
private List<Action> fSelectionActions = new ArrayList<Action>();
private List<AbstractDisassemblyAction> fStateDependentActions = new ArrayList<AbstractDisassemblyAction>();
private boolean fShowSource;
- private boolean fShowFunctionOffsets;
- private boolean fShowOpcodes;
private boolean fShowSymbols;
private Map<String, Object> fFile2Storage = new HashMap<String, Object>();
private boolean fShowDisassembly = true;
@@ -294,26 +303,34 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
protected IPartListener2 fPartListener =
new IPartListener2() {
+ @Override
public void partActivated(IWorkbenchPartReference partRef) {
}
+ @Override
public void partBroughtToTop(IWorkbenchPartReference partRef) {
}
+ @Override
public void partClosed(IWorkbenchPartReference partRef) {
}
+ @Override
public void partDeactivated(IWorkbenchPartReference partRef) {
}
+ @Override
public void partOpened(IWorkbenchPartReference partRef) {
}
+ @Override
public void partHidden(IWorkbenchPartReference partRef) {
if (partRef.getPart(false) == DisassemblyPart.this) {
setActive(false);
}
}
+ @Override
public void partVisible(IWorkbenchPartReference partRef) {
if (partRef.getPart(false) == DisassemblyPart.this) {
setActive(true);
}
}
+ @Override
public void partInputChanged(IWorkbenchPartReference partRef) {
}
};
@@ -338,6 +355,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
private IDebugContextListener fDebugContextListener;
+ private IColumnSupport fColumnSupport;
+
private final class SyncActiveDebugContextAction extends Action {
public SyncActiveDebugContextAction() {
setChecked(DisassemblyPart.this.isSyncWithActiveDebugContext());
@@ -380,54 +399,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
}
}
- private final class ActionToggleAddressColumn extends AbstractDisassemblyAction {
- ActionToggleAddressColumn () {
- super(DisassemblyPart.this);
- setText(DisassemblyMessages.Disassembly_action_ShowAddresses_label);
- }
- @Override
- public void run() {
- IPreferenceStore store = DsfUIPlugin.getDefault().getPreferenceStore();
- store.setValue(DisassemblyPreferenceConstants.SHOW_ADDRESS_RULER, !isAddressRulerVisible());
- }
- @Override
- public void update() {
- setChecked(isAddressRulerVisible());
- }
- }
-
- private final class ActionToggleFunctionColumn extends AbstractDisassemblyAction {
- ActionToggleFunctionColumn() {
- super(DisassemblyPart.this);
- setText(DisassemblyMessages.Disassembly_action_ShowFunctionOffsets_label);
- }
- @Override
- public void run() {
- IPreferenceStore store = DsfUIPlugin.getDefault().getPreferenceStore();
- store.setValue(DisassemblyPreferenceConstants.SHOW_FUNCTION_OFFSETS, !isFunctionOffsetsRulerVisible());
- }
- @Override
- public void update() {
- setChecked(isFunctionOffsetsRulerVisible());
- }
- }
-
- private final class ActionToggleOpcodeColumn extends AbstractDisassemblyAction {
- ActionToggleOpcodeColumn() {
- super(DisassemblyPart.this);
- setText(DisassemblyMessages.Disassembly_action_ShowOpcode_label);
- }
- @Override
- public void run() {
- IPreferenceStore store = DsfUIPlugin.getDefault().getPreferenceStore();
- store.setValue(DisassemblyPreferenceConstants.SHOW_CODE_BYTES, !isOpcodeRulerVisible());
- }
- @Override
- public void update() {
- setChecked(isOpcodeRulerVisible());
- }
- }
-
private final class ActionToggleBreakpointEnablement extends AbstractDisassemblyAction {
private IBreakpoint fBreakpoint;
public ActionToggleBreakpointEnablement() {
@@ -511,6 +482,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/*
* @see IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
+ @Override
public void propertyChange(PropertyChangeEvent event) {
handlePreferenceStoreChanged(event);
}
@@ -537,8 +509,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
else
fEndAddress = new BigInteger(endAddressString, 16);
fShowSource = prefs.getBoolean(DisassemblyPreferenceConstants.SHOW_SOURCE);
- fShowFunctionOffsets = prefs.getBoolean(DisassemblyPreferenceConstants.SHOW_FUNCTION_OFFSETS);
- fShowOpcodes = prefs.getBoolean(DisassemblyPreferenceConstants.SHOW_CODE_BYTES);
fShowSymbols = prefs.getBoolean(DisassemblyPreferenceConstants.SHOW_SYMBOLS);
fUpdateBeforeFocus = !prefs.getBoolean(DisassemblyPreferenceConstants.AVOID_READ_BEFORE_PC);
fPCHistorySizeMax = prefs.getInt(DisassemblyPreferenceConstants.PC_HISTORY_SIZE);
@@ -571,13 +541,76 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
return fViewer != null ? fViewer.getTextWidget() : null;
} else if (IGotoMarker.class.equals(required)) {
return new IGotoMarker() {
+ @Override
public void gotoMarker(IMarker marker) {
DisassemblyPart.this.gotoMarker(marker);
}};
+ } else if (IColumnSupport.class.equals(required)) {
+ if (fColumnSupport == null)
+ fColumnSupport= createColumnSupport();
+ return fColumnSupport;
}
+
return super.getAdapter(required);
}
+ /**
+ * Adds "show" actions for all contributed rulers that support it.
+ *
+ * @param menu the ruler context menu
+ */
+ private void addRulerContributionActions(IMenuManager menu) {
+ // store directly in generic editor preferences
+ final IColumnSupport support= (IColumnSupport) getAdapter(IColumnSupport.class);
+ IPreferenceStore store= DsfUIPlugin.getDefault().getPreferenceStore();
+ final RulerColumnPreferenceAdapter adapter= new RulerColumnPreferenceAdapter(store, PREFERENCE_RULER_CONTRIBUTIONS);
+ List<RulerColumnDescriptor> descriptors= RulerColumnRegistry.getDefault().getColumnDescriptors();
+ for (final RulerColumnDescriptor descriptor : descriptors) {
+ if (!descriptor.isIncludedInMenu() || !support.isColumnSupported(descriptor))
+ continue;
+ final boolean isVisible= support.isColumnVisible(descriptor);
+ IAction action= new Action(MessageFormat.format(DisassemblyMessages.DisassemblyPart_showRulerColumn_label, new Object[] {descriptor.getName()}), IAction.AS_CHECK_BOX) {
+ @Override
+ public void run() {
+ if (descriptor.isGlobal())
+ // column state is modified via preference listener
+ adapter.setEnabled(descriptor, !isVisible);
+ else
+ // directly modify column for this editor instance
+ support.setColumnVisible(descriptor, !isVisible);
+ }
+ };
+ action.setChecked(isVisible);
+ action.setImageDescriptor(descriptor.getIcon());
+ menu.appendToGroup(ITextEditorActionConstants.GROUP_RULERS, action);
+ }
+ }
+
+ /**
+ * Adds enabled ruler contributions to the vertical ruler.
+ *
+ * @param ruler the composite ruler to add contributions to
+ */
+ protected void updateContributedRulerColumns(CompositeRuler ruler) {
+ IColumnSupport support= (IColumnSupport)getAdapter(IColumnSupport.class);
+ if (support == null)
+ return;
+
+ RulerColumnPreferenceAdapter adapter= null;
+ if (fPreferenceStore != null)
+ adapter= new RulerColumnPreferenceAdapter(getPreferenceStore(), PREFERENCE_RULER_CONTRIBUTIONS);
+
+ RulerColumnRegistry registry= RulerColumnRegistry.getDefault();
+ List<RulerColumnDescriptor> descriptors= registry.getColumnDescriptors();
+ for (RulerColumnDescriptor descriptor : descriptors) {
+ support.setColumnVisible(descriptor, adapter == null || adapter.isEnabled(descriptor));
+ }
+ }
+
+ protected IColumnSupport createColumnSupport() {
+ return new DisassemblyColumnSupport(this, RulerColumnRegistry.getDefault());
+ }
+
private void setPreferenceStore(IPreferenceStore store) {
if (fPreferenceStore != null) {
fPreferenceStore.removePropertyChangeListener(fPropertyChangeListener);
@@ -610,28 +643,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
if (getFontPropertyPreferenceKey().equals(property)) {
initializeViewerFont(fViewer);
- } else if (property.equals(DisassemblyPreferenceConstants.SHOW_ADDRESS_RULER)) {
- fActionToggleAddressColumn.update();
- if (isAddressRulerVisible()) {
- showAddressRuler();
- } else {
- hideAddressRuler();
- }
- } else if (property.equals(DisassemblyPreferenceConstants.ADDRESS_RADIX)) {
- if (fAddressRulerColumn != null) {
- hideAddressRuler();
- showAddressRuler();
- }
- } else if (property.equals(DisassemblyPreferenceConstants.OPCODE_RADIX)) {
- if (isOpcodeRulerVisible()) {
- hideOpcodeRuler();
- showOpcodeRuler();
- }
- } else if (property.equals(DisassemblyPreferenceConstants.SHOW_ADDRESS_RADIX)) {
- if (fAddressRulerColumn != null) {
- hideAddressRuler();
- showAddressRuler();
- }
} else if (property.equals(DisassemblyPreferenceConstants.SHOW_SOURCE)) {
boolean showSource = store.getBoolean(property);
if (fShowSource == showSource) {
@@ -648,22 +659,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
fShowSymbols = showSymbols;
fActionToggleSymbols.update();
refreshView(10);
- } else if (property.equals(DisassemblyPreferenceConstants.SHOW_FUNCTION_OFFSETS)) {
- fShowFunctionOffsets = store.getBoolean(property);
- fActionToggleFunctionColumn.update();
- if (isFunctionOffsetsRulerVisible()) {
- showFunctionOffsetsRuler();
- } else {
- hideFunctionOffsetsRuler();
- }
- } else if (property.equals(DisassemblyPreferenceConstants.SHOW_CODE_BYTES)) {
- fShowOpcodes = store.getBoolean(property);
- fActionToggleOpcodeColumn.update();
- if (isOpcodeRulerVisible()) {
- showOpcodeRuler();
- } else {
- hideOpcodeRuler();
- }
} else if (property.equals(DisassemblyPreferenceConstants.AVOID_READ_BEFORE_PC)) {
fUpdateBeforeFocus = !store.getBoolean(property);
updateVisibleArea();
@@ -676,7 +671,18 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
}
} else if (property.equals(DisassemblyPreferenceConstants.PC_HISTORY_SIZE)) {
fPCHistorySizeMax = store.getInt(property);
+ } else if (PREFERENCE_RULER_CONTRIBUTIONS.equals(property)) {
+ String[] difference= StringSetSerializer.getDifference((String) event.getOldValue(), (String) event.getNewValue());
+ IColumnSupport support= (IColumnSupport) getAdapter(IColumnSupport.class);
+ for (int i= 0; i < difference.length; i++) {
+ RulerColumnDescriptor desc= RulerColumnRegistry.getDefault().getColumnDescriptor(difference[i]);
+ if (desc != null && support.isColumnSupported(desc)) {
+ boolean newState= !support.isColumnVisible(desc);
+ support.setColumnVisible(desc, newState);
+ }
+ }
}
+
}
/**
@@ -691,7 +697,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
parent.setLayout(layout);
fVerticalRuler = createVerticalRuler();
int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION;
- fViewer = new DisassemblyViewer(this, parent, fVerticalRuler, getOverviewRuler(), true, styles);
+ fViewer = new DisassemblyViewer(parent, fVerticalRuler, getOverviewRuler(), true, styles);
SourceViewerConfiguration sourceViewerConfig = new DisassemblyViewerConfiguration(this);
fViewer.addTextPresentationListener(this);
fViewer.configure(sourceViewerConfig);
@@ -715,7 +721,21 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
hookContextMenu();
contributeToActionBars();
+ fViewer.getTextWidget().addVerifyKeyListener(new VerifyKeyListener() {
+ @Override
+ public void verifyKey(VerifyEvent event) {
+ switch (event.keyCode) {
+ case SWT.PAGE_UP:
+ case SWT.PAGE_DOWN:
+ case SWT.ARROW_UP:
+ case SWT.ARROW_DOWN:
+ event.doit = !keyScroll(event.keyCode);
+ }
+ }
+ });
+
fViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
public void selectionChanged(SelectionChangedEvent event) {
updateSelectionDependentActions();
}
@@ -726,14 +746,9 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
fSourceColor = getSharedColors().getColor(new RGB(64, 0, 80));
fLabelColor = getSharedColors().getColor(new RGB(0, 0, 96));
- if (isAddressRulerVisible()) {
- showAddressRuler();
- }
- if (isFunctionOffsetsRulerVisible()) {
- showFunctionOffsetsRuler();
- }
- if (isOpcodeRulerVisible()) {
- showOpcodeRuler();
+ IVerticalRuler ruler= getVerticalRuler();
+ if (ruler instanceof CompositeRuler) {
+ updateContributedRulerColumns((CompositeRuler) ruler);
}
initDragAndDrop();
@@ -756,7 +771,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
super.setSite(site);
site.getPage().addPartListener(fPartListener);
fDebugContextListener = new IDebugContextListener() {
- public void debugContextChanged(DebugContextEvent event) {
+ @Override
+ public void debugContextChanged(DebugContextEvent event) {
if ((event.getFlags() & DebugContextEvent.ACTIVATED) != 0) {
updateDebugContext();
}
@@ -823,6 +839,10 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
}
fPropertyChangeListener = null;
}
+ if (fColumnSupport != null) {
+ fColumnSupport.dispose();
+ fColumnSupport= null;
+ }
fDocument.dispose();
fDocument = null;
@@ -1043,44 +1063,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
}
/**
- * Creates a new address ruler column that is appropriately initialized.
- *
- * @return the created line number column
- */
- protected IVerticalRulerColumn createAddressRulerColumn() {
- fAddressRulerColumn= new AddressRulerColumn();
- initializeRulerColumn(fAddressRulerColumn, DisassemblyPreferenceConstants.ADDRESS_COLOR);
- IPreferenceStore prefs = getPreferenceStore();
- fAddressRulerColumn.setRadix(prefs.getInt(DisassemblyPreferenceConstants.ADDRESS_RADIX));
- fAddressRulerColumn.setShowRadixPrefix(prefs.getBoolean(DisassemblyPreferenceConstants.SHOW_ADDRESS_RADIX));
- return fAddressRulerColumn;
- }
-
- /**
- * Creates a new ruler column that is appropriately initialized.
- *
- * @return the created line number column
- */
- protected IVerticalRulerColumn createFunctionOffsetsRulerColumn() {
- fFunctionOffsetRulerColumn= new FunctionOffsetRulerColumn();
-
- initializeRulerColumn(fFunctionOffsetRulerColumn, DisassemblyPreferenceConstants.FUNCTION_OFFSETS_COLOR);
-
- return fFunctionOffsetRulerColumn;
- }
-
- protected IVerticalRulerColumn createOpcodeRulerColumn() {
- fOpcodeRulerColumn= new OpcodeRulerColumn();
-
- initializeRulerColumn(fOpcodeRulerColumn, DisassemblyPreferenceConstants.CODE_BYTES_COLOR);
-
- IPreferenceStore prefs = getPreferenceStore();
- fOpcodeRulerColumn.setRadix(prefs.getInt(DisassemblyPreferenceConstants.OPCODE_RADIX));
-
- return fOpcodeRulerColumn;
- }
-
- /**
* Initializes the given address ruler column from the preference store.
*
* @param rulerColumn the ruler column to be initialized
@@ -1128,99 +1110,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
return ruler;
}
- private boolean isAddressRulerVisible() {
- return getPreferenceStore().getBoolean(DisassemblyPreferenceConstants.SHOW_ADDRESS_RULER);
- }
-
- /**
- * Shows the address ruler column.
- */
- private void showAddressRuler() {
- if (fAddressRulerColumn == null) {
- IVerticalRuler v= getVerticalRuler();
- if (v instanceof CompositeRuler) {
- CompositeRuler c= (CompositeRuler) v;
- c.addDecorator(1, createAddressRulerColumn());
- }
- }
- }
-
- /**
- * Hides the address ruler column.
- */
- private void hideAddressRuler() {
- if (fAddressRulerColumn != null) {
- IVerticalRuler v= getVerticalRuler();
- if (v instanceof CompositeRuler) {
- CompositeRuler c= (CompositeRuler) v;
- c.removeDecorator(fAddressRulerColumn);
- }
- fAddressRulerColumn = null;
- }
- }
-
- private boolean isFunctionOffsetsRulerVisible() {
- return fShowFunctionOffsets;
- }
-
- private boolean isOpcodeRulerVisible() {
- return fShowOpcodes;
- }
-
- /**
- * Shows the function offset ruler column.
- */
- private void showFunctionOffsetsRuler() {
- if (fFunctionOffsetRulerColumn == null) {
- IVerticalRuler v= getVerticalRuler();
- if (v instanceof CompositeRuler) {
- CompositeRuler c= (CompositeRuler) v;
- c.addDecorator(3, createFunctionOffsetsRulerColumn());
- }
- }
- }
-
- /**
- * Hides the function offset ruler column.
- */
- private void hideFunctionOffsetsRuler() {
- if (fFunctionOffsetRulerColumn != null) {
- IVerticalRuler v= getVerticalRuler();
- if (v instanceof CompositeRuler) {
- CompositeRuler c= (CompositeRuler) v;
- c.removeDecorator(fFunctionOffsetRulerColumn);
- }
- fFunctionOffsetRulerColumn = null;
- }
- }
-
- /**
- * Shows the opcode ruler column.
- */
- private void showOpcodeRuler() {
- if (fOpcodeRulerColumn == null) {
- IVerticalRuler v= getVerticalRuler();
- if (v instanceof CompositeRuler) {
- CompositeRuler c= (CompositeRuler) v;
- c.addDecorator(2, createOpcodeRulerColumn());
- }
- }
- }
-
- /**
- * Hides the opcode ruler column.
- */
- private void hideOpcodeRuler() {
- if (fOpcodeRulerColumn != null) {
- IVerticalRuler v= getVerticalRuler();
- if (v instanceof CompositeRuler) {
- CompositeRuler c= (CompositeRuler) v;
- c.removeDecorator(fOpcodeRulerColumn);
- }
- fOpcodeRulerColumn = null;
- }
- }
-
/**
* Returns the annotation access.
*
@@ -1246,6 +1135,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
MenuManager menuMgr = new MenuManager(id, id);
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
+ @Override
public void menuAboutToShow(IMenuManager manager) {
DisassemblyPart.this.fillContextMenu(manager);
}
@@ -1260,6 +1150,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
MenuManager menuMgr = new MenuManager(id, id);
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
+ @Override
public void menuAboutToShow(IMenuManager manager) {
DisassemblyPart.this.fillRulerContextMenu(manager);
}
@@ -1315,9 +1206,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
protected void fillRulerContextMenu(IMenuManager manager) {
fActionToggleBreakpointEnablement.update();
- fActionToggleAddressColumn.update();
- fActionToggleOpcodeColumn.update();
- fActionToggleFunctionColumn.update();
manager.add(new GroupMarker("group.top")); // ICommonMenuConstants.GROUP_TOP //$NON-NLS-1$
manager.add(new Separator("group.breakpoints")); //$NON-NLS-1$
@@ -1327,9 +1215,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
manager.add(new GroupMarker(ITextEditorActionConstants.GROUP_RESTORE));
manager.add(new Separator("add")); //$NON-NLS-1$
manager.add(new Separator(ITextEditorActionConstants.GROUP_RULERS));
- manager.add(fActionToggleAddressColumn);
- manager.add(fActionToggleOpcodeColumn);
- manager.add(fActionToggleFunctionColumn);
+ addRulerContributionActions(manager);
manager.add(new Separator(ITextEditorActionConstants.GROUP_REST));
for (Object listener : fRulerContextMenuListeners.getListeners())
@@ -1429,9 +1315,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
}
});
fActionToggleBreakpointEnablement = new ActionToggleBreakpointEnablement();
- fActionToggleAddressColumn = new ActionToggleAddressColumn();
- fActionToggleOpcodeColumn = new ActionToggleOpcodeColumn();
- fActionToggleFunctionColumn = new ActionToggleFunctionColumn();
fActionToggleSymbols = new ActionToggleSymbols();
fActionRefreshView = new ActionRefreshView();
fSyncAction = new SyncActiveDebugContextAction();
@@ -1457,6 +1340,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/*
* @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart#gotoProgramCounter()
*/
+ @Override
public final void gotoProgramCounter() {
if (fPCAddress != PC_RUNNING) {
fPCLastAddress = PC_UNKNOWN;
@@ -1467,6 +1351,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/*
* @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart#gotoAddress(java.math.BigInteger)
*/
+ @Override
public final void gotoAddress(IAddress address) {
if (address != null) {
gotoAddress(address.getValue());
@@ -1486,6 +1371,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/*
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#gotoAddress(java.math.BigInteger)
*/
+ @Override
public final void gotoAddress(BigInteger address) {
fFocusAddress = address;
if (fDebugSessionId == null) {
@@ -1517,6 +1403,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/*
* @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart#gotoSymbol(java.lang.String)
*/
+ @Override
public final void gotoSymbol(final String symbol) {
if (!fActive || fBackend == null || !fBackend.hasFrameContext()) {
return;
@@ -1563,12 +1450,14 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/*
* @see org.eclipse.jface.text.IViewportListener#viewportChanged(int)
*/
+ @Override
public void viewportChanged(int verticalOffset) {
if (fDebugSessionId != null && fGotoAddressPending == PC_UNKNOWN && fScrollPos == null && !fUpdatePending && !fRefreshViewPending) {
fUpdatePending = true;
final int updateCount = fUpdateCount;
invokeLater(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
if (updateCount == fUpdateCount) {
assert fUpdatePending;
if (fUpdatePending) {
@@ -1586,6 +1475,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
*
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#updateVisibleArea()
*/
+ @Override
public void updateVisibleArea() {
assert isGuiThread();
if (!fActive || fUpdatePending || fViewer == null || fDebugSessionId == null) {
@@ -1699,6 +1589,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#asyncExec(java.lang.Runnable)
*/
+ @Override
public void asyncExec(Runnable runnable) {
if (fViewer != null) {
fViewer.getControl().getDisplay().asyncExec(runnable);
@@ -1718,6 +1609,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
*
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#updateInvalidSource()
*/
+ @Override
public void updateInvalidSource() {
assert isGuiThread();
if (fViewer == null) {
@@ -1765,7 +1657,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
return;
}
startUpdate(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
if (DEBUG) System.out.println("retrieveDisassembly "+file); //$NON-NLS-1$
fBackend.retrieveDisassembly(file, lines, fEndAddress, mixed, fShowSymbols, fShowDisassembly);
}
@@ -1783,6 +1676,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#retrieveDisassembly(java.math.BigInteger, java.math.BigInteger, int, boolean, boolean)
*/
+ @Override
public void retrieveDisassembly(final BigInteger startAddress, BigInteger endAddress, final int linesHint, boolean mixed, boolean ignoreFile) {
assert isGuiThread();
assert !fUpdatePending;
@@ -1811,6 +1705,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#insertError(java.math.BigInteger, java.lang.String)
*/
+ @Override
public void insertError(BigInteger address, String message) {
assert isGuiThread();
AddressRangePosition p = null;
@@ -1828,6 +1723,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#getAddressSize()
*/
+ @Override
public int getAddressSize() {
assert isGuiThread();
return fAddressSize;
@@ -1836,6 +1732,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#addressSizeChanged(int)
*/
+ @Override
public void addressSizeChanged(int addressSize) {
assert isGuiThread();
BigInteger oldEndAddress= fEndAddress;
@@ -1864,7 +1761,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
} else {
return;
}
- if (fAddressRulerColumn != null) {
+ AddressRulerColumn fAddressRulerColumn = (AddressRulerColumn) getRulerColumn(AddressRulerColumn.ID);
+ if (fAddressRulerColumn != null) {
fAddressRulerColumn.setAddressSize(addressSize);
if (fComposite != null) {
fComposite.layout(true);
@@ -1872,9 +1770,24 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
}
}
+ private IContributedRulerColumn getRulerColumn(String id) {
+ CompositeRuler compositeRuler = (CompositeRuler) getVerticalRuler();
+ for (Iterator<?> iter = compositeRuler.getDecoratorIterator(); iter.hasNext();) {
+ IVerticalRulerColumn column = (IVerticalRulerColumn) iter.next();
+ if (column instanceof IContributedRulerColumn) {
+ IContributedRulerColumn contributedColumn = (IContributedRulerColumn) column;
+ if (id.equals(contributedColumn.getDescriptor().getId())) {
+ return contributedColumn;
+ }
+ }
+ }
+ return null;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#getPositionOfAddress(java.math.BigInteger)
*/
+ @Override
public AddressRangePosition getPositionOfAddress(BigInteger address) {
assert isGuiThread();
if (address == null || address.compareTo(BigInteger.ZERO) < 0) {
@@ -1967,6 +1880,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
}
if (needUpdate && fViewer != null) {
startUpdate(new Runnable() {
+ @Override
public void run() {
debugContextChanged();
}
@@ -1980,7 +1894,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
final int updateCount = fUpdateCount;
final SafeRunnable safeUpdate = new SafeRunnable() {
- public void run() {
+ @Override
+ public void run() {
if (updateCount == fUpdateCount) {
update.run();
}
@@ -1992,7 +1907,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
};
if (fUpdatePending) {
invokeLater(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
if (updateCount == fUpdateCount) {
SafeRunner.run(safeUpdate);
}
@@ -2057,6 +1973,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
fRefreshViewPending = true;
final long refreshViewScheduled = System.currentTimeMillis() + delay;
final Runnable refresh = new Runnable() {
+ @Override
public void run() {
fRefreshViewPending = false;
long now = System.currentTimeMillis();
@@ -2087,6 +2004,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
}};
if (delay > 0) {
invokeLater(delay, new Runnable() {
+ @Override
public void run() {
doScrollLocked(refresh);
}});
@@ -2230,6 +2148,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#gotoFrame(int)
*/
+ @Override
public void gotoFrame(int frame) {
assert isGuiThread();
fGotoAddressPending = PC_UNKNOWN;
@@ -2239,6 +2158,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#gotoFrameIfActive(int)
*/
+ @Override
public void gotoFrameIfActive(int frame) {
assert isGuiThread();
if (fActive) {
@@ -2252,6 +2172,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#gotoFrame(int, java.math.BigInteger)
*/
+ @Override
public void gotoFrame(int frame, BigInteger address) {
assert isGuiThread();
if (DEBUG) System.out.println("gotoFrame " + frame + " " + getAddressText(address)); //$NON-NLS-1$ //$NON-NLS-2$
@@ -2332,6 +2253,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/*
* @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart#isActive()
*/
+ @Override
public final boolean isActive() {
return fActive;
}
@@ -2339,6 +2261,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/*
* @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart#isConnected()
*/
+ @Override
public final boolean isConnected() {
if (fDebugSessionId == null) {
return false;
@@ -2350,6 +2273,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/*
* @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart#isSuspended()
*/
+ @Override
public final boolean isSuspended() {
return isConnected() && fBackend.isSuspended();
}
@@ -2357,10 +2281,12 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/*
* @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart#getTextViewer()
*/
+ @Override
public final ISourceViewer getTextViewer() {
return fViewer;
}
+ @Override
public final boolean hasViewer() {
return fViewer != null;
}
@@ -2368,6 +2294,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/*
* @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart#addRulerContextMenuListener(org.eclipse.jface.action.IMenuListener)
*/
+ @Override
public final void addRulerContextMenuListener(IMenuListener listener) {
fRulerContextMenuListeners.add(listener);
}
@@ -2375,6 +2302,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/*
* @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart#removeRulerContextMenuListener(org.eclipse.jface.action.IMenuListener)
*/
+ @Override
public final void removeRulerContextMenuListener(IMenuListener listener) {
fRulerContextMenuListeners.remove(listener);
}
@@ -2476,6 +2404,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
* means target resumed
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#updatePC(java.math.BigInteger)
*/
+ @Override
public void updatePC(BigInteger pc) {
assert isGuiThread();
if (!fPendingPCUpdates.isEmpty()) {
@@ -2535,6 +2464,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
if (!fUpdatePending && !fDoPendingPosted) {
fDoPendingPosted = true;
invokeLater(new Runnable() {
+ @Override
public void run() {
doPending();
fDoPendingPosted = false;
@@ -2546,6 +2476,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#doPending()
*/
+ @Override
public void doPending() {
assert isGuiThread();
if (fViewer == null || fDocument == null) {
@@ -2581,6 +2512,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
* @param doit
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#doScrollLocked(java.lang.Runnable)
*/
+ @Override
public void doScrollLocked(final Runnable doit) {
assert isGuiThread();
if (fViewer == null || fDebugSessionId == null) {
@@ -2600,7 +2532,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
if (fUpdatePending) {
if (fRunnableQueue.size() == 1) {
Runnable doitlater = new Runnable() {
- public void run() {
+ @Override
+ public void run() {
if (updateCount == fUpdateCount) {
doScrollLocked(null);
}
@@ -2636,14 +2569,11 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#lockScroller()
*/
+ @Override
public void lockScroller() {
assert isGuiThread();
assert fScrollPos == null;
- if (isFunctionOffsetsRulerVisible()) {
- fRedrawControl = fViewer.getControl();
- } else {
- fRedrawControl = fViewer.getTextWidget();
- }
+ fRedrawControl = fViewer.getControl();
fRedrawControl.setRedraw(false);
try {
int topOffset = fViewer.getTopIndexStartOffset();
@@ -2680,6 +2610,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#unlockScroller()
*/
+ @Override
public void unlockScroller() {
assert isGuiThread();
try {
@@ -2732,7 +2663,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#insertSource(org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition)
*/
- public void insertSource(AddressRangePosition _pos) {
+ @Override
+ public void insertSource(AddressRangePosition _pos) {
assert isGuiThread();
// IDisassemblyPartCallback does not have visibility to the
// SourcePosition type, which is DSF-specific, so it uses the base type
@@ -2838,6 +2770,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/*
* @see org.eclipse.jface.text.ITextPresentationListener#applyTextPresentation(org.eclipse.jface.text.TextPresentation)
*/
+ @Override
@SuppressWarnings("unchecked")
public void applyTextPresentation(TextPresentation textPresentation) {
IRegion coverage = textPresentation.getExtent();
@@ -2934,9 +2867,11 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
}
}
+ @Override
public AddressRangePosition insertSource(AddressRangePosition pos, BigInteger address, final String file, int lineNumber) {
return insertSource(pos, address, file, lineNumber, lineNumber);
}
+ @Override
public AddressRangePosition insertSource(AddressRangePosition pos, BigInteger address, final String file, int firstLine, int lastLine) {
assert isGuiThread();
Object sourceElement = null;
@@ -3020,8 +2955,10 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#handleTargetSuspended()
*/
+ @Override
public void handleTargetSuspended() {
asyncExec(new Runnable() {
+ @Override
public void run() {
updatePC(PC_UNKNOWN);
firePropertyChange(PROP_SUSPENDED);
@@ -3032,8 +2969,10 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#handleTargetResumed()
*/
+ @Override
public void handleTargetResumed() {
asyncExec(new Runnable() {
+ @Override
public void run() {
updatePC(PC_RUNNING);
firePropertyChange(PROP_SUSPENDED);
@@ -3044,12 +2983,15 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#handleTargetEnded()
*/
+ @Override
public void handleTargetEnded() {
asyncExec(new Runnable() {
+ @Override
public void run() {
fDebugSessionId = null;
startUpdate(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
debugContextChanged();
}
});
@@ -3060,6 +3002,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#setUpdatePending(boolean)
*/
+ @Override
public void setUpdatePending(boolean pending) {
fUpdatePending = pending;
}
@@ -3067,6 +3010,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#getUpdatePending()
*/
+ @Override
public boolean getUpdatePending() {
assert isGuiThread();
return fUpdatePending;
@@ -3075,6 +3019,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#setGotoAddressPending(java.math.BigInteger)
*/
+ @Override
public void setGotoAddressPending(BigInteger address) {
assert isGuiThread();
fGotoAddressPending = address;
@@ -3083,6 +3028,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#getGotoAddressPending()
*/
+ @Override
public BigInteger getGotoAddressPending() {
assert isGuiThread();
return fGotoAddressPending;
@@ -3091,6 +3037,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#getDocument()
*/
+ @Override
public IDisassemblyDocument getDocument() {
assert isGuiThread();
return fDocument;
@@ -3099,6 +3046,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#getStorageForFile(java.lang.String)
*/
+ @Override
public Object getStorageForFile(String file) {
assert isGuiThread();
return fFile2Storage.get(file);
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/FunctionOffsetRulerColumn.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/FunctionOffsetRulerColumn.java
index 119cfb845c3..0c2fb8fddce 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/FunctionOffsetRulerColumn.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/FunctionOffsetRulerColumn.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Wind River Systems and others.
+ * Copyright (c) 2007, 2011 Wind River 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
@@ -13,13 +13,18 @@ package org.eclipse.cdt.dsf.debug.internal.ui.disassembly;
import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition;
import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.DisassemblyPosition;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.DisassemblyDocument;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.preferences.DisassemblyPreferenceConstants;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblyRulerColumn;
import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.util.PropertyChangeEvent;
/**
* A vertical ruler column to display the function + offset of instructions.
*/
public class FunctionOffsetRulerColumn extends DisassemblyRulerColumn {
+ public static final String ID = "org.eclipse.cdt.dsf.ui.disassemblyColumn.functionOffset"; //$NON-NLS-1$
+
/** Maximum width of column (in characters) */
private static final int MAXWIDTH= 20;
@@ -28,6 +33,7 @@ public class FunctionOffsetRulerColumn extends DisassemblyRulerColumn {
*/
public FunctionOffsetRulerColumn() {
super();
+ setForeground(getColor(DisassemblyPreferenceConstants.FUNCTION_OFFSETS_COLOR));
}
/*
@@ -62,4 +68,17 @@ public class FunctionOffsetRulerColumn extends DisassemblyRulerColumn {
return Math.min(MAXWIDTH, doc.getMaxFunctionLength());
}
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ String property = event.getProperty();
+ boolean needRedraw = false;
+ if (DisassemblyPreferenceConstants.FUNCTION_OFFSETS_COLOR.equals(property)) {
+ setForeground(getColor(property));
+ needRedraw = true;
+ }
+ if (needRedraw) {
+ redraw();
+ }
+ }
+
}
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/OpcodeRulerColumn.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/OpcodeRulerColumn.java
index 707d32205d7..bfcf196172f 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/OpcodeRulerColumn.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/OpcodeRulerColumn.java
@@ -13,13 +13,19 @@ package org.eclipse.cdt.dsf.debug.internal.ui.disassembly;
import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition;
import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.DisassemblyPosition;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.DisassemblyDocument;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.preferences.DisassemblyPreferenceConstants;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblyRulerColumn;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.util.PropertyChangeEvent;
/**
* A vertical ruler column to display the opcodes of instructions.
*/
public class OpcodeRulerColumn extends DisassemblyRulerColumn {
+ public static final String ID = "org.eclipse.cdt.dsf.ui.disassemblyColumn.opcode"; //$NON-NLS-1$
+
private int fRadix;
private String fRadixPrefix;
@@ -28,6 +34,8 @@ public class OpcodeRulerColumn extends DisassemblyRulerColumn {
*/
public OpcodeRulerColumn() {
super();
+ setForeground(getColor(DisassemblyPreferenceConstants.CODE_BYTES_COLOR));
+ setRadix(getPreferenceStore().getInt(DisassemblyPreferenceConstants.OPCODE_RADIX));
}
public void setRadix(int radix) {
@@ -91,4 +99,23 @@ public class OpcodeRulerColumn extends DisassemblyRulerColumn {
DisassemblyDocument doc = (DisassemblyDocument)getParentRuler().getTextViewer().getDocument();
return doc.getMaxOpcodeLength(fRadix);
}
+
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ String property = event.getProperty();
+ IPreferenceStore store = getPreferenceStore();
+ boolean needRedraw = false;
+ if (DisassemblyPreferenceConstants.CODE_BYTES_COLOR.equals(property)) {
+ setForeground(getColor(property));
+ needRedraw = true;
+ } else if (DisassemblyPreferenceConstants.OPCODE_RADIX.equals(property)) {
+ setRadix(store.getInt(property));
+ layout(false);
+ needRedraw = true;
+ }
+ if (needRedraw) {
+ redraw();
+ }
+ }
+
}
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/model/DisassemblyDocument.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/model/DisassemblyDocument.java
index befaeac8abd..a23a5ac80e4 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/model/DisassemblyDocument.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/model/DisassemblyDocument.java
@@ -103,6 +103,7 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu
setShowRadixPrefix(false);
fNumberOfInstructions = 0;
fMeanSizeOfInstructions = 4;
+ fMaxFunctionLength = 0;
}
/**
@@ -120,9 +121,7 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu
fi.dispose();
}
fFileInfoMap.clear();
-
fInvalidAddressRanges.clear();
-
fInvalidSource.clear();
}
@@ -141,8 +140,8 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu
return fInvalidAddressRanges.toArray(new AddressRangePosition[fInvalidAddressRanges.size()]);
}
- public void setMaxFunctionLength(int opcodeLength) {
- fMaxFunctionLength = opcodeLength;
+ public void setMaxFunctionLength(int functionLength) {
+ fMaxFunctionLength = functionLength;
}
public int getMaxFunctionLength() {
@@ -1019,6 +1018,7 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyDocument#insertDisassemblyLine(org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition, java.math.BigInteger, int, java.lang.String, java.lang.String, java.lang.String, int)
*/
+ @Override
public AddressRangePosition insertDisassemblyLine(AddressRangePosition pos, BigInteger address, int length, String functionOffset, String instruction, String file, int lineNr)
throws BadLocationException {
return insertDisassemblyLine(pos, address, length, functionOffset, null, instruction, file, lineNr);
@@ -1027,6 +1027,7 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyDocument#insertDisassemblyLine(org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition, java.math.BigInteger, int, java.lang.String, java.lang.String, java.lang.String, int)
*/
+ @Override
public AddressRangePosition insertDisassemblyLine(AddressRangePosition pos, BigInteger address, int length, String functionOffset, BigInteger opcode, String instruction, String file, int lineNr)
throws BadLocationException {
assert isGuiThread();
@@ -1194,6 +1195,7 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyDocument#insertLabel(org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition, java.math.BigInteger, java.lang.String, boolean)
*/
+ @Override
public AddressRangePosition insertLabel(AddressRangePosition pos, BigInteger address, String label, boolean showLabels)
throws BadLocationException {
assert isGuiThread();
@@ -1552,6 +1554,7 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu
}
}
+ @Override
public void addInvalidAddressRange(AddressRangePosition pos) {
assert isGuiThread();
if (DEBUG) System.out.println("Adding to invalid range list: " + pos); //$NON-NLS-1$
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferenceConstants.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferenceConstants.java
index 381ad0c2001..8af99458e51 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferenceConstants.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferenceConstants.java
@@ -32,11 +32,8 @@ public class DisassemblyPreferenceConstants {
public static final String ADDRESS_RADIX = "disassembly.addressRadix"; //$NON-NLS-1$
public static final String OPCODE_RADIX = "disassembly.opcodeRadix"; //$NON-NLS-1$
public static final String SHOW_ADDRESS_RADIX = "disassembly.showAddressRadix"; //$NON-NLS-1$
- public static final String SHOW_ADDRESS_RULER = "disassembly.showAddressRuler"; //$NON-NLS-1$
public static final String ADDRESS_COLOR = "disassembly.addressColor"; //$NON-NLS-1$
- public static final String SHOW_FUNCTION_OFFSETS = "disassembly.showFunctionOffsetRuler"; //$NON-NLS-1$
public static final String FUNCTION_OFFSETS_COLOR = "disassembly.functionOffsetsColor"; //$NON-NLS-1$
- public static final String SHOW_CODE_BYTES = "disassembly.showCodeBytesRuler"; //$NON-NLS-1$
public static final String CODE_BYTES_COLOR = "disassembly.codeBytesColor"; //$NON-NLS-1$
public static final String AVOID_READ_BEFORE_PC = "disassembly.avoidReadBeforePC"; //$NON-NLS-1$
public static final String TRACK_EXPRESSION = "disassembly.trackExpression"; //$NON-NLS-1$
@@ -58,13 +55,10 @@ public class DisassemblyPreferenceConstants {
store.setDefault(END_ADDRESS, "0x" + BigInteger.ONE.shiftLeft(64).toString(16)); //$NON-NLS-1$
store.setDefault(PC_HISTORY_SIZE, 4);
store.setDefault(SHOW_SOURCE, true);
- store.setDefault(SHOW_FUNCTION_OFFSETS, false);
- store.setDefault(SHOW_CODE_BYTES, false);
store.setDefault(SHOW_SYMBOLS, true);
store.setDefault(ADDRESS_RADIX, 16);
store.setDefault(OPCODE_RADIX, 16);
store.setDefault(SHOW_ADDRESS_RADIX, false);
- store.setDefault(SHOW_ADDRESS_RULER, true);
store.setDefault(AVOID_READ_BEFORE_PC, false);
PreferenceConverter.setDefault(store, ADDRESS_COLOR, new RGB(0, 96, 0));
PreferenceConverter.setDefault(store, FUNCTION_OFFSETS_COLOR, new RGB(96, 0, 0));
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferencePage.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferencePage.java
index 25cc9600e9b..0fa58417d5e 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferencePage.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferencePage.java
@@ -23,8 +23,6 @@ import org.eclipse.jface.preference.PreferencePage;
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;
@@ -46,6 +44,7 @@ public class DisassemblyPreferencePage extends PreferencePage implements IWorkbe
private List<Combo> fComboBoxes = new ArrayList<Combo>();
private ArrayList<Text> fNumberFields = new ArrayList<Text>();
private ModifyListener fNumberFieldListener = new ModifyListener() {
+ @Override
public void modifyText(ModifyEvent e) {
numberFieldChanged((Text)e.widget);
}
@@ -93,38 +92,17 @@ public class DisassemblyPreferencePage extends PreferencePage implements IWorkbe
String label;
-// label = DisassemblyMessages.DisassemblyPreferencePage_startAddress; //$NON-NLS-1$
-// addTextField(composite, label, DisassemblyPreferenceConstants.START_ADDRESS, 20, 0, true);
-// label = DisassemblyMessages.DisassemblyPreferencePage_endAddress; //$NON-NLS-1$
-// addTextField(composite, label, DisassemblyPreferenceConstants.END_ADDRESS, 20, 0, true);
-
- label = DisassemblyMessages.DisassemblyPreferencePage_showAddress;
- final Button showAddressCB = addCheckBox(composite, label, DisassemblyPreferenceConstants.SHOW_ADDRESS_RULER, 0);
- showAddressCB.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- fAddressFormatCombo.setEnabled(showAddressCB.getSelection());
- }
- });
- showAddressCB.setToolTipText(DisassemblyMessages.DisassemblyPreferencePage_showAddressTooltip);
label = DisassemblyMessages.DisassemblyPreferencePage_addressRadix;
fAddressFormatCombo = addComboBox(composite, label, DisassemblyPreferenceConstants.ADDRESS_RADIX, fcRadixItems);
fAddressFormatCombo.setToolTipText(DisassemblyMessages.DisassemblyPreferencePage_addressFormatTooltip);
- label = DisassemblyMessages.DisassemblyPreferencePage_showCodeBytes;
- final Button showCodeBytes= addCheckBox(composite, label, DisassemblyPreferenceConstants.SHOW_CODE_BYTES, 0);
- showCodeBytes.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- fOpcodeFormatCombo.setEnabled(showCodeBytes.getSelection());
- }
- });
- showCodeBytes.setToolTipText(DisassemblyMessages.DisassemblyPreferencePage_showCodeBytesTooltip);
+ label = DisassemblyMessages.DisassemblyPreferencePage_showAddressRadix;
+ Button showRadixCB = addCheckBox(composite, label, DisassemblyPreferenceConstants.SHOW_ADDRESS_RADIX, 0);
+ showRadixCB.setToolTipText(DisassemblyMessages.DisassemblyPreferencePage_showRadixTooltip);
+
label = DisassemblyMessages.DisassemblyPreferencePage_OpcodeFormat;
fOpcodeFormatCombo = addComboBox(composite, label, DisassemblyPreferenceConstants.OPCODE_RADIX, fcRadixItems);
fOpcodeFormatCombo.setToolTipText(DisassemblyMessages.DisassemblyPreferencePage_OpcodeFormatTooltip);
-// label = DisassemblyMessages.DisassemblyPreferencePage_instructionRadix;
-// addComboBox(composite, label, DisassemblyPreferenceConstants.INSTRUCTION_RADIX, fcRadixItems);
label = DisassemblyMessages.DisassemblyPreferencePage_showSource;
Button showSourceCB = addCheckBox(composite, label, DisassemblyPreferenceConstants.SHOW_SOURCE, 0);
@@ -132,42 +110,6 @@ public class DisassemblyPreferencePage extends PreferencePage implements IWorkbe
label = DisassemblyMessages.DisassemblyPreferencePage_showSymbols;
Button showSymbolsCB = addCheckBox(composite, label, DisassemblyPreferenceConstants.SHOW_SYMBOLS, 0);
showSymbolsCB.setToolTipText(DisassemblyMessages.DisassemblyPreferencePage_showSymbolsTooltip);
-// label = DisassemblyMessages.DisassemblyPreferencePage_simplifiedMnemonics;
-// addCheckBox(composite, label, DisassemblyPreferenceConstants.SIMPLIFIED, 0);
- label = DisassemblyMessages.DisassemblyPreferencePage_showAddressRadix;
- Button showRadixCB = addCheckBox(composite, label, DisassemblyPreferenceConstants.SHOW_ADDRESS_RADIX, 0);
- showRadixCB.setToolTipText(DisassemblyMessages.DisassemblyPreferencePage_showRadixTooltip);
- label = DisassemblyMessages.DisassemblyPreferencePage_showFunctionOffsets;
- Button showFunctionOffsets = addCheckBox(composite, label, DisassemblyPreferenceConstants.SHOW_FUNCTION_OFFSETS, 0);
- showFunctionOffsets.setToolTipText(DisassemblyMessages.DisassemblyPreferencePage_showFunctionOffsetsTooltip);
-// label = DisassemblyMessages.DisassemblyPreferencePage_avoidReadBeforePC;
-// addCheckBox(composite, label, DisassemblyPreferenceConstants.AVOID_READ_BEFORE_PC, 0);
-
- // horizontal line
-// Label separator = new Label(composite, SWT.SEPARATOR|SWT.HORIZONTAL);
-// GridData data;
-// data = new GridData(GridData.FILL_HORIZONTAL);
-// data.horizontalSpan = layout.numColumns;
-// separator.setLayoutData(data);
-//
-// label = DisassemblyMessages.DisassemblyPreferencePage_useSourceOnlyMode;
-// addCheckBox(composite, label, DisassemblyPreferenceConstants.USE_SOURCE_ONLY_MODE, 0);
-//
-// // note
-// String noteTitle = DisassemblyMessages.DisassemblyPreferencePage_useSourceOnlyMode_noteTtitle;
-// String noteMessage = DisassemblyMessages.DisassemblyPreferencePage_useSourceOnlyMode_noteMessage;
-// Composite note = createNoteComposite(composite.getFont(), composite, noteTitle, noteMessage);
-// data = (GridData)note.getLayoutData();
-// if (data == null) {
-// data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
-// note.setLayoutData(data);
-// }
-// data.horizontalSpan = layout.numColumns;
-// Control msgControl = note.getChildren()[1];
-// data = new GridData(GridData.FILL_HORIZONTAL);
-// data.widthHint = convertWidthInCharsToPixels(65);
-// data.heightHint = convertHeightInCharsToPixels(3);
-// msgControl.setLayoutData(data);
Dialog.applyDialogFont(parent);
@@ -179,6 +121,7 @@ public class DisassemblyPreferencePage extends PreferencePage implements IWorkbe
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
*/
+ @Override
public void init(IWorkbench workbench) {
}
@@ -200,7 +143,7 @@ public class DisassemblyPreferencePage extends PreferencePage implements IWorkbe
Label labelControl= new Label(parent, SWT.NONE);
labelControl.setText(label);
GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent = 16;
+ gd.horizontalIndent = 0;
gd.horizontalSpan = 2;
labelControl.setLayoutData(gd);
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyRulerColumn.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyRulerColumn.java
index f7017ef1a29..e3edb3db2b4 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyRulerColumn.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyRulerColumn.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * 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
@@ -10,11 +10,15 @@
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/
-package org.eclipse.cdt.dsf.debug.internal.ui.disassembly;
+package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional;
import java.util.Arrays;
+import org.eclipse.cdt.debug.ui.disassembly.rulers.AbstractContributedRulerColumn;
+import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
@@ -26,7 +30,8 @@ import org.eclipse.jface.text.IViewportListener;
import org.eclipse.jface.text.TextEvent;
import org.eclipse.jface.text.source.CompositeRuler;
import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.IVerticalRulerColumn;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
@@ -46,11 +51,13 @@ import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.editors.text.EditorsUI;
/**
* Vertical ruler column for use with disassembly parts.
@@ -58,7 +65,7 @@ import org.eclipse.swt.widgets.Display;
* Derived from {@link org.eclipse.jface.text.source.LineNumberRulerColumn}.
* </p>
*/
-public class DisassemblyRulerColumn implements IVerticalRulerColumn {
+public class DisassemblyRulerColumn extends AbstractContributedRulerColumn implements IPropertyChangeListener {
protected final static String DOTS = "......................................................................"; //$NON-NLS-1$
protected final static String SPACES = " "; //$NON-NLS-1$
@@ -70,6 +77,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
/*
* @see IViewportListener#viewportChanged(int)
*/
+ @Override
public void viewportChanged(int verticalPosition) {
if (verticalPosition != fScrollPos)
redraw();
@@ -78,6 +86,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
/*
* @see ITextListener#textChanged(TextEvent)
*/
+ @Override
public void textChanged(TextEvent event) {
if (updateNumberOfDigits()) {
@@ -97,6 +106,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
/*
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
*/
+ @Override
public void selectionChanged(SelectionChangedEvent event) {
postRedraw();
}
@@ -119,6 +129,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
/*
* @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
*/
+ @Override
public void mouseUp(MouseEvent event) {
// see bug 45700
if (event.button == 1) {
@@ -131,6 +142,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
/*
* @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
*/
+ @Override
public void mouseDown(MouseEvent event) {
fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
// see bug 45700
@@ -142,6 +154,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
/*
* @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
*/
+ @Override
public void mouseDoubleClick(MouseEvent event) {
fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
stopSelecting();
@@ -151,6 +164,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
/*
* @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent)
*/
+ @Override
public void mouseMove(MouseEvent event) {
if (!autoScroll(event)) {
int newLine = fParentRuler.toDocumentLineNumber(event.y);
@@ -161,18 +175,21 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
/*
* @see org.eclipse.swt.events.MouseTrackListener#mouseEnter(org.eclipse.swt.events.MouseEvent)
*/
+ @Override
public void mouseEnter(MouseEvent event) {
}
/*
* @see org.eclipse.swt.events.MouseTrackListener#mouseExit(org.eclipse.swt.events.MouseEvent)
*/
+ @Override
public void mouseExit(MouseEvent event) {
}
/*
* @see org.eclipse.swt.events.MouseTrackListener#mouseHover(org.eclipse.swt.events.MouseEvent)
*/
+ @Override
public void mouseHover(MouseEvent event) {
}
@@ -283,6 +300,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
switch (direction) {
case SWT.UP:
timer = new Runnable() {
+ @Override
public void run() {
if (fAutoScrollDirection == SWT.UP) {
int top = getInclusiveTopIndex();
@@ -297,6 +315,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
break;
case SWT.DOWN:
timer = new Runnable() {
+ @Override
public void run() {
if (fAutoScrollDirection == SWT.DOWN) {
int top = getInclusiveTopIndex();
@@ -372,6 +391,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
* Redraw runnable
*/
private Runnable fRunnable = new Runnable() {
+ @Override
public void run() {
synchronized (fRunnableLock) {
fIsRunnablePosted = false;
@@ -402,6 +422,18 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
fPaintStyleBackground = paintStyle;
}
+ @Override
+ public void columnCreated() {
+ super.columnCreated();
+ getPreferenceStore().addPropertyChangeListener(this);
+ }
+
+ @Override
+ public void columnRemoved() {
+ getPreferenceStore().removePropertyChangeListener(this);
+ super.columnRemoved();
+ }
+
/**
* Sets the foreground color of this column.
*
@@ -446,9 +478,14 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
return fBackground;
}
+ public IPreferenceStore getPreferenceStore() {
+ return DsfUIPlugin.getDefault().getPreferenceStore();
+ }
+
/*
* @see IVerticalRulerColumn#getControl()
*/
+ @Override
public Control getControl() {
return fCanvas;
}
@@ -456,6 +493,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
/*
* @see IVerticalRuleColumnr#getWidth
*/
+ @Override
public int getWidth() {
return fIndentation[0];
}
@@ -556,6 +594,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
/*
* @see IVerticalRulerColumn#createControl(CompositeRuler, Composite)
*/
+ @Override
public Control createControl(CompositeRuler parentRuler, Composite parentControl) {
fParentRuler= parentRuler;
@@ -567,6 +606,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
fCanvas.setForeground(fForeground);
fCanvas.addPaintListener(new PaintListener() {
+ @Override
public void paintControl(PaintEvent event) {
if (fCachedTextViewer != null)
doubleBufferPaint(event.gc);
@@ -574,6 +614,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
});
fCanvas.addDisposeListener(new DisposeListener() {
+ @Override
public void widgetDisposed(DisposeEvent e) {
handleDispose();
fCachedTextViewer= null;
@@ -620,6 +661,14 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
}
}
+ protected Color getColor(String key) {
+ return EditorsUI.getSharedTextColors().getColor(PreferenceConverter.getColor(getPreferenceStore(), key));
+ }
+
+ protected Color getColor(RGB color) {
+ return EditorsUI.getSharedTextColors().getColor(color);
+ }
+
/**
* Double buffer drawing.
*
@@ -769,7 +818,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
* the line number for which the string is generated
* @return the string to be printed on the ruler column for <code>line</code>
*/
- String createDisplayString(int line) {
+ protected String createDisplayString(int line) {
return Integer.toString(line + 1);
}
@@ -941,6 +990,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
/*
* @see IVerticalRulerColumn#redraw()
*/
+ @Override
public void redraw() {
if (fRelayoutRequired) {
@@ -958,12 +1008,14 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
/*
* @see IVerticalRulerColumn#setModel(IAnnotationModel)
*/
+ @Override
public void setModel(IAnnotationModel model) {
}
/*
* @see IVerticalRulerColumn#setFont(Font)
*/
+ @Override
public void setFont(Font font) {
fFont= font;
if (fCanvas != null && !fCanvas.isDisposed()) {
@@ -982,4 +1034,8 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn {
return fParentRuler;
}
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ }
+
}
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyViewer.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyViewer.java
index 7d4a4e43006..b790a0339ce 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyViewer.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyViewer.java
@@ -8,7 +8,7 @@
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.dsf.debug.internal.ui.disassembly;
+package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional;
import java.util.Iterator;
@@ -24,15 +24,12 @@ import org.eclipse.jface.text.source.IOverviewRuler;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.jface.text.source.IVerticalRulerColumn;
import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.custom.VerifyKeyListener;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
@@ -43,15 +40,11 @@ import org.eclipse.swt.widgets.Composite;
public class DisassemblyViewer extends SourceViewer {
class ResizeListener implements ControlListener {
- /*
- * @see ControlListener#controlResized(ControlEvent)
- */
+ @Override
public void controlResized(ControlEvent e) {
updateViewportListeners(RESIZE);
}
- /*
- * @see ControlListener#controlMoved(ControlEvent)
- */
+ @Override
public void controlMoved(ControlEvent e) {
}
}
@@ -59,11 +52,6 @@ public class DisassemblyViewer extends SourceViewer {
private boolean fUserTriggeredScrolling;
private int fCachedLastTopPixel;
- // extra resize listener to workaround bug 171018
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171018
- private ResizeListener fResizeListener;
- private DisassemblyPart fPart;
-
/**
* Create a new DisassemblyViewer.
* @param parent
@@ -72,9 +60,8 @@ public class DisassemblyViewer extends SourceViewer {
* @param showsAnnotationOverview
* @param styles
*/
- public DisassemblyViewer(DisassemblyPart part, Composite parent, IVerticalRuler ruler, IOverviewRuler overviewRuler, boolean showsAnnotationOverview, int styles) {
+ public DisassemblyViewer(Composite parent, IVerticalRuler ruler, IOverviewRuler overviewRuler, boolean showsAnnotationOverview, int styles) {
super(parent, ruler, overviewRuler, showsAnnotationOverview, styles);
- fPart = part;
// always readonly
setEditable(false);
}
@@ -86,30 +73,9 @@ public class DisassemblyViewer extends SourceViewer {
protected void createControl(Composite parent, int styles) {
super.createControl(parent, styles);
StyledText textWidget = getTextWidget();
+ // extra resize listener to workaround bug 171018
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=171018
- textWidget.addControlListener(fResizeListener= new ResizeListener());
- textWidget.addVerifyKeyListener(new VerifyKeyListener() {
- public void verifyKey(VerifyEvent event) {
- switch (event.keyCode) {
- case SWT.PAGE_UP:
- case SWT.PAGE_DOWN:
- case SWT.ARROW_UP:
- case SWT.ARROW_DOWN:
- event.doit = !fPart.keyScroll(event.keyCode);
- }
- }
- });
- }
-
- /*
- * @see org.eclipse.jface.text.source.SourceViewer#handleDispose()
- */
- @Override
- protected void handleDispose() {
- if (fResizeListener != null) {
- getTextWidget().removeControlListener(fResizeListener);
- }
- super.handleDispose();
+ textWidget.addControlListener(new ResizeListener());
}
/*
@@ -150,7 +116,7 @@ public class DisassemblyViewer extends SourceViewer {
* @throws BadLocationException
*/
public String getSelectedText() throws BadLocationException {
- StringBuffer text = new StringBuffer(200);
+ StringBuilder text = new StringBuilder(200);
String lineSeparator = System.getProperty("line.separator"); //$NON-NLS-1$
DisassemblyDocument doc = (DisassemblyDocument)getDocument();
Point selection = getSelectedRange();
@@ -204,7 +170,7 @@ public class DisassemblyViewer extends SourceViewer {
* @return the prefix string with trailing blank or the empty string
*/
public String getLinePrefix(int line) {
- StringBuffer prefix = new StringBuffer(10);
+ StringBuilder prefix = new StringBuilder(10);
IVerticalRuler ruler = getVerticalRuler();
if (ruler instanceof CompositeRuler) {
for (Iterator<?> iter = ((CompositeRuler)ruler).getDecoratorIterator(); iter.hasNext();) {
@@ -280,10 +246,11 @@ public class DisassemblyViewer extends SourceViewer {
return -1;
}
- int getLastTopPixel() {
+ public int getLastTopPixel() {
return fCachedLastTopPixel;
}
- boolean isUserTriggeredScrolling() {
+
+ public boolean isUserTriggeredScrolling() {
return fUserTriggeredScrolling;
}

Back to the top