From 3b42a40c5480e85af286c1aea097eaa65af995fe Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Tue, 20 Jan 2004 21:15:52 +0000 Subject: [PATCH] Remove the hardcode "objdump" --- core/org.eclipse.cdt.ui/ChangeLog | 6 +++ .../cdt/internal/ui/util/EditorUtility.java | 40 +++++-------------- 2 files changed, 15 insertions(+), 31 deletions(-) diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index e0f11ee9985..83c725d83dc 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -1,3 +1,9 @@ +2004-01-20 Alain Magloire + + Remove the hardcode "objdump" in the EditorUtility. + + * src/org/eclipse/cdt/internal/ui/util/EditorUtility.java + 2004-01-19 Hoda Amer Completed looking up macros with function style. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java index dd1c48accd7..1de3962a22b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java @@ -5,10 +5,7 @@ package org.eclipse.cdt.internal.ui.util; * All Rights Reserved. */ -import java.io.BufferedReader; import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStreamReader; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.IBinary; @@ -19,11 +16,9 @@ import org.eclipse.cdt.core.model.IWorkingCopy; import org.eclipse.cdt.core.resources.FileStorage; import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.cdt.utils.spawner.ProcessFactory; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IStorage; -import org.eclipse.core.runtime.IPath; import org.eclipse.ui.IEditorDescriptor; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; @@ -38,6 +33,11 @@ import org.eclipse.ui.texteditor.ITextEditor; public class EditorUtility { + /** + * The ID of the default text editor + */ + public static final String DEFAULT_TEXT_EDITOR_ID = "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$ + private EditorUtility () { } @@ -286,7 +286,7 @@ public class EditorUtility { if (descriptor != null) { return descriptor.getId(); } else { - return registry.getDefaultEditor().getId(); + return registry.findEditor(DEFAULT_TEXT_EDITOR_ID).getId(); } } return null; @@ -298,32 +298,10 @@ public class EditorUtility { public static IStorage getStorage(IBinary bin) { IStorage store = null; - Process objdump = null; - IPath path; - IResource file = null; - file = bin.getResource(); - if (file == null) - return store; - path = file.getLocation(); try { - String[] args = new String[] {"objdump", "-CxS", path.toOSString()}; - objdump = ProcessFactory.getFactory().exec(args); - StringBuffer buffer = new StringBuffer(); - BufferedReader stdout = - new BufferedReader(new InputStreamReader(objdump.getInputStream())); - char[] buf = new char[128]; - while (stdout.read(buf, 0, buf.length) != -1) { - buffer.append(buf); - } - store = new FileStorage(new ByteArrayInputStream(buffer.toString().getBytes()), path); - } catch (SecurityException e) { - } catch (IndexOutOfBoundsException e) { - } catch (NullPointerException e) { - } catch (IOException e) { - } finally { - if (objdump != null) { - objdump.destroy(); - } + store = new FileStorage (new ByteArrayInputStream(bin.getBuffer().getContents().getBytes()), bin.getPath()); + } catch (CModelException e) { + // nothing; } return store; }