diff options
author | Jonah Graham | 2018-11-20 21:20:39 +0000 |
---|---|---|
committer | Jonah Graham | 2018-11-20 21:20:39 +0000 |
commit | 48d2271a58a68743e428d3096d2bca054d04e310 (patch) | |
tree | 235ba23e71c393ad22d1d57fc8fdfec14754c4ee /debug/org.eclipse.cdt.debug.ui/src/org/eclipse | |
parent | 3cf0297769e5cfb91823e93ce570120a75fe01ce (diff) | |
download | org.eclipse.cdt-48d2271a58a68743e428d3096d2bca054d04e310.tar.gz org.eclipse.cdt-48d2271a58a68743e428d3096d2bca054d04e310.tar.xz org.eclipse.cdt-48d2271a58a68743e428d3096d2bca054d04e310.zip |
Bug 540373: Normalize newlines with .gitattributes
There is also a new script to verify completeness of .gitattributes:
releng/scripts/verify_gitattributes.sh
Change-Id: I2ce270852ab54b66b6c474a6ec94203fe5bba78b
Diffstat (limited to 'debug/org.eclipse.cdt.debug.ui/src/org/eclipse')
15 files changed, 1467 insertions, 1467 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/StringSetSerializer.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/StringSetSerializer.java index fd8c60fea3e..42da492c9ba 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/StringSetSerializer.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/StringSetSerializer.java @@ -1,55 +1,55 @@ -/*******************************************************************************
- * Copyright (c) 2006, 2016 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
+/******************************************************************************* + * Copyright (c) 2006, 2016 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.preferences;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.Assert;
-
-public final class StringSetSerializer {
- private static final String DELIM= "\0"; //$NON-NLS-1$
- private StringSetSerializer() {
- }
-
- public static String serialize(Set<String> strings) {
- Assert.isLegal(strings != null);
- StringBuilder buf= new StringBuilder(strings.size() * 20);
- for (Iterator<String> it= strings.iterator(); it.hasNext();) {
- buf.append(it.next());
- if (it.hasNext())
- buf.append(DELIM);
- }
- return buf.toString();
- }
-
- public static Set<String> deserialize(String serialized) {
- Assert.isLegal(serialized != null);
- Set<String> marked= new HashSet<String>();
- StringTokenizer tok= new StringTokenizer(serialized, DELIM);
- while (tok.hasMoreTokens())
- marked.add(tok.nextToken());
- return marked;
- }
-
- public static String[] getDifference(String oldValue, String newValue) {
- Set<String> oldSet= deserialize(oldValue);
- Set<String> newSet= deserialize(newValue);
- Set<String> intersection= new HashSet<String>(oldSet);
- intersection.retainAll(newSet);
- oldSet.removeAll(intersection);
- newSet.removeAll(intersection);
- oldSet.addAll(newSet);
- return oldSet.toArray(new String[oldSet.size()]);
- }
-}
+package org.eclipse.cdt.debug.internal.ui.preferences; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import java.util.StringTokenizer; + +import org.eclipse.core.runtime.Assert; + +public final class StringSetSerializer { + private static final String DELIM= "\0"; //$NON-NLS-1$ + private StringSetSerializer() { + } + + public static String serialize(Set<String> strings) { + Assert.isLegal(strings != null); + StringBuilder buf= new StringBuilder(strings.size() * 20); + for (Iterator<String> it= strings.iterator(); it.hasNext();) { + buf.append(it.next()); + if (it.hasNext()) + buf.append(DELIM); + } + return buf.toString(); + } + + public static Set<String> deserialize(String serialized) { + Assert.isLegal(serialized != null); + Set<String> marked= new HashSet<String>(); + StringTokenizer tok= new StringTokenizer(serialized, DELIM); + while (tok.hasMoreTokens()) + marked.add(tok.nextToken()); + return marked; + } + + public static String[] getDifference(String oldValue, String newValue) { + Set<String> oldSet= deserialize(oldValue); + Set<String> newSet= deserialize(newValue); + Set<String> intersection= new HashSet<String>(oldSet); + intersection.retainAll(newSet); + oldSet.removeAll(intersection); + newSet.removeAll(intersection); + oldSet.addAll(newSet); + return oldSet.toArray(new String[oldSet.size()]); + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandAction.java index f5b11815764..3fed228efb2 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandAction.java @@ -1,124 +1,124 @@ -/*******************************************************************************
- * Copyright (c) 2016 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Alena Laskavaia (QNX)- Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.debug.ui.breakpointactions;
-
-import java.text.MessageFormat;
-
-import org.eclipse.cdt.debug.core.CDIDebugModel;
-import org.eclipse.cdt.debug.core.breakpointactions.AbstractBreakpointAction;
-import org.eclipse.cdt.debug.core.breakpointactions.ICLIDebugActionEnabler;
-import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
-import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
-import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.model.IBreakpoint;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * This breakpoint action allows to pass arbitrary command line command to debugger backend.
- * For example in case of gdb it would be something like
- * p myGlobal
- * cont
- * @since 8.0
- */
-public class CLICommandAction extends AbstractBreakpointAction {
- private static final String COMMAND_ATT = "command"; //$NON-NLS-1$
- private String command = ""; //$NON-NLS-1$
-
- @Override
- public IStatus execute(IBreakpoint breakpoint, IAdaptable context, IProgressMonitor monitor) {
- ICLIDebugActionEnabler enabler = context.getAdapter(ICLIDebugActionEnabler.class);
- if (enabler != null) {
- try {
- enabler.execute(getCommand());
- } catch (Exception e) {
- return errorStatus(e);
- }
- } else
- return new Status(IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(),
- IInternalCDebugUIConstants.INTERNAL_ERROR,
- Messages.getString("CLICommandAction.NoSupport"), null); //$NON-NLS-1$
- return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
- }
-
- private IStatus errorStatus(Exception ex) {
- String errorMsg = MessageFormat.format(Messages.getString("CLICommandAction.error.0"), //$NON-NLS-1$
- new Object[] { getSummary() });
- return new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(),
- ICDebugInternalConstants.STATUS_CODE_ERROR, errorMsg, ex);
- }
-
- @Override
- public String getDefaultName() {
- return Messages.getString("CLICommandAction.UntitledName"); //$NON-NLS-1$
- }
-
- @Override
- public String getIdentifier() {
- return "org.eclipse.cdt.debug.ui.breakpointactions.CLICommandAction"; //$NON-NLS-1$
- }
-
- @Override
- public String getMemento() {
- try {
- Document doc = DebugPlugin.newDocument();
- Element rootElement = doc.createElement(COMMAND_ATT);
- rootElement.setAttribute(COMMAND_ATT, command);
- doc.appendChild(rootElement);
- return DebugPlugin.serializeDocument(doc);
- } catch (DOMException | CoreException e) {
- CDebugUIPlugin.log(e);
-
- }
- return ""; //$NON-NLS-1$
- }
-
- public String getCommand() {
- return command;
- }
-
- public void setCommand(String command) {
- this.command = command;
- }
-
- @Override
- public String getSummary() {
- String summary = getCommand();
- if (summary.length() > 32)
- summary = summary.substring(0, 32);
- return summary;
- }
-
- @Override
- public String getTypeName() {
- return Messages.getString("CLICommandAction.TypeName"); //$NON-NLS-1$
- }
-
- @Override
- public void initializeFromMemento(String data) {
- try {
- Element root = DebugPlugin.parseDocument(data);
- String value = root.getAttribute(COMMAND_ATT);
- if (value == null)
- value = ""; //$NON-NLS-1$
- command = value;
- } catch (Exception e) {
- CDebugUIPlugin.log(e);
- }
- }
-}
+/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alena Laskavaia (QNX)- Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +import java.text.MessageFormat; + +import org.eclipse.cdt.debug.core.CDIDebugModel; +import org.eclipse.cdt.debug.core.breakpointactions.AbstractBreakpointAction; +import org.eclipse.cdt.debug.core.breakpointactions.ICLIDebugActionEnabler; +import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants; +import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants; +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.model.IBreakpoint; +import org.w3c.dom.DOMException; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +/** + * This breakpoint action allows to pass arbitrary command line command to debugger backend. + * For example in case of gdb it would be something like + * p myGlobal + * cont + * @since 8.0 + */ +public class CLICommandAction extends AbstractBreakpointAction { + private static final String COMMAND_ATT = "command"; //$NON-NLS-1$ + private String command = ""; //$NON-NLS-1$ + + @Override + public IStatus execute(IBreakpoint breakpoint, IAdaptable context, IProgressMonitor monitor) { + ICLIDebugActionEnabler enabler = context.getAdapter(ICLIDebugActionEnabler.class); + if (enabler != null) { + try { + enabler.execute(getCommand()); + } catch (Exception e) { + return errorStatus(e); + } + } else + return new Status(IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), + IInternalCDebugUIConstants.INTERNAL_ERROR, + Messages.getString("CLICommandAction.NoSupport"), null); //$NON-NLS-1$ + return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS; + } + + private IStatus errorStatus(Exception ex) { + String errorMsg = MessageFormat.format(Messages.getString("CLICommandAction.error.0"), //$NON-NLS-1$ + new Object[] { getSummary() }); + return new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, errorMsg, ex); + } + + @Override + public String getDefaultName() { + return Messages.getString("CLICommandAction.UntitledName"); //$NON-NLS-1$ + } + + @Override + public String getIdentifier() { + return "org.eclipse.cdt.debug.ui.breakpointactions.CLICommandAction"; //$NON-NLS-1$ + } + + @Override + public String getMemento() { + try { + Document doc = DebugPlugin.newDocument(); + Element rootElement = doc.createElement(COMMAND_ATT); + rootElement.setAttribute(COMMAND_ATT, command); + doc.appendChild(rootElement); + return DebugPlugin.serializeDocument(doc); + } catch (DOMException | CoreException e) { + CDebugUIPlugin.log(e); + + } + return ""; //$NON-NLS-1$ + } + + public String getCommand() { + return command; + } + + public void setCommand(String command) { + this.command = command; + } + + @Override + public String getSummary() { + String summary = getCommand(); + if (summary.length() > 32) + summary = summary.substring(0, 32); + return summary; + } + + @Override + public String getTypeName() { + return Messages.getString("CLICommandAction.TypeName"); //$NON-NLS-1$ + } + + @Override + public void initializeFromMemento(String data) { + try { + Element root = DebugPlugin.parseDocument(data); + String value = root.getAttribute(COMMAND_ATT); + if (value == null) + value = ""; //$NON-NLS-1$ + command = value; + } catch (Exception e) { + CDebugUIPlugin.log(e); + } + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandActionComposite.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandActionComposite.java index 2ee432bc6ba..663a233cfa3 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandActionComposite.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandActionComposite.java @@ -1,43 +1,43 @@ -/*******************************************************************************
- * Copyright (c) 2016 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Alena Laskavaia (QNX)- Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.debug.ui.breakpointactions;
-
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * This composite show a little text field (multi-line) that allow to enter to enter debugger commands.
- * Interpretation of that depends on the backend
- *
- * @since 8.0
- */
-public class CLICommandActionComposite extends Composite {
- private Text command;
-
- public CLICommandActionComposite(Composite parent, int style, CLICommandActionPage commandActionPage) {
- super(parent, style);
- setLayout(GridLayoutFactory.fillDefaults().create());
- Label messageToLogLabel = new Label(this, SWT.NONE);
- messageToLogLabel.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
- messageToLogLabel.setText(Messages.getString("CLICommandActionComposite.0")); //$NON-NLS-1$
- command = new Text(this, SWT.BORDER | SWT.WRAP);
- command.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
- command.setText(commandActionPage.getCLICommandAction().getCommand());
- }
-
- public String getCommand() {
- return command.getText();
- }
-}
+/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alena Laskavaia (QNX)- Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.layout.GridLayoutFactory; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +/** + * This composite show a little text field (multi-line) that allow to enter to enter debugger commands. + * Interpretation of that depends on the backend + * + * @since 8.0 + */ +public class CLICommandActionComposite extends Composite { + private Text command; + + public CLICommandActionComposite(Composite parent, int style, CLICommandActionPage commandActionPage) { + super(parent, style); + setLayout(GridLayoutFactory.fillDefaults().create()); + Label messageToLogLabel = new Label(this, SWT.NONE); + messageToLogLabel.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); + messageToLogLabel.setText(Messages.getString("CLICommandActionComposite.0")); //$NON-NLS-1$ + command = new Text(this, SWT.BORDER | SWT.WRAP); + command.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); + command.setText(commandActionPage.getCLICommandAction().getCommand()); + } + + public String getCommand() { + return command.getText(); + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandActionPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandActionPage.java index 7b6d606a89a..0979ac5cfa8 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandActionPage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandActionPage.java @@ -1,45 +1,45 @@ -/*******************************************************************************
- * Copyright (c) 2016 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Alena Laskavaia (QNX)- Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.debug.ui.breakpointactions;
-
-import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction;
-import org.eclipse.cdt.debug.ui.breakpointactions.IBreakpointActionPage;
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @since 8.0
- */
-public class CLICommandActionPage extends PlatformObject implements
- IBreakpointActionPage {
- private CLICommandAction cliCommandAction;
- private CLICommandActionComposite editor;
-
- public CLICommandAction getCLICommandAction() {
- return cliCommandAction;
- }
-
- @Override
- public void actionDialogCanceled() {
- }
-
- @Override
- public void actionDialogOK() {
- cliCommandAction.setCommand(editor.getCommand());
- }
-
- @Override
- public Composite createComposite(IBreakpointAction action, Composite composite, int style) {
- cliCommandAction = (CLICommandAction) action;
- editor = new CLICommandActionComposite(composite, style, this);
- return editor;
- }
-}
+/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alena Laskavaia (QNX)- Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction; +import org.eclipse.cdt.debug.ui.breakpointactions.IBreakpointActionPage; +import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.swt.widgets.Composite; + +/** + * @since 8.0 + */ +public class CLICommandActionPage extends PlatformObject implements + IBreakpointActionPage { + private CLICommandAction cliCommandAction; + private CLICommandActionComposite editor; + + public CLICommandAction getCLICommandAction() { + return cliCommandAction; + } + + @Override + public void actionDialogCanceled() { + } + + @Override + public void actionDialogOK() { + cliCommandAction.setCommand(editor.getCommand()); + } + + @Override + public Composite createComposite(IBreakpointAction action, Composite composite, int style) { + cliCommandAction = (CLICommandAction) action; + editor = new CLICommandActionComposite(composite, style, this); + return editor; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/IBreakpointActionPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/IBreakpointActionPage.java index f89419a0a6b..3bf7ffdd881 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/IBreakpointActionPage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/IBreakpointActionPage.java @@ -1,32 +1,32 @@ -/*******************************************************************************
- * Copyright (c) 2007 Nokia and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nokia - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.debug.ui.breakpointactions;
-
-import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- *
- * THIS INTERFACE IS PROVISIONAL AND WILL CHANGE IN THE FUTURE
- * PLUG-INS USING THIS INTERFACE WILL NEED
- * TO BE REVISED TO WORK WITH FUTURE VERSIONS OF CDT.
- *
- */
-
-public interface IBreakpointActionPage {
-
- public void actionDialogCanceled();
-
- public void actionDialogOK();
-
- public Composite createComposite(IBreakpointAction action, Composite composite, int style);
-
-}
+/******************************************************************************* + * Copyright (c) 2007 Nokia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction; +import org.eclipse.swt.widgets.Composite; + +/** + * + * THIS INTERFACE IS PROVISIONAL AND WILL CHANGE IN THE FUTURE + * PLUG-INS USING THIS INTERFACE WILL NEED + * TO BE REVISED TO WORK WITH FUTURE VERSIONS OF CDT. + * + */ + +public interface IBreakpointActionPage { + + public void actionDialogCanceled(); + + public void actionDialogOK(); + + public Composite createComposite(IBreakpointAction action, Composite composite, int style); + +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogActionComposite.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogActionComposite.java index 031b30979e7..63d922cc8db 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogActionComposite.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogActionComposite.java @@ -1,75 +1,75 @@ -/*******************************************************************************
- * Copyright (c) 2007, 2012 Nokia and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nokia - initial API and implementation
+/******************************************************************************* + * Copyright (c) 2007, 2012 Nokia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.ui.breakpointactions;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-public class LogActionComposite extends Composite {
-
- private Button expressionButton;
- private LogActionPage logActionPage;
- private Text message;
-
- public LogActionComposite(Composite parent, int style, LogActionPage logActionPage) {
- super(parent, style);
- final GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 2;
- setLayout(gridLayout);
-
- this.logActionPage = logActionPage;
-
- final Label messageToLogLabel = new Label(this, SWT.NONE);
- messageToLogLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 2, 1));
- messageToLogLabel.setText(Messages.getString("LogActionComposite.0")); //$NON-NLS-1$
-
- message = new Text(this, SWT.BORDER | SWT.WRAP);
- message.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1));
-
- expressionButton = new Button(this, SWT.CHECK);
- expressionButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(final SelectionEvent e) {
- }
- });
- expressionButton.setText(Messages.getString("LogActionComposite.1")); //$NON-NLS-1$
- //
-
- message.setText(this.logActionPage.getLogAction().getMessage());
- expressionButton.setSelection(this.logActionPage.getLogAction().isEvaluateExpression());
- }
-
- @Override
- protected void checkSubclass() {
- // Disable the check that prevents subclassing of SWT components
- }
-
- @Override
- public void dispose() {
- super.dispose();
- }
-
- public boolean getIsExpression() {
- return expressionButton.getSelection();
- }
-
- public String getMessage() {
- return message.getText();
- }
-
-}
+package org.eclipse.cdt.debug.ui.breakpointactions; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +public class LogActionComposite extends Composite { + + private Button expressionButton; + private LogActionPage logActionPage; + private Text message; + + public LogActionComposite(Composite parent, int style, LogActionPage logActionPage) { + super(parent, style); + final GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 2; + setLayout(gridLayout); + + this.logActionPage = logActionPage; + + final Label messageToLogLabel = new Label(this, SWT.NONE); + messageToLogLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 2, 1)); + messageToLogLabel.setText(Messages.getString("LogActionComposite.0")); //$NON-NLS-1$ + + message = new Text(this, SWT.BORDER | SWT.WRAP); + message.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1)); + + expressionButton = new Button(this, SWT.CHECK); + expressionButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(final SelectionEvent e) { + } + }); + expressionButton.setText(Messages.getString("LogActionComposite.1")); //$NON-NLS-1$ + // + + message.setText(this.logActionPage.getLogAction().getMessage()); + expressionButton.setSelection(this.logActionPage.getLogAction().isEvaluateExpression()); + } + + @Override + protected void checkSubclass() { + // Disable the check that prevents subclassing of SWT components + } + + @Override + public void dispose() { + super.dispose(); + } + + public boolean getIsExpression() { + return expressionButton.getSelection(); + } + + public String getMessage() { + return message.getText(); + } + +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/Messages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/Messages.java index 13dc00cafd6..24261cf6841 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/Messages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/Messages.java @@ -1,32 +1,32 @@ -/*******************************************************************************
- * Copyright (c) 2007 Nokia and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nokia - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.debug.ui.breakpointactions;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class Messages {
- private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.ui.breakpointactions.messages"; //$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
-
- private Messages() {
- }
-
- public static String getString(String key) {
- // TODO Auto-generated method stub
- try {
- return RESOURCE_BUNDLE.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-}
+/******************************************************************************* + * Copyright (c) 2007 Nokia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class Messages { + private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.ui.breakpointactions.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); + + private Messages() { + } + + public static String getString(String key) { + // TODO Auto-generated method stub + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceConstants.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceConstants.java index 96a77c8e18f..e77ec1105dc 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceConstants.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceConstants.java @@ -1,26 +1,26 @@ -/*******************************************************************************
- * Copyright (c) 2007 Nokia and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nokia - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.debug.ui.breakpointactions;
-
-/**
- * Constant definitions for plug-in preferences
- */
-public class PreferenceConstants {
-
- public static final String P_PATH = "pathPreference"; //$NON-NLS-1$
-
- public static final String P_BOOLEAN = "booleanPreference"; //$NON-NLS-1$
-
- public static final String P_CHOICE = "choicePreference"; //$NON-NLS-1$
-
- public static final String P_STRING = "stringPreference"; //$NON-NLS-1$
-
-}
+/******************************************************************************* + * Copyright (c) 2007 Nokia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +/** + * Constant definitions for plug-in preferences + */ +public class PreferenceConstants { + + public static final String P_PATH = "pathPreference"; //$NON-NLS-1$ + + public static final String P_BOOLEAN = "booleanPreference"; //$NON-NLS-1$ + + public static final String P_CHOICE = "choicePreference"; //$NON-NLS-1$ + + public static final String P_STRING = "stringPreference"; //$NON-NLS-1$ + +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceInitializer.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceInitializer.java index a87093be472..d6a717a5e3e 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceInitializer.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceInitializer.java @@ -1,35 +1,35 @@ -/*******************************************************************************
- * Copyright (c) 2007, 2012 Nokia and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nokia - initial API and implementation
+/******************************************************************************* + * Copyright (c) 2007, 2012 Nokia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.ui.breakpointactions;
-
-import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
-import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
-import org.eclipse.jface.preference.IPreferenceStore;
-
-/**
- * Class used to initialize default preference values.
- */
-public class PreferenceInitializer extends AbstractPreferenceInitializer {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
- */
- @Override
- public void initializeDefaultPreferences() {
- IPreferenceStore store = CDebugUIPlugin.getDefault().getPreferenceStore();
- store.setDefault(PreferenceConstants.P_BOOLEAN, true);
- store.setDefault(PreferenceConstants.P_CHOICE, "choice2"); //$NON-NLS-1$
- store.setDefault(PreferenceConstants.P_STRING, Messages.getString("PreferenceInitializer.1")); //$NON-NLS-1$
- }
-
-}
+package org.eclipse.cdt.debug.ui.breakpointactions; + +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; + +/** + * Class used to initialize default preference values. + */ +public class PreferenceInitializer extends AbstractPreferenceInitializer { + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() + */ + @Override + public void initializeDefaultPreferences() { + IPreferenceStore store = CDebugUIPlugin.getDefault().getPreferenceStore(); + store.setDefault(PreferenceConstants.P_BOOLEAN, true); + store.setDefault(PreferenceConstants.P_CHOICE, "choice2"); //$NON-NLS-1$ + store.setDefault(PreferenceConstants.P_STRING, Messages.getString("PreferenceInitializer.1")); //$NON-NLS-1$ + } + +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionComposite.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionComposite.java index 5c44796655e..59685c2b9a5 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionComposite.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionComposite.java @@ -1,178 +1,178 @@ -/*******************************************************************************
- * Copyright (c) 2007, 2012 Nokia and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nokia - initial API and implementation
+/******************************************************************************* + * Copyright (c) 2007, 2012 Nokia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.ui.breakpointactions;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-
-public class SoundActionComposite extends Composite {
-
- private static final String[] soundFileExtensions = new String[] { "*.wav", "*.mid", "*.au", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "*.aiff" }; //$NON-NLS-1$
-
- private Combo combo_1;
- private ModifyListener comboModifyListener = null;
- private File selectedSoundFile = null;
- private SoundActionPage soundActionPage;
- private Label soundFilePathLabel;
- private Button tryItButton;
-
- /**
- * Create the composite
- *
- * @param parent
- * @param style
- * @param page
- */
- public SoundActionComposite(Composite parent, int style, SoundActionPage page) {
- super(parent, style);
- soundActionPage = page;
- final GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 2;
- setLayout(gridLayout);
-
- final Label playSoundLabel = new Label(this, SWT.NONE);
- playSoundLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
- playSoundLabel.setText(Messages.getString("SoundActionComposite.4")); //$NON-NLS-1$
-
- combo_1 = new Combo(this, SWT.READ_ONLY);
- final GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
- combo_1.setLayoutData(gridData);
-
- comboModifyListener = new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- if (combo_1.getText().length() > 0) {
- String filePath = combo_1.getText();
- File soundFile = new File(filePath);
- if (soundFile.exists()) {
- soundFilePathLabel.setText(filePath);
- tryItButton.setEnabled(true);
- selectedSoundFile = soundFile;
- } else {
- soundFilePathLabel.setText(Messages.getString("SoundActionComposite.9")); //$NON-NLS-1$
- tryItButton.setEnabled(false);
- }
- }
- }
- };
- rebuildRecentSoundsCombo();
- combo_1.addModifyListener(comboModifyListener);
-
- final String mediaPath = page.getMediaPath();
-
- final Button browseButton = new Button(this, SWT.NONE);
- browseButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
- dialog.setText(Messages.getString("SoundActionComposite.5")); //$NON-NLS-1$
- dialog.setFilterExtensions(soundFileExtensions);
- if (mediaPath.length() > 0)
- dialog.setFilterPath(mediaPath);
-
- String res = dialog.open();
- if (res != null) {
- setSoundFile(res);
- }
- }
- });
- browseButton.setText(Messages.getString("SoundActionComposite.6")); //$NON-NLS-1$
-
- tryItButton = new Button(this, SWT.NONE);
- tryItButton.setLayoutData(new GridData());
- tryItButton.setText(Messages.getString("SoundActionComposite.7")); //$NON-NLS-1$
- tryItButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- File soundFile = new File(soundFilePathLabel.getText());
- playSoundFile(soundFile);
- }
- });
-
- soundFilePathLabel = new Label(this, SWT.NONE);
- final GridData gridData_1 = new GridData(GridData.FILL_HORIZONTAL);
- gridData_1.horizontalSpan = 2;
- soundFilePathLabel.setLayoutData(gridData_1);
- soundFilePathLabel.setText(""); //$NON-NLS-1$
-
- //
- if (soundActionPage.getSoundAction().getSoundFile() != null)
- setSoundFile(soundActionPage.getSoundAction().getSoundFile().getAbsolutePath());
- }
-
- private void addRecentSound(File soundFile) {
- soundActionPage.addRecentSound(soundFile);
- rebuildRecentSoundsCombo();
- }
-
- @Override
- protected void checkSubclass() {
- // Disable the check that prevents subclassing of SWT components
- }
-
- @Override
- public void dispose() {
- super.dispose();
- }
-
- public File getSoundFile() {
- return selectedSoundFile;
- }
-
- protected void playSoundFile(File soundFile) {
- SoundAction.playSoundFile(soundFile);
- }
-
- private void rebuildRecentSoundsCombo() {
- combo_1.removeAll();
-
- ArrayList<File> sortedSounds = new ArrayList<File>(soundActionPage.getRecentSounds());
- Collections.sort(sortedSounds);
-
- for (Iterator<File> iter = sortedSounds.iterator(); iter.hasNext();) {
- File element = iter.next();
- combo_1.add(element.getAbsolutePath());
- }
- }
-
- private void setSoundFile(String filePath) {
- combo_1.removeModifyListener(comboModifyListener);
- File soundFile = new File(filePath);
- if (soundFile.exists()) {
- addRecentSound(soundFile);
- combo_1.setText(soundFile.getAbsolutePath());
- soundFilePathLabel.setText(filePath);
- tryItButton.setEnabled(true);
- selectedSoundFile = soundFile;
- } else {
- soundFilePathLabel.setText(Messages.getString("SoundActionComposite.9")); //$NON-NLS-1$
- tryItButton.setEnabled(false);
- }
- combo_1.addModifyListener(comboModifyListener);
- }
-
-}
+package org.eclipse.cdt.debug.ui.breakpointactions; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; + +public class SoundActionComposite extends Composite { + + private static final String[] soundFileExtensions = new String[] { "*.wav", "*.mid", "*.au", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + "*.aiff" }; //$NON-NLS-1$ + + private Combo combo_1; + private ModifyListener comboModifyListener = null; + private File selectedSoundFile = null; + private SoundActionPage soundActionPage; + private Label soundFilePathLabel; + private Button tryItButton; + + /** + * Create the composite + * + * @param parent + * @param style + * @param page + */ + public SoundActionComposite(Composite parent, int style, SoundActionPage page) { + super(parent, style); + soundActionPage = page; + final GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 2; + setLayout(gridLayout); + + final Label playSoundLabel = new Label(this, SWT.NONE); + playSoundLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); + playSoundLabel.setText(Messages.getString("SoundActionComposite.4")); //$NON-NLS-1$ + + combo_1 = new Combo(this, SWT.READ_ONLY); + final GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); + combo_1.setLayoutData(gridData); + + comboModifyListener = new ModifyListener() { + @Override + public void modifyText(ModifyEvent e) { + if (combo_1.getText().length() > 0) { + String filePath = combo_1.getText(); + File soundFile = new File(filePath); + if (soundFile.exists()) { + soundFilePathLabel.setText(filePath); + tryItButton.setEnabled(true); + selectedSoundFile = soundFile; + } else { + soundFilePathLabel.setText(Messages.getString("SoundActionComposite.9")); //$NON-NLS-1$ + tryItButton.setEnabled(false); + } + } + } + }; + rebuildRecentSoundsCombo(); + combo_1.addModifyListener(comboModifyListener); + + final String mediaPath = page.getMediaPath(); + + final Button browseButton = new Button(this, SWT.NONE); + browseButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(getShell(), SWT.NONE); + dialog.setText(Messages.getString("SoundActionComposite.5")); //$NON-NLS-1$ + dialog.setFilterExtensions(soundFileExtensions); + if (mediaPath.length() > 0) + dialog.setFilterPath(mediaPath); + + String res = dialog.open(); + if (res != null) { + setSoundFile(res); + } + } + }); + browseButton.setText(Messages.getString("SoundActionComposite.6")); //$NON-NLS-1$ + + tryItButton = new Button(this, SWT.NONE); + tryItButton.setLayoutData(new GridData()); + tryItButton.setText(Messages.getString("SoundActionComposite.7")); //$NON-NLS-1$ + tryItButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + File soundFile = new File(soundFilePathLabel.getText()); + playSoundFile(soundFile); + } + }); + + soundFilePathLabel = new Label(this, SWT.NONE); + final GridData gridData_1 = new GridData(GridData.FILL_HORIZONTAL); + gridData_1.horizontalSpan = 2; + soundFilePathLabel.setLayoutData(gridData_1); + soundFilePathLabel.setText(""); //$NON-NLS-1$ + + // + if (soundActionPage.getSoundAction().getSoundFile() != null) + setSoundFile(soundActionPage.getSoundAction().getSoundFile().getAbsolutePath()); + } + + private void addRecentSound(File soundFile) { + soundActionPage.addRecentSound(soundFile); + rebuildRecentSoundsCombo(); + } + + @Override + protected void checkSubclass() { + // Disable the check that prevents subclassing of SWT components + } + + @Override + public void dispose() { + super.dispose(); + } + + public File getSoundFile() { + return selectedSoundFile; + } + + protected void playSoundFile(File soundFile) { + SoundAction.playSoundFile(soundFile); + } + + private void rebuildRecentSoundsCombo() { + combo_1.removeAll(); + + ArrayList<File> sortedSounds = new ArrayList<File>(soundActionPage.getRecentSounds()); + Collections.sort(sortedSounds); + + for (Iterator<File> iter = sortedSounds.iterator(); iter.hasNext();) { + File element = iter.next(); + combo_1.add(element.getAbsolutePath()); + } + } + + private void setSoundFile(String filePath) { + combo_1.removeModifyListener(comboModifyListener); + File soundFile = new File(filePath); + if (soundFile.exists()) { + addRecentSound(soundFile); + combo_1.setText(soundFile.getAbsolutePath()); + soundFilePathLabel.setText(filePath); + tryItButton.setEnabled(true); + selectedSoundFile = soundFile; + } else { + soundFilePathLabel.setText(Messages.getString("SoundActionComposite.9")); //$NON-NLS-1$ + tryItButton.setEnabled(false); + } + combo_1.addModifyListener(comboModifyListener); + } + +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/AbstractContributedRulerColumn.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/AbstractContributedRulerColumn.java index a46aaf45a49..b32434c71ea 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/AbstractContributedRulerColumn.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/AbstractContributedRulerColumn.java @@ -1,66 +1,66 @@ -/*******************************************************************************
- * Copyright (c) 2006, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Wind River Systems, Inc. - adapted for for disassembly parts
- *******************************************************************************/
-package org.eclipse.cdt.debug.ui.disassembly.rulers;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IConfigurationElement;
-
-import org.eclipse.ui.IWorkbenchPart;
-
-
-/**
- * Helper class for contributions to the
- * <code>org.eclipse.cdt.debug.ui.disassemblyRulerColumns</code> extension point.
- * <p>
- * Subclasses must have a zero-argument constructor so that they can be created by
- * {@link IConfigurationElement#createExecutableExtension(String)}.</p>
- *
- * @since 7.2
- */
-public abstract class AbstractContributedRulerColumn implements IContributedRulerColumn {
- /** The contribution descriptor. */
- private RulerColumnDescriptor fDescriptor;
- /** The target disassembly part. */
- private IWorkbenchPart fDisassembly;
-
- @Override
- public final RulerColumnDescriptor getDescriptor() {
- return fDescriptor;
- }
-
- @Override
- public final void setDescriptor(RulerColumnDescriptor descriptor) {
- Assert.isLegal(descriptor != null);
- Assert.isTrue(fDescriptor == null);
- fDescriptor= descriptor;
- }
-
- @Override
- public final void setDisassemblyPart(IWorkbenchPart disassembly) {
- Assert.isLegal(disassembly != null);
- Assert.isTrue(fDisassembly == null);
- fDisassembly= disassembly;
- }
-
- @Override
- public final IWorkbenchPart getDisassemblyPart() {
- return fDisassembly;
- }
-
- @Override
- public void columnCreated() {
- }
-
- @Override
- public void columnRemoved() {
- }
-}
+/******************************************************************************* + * Copyright (c) 2006, 2011 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Wind River Systems, Inc. - adapted for for disassembly parts + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.disassembly.rulers; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IConfigurationElement; + +import org.eclipse.ui.IWorkbenchPart; + + +/** + * Helper class for contributions to the + * <code>org.eclipse.cdt.debug.ui.disassemblyRulerColumns</code> extension point. + * <p> + * Subclasses must have a zero-argument constructor so that they can be created by + * {@link IConfigurationElement#createExecutableExtension(String)}.</p> + * + * @since 7.2 + */ +public abstract class AbstractContributedRulerColumn implements IContributedRulerColumn { + /** The contribution descriptor. */ + private RulerColumnDescriptor fDescriptor; + /** The target disassembly part. */ + private IWorkbenchPart fDisassembly; + + @Override + public final RulerColumnDescriptor getDescriptor() { + return fDescriptor; + } + + @Override + public final void setDescriptor(RulerColumnDescriptor descriptor) { + Assert.isLegal(descriptor != null); + Assert.isTrue(fDescriptor == null); + fDescriptor= descriptor; + } + + @Override + public final void setDisassemblyPart(IWorkbenchPart disassembly) { + Assert.isLegal(disassembly != null); + Assert.isTrue(fDisassembly == null); + fDisassembly= disassembly; + } + + @Override + public final IWorkbenchPart getDisassemblyPart() { + return fDisassembly; + } + + @Override + public void columnCreated() { + } + + @Override + public void columnRemoved() { + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IColumnSupport.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IColumnSupport.java index ea21e15a4b7..1a6f316f961 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IColumnSupport.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IColumnSupport.java @@ -1,62 +1,62 @@ -/*******************************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Wind River Systems, Inc. - adapted for for disassembly parts
- *******************************************************************************/
-package org.eclipse.cdt.debug.ui.disassembly.rulers;
-
-
-/**
- * Provides support to modify and query the visibility of
- * ruler columns and test whether a ruler column is supported.
- * <p>
- * This interface must not be implemented by clients.
- * </p>
- *
- * @since 7.2
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
- */
-public interface IColumnSupport {
-
- /**
- * Returns <code>true</code> if the column described by <code>descriptor</code> is
- * currently showing, <code>false</code> if not.
- *
- * @param descriptor the column descriptor
- * @return <code>true</code> if the specified column is currently visible
- */
- boolean isColumnVisible(RulerColumnDescriptor descriptor);
-
- /**
- * Attempts to set the visibility of the column described by <code>descriptor</code>. Nothing
- * happens if the visibility is already as requested, or if the column is not supported by the
- * editor.
- *
- * @param descriptor the column descriptor
- * @param visible <code>true</code> to show the column, <code>false</code> to hide it
- */
- void setColumnVisible(RulerColumnDescriptor descriptor, boolean visible);
-
- /**
- * Returns <code>true</code> if the column described by <code>descriptor</code> is
- * supported by the receiver's editor, <code>false</code> if <code>id</code> is not the
- * identifier of a known column contribution, if the column does not target the editor, or if
- * the editor does not support contributed columns.
- *
- * @param descriptor the column descriptor
- * @return <code>true</code> if the specified column is supported
- */
- boolean isColumnSupported(RulerColumnDescriptor descriptor);
-
- /**
- * Removes and disposes all currently visible ruler columns.
- */
- void dispose();
+/******************************************************************************* + * Copyright (c) 2007, 2011 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Wind River Systems, Inc. - adapted for for disassembly parts + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.disassembly.rulers; + + +/** + * Provides support to modify and query the visibility of + * ruler columns and test whether a ruler column is supported. + * <p> + * This interface must not be implemented by clients. + * </p> + * + * @since 7.2 + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. + */ +public interface IColumnSupport { + + /** + * Returns <code>true</code> if the column described by <code>descriptor</code> is + * currently showing, <code>false</code> if not. + * + * @param descriptor the column descriptor + * @return <code>true</code> if the specified column is currently visible + */ + boolean isColumnVisible(RulerColumnDescriptor descriptor); + + /** + * Attempts to set the visibility of the column described by <code>descriptor</code>. Nothing + * happens if the visibility is already as requested, or if the column is not supported by the + * editor. + * + * @param descriptor the column descriptor + * @param visible <code>true</code> to show the column, <code>false</code> to hide it + */ + void setColumnVisible(RulerColumnDescriptor descriptor, boolean visible); + + /** + * Returns <code>true</code> if the column described by <code>descriptor</code> is + * supported by the receiver's editor, <code>false</code> if <code>id</code> is not the + * identifier of a known column contribution, if the column does not target the editor, or if + * the editor does not support contributed columns. + * + * @param descriptor the column descriptor + * @return <code>true</code> if the specified column is supported + */ + boolean isColumnSupported(RulerColumnDescriptor descriptor); + + /** + * Removes and disposes all currently visible ruler columns. + */ + void dispose(); }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IContributedRulerColumn.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IContributedRulerColumn.java index 4c2e7c616ba..20d4fbca9af 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IContributedRulerColumn.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IContributedRulerColumn.java @@ -1,99 +1,99 @@ -/*******************************************************************************
- * Copyright (c) 2006, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Wind River Systems, Inc. - adapted for for disassembly parts
- *******************************************************************************/
-package org.eclipse.cdt.debug.ui.disassembly.rulers;
-
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.jface.text.source.IVerticalRulerColumn;
-import org.eclipse.ui.IWorkbenchPart;
-
-
-/**
- * Interface that has to be implemented by contributions to the
- * <code>org.eclipse.cdt.debug.ui.disassembly.rulerColumns</code> extension point.
- * <p>
- * Implementors must have a zero-argument constructor so that they can be created
- * by {@link IConfigurationElement#createExecutableExtension(String)}.</p>
- *
- * @since 7.2
- */
-public interface IContributedRulerColumn extends IVerticalRulerColumn {
-
- /**
- * Returns the extension point descriptor of this ruler.
- *
- * @return descriptor the extension point descriptor of this ruler or <code>null</code> if called before {@link #columnCreated()}
- */
- RulerColumnDescriptor getDescriptor();
-
- /**
- * Sets the extension point descriptor of this ruler.
- * <p>
- * <em>This method will be called by the framework and must not
- * be called by clients.</em></p>
- *
- * @param descriptor the extension point descriptor
- */
- void setDescriptor(RulerColumnDescriptor descriptor);
-
- /**
- * Sets the disassembly part (called right after the extension was instantiated).
- * <p>
- * <em>This method will be called by the framework and must not
- * be called by clients.</em></p>
- *
- * @param disassembly the disassembly part targeted by this ruler instance
- */
- void setDisassemblyPart(IWorkbenchPart disassembly);
-
- /**
- * Returns the disassembly part targeted by this ruler instance.
- *
- * @return the disassembly part targeted by this ruler instance or <code>null</code> if called before {@link #columnCreated()}
- */
- IWorkbenchPart getDisassemblyPart();
-
- /**
- * Hook method called after a column has been instantiated, but before it is
- * added to a {@link org.eclipse.jface.text.source.CompositeRuler} and before
- * {@linkplain org.eclipse.jface.text.source.IVerticalRulerColumn#createControl(org.eclipse.jface.text.source.CompositeRuler, org.eclipse.swt.widgets.Composite) createControl}
- * is called.
- * <p>
- * This happens when
- * <ul>
- * <li>the column is set visible by the user or programmatically</li>
- * <li>the disassembly part is created, if this ruler targets the disassembly part and is enabled by default</li>
- * <li>the disassembly part input changes and the column now targets the new disassembly part contents.</li>
- * </ul></p>
- */
- void columnCreated();
-
- /**
- * Hook method called after a column has been removed from the {@link org.eclipse.jface.text.source.CompositeRuler}.
- * <p>
- * This happens when
- * <ul>
- * <li>the column is hidden by the user or programmatically</li>
- * <li>the disassembly part is closed</li>
- * <li>the disassembly part input changes and the column no longer targets the disassembly part
- * contents.</li>
- * </ul>
- * </p>
- * <p>
- * The column will not be used after this method has been called. A new
- * column will be instantiated if the same column type should be shown for
- * the same disassembly part.
- * </p>
- */
- void columnRemoved();
-
-}
+/******************************************************************************* + * Copyright (c) 2006, 2011 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Wind River Systems, Inc. - adapted for for disassembly parts + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.disassembly.rulers; + + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.jface.text.source.IVerticalRulerColumn; +import org.eclipse.ui.IWorkbenchPart; + + +/** + * Interface that has to be implemented by contributions to the + * <code>org.eclipse.cdt.debug.ui.disassembly.rulerColumns</code> extension point. + * <p> + * Implementors must have a zero-argument constructor so that they can be created + * by {@link IConfigurationElement#createExecutableExtension(String)}.</p> + * + * @since 7.2 + */ +public interface IContributedRulerColumn extends IVerticalRulerColumn { + + /** + * Returns the extension point descriptor of this ruler. + * + * @return descriptor the extension point descriptor of this ruler or <code>null</code> if called before {@link #columnCreated()} + */ + RulerColumnDescriptor getDescriptor(); + + /** + * Sets the extension point descriptor of this ruler. + * <p> + * <em>This method will be called by the framework and must not + * be called by clients.</em></p> + * + * @param descriptor the extension point descriptor + */ + void setDescriptor(RulerColumnDescriptor descriptor); + + /** + * Sets the disassembly part (called right after the extension was instantiated). + * <p> + * <em>This method will be called by the framework and must not + * be called by clients.</em></p> + * + * @param disassembly the disassembly part targeted by this ruler instance + */ + void setDisassemblyPart(IWorkbenchPart disassembly); + + /** + * Returns the disassembly part targeted by this ruler instance. + * + * @return the disassembly part targeted by this ruler instance or <code>null</code> if called before {@link #columnCreated()} + */ + IWorkbenchPart getDisassemblyPart(); + + /** + * Hook method called after a column has been instantiated, but before it is + * added to a {@link org.eclipse.jface.text.source.CompositeRuler} and before + * {@linkplain org.eclipse.jface.text.source.IVerticalRulerColumn#createControl(org.eclipse.jface.text.source.CompositeRuler, org.eclipse.swt.widgets.Composite) createControl} + * is called. + * <p> + * This happens when + * <ul> + * <li>the column is set visible by the user or programmatically</li> + * <li>the disassembly part is created, if this ruler targets the disassembly part and is enabled by default</li> + * <li>the disassembly part input changes and the column now targets the new disassembly part contents.</li> + * </ul></p> + */ + void columnCreated(); + + /** + * Hook method called after a column has been removed from the {@link org.eclipse.jface.text.source.CompositeRuler}. + * <p> + * This happens when + * <ul> + * <li>the column is hidden by the user or programmatically</li> + * <li>the disassembly part is closed</li> + * <li>the disassembly part input changes and the column no longer targets the disassembly part + * contents.</li> + * </ul> + * </p> + * <p> + * The column will not be used after this method has been called. A new + * column will be instantiated if the same column type should be shown for + * the same disassembly part. + * </p> + */ + void columnRemoved(); + +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnDescriptor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnDescriptor.java index 1154a9e94d4..6a89a44d8d0 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnDescriptor.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnDescriptor.java @@ -1,307 +1,307 @@ -/*******************************************************************************
- * Copyright (c) 2005, 2015 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Wind River Systems, Inc. - adapted for for disassembly parts
+/******************************************************************************* + * Copyright (c) 2005, 2015 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Wind River Systems, Inc. - adapted for for disassembly parts *******************************************************************************/ -package org.eclipse.cdt.debug.ui.disassembly.rulers;
-
-import java.net.URL;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.InvalidRegistryObjectException;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.internal.texteditor.rulers.ExtensionPointHelper;
-import org.eclipse.ui.internal.texteditor.rulers.RulerColumnMessages;
-import org.eclipse.ui.internal.texteditor.rulers.RulerColumnPlacement;
-import org.eclipse.ui.internal.texteditor.rulers.RulerColumnTarget;
-
-
-/**
- * The description of an extension to the
- * <code>org.eclipse.ui.workbench.texteditor.rulerColumns</code> extension point. Instances are
- * immutable. Instances can be obtained from a {@link RulerColumnRegistry}.
- *
- * @since 7.2
- * @noinstantiate This class is not intended to be instantiated by clients.
- */
-public final class RulerColumnDescriptor {
- /** The extension schema name of the class attribute. */
- private static final String CLASS= "class"; //$NON-NLS-1$
- /** The extension schema name of the id attribute. */
- private static final String ID= "id"; //$NON-NLS-1$
- /** The extension schema name of the optional name attribute. */
- private static final String NAME= "name"; //$NON-NLS-1$
- /** The extension schema name of the optional enabled attribute. */
- private static final String ENABLED= "enabled"; //$NON-NLS-1$
- /** The extension schema name of the optional icon attribute. */
- private static final String ICON= "icon"; //$NON-NLS-1$
- /** The extension schema name of the optional global attribute. */
- private static final String GLOBAL= "global"; //$NON-NLS-1$
- /** The extension schema name of the optional menu inclusion attribute. */
- private static final String INCLUDE_IN_MENU= "includeInMenu"; //$NON-NLS-1$
- /** The extension schema name of the targetEditor element. */
- private static final String TARGET_ID= "targetId"; //$NON-NLS-1$
- /** The extension schema name of the targetClass element. */
- private static final String TARGET_CLASS= "targetClass"; //$NON-NLS-1$
- /** The extension schema name of the placement element. */
- private static final String PLACEMENT= "placement"; //$NON-NLS-1$
-
- /** The identifier of the extension. */
- private final String fId;
- /** The name of the extension, equal to the id if no name is given. */
- private final String fName;
- /** The icon descriptor. */
- private final ImageDescriptor fIcon;
- /** The configuration element of this extension. */
- private final IConfigurationElement fElement;
- /** The target specification of the ruler column contribution. */
- private final RulerColumnTarget fTarget;
- /** The placement specification of the ruler column contribution. */
- private final RulerColumnPlacement fRulerColumnPlacement;
- /** The default enablement setting of the ruler column contribution. */
- private final boolean fDefaultEnablement;
- /** The global setting of the ruler column contribution. */
- private final boolean fIsGlobal;
- /** The menu inclusion setting of the ruler column contribution. */
- private final boolean fIncludeInMenu;
-
- /**
- * Creates a new descriptor.
- *
- * @param element the configuration element to read
- * @param registry the computer registry creating this descriptor
- * @throws InvalidRegistryObjectException if the configuration element is no longer valid
- * @throws CoreException if the configuration element does not conform to the extension point spec
- */
- RulerColumnDescriptor(IConfigurationElement element, RulerColumnRegistry registry) throws InvalidRegistryObjectException, CoreException {
- Assert.isLegal(registry != null);
- Assert.isLegal(element != null);
- fElement= element;
-
- ExtensionPointHelper helper= new ExtensionPointHelper(element);
-
- fId= helper.getNonNullAttribute(ID);
- fName= helper.getDefaultAttribute(NAME, fId);
- helper.getNonNullAttribute(CLASS); // just check validity
- URL iconURL= helper.getDefaultResourceURL(ICON, null);
- fIcon= iconURL == null ? null : ImageDescriptor.createFromURL(iconURL);
- fDefaultEnablement= helper.getDefaultAttribute(ENABLED, true);
- fIsGlobal= helper.getDefaultAttribute(GLOBAL, true);
- fIncludeInMenu= helper.getDefaultAttribute(INCLUDE_IN_MENU, true);
-
- IConfigurationElement[] targetEditors= element.getChildren(TARGET_ID);
- IConfigurationElement[] targetClasses= element.getChildren(TARGET_CLASS);
-
- RulerColumnTarget combined= null;
- for (int i= 0; i < targetEditors.length; i++) {
- IConfigurationElement targetEditor= targetEditors[i];
- RulerColumnTarget target= RulerColumnTarget.createEditorIdTarget(new ExtensionPointHelper(targetEditor).getNonNullAttribute(ID));
- combined= RulerColumnTarget.createOrTarget(combined, target);
- }
- for (int i= 0; i < targetClasses.length; i++) {
- IConfigurationElement targetClass= targetClasses[i];
- RulerColumnTarget target= RulerColumnTarget.createClassTarget(new ExtensionPointHelper(targetClass).getNonNullAttribute(CLASS));
- combined= RulerColumnTarget.createOrTarget(combined, target);
- }
- fTarget= combined;
-
- IConfigurationElement[] placements= element.getChildren(PLACEMENT);
- switch (placements.length) {
- case 0:
- fRulerColumnPlacement= new RulerColumnPlacement();
- break;
- case 1:
- fRulerColumnPlacement= new RulerColumnPlacement(placements[0]);
- break;
- default:
- helper.fail(RulerColumnMessages.RulerColumnDescriptor_invalid_placement_msg);
- fRulerColumnPlacement= null; // dummy
- break;
- }
-
- Assert.isTrue(fTarget != null);
- Assert.isTrue(fRulerColumnPlacement != null);
- }
-
- /**
- * Returns the identifier of the described extension.
- *
- * @return the identifier of the described extension
- */
- public String getId() {
- return fId;
- }
-
- /**
- * Returns the name of the described extension.
- *
- * @return the name of the described extension
- */
- public String getName() {
- return fName;
- }
-
- /**
- * Returns the image descriptor of the described extension, <code>null</code> if it does not
- * have an image.
- *
- * @return the image descriptor of the described extension or <code>null</code> for no image
- */
- public ImageDescriptor getIcon() {
- return fIcon;
- }
-
- RulerColumnTarget getTarget() {
- return fTarget;
- }
-
- RulerColumnPlacement getPlacement() {
- return fRulerColumnPlacement;
- }
-
- /**
- * Returns the default enablement of the described extension. Editors that support this
- * contribution should typically enable the column by default.
- *
- * @return the default enablement of the described extension
- */
- public boolean getDefaultEnablement() {
- return fDefaultEnablement;
- }
-
- /**
- * Returns the global property of the described extension. Changing the visibility of a column
- * with the global property set to <code>true</code> should typically affect all matching
- * editors. Changing the visibility of a column with the global property set to
- * <code>false</code> should only affect the current disassembly part.
- *
- * @return the global property of the described extension
- */
- public boolean isGlobal() {
- return fIsGlobal;
- }
-
- /**
- * Returns the menu inclusion property of the described extension. A toggle menu entry should be
- * inluded in the ruler context menu for columns with this property set to <code>true</code>.
- *
- * @return the menu inclusion property of the described extension
- */
- public boolean isIncludedInMenu() {
- return fIncludeInMenu;
- }
-
- /**
- * Returns <code>true</code> if this contribution matches the passed disassembly part , <code>false</code> if not.
- *
- * @param disassembly the disassembly part to check
- * @return <code>true</code> if this contribution targets the passed disassembly part
- */
- public boolean matchesPart(IWorkbenchPart disassembly) {
- Assert.isLegal(disassembly != null);
- RulerColumnTarget target= getTarget();
-
- IWorkbenchPartSite site= disassembly.getSite();
- if (site != null && target.matchesEditorId(site.getId()))
- return true;
-
- if (target.matchesClass(disassembly.getClass()))
- return true;
-
- IContentType contentType= getContentType(disassembly);
- return contentType != null && target.matchesContentType(contentType);
-
- }
-
- /**
- * Creates a {@link IContributedRulerColumn} instance as described by the receiver. This may load the contributing plug-in.
- *
- * @param disassembly the disassembly part that loads the contributed column
- * @return the instantiated column
- * @throws CoreException as thrown by {@link IConfigurationElement#createExecutableExtension(String)}
- * @throws InvalidRegistryObjectException as thrown by {@link IConfigurationElement#createExecutableExtension(String)}
- */
- public IContributedRulerColumn createColumn(IWorkbenchPart disassembly) throws CoreException, InvalidRegistryObjectException {
- Assert.isLegal(disassembly != null);
- IContributedRulerColumn column= (IContributedRulerColumn)fElement.createExecutableExtension(CLASS);
- column.setDescriptor(this);
- column.setDisassemblyPart(disassembly);
- column.columnCreated();
- return column;
- }
-
- /*
- * @see java.lang.Object#toString()
- * @since 3.3
- */
- @Override
- public String toString() {
- return "RulerColumnDescriptor[name=" + getName() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- IConfigurationElement getConfigurationElement() {
- return fElement;
- }
-
- /*
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime= 31;
- int result= 1;
- result= prime * result + ((fId == null) ? 0 : fId.hashCode());
- return result;
- }
-
- /*
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final RulerColumnDescriptor other= (RulerColumnDescriptor) obj;
- if (fId == null) {
- if (other.fId != null)
- return false;
- } else if (!fId.equals(other.fId))
- return false;
- return true;
- }
-
- /**
- * Returns the content type of the disassembly part's input, <code>null</code> if the disassembly part input or
- * the document provider is <code>null</code> or the content type cannot be determined.
- *
- * @param disassembly part the disassembly part to get the content type from
- * @return the content type of the disassembly part's input, <code>null</code> if it cannot be
- * determined
- */
- private IContentType getContentType(IWorkbenchPart disassembly) {
- return null;
- }
-
- String getContributor() {
- try {
- return fElement.getContributor().getName();
- } catch (InvalidRegistryObjectException e) {
- return "unknown"; //$NON-NLS-1$
- }
- }
-}
+package org.eclipse.cdt.debug.ui.disassembly.rulers; + +import java.net.URL; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.InvalidRegistryObjectException; +import org.eclipse.core.runtime.content.IContentType; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchPartSite; +import org.eclipse.ui.internal.texteditor.rulers.ExtensionPointHelper; +import org.eclipse.ui.internal.texteditor.rulers.RulerColumnMessages; +import org.eclipse.ui.internal.texteditor.rulers.RulerColumnPlacement; +import org.eclipse.ui.internal.texteditor.rulers.RulerColumnTarget; + + +/** + * The description of an extension to the + * <code>org.eclipse.ui.workbench.texteditor.rulerColumns</code> extension point. Instances are + * immutable. Instances can be obtained from a {@link RulerColumnRegistry}. + * + * @since 7.2 + * @noinstantiate This class is not intended to be instantiated by clients. + */ +public final class RulerColumnDescriptor { + /** The extension schema name of the class attribute. */ + private static final String CLASS= "class"; //$NON-NLS-1$ + /** The extension schema name of the id attribute. */ + private static final String ID= "id"; //$NON-NLS-1$ + /** The extension schema name of the optional name attribute. */ + private static final String NAME= "name"; //$NON-NLS-1$ + /** The extension schema name of the optional enabled attribute. */ + private static final String ENABLED= "enabled"; //$NON-NLS-1$ + /** The extension schema name of the optional icon attribute. */ + private static final String ICON= "icon"; //$NON-NLS-1$ + /** The extension schema name of the optional global attribute. */ + private static final String GLOBAL= "global"; //$NON-NLS-1$ + /** The extension schema name of the optional menu inclusion attribute. */ + private static final String INCLUDE_IN_MENU= "includeInMenu"; //$NON-NLS-1$ + /** The extension schema name of the targetEditor element. */ + private static final String TARGET_ID= "targetId"; //$NON-NLS-1$ + /** The extension schema name of the targetClass element. */ + private static final String TARGET_CLASS= "targetClass"; //$NON-NLS-1$ + /** The extension schema name of the placement element. */ + private static final String PLACEMENT= "placement"; //$NON-NLS-1$ + + /** The identifier of the extension. */ + private final String fId; + /** The name of the extension, equal to the id if no name is given. */ + private final String fName; + /** The icon descriptor. */ + private final ImageDescriptor fIcon; + /** The configuration element of this extension. */ + private final IConfigurationElement fElement; + /** The target specification of the ruler column contribution. */ + private final RulerColumnTarget fTarget; + /** The placement specification of the ruler column contribution. */ + private final RulerColumnPlacement fRulerColumnPlacement; + /** The default enablement setting of the ruler column contribution. */ + private final boolean fDefaultEnablement; + /** The global setting of the ruler column contribution. */ + private final boolean fIsGlobal; + /** The menu inclusion setting of the ruler column contribution. */ + private final boolean fIncludeInMenu; + + /** + * Creates a new descriptor. + * + * @param element the configuration element to read + * @param registry the computer registry creating this descriptor + * @throws InvalidRegistryObjectException if the configuration element is no longer valid + * @throws CoreException if the configuration element does not conform to the extension point spec + */ + RulerColumnDescriptor(IConfigurationElement element, RulerColumnRegistry registry) throws InvalidRegistryObjectException, CoreException { + Assert.isLegal(registry != null); + Assert.isLegal(element != null); + fElement= element; + + ExtensionPointHelper helper= new ExtensionPointHelper(element); + + fId= helper.getNonNullAttribute(ID); + fName= helper.getDefaultAttribute(NAME, fId); + helper.getNonNullAttribute(CLASS); // just check validity + URL iconURL= helper.getDefaultResourceURL(ICON, null); + fIcon= iconURL == null ? null : ImageDescriptor.createFromURL(iconURL); + fDefaultEnablement= helper.getDefaultAttribute(ENABLED, true); + fIsGlobal= helper.getDefaultAttribute(GLOBAL, true); + fIncludeInMenu= helper.getDefaultAttribute(INCLUDE_IN_MENU, true); + + IConfigurationElement[] targetEditors= element.getChildren(TARGET_ID); + IConfigurationElement[] targetClasses= element.getChildren(TARGET_CLASS); + + RulerColumnTarget combined= null; + for (int i= 0; i < targetEditors.length; i++) { + IConfigurationElement targetEditor= targetEditors[i]; + RulerColumnTarget target= RulerColumnTarget.createEditorIdTarget(new ExtensionPointHelper(targetEditor).getNonNullAttribute(ID)); + combined= RulerColumnTarget.createOrTarget(combined, target); + } + for (int i= 0; i < targetClasses.length; i++) { + IConfigurationElement targetClass= targetClasses[i]; + RulerColumnTarget target= RulerColumnTarget.createClassTarget(new ExtensionPointHelper(targetClass).getNonNullAttribute(CLASS)); + combined= RulerColumnTarget.createOrTarget(combined, target); + } + fTarget= combined; + + IConfigurationElement[] placements= element.getChildren(PLACEMENT); + switch (placements.length) { + case 0: + fRulerColumnPlacement= new RulerColumnPlacement(); + break; + case 1: + fRulerColumnPlacement= new RulerColumnPlacement(placements[0]); + break; + default: + helper.fail(RulerColumnMessages.RulerColumnDescriptor_invalid_placement_msg); + fRulerColumnPlacement= null; // dummy + break; + } + + Assert.isTrue(fTarget != null); + Assert.isTrue(fRulerColumnPlacement != null); + } + + /** + * Returns the identifier of the described extension. + * + * @return the identifier of the described extension + */ + public String getId() { + return fId; + } + + /** + * Returns the name of the described extension. + * + * @return the name of the described extension + */ + public String getName() { + return fName; + } + + /** + * Returns the image descriptor of the described extension, <code>null</code> if it does not + * have an image. + * + * @return the image descriptor of the described extension or <code>null</code> for no image + */ + public ImageDescriptor getIcon() { + return fIcon; + } + + RulerColumnTarget getTarget() { + return fTarget; + } + + RulerColumnPlacement getPlacement() { + return fRulerColumnPlacement; + } + + /** + * Returns the default enablement of the described extension. Editors that support this + * contribution should typically enable the column by default. + * + * @return the default enablement of the described extension + */ + public boolean getDefaultEnablement() { + return fDefaultEnablement; + } + + /** + * Returns the global property of the described extension. Changing the visibility of a column + * with the global property set to <code>true</code> should typically affect all matching + * editors. Changing the visibility of a column with the global property set to + * <code>false</code> should only affect the current disassembly part. + * + * @return the global property of the described extension + */ + public boolean isGlobal() { + return fIsGlobal; + } + + /** + * Returns the menu inclusion property of the described extension. A toggle menu entry should be + * inluded in the ruler context menu for columns with this property set to <code>true</code>. + * + * @return the menu inclusion property of the described extension + */ + public boolean isIncludedInMenu() { + return fIncludeInMenu; + } + + /** + * Returns <code>true</code> if this contribution matches the passed disassembly part , <code>false</code> if not. + * + * @param disassembly the disassembly part to check + * @return <code>true</code> if this contribution targets the passed disassembly part + */ + public boolean matchesPart(IWorkbenchPart disassembly) { + Assert.isLegal(disassembly != null); + RulerColumnTarget target= getTarget(); + + IWorkbenchPartSite site= disassembly.getSite(); + if (site != null && target.matchesEditorId(site.getId())) + return true; + + if (target.matchesClass(disassembly.getClass())) + return true; + + IContentType contentType= getContentType(disassembly); + return contentType != null && target.matchesContentType(contentType); + + } + + /** + * Creates a {@link IContributedRulerColumn} instance as described by the receiver. This may load the contributing plug-in. + * + * @param disassembly the disassembly part that loads the contributed column + * @return the instantiated column + * @throws CoreException as thrown by {@link IConfigurationElement#createExecutableExtension(String)} + * @throws InvalidRegistryObjectException as thrown by {@link IConfigurationElement#createExecutableExtension(String)} + */ + public IContributedRulerColumn createColumn(IWorkbenchPart disassembly) throws CoreException, InvalidRegistryObjectException { + Assert.isLegal(disassembly != null); + IContributedRulerColumn column= (IContributedRulerColumn)fElement.createExecutableExtension(CLASS); + column.setDescriptor(this); + column.setDisassemblyPart(disassembly); + column.columnCreated(); + return column; + } + + /* + * @see java.lang.Object#toString() + * @since 3.3 + */ + @Override + public String toString() { + return "RulerColumnDescriptor[name=" + getName() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ + } + + IConfigurationElement getConfigurationElement() { + return fElement; + } + + /* + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime= 31; + int result= 1; + result= prime * result + ((fId == null) ? 0 : fId.hashCode()); + return result; + } + + /* + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final RulerColumnDescriptor other= (RulerColumnDescriptor) obj; + if (fId == null) { + if (other.fId != null) + return false; + } else if (!fId.equals(other.fId)) + return false; + return true; + } + + /** + * Returns the content type of the disassembly part's input, <code>null</code> if the disassembly part input or + * the document provider is <code>null</code> or the content type cannot be determined. + * + * @param disassembly part the disassembly part to get the content type from + * @return the content type of the disassembly part's input, <code>null</code> if it cannot be + * determined + */ + private IContentType getContentType(IWorkbenchPart disassembly) { + return null; + } + + String getContributor() { + try { + return fElement.getContributor().getName(); + } catch (InvalidRegistryObjectException e) { + return "unknown"; //$NON-NLS-1$ + } + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnRegistry.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnRegistry.java index 024d07e97b0..1fb7f1229f3 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnRegistry.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnRegistry.java @@ -1,294 +1,294 @@ -/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Wind River Systems, Inc. - adapted for for disassembly parts
- *******************************************************************************/
-package org.eclipse.cdt.debug.ui.disassembly.rulers;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.InvalidRegistryObjectException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.ui.internal.texteditor.TextEditorPlugin;
-import org.eclipse.ui.internal.texteditor.rulers.DAG;
-import org.eclipse.ui.internal.texteditor.rulers.ExtensionPointHelper;
-import org.eclipse.ui.internal.texteditor.rulers.RulerColumnMessages;
-import org.eclipse.ui.internal.texteditor.rulers.RulerColumnPlacementConstraint;
-import org.eclipse.ui.texteditor.ConfigurationElementSorter;
-
-import com.ibm.icu.text.MessageFormat;
-
-
-/**
- * A registry for all extensions to the
- * <code>rulerColumns</code> extension point.
- *
- * @since 7.2
- * @noinstantiate This class is not intended to be instantiated by clients.
- */
-public final class RulerColumnRegistry {
-
- private static final String EXTENSION_POINT= "disassemblyRulerColumns"; //$NON-NLS-1$
- private static final String QUALIFIED_EXTENSION_POINT= CDebugUIPlugin.PLUGIN_ID + '.' + EXTENSION_POINT;
-
- /** The singleton instance. */
- private static RulerColumnRegistry fgSingleton= null;
-
- /**
- * Returns the default computer registry.
- *
- * @return the singleton instance
- */
- public static synchronized RulerColumnRegistry getDefault() {
- if (fgSingleton == null) {
- fgSingleton= new RulerColumnRegistry();
- }
-
- return fgSingleton;
- }
-
- /**
- * All descriptors (element type:
- * {@link RulerColumnDescriptor}).
- */
- private List<RulerColumnDescriptor> fDescriptors= null;
- /**
- * All descriptors by id (element type: {@link RulerColumnDescriptor}).
- */
- private Map<String, RulerColumnDescriptor> fDescriptorMap= null;
-
- /**
- * <code>true</code> if this registry has been loaded.
- */
- private boolean fLoaded= false;
-
- /**
- * Creates a new instance.
- */
- RulerColumnRegistry() {
- }
-
- /**
- * Returns the list of {@link RulerColumnDescriptor}s describing all extensions to the
- * <code>rulerColumns</code> extension point. The list's iterator traverses the descriptors in
- * the ordering implied by the placement specifications of the contributions.
- * <p>
- * The returned list is unmodifiable and guaranteed to never change. Note that the set of
- * descriptors may change over time due to dynamic plug-in removal or addition.
- * </p>
- *
- * @return the sorted list of extensions to the <code>rulerColumns</code> extension point
- * (element type: {@link RulerColumnDescriptor})
- */
- public List<RulerColumnDescriptor> getColumnDescriptors() {
- ensureExtensionPointRead();
- return fDescriptors;
- }
-
- /**
- * Returns the {@link RulerColumnDescriptor} with the given identity, <code>null</code> if no
- * such descriptor exists.
- *
- * @param id the identity of the ruler contribution as given in the extension point xml.
- * @return the {@link RulerColumnDescriptor} with the given identity, <code>null</code> if no
- * such descriptor exists
- */
- public RulerColumnDescriptor getColumnDescriptor(String id) {
- Assert.isLegal(id != null);
- ensureExtensionPointRead();
- return fDescriptorMap.get(id);
- }
-
- /**
- * Ensures that the extensions are read and stored in
- * <code>fDescriptorsByPartition</code>.
- */
- private void ensureExtensionPointRead() {
- boolean reload;
- synchronized (this) {
- reload= !fLoaded;
- fLoaded= true;
- }
- if (reload)
- reload();
- }
-
- /**
- * Reloads the extensions to the extension point.
- * <p>
- * This method can be called more than once in order to reload from
- * a changed extension registry.
- * </p>
- */
- public void reload() {
- IExtensionRegistry registry= Platform.getExtensionRegistry();
- List<IConfigurationElement> elements= new ArrayList<IConfigurationElement>(Arrays.asList(registry.getConfigurationElementsFor(CDebugUIPlugin.PLUGIN_ID, EXTENSION_POINT)));
-
- List<RulerColumnDescriptor> descriptors= new ArrayList<RulerColumnDescriptor>();
- Map<String, RulerColumnDescriptor> descriptorMap= new HashMap<String, RulerColumnDescriptor>();
-
- for (Iterator<IConfigurationElement> iter= elements.iterator(); iter.hasNext();) {
- IConfigurationElement element= iter.next();
- try {
- RulerColumnDescriptor desc= new RulerColumnDescriptor(element, this);
- String id= desc.getId();
- if (descriptorMap.containsKey(id)) {
- noteDuplicateId(desc);
- continue;
- }
-
- descriptors.add(desc);
- descriptorMap.put(id, desc);
- } catch (InvalidRegistryObjectException x) {
- /*
- * Element is not valid any longer as the contributing plug-in was unloaded or for
- * some other reason. Do not include the extension in the list and inform the user
- * about it.
- */
- noteInvalidExtension(element, x);
- } catch (CoreException x) {
- warnUser(x.getStatus());
- }
- }
-
- sort(descriptors);
-
- synchronized (this) {
- fDescriptors= Collections.unmodifiableList(descriptors);
- fDescriptorMap= Collections.unmodifiableMap(descriptorMap);
- }
- }
-
- /**
- * Sorts the column contributions.
- *
- * @param descriptors the descriptors to sort
- */
- @SuppressWarnings("unchecked")
- private void sort(List<RulerColumnDescriptor> descriptors) {
- /*
- * Topological sort of the DAG defined by the plug-in dependencies
- * 1. TopoSort descriptors by plug-in dependency
- * 2. Insert into Directed Acyclic Graph
- * 3. TopoSort DAG: pick the source with the lowest gravity and remove from DAG
- */
- ConfigurationElementSorter sorter= new ConfigurationElementSorter() {
- @Override
- public IConfigurationElement getConfigurationElement(Object object) {
- return ((RulerColumnDescriptor) object).getConfigurationElement();
- }
- };
- RulerColumnDescriptor[] array= new RulerColumnDescriptor[descriptors.size()];
- descriptors.toArray(array);
- sorter.sort(array);
-
- Map<String, RulerColumnDescriptor> descriptorsById= new HashMap<String, RulerColumnDescriptor>();
- for (RulerColumnDescriptor desc : array) {
- descriptorsById.put(desc.getId(), desc);
- }
-
- DAG dag= new DAG();
- for (RulerColumnDescriptor desc : array) {
- dag.addVertex(desc);
-
- Set<?> before= desc.getPlacement().getConstraints();
- for (Iterator<?> it= before.iterator(); it.hasNext();) {
- RulerColumnPlacementConstraint constraint= (RulerColumnPlacementConstraint) it.next();
- String id= constraint.getId();
- RulerColumnDescriptor target= descriptorsById.get(id);
- if (target == null) {
- noteUnknownTarget(desc, id);
- } else {
- boolean success;
- if (constraint.isBefore())
- success= dag.addEdge(desc, target);
- else
- success= dag.addEdge(target, desc);
- if (!success)
- noteCycle(desc, target);
- }
- }
- }
-
- Comparator<RulerColumnDescriptor> gravityComp= new Comparator<RulerColumnDescriptor>() {
- @Override
- public int compare(RulerColumnDescriptor o1, RulerColumnDescriptor o2) {
- float diff= o1.getPlacement().getGravity() - o2.getPlacement().getGravity();
- if (diff == 0)
- return 0;
- if (diff < 0)
- return -1;
- return 1;
- }
- };
-
- /* Topological sort - always select the source with the least gravity */
- Set<RulerColumnDescriptor> toProcess= dag.getSources();
- int index= 0;
- while (!toProcess.isEmpty()) {
- RulerColumnDescriptor next= Collections.min(toProcess, gravityComp);
- array[index]= next;
- index++;
- dag.removeVertex(next);
- toProcess= dag.getSources();
- }
- Assert.isTrue(index == array.length);
-
- ListIterator<RulerColumnDescriptor> it= descriptors.listIterator();
- for (int i= 0; i < index; i++) {
- it.next();
- it.set(array[i]);
- }
- }
-
- private void noteInvalidExtension(IConfigurationElement element, InvalidRegistryObjectException x) {
- String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_invalid_msg, new Object[] {ExtensionPointHelper.findId(element)});
- warnUser(message, x);
- }
-
- private void noteUnknownTarget(RulerColumnDescriptor desc, String referencedId) {
- String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_unresolved_placement_msg, new Object[] {QUALIFIED_EXTENSION_POINT, referencedId, desc.getName(), desc.getContributor()});
- warnUser(message, null);
- }
-
- private void noteCycle(RulerColumnDescriptor desc, RulerColumnDescriptor target) {
- String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_cyclic_placement_msg, new Object[] {QUALIFIED_EXTENSION_POINT, target.getName(), desc.getName(), desc.getContributor()});
- warnUser(message, null);
- }
-
- private void noteDuplicateId(RulerColumnDescriptor desc) {
- String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_duplicate_id_msg, new Object[] {QUALIFIED_EXTENSION_POINT, desc.getId(), desc.getContributor()});
- warnUser(message, null);
- }
-
- private void warnUser(String message, Exception exception) {
- IStatus status= new Status(IStatus.WARNING, TextEditorPlugin.PLUGIN_ID, IStatus.OK, message, exception);
- warnUser(status);
- }
-
- private void warnUser(IStatus status) {
- TextEditorPlugin.getDefault().getLog().log(status);
- }
-}
+/******************************************************************************* + * Copyright (c) 2000, 2011 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Wind River Systems, Inc. - adapted for for disassembly parts + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.disassembly.rulers; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Set; + +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.InvalidRegistryObjectException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.ui.internal.texteditor.TextEditorPlugin; +import org.eclipse.ui.internal.texteditor.rulers.DAG; +import org.eclipse.ui.internal.texteditor.rulers.ExtensionPointHelper; +import org.eclipse.ui.internal.texteditor.rulers.RulerColumnMessages; +import org.eclipse.ui.internal.texteditor.rulers.RulerColumnPlacementConstraint; +import org.eclipse.ui.texteditor.ConfigurationElementSorter; + +import com.ibm.icu.text.MessageFormat; + + +/** + * A registry for all extensions to the + * <code>rulerColumns</code> extension point. + * + * @since 7.2 + * @noinstantiate This class is not intended to be instantiated by clients. + */ +public final class RulerColumnRegistry { + + private static final String EXTENSION_POINT= "disassemblyRulerColumns"; //$NON-NLS-1$ + private static final String QUALIFIED_EXTENSION_POINT= CDebugUIPlugin.PLUGIN_ID + '.' + EXTENSION_POINT; + + /** The singleton instance. */ + private static RulerColumnRegistry fgSingleton= null; + + /** + * Returns the default computer registry. + * + * @return the singleton instance + */ + public static synchronized RulerColumnRegistry getDefault() { + if (fgSingleton == null) { + fgSingleton= new RulerColumnRegistry(); + } + + return fgSingleton; + } + + /** + * All descriptors (element type: + * {@link RulerColumnDescriptor}). + */ + private List<RulerColumnDescriptor> fDescriptors= null; + /** + * All descriptors by id (element type: {@link RulerColumnDescriptor}). + */ + private Map<String, RulerColumnDescriptor> fDescriptorMap= null; + + /** + * <code>true</code> if this registry has been loaded. + */ + private boolean fLoaded= false; + + /** + * Creates a new instance. + */ + RulerColumnRegistry() { + } + + /** + * Returns the list of {@link RulerColumnDescriptor}s describing all extensions to the + * <code>rulerColumns</code> extension point. The list's iterator traverses the descriptors in + * the ordering implied by the placement specifications of the contributions. + * <p> + * The returned list is unmodifiable and guaranteed to never change. Note that the set of + * descriptors may change over time due to dynamic plug-in removal or addition. + * </p> + * + * @return the sorted list of extensions to the <code>rulerColumns</code> extension point + * (element type: {@link RulerColumnDescriptor}) + */ + public List<RulerColumnDescriptor> getColumnDescriptors() { + ensureExtensionPointRead(); + return fDescriptors; + } + + /** + * Returns the {@link RulerColumnDescriptor} with the given identity, <code>null</code> if no + * such descriptor exists. + * + * @param id the identity of the ruler contribution as given in the extension point xml. + * @return the {@link RulerColumnDescriptor} with the given identity, <code>null</code> if no + * such descriptor exists + */ + public RulerColumnDescriptor getColumnDescriptor(String id) { + Assert.isLegal(id != null); + ensureExtensionPointRead(); + return fDescriptorMap.get(id); + } + + /** + * Ensures that the extensions are read and stored in + * <code>fDescriptorsByPartition</code>. + */ + private void ensureExtensionPointRead() { + boolean reload; + synchronized (this) { + reload= !fLoaded; + fLoaded= true; + } + if (reload) + reload(); + } + + /** + * Reloads the extensions to the extension point. + * <p> + * This method can be called more than once in order to reload from + * a changed extension registry. + * </p> + */ + public void reload() { + IExtensionRegistry registry= Platform.getExtensionRegistry(); + List<IConfigurationElement> elements= new ArrayList<IConfigurationElement>(Arrays.asList(registry.getConfigurationElementsFor(CDebugUIPlugin.PLUGIN_ID, EXTENSION_POINT))); + + List<RulerColumnDescriptor> descriptors= new ArrayList<RulerColumnDescriptor>(); + Map<String, RulerColumnDescriptor> descriptorMap= new HashMap<String, RulerColumnDescriptor>(); + + for (Iterator<IConfigurationElement> iter= elements.iterator(); iter.hasNext();) { + IConfigurationElement element= iter.next(); + try { + RulerColumnDescriptor desc= new RulerColumnDescriptor(element, this); + String id= desc.getId(); + if (descriptorMap.containsKey(id)) { + noteDuplicateId(desc); + continue; + } + + descriptors.add(desc); + descriptorMap.put(id, desc); + } catch (InvalidRegistryObjectException x) { + /* + * Element is not valid any longer as the contributing plug-in was unloaded or for + * some other reason. Do not include the extension in the list and inform the user + * about it. + */ + noteInvalidExtension(element, x); + } catch (CoreException x) { + warnUser(x.getStatus()); + } + } + + sort(descriptors); + + synchronized (this) { + fDescriptors= Collections.unmodifiableList(descriptors); + fDescriptorMap= Collections.unmodifiableMap(descriptorMap); + } + } + + /** + * Sorts the column contributions. + * + * @param descriptors the descriptors to sort + */ + @SuppressWarnings("unchecked") + private void sort(List<RulerColumnDescriptor> descriptors) { + /* + * Topological sort of the DAG defined by the plug-in dependencies + * 1. TopoSort descriptors by plug-in dependency + * 2. Insert into Directed Acyclic Graph + * 3. TopoSort DAG: pick the source with the lowest gravity and remove from DAG + */ + ConfigurationElementSorter sorter= new ConfigurationElementSorter() { + @Override + public IConfigurationElement getConfigurationElement(Object object) { + return ((RulerColumnDescriptor) object).getConfigurationElement(); + } + }; + RulerColumnDescriptor[] array= new RulerColumnDescriptor[descriptors.size()]; + descriptors.toArray(array); + sorter.sort(array); + + Map<String, RulerColumnDescriptor> descriptorsById= new HashMap<String, RulerColumnDescriptor>(); + for (RulerColumnDescriptor desc : array) { + descriptorsById.put(desc.getId(), desc); + } + + DAG dag= new DAG(); + for (RulerColumnDescriptor desc : array) { + dag.addVertex(desc); + + Set<?> before= desc.getPlacement().getConstraints(); + for (Iterator<?> it= before.iterator(); it.hasNext();) { + RulerColumnPlacementConstraint constraint= (RulerColumnPlacementConstraint) it.next(); + String id= constraint.getId(); + RulerColumnDescriptor target= descriptorsById.get(id); + if (target == null) { + noteUnknownTarget(desc, id); + } else { + boolean success; + if (constraint.isBefore()) + success= dag.addEdge(desc, target); + else + success= dag.addEdge(target, desc); + if (!success) + noteCycle(desc, target); + } + } + } + + Comparator<RulerColumnDescriptor> gravityComp= new Comparator<RulerColumnDescriptor>() { + @Override + public int compare(RulerColumnDescriptor o1, RulerColumnDescriptor o2) { + float diff= o1.getPlacement().getGravity() - o2.getPlacement().getGravity(); + if (diff == 0) + return 0; + if (diff < 0) + return -1; + return 1; + } + }; + + /* Topological sort - always select the source with the least gravity */ + Set<RulerColumnDescriptor> toProcess= dag.getSources(); + int index= 0; + while (!toProcess.isEmpty()) { + RulerColumnDescriptor next= Collections.min(toProcess, gravityComp); + array[index]= next; + index++; + dag.removeVertex(next); + toProcess= dag.getSources(); + } + Assert.isTrue(index == array.length); + + ListIterator<RulerColumnDescriptor> it= descriptors.listIterator(); + for (int i= 0; i < index; i++) { + it.next(); + it.set(array[i]); + } + } + + private void noteInvalidExtension(IConfigurationElement element, InvalidRegistryObjectException x) { + String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_invalid_msg, new Object[] {ExtensionPointHelper.findId(element)}); + warnUser(message, x); + } + + private void noteUnknownTarget(RulerColumnDescriptor desc, String referencedId) { + String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_unresolved_placement_msg, new Object[] {QUALIFIED_EXTENSION_POINT, referencedId, desc.getName(), desc.getContributor()}); + warnUser(message, null); + } + + private void noteCycle(RulerColumnDescriptor desc, RulerColumnDescriptor target) { + String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_cyclic_placement_msg, new Object[] {QUALIFIED_EXTENSION_POINT, target.getName(), desc.getName(), desc.getContributor()}); + warnUser(message, null); + } + + private void noteDuplicateId(RulerColumnDescriptor desc) { + String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_duplicate_id_msg, new Object[] {QUALIFIED_EXTENSION_POINT, desc.getId(), desc.getContributor()}); + warnUser(message, null); + } + + private void warnUser(String message, Exception exception) { + IStatus status= new Status(IStatus.WARNING, TextEditorPlugin.PLUGIN_ID, IStatus.OK, message, exception); + warnUser(status); + } + + private void warnUser(IStatus status) { + TextEditorPlugin.getDefault().getLog().log(status); + } +} |