Commit a191ea7f authored by andrei's avatar andrei

-fixed different 3.3 problems: compare editor toolbar fix; reference view fix

-added "link to editor" for refrence view and BCO editor
-added *.class file association back
-refrence view remembers now buttons state
parent e3f7af9f
......@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Bytecode Outline Plug-in
Bundle-SymbolicName: de.loskutov.BytecodeOutline;singleton:=true
Bundle-Version: 2.2.2
Bundle-Version: 2.2.3
Bundle-ClassPath: .,
lib/asm-3.0.jar,
lib/asm-analysis-3.0.jar,
......
plugin.id=de.loskutov.BytecodeOutline
plugin.version=2.2.2
plugin.version=2.2.3
bin.includes = LICENSE.txt,\
README.txt,\
......
......@@ -183,6 +183,7 @@
class="de.loskutov.bco.editors.BytecodeClassFileEditor"
contributorClass="de.loskutov.bco.editors.BytecodeActionBarContributor"
default="true"
extensions="class"
icon="icons/bytecodeview.gif"
id="de.loskutov.bco.editors.BytecodeClassFileEditor"
name="Class File Bytecode Viewer"
......
......@@ -69,6 +69,10 @@ action.linkViewToEditor.text=Link with editor
action.linkViewToEditor.toolTipText=Link With Editor
action.linkViewToEditor.image=icons/link_with_editor.gif
action.linkRefViewToEditor.text=Link with editor
action.linkRefViewToEditor.toolTipText=Link With Editor
action.linkRefViewToEditor.image=icons/link_with_editor.gif
action.showHexValues.text=Show values in hex format
action.showHexValues.toolTipText=Show numerical constant values in hex format
action.showHexValues.image=icons/hex_mode.gif
\ No newline at end of file
action.showHexValues.image=icons/hex_mode.gif
/* $Id: BytecodeClassFileEditor.java,v 1.6 2006-11-24 10:14:51 andrei Exp $ */
/* $Id: BytecodeClassFileEditor.java,v 1.7 2007-10-05 22:05:41 andrei Exp $ */
package de.loskutov.bco.editors;
......@@ -31,7 +31,6 @@ import org.eclipse.jdt.internal.ui.javaeditor.ExternalClassFileEditorInput;
import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput;
import org.eclipse.jdt.internal.ui.javaeditor.InternalClassFileEditorInput;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
......@@ -39,12 +38,7 @@ import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.ITextViewerExtension5;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.text.source.IOverviewRuler;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.custom.StyledText;
......@@ -61,6 +55,7 @@ import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.IDocumentProvider;
import de.loskutov.bco.BytecodeOutlinePlugin;
import de.loskutov.bco.asm.DecompiledClass;
import de.loskutov.bco.preferences.BCOConstants;
import de.loskutov.bco.ui.JdtUtils;
......@@ -82,7 +77,7 @@ public class BytecodeClassFileEditor extends JavaEditor
private BitSet decompilerFlags;
/** is not null only on class files with decompiled source */
private static BytecodeSourceMapper sourceMapper;
private static BytecodeDocumentProvider fClassFileDocumentProvider;
private BytecodeDocumentProvider fClassFileDocumentProvider;
private boolean hasMappedSource;
private boolean decompiled;
private boolean initDone;
......@@ -123,9 +118,9 @@ public class BytecodeClassFileEditor extends JavaEditor
this.hasMappedSource = hasMappedSource;
}
private static ClassFileDocumentProvider getClassFileDocumentProvider() {
private ClassFileDocumentProvider getClassFileDocumentProvider() {
if (fClassFileDocumentProvider == null) {
fClassFileDocumentProvider = new BytecodeDocumentProvider();
fClassFileDocumentProvider = new BytecodeDocumentProvider(this);
}
return fClassFileDocumentProvider;
}
......@@ -182,11 +177,12 @@ public class BytecodeClassFileEditor extends JavaEditor
protected void doSetInput(IEditorInput input) throws CoreException {
input = transformEditorInput(input);
if (!(input instanceof IClassFileEditorInput))
if (!(input instanceof IClassFileEditorInput)) {
throw new CoreException(JavaUIStatus.createError(
IJavaModelStatusConstants.INVALID_RESOURCE_TYPE,
"invalid input", // JavaEditorMessages.ClassFileEditor_error_invalid_input_message,
null));
}
IDocumentProvider documentProvider = getDocumentProvider();
if (documentProvider instanceof ClassFileDocumentProvider) {
......@@ -557,118 +553,6 @@ public class BytecodeClassFileEditor extends JavaEditor
return (ISourceReference) element;
}
/*
* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#createJavaSourceViewer(org.eclipse.swt.widgets.Composite,
* org.eclipse.jface.text.source.IVerticalRuler,
* org.eclipse.jface.text.source.IOverviewRuler, boolean, int,
* org.eclipse.jface.preference.IPreferenceStore)
*/
protected ISourceViewer createJavaSourceViewer(Composite parent,
IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
boolean isOverviewRulerVisible, int styles, IPreferenceStore store) {
return super.createJavaSourceViewer(
parent, verticalRuler, overviewRuler, isOverviewRulerVisible,
styles, store);
}
/*
* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#doSelectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
*/
protected void doSelectionChanged(SelectionChangedEvent event) {
super.doSelectionChanged(event);
}
/*
* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#doSetSelection(org.eclipse.jface.viewers.ISelection)
*/
protected void doSetSelection(ISelection selection) {
super.doSetSelection(selection);
}
/*
* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#getSignedSelection(org.eclipse.jface.text.source.ISourceViewer)
*/
protected IRegion getSignedSelection(ISourceViewer sourceViewer) {
return super.getSignedSelection(sourceViewer);
}
/*
* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#synchronizeOutlinePage(org.eclipse.jdt.core.ISourceReference,
* boolean)
*/
protected void synchronizeOutlinePage(ISourceReference element,
boolean checkIfOutlinePageActive) {
super.synchronizeOutlinePage(element, checkIfOutlinePageActive);
}
/*
* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#synchronizeOutlinePage(org.eclipse.jdt.core.ISourceReference)
*/
protected void synchronizeOutlinePage(ISourceReference element) {
super.synchronizeOutlinePage(element);
}
/*
* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#synchronizeOutlinePageSelection()
*/
public void synchronizeOutlinePageSelection() {
super.synchronizeOutlinePageSelection();
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.texteditor.AbstractTextEditor#getSelectionProvider()
*/
public ISelectionProvider getSelectionProvider() {
return super.getSelectionProvider();
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.texteditor.AbstractTextEditor#selectAndReveal(int, int, int,
* int)
*/
protected void selectAndReveal(int selectionStart, int selectionLength,
int revealStart, int revealLength) {
super.selectAndReveal(
selectionStart, selectionLength, revealStart, revealLength);
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.texteditor.AbstractTextEditor#selectAndReveal(int, int)
*/
public void selectAndReveal(int start, int length) {
super.selectAndReveal(start, length);
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.texteditor.AbstractTextEditor#setHighlightRange(int, int,
* boolean)
*/
public void setHighlightRange(int offset, int length, boolean moveCursor) {
super.setHighlightRange(offset, length, moveCursor);
}
public void showHighlightRangeOnly(boolean showHighlightRangeOnly) {
// disabled as we currently do not support "partial" view on selected
// elements
......@@ -726,8 +610,9 @@ public class BytecodeClassFileEditor extends JavaEditor
synchronized (this) {
if (fPosted) {
if (input != null && input.equals(fClassFileEditorInput))
if (input != null && input.equals(fClassFileEditorInput)) {
fClassFileEditorInput = input;
}
return;
}
}
......@@ -748,31 +633,6 @@ public class BytecodeClassFileEditor extends JavaEditor
}
}
/*
* @see AbstractTextEditor#createActions()
*/
protected void createActions() {
super.createActions();
// setAction(ITextEditorActionConstants.SAVE, null);
// setAction(ITextEditorActionConstants.REVERT_TO_SAVED, null);
/*
* 1GF82PL: ITPJUI:ALL - Need to be able to add bookmark to classfile // replace
* default action with class file specific ones
* setAction(ITextEditorActionConstants.BOOKMARK, new
* AddClassFileMarkerAction("AddBookmark.", this, IMarker.BOOKMARK, true));
* //$NON-NLS-1$ setAction(ITextEditorActionConstants.ADD_TASK, new
* AddClassFileMarkerAction("AddTask.", this, IMarker.TASK, false)); //$NON-NLS-1$
* setAction(ITextEditorActionConstants.RULER_MANAGE_BOOKMARKS, new
* ClassFileMarkerRulerAction("ManageBookmarks.", getVerticalRuler(), this,
* IMarker.BOOKMARK, true)); //$NON-NLS-1$
* setAction(ITextEditorActionConstants.RULER_MANAGE_TASKS, new
* ClassFileMarkerRulerAction("ManageTasks.", getVerticalRuler(), this,
* IMarker.TASK, true)); //$NON-NLS-1$
*/
}
/*
* @see JavaEditor#getCorrespondingElement(IJavaElement)
*/
......@@ -1045,6 +905,9 @@ public class BytecodeClassFileEditor extends JavaEditor
} else {
newLine = sourceMapper.mapToSource(startLine, getClassFile()) - 1;
}
if(newLine < 0) {
return null;
}
IDocument document = getDocumentProvider()
.getDocument(getEditorInput());
try {
......@@ -1075,12 +938,14 @@ public class BytecodeClassFileEditor extends JavaEditor
return null;
}
/*
* @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#installOverrideIndicator(boolean)
* @since 3.0
*/
protected void installOverrideIndicator(boolean provideAST) {
super.installOverrideIndicator(true);
public int getBytecodeInstructionAtLine(int line) {
if (isDecompiled()) {
DecompiledClass decompiledClass = sourceMapper.getDecompiledClass(getClassFile());
if(line > 0 && decompiledClass != null) {
return decompiledClass.getBytecodeInsn(line);
}
}
return -1;
}
}
......@@ -18,10 +18,15 @@ import java.util.Map;
*/
public interface BCOConstants {
/**
* toggle "view content/selection follows editor selection"
* toggle BCO "view content/selection follows editor selection"
*/
String LINK_VIEW_TO_EDITOR = "linkViewToEditor";
/**
* toggle reference "view content/selection follows editor selection"
*/
String LINK_REF_VIEW_TO_EDITOR = "linkRefViewToEditor";
/**
* show bytecode only for selected element in editor
*/
......@@ -32,6 +37,11 @@ public interface BCOConstants {
*/
String SHOW_ASMIFIER_CODE = "showASMifierCode";
/**
* show ASMifier java code instead of bytecode in compare pane
*/
String DIFF_SHOW_ASMIFIER_CODE = "diff_showASMifierCode";
/**
* show raw bytecode (without any additional help like readable class names etc)
*/
......@@ -42,21 +52,41 @@ public interface BCOConstants {
*/
String SHOW_LINE_INFO = "showLineInfo";
/**
* show line information (if available) in compare pane
*/
String DIFF_SHOW_LINE_INFO = "diff_showLineInfo";
/**
* show variables information (if available)
*/
String SHOW_VARIABLES = "showVariables";
/**
* show variables information (if available) in compare pane
*/
String DIFF_SHOW_VARIABLES = "diff_showVariables";
/**
* recalculate stackmap (to see computed frames, works for all classes even before MUSTANG)
*/
String SHOW_STACKMAP = "showStackmap";
/**
* recalculate stackmap (to see computed frames, works for all classes even before MUSTANG) in compare
*/
String DIFF_SHOW_STACKMAP = "diff_showStackmap";
/**
* expand stackmap frames
*/
String EXPAND_STACKMAP = "expandStackmap";
/**
* expand stackmap frames in compare pane
*/
String DIFF_EXPAND_STACKMAP = "diff_expandStackmap";
/**
* recalculate stackmap (to see computed frames, works for all classes even before MUSTANG)
*/
......
......@@ -25,18 +25,29 @@ public class BCOPreferenceInitializer extends AbstractPreferenceInitializer {
public void initializeDefaultPreferences() {
IPreferenceStore store = BytecodeOutlinePlugin.getDefault().getPreferenceStore();
store.setDefault(BCOConstants.LINK_VIEW_TO_EDITOR, true);
store.setDefault(BCOConstants.LINK_REF_VIEW_TO_EDITOR, true);
store.setDefault(BCOConstants.SHOW_ONLY_SELECTED_ELEMENT, true);
store.setDefault(BCOConstants.SHOW_RAW_BYTECODE, false);
store.setDefault(BCOConstants.SHOW_ASMIFIER_CODE, false);
store.setDefault(BCOConstants.DIFF_SHOW_ASMIFIER_CODE, false);
store.setDefault(BCOConstants.SHOW_ANALYZER, false);
store.setDefault(BCOConstants.SHOW_VARIABLES, true);
store.setDefault(BCOConstants.DIFF_SHOW_VARIABLES, true);
store.setDefault(BCOConstants.SHOW_LINE_INFO, true);
store.setDefault(BCOConstants.DIFF_SHOW_LINE_INFO, true);
store.setDefault(BCOConstants.SHOW_STACKMAP, true);
store.setDefault(BCOConstants.DIFF_SHOW_STACKMAP, true);
store.setDefault(BCOConstants.EXPAND_STACKMAP, false);
store.setDefault(BCOConstants.DIFF_EXPAND_STACKMAP, false);
store.setDefault(BCOConstants.RECALCULATE_STACKMAP, false);
store.setDefault(BCOConstants.SHOW_HEX_VALUES, false);
}
......
......@@ -99,12 +99,12 @@ public abstract class BytecodeAction implements IObjectActionDelegate {
modes.set(BCOConstants.F_LINK_VIEW_TO_EDITOR, store.getBoolean(BCOConstants.LINK_VIEW_TO_EDITOR));
modes.set(BCOConstants.F_SHOW_ONLY_SELECTED_ELEMENT, store.getBoolean(BCOConstants.SHOW_ONLY_SELECTED_ELEMENT));
modes.set(BCOConstants.F_SHOW_RAW_BYTECODE, store.getBoolean(BCOConstants.SHOW_RAW_BYTECODE));
modes.set(BCOConstants.F_SHOW_LINE_INFO, store.getBoolean(BCOConstants.SHOW_LINE_INFO));
modes.set(BCOConstants.F_SHOW_VARIABLES, store.getBoolean(BCOConstants.SHOW_VARIABLES));
modes.set(BCOConstants.F_SHOW_ASMIFIER_CODE, store.getBoolean(BCOConstants.SHOW_ASMIFIER_CODE));
modes.set(BCOConstants.F_SHOW_LINE_INFO, store.getBoolean(BCOConstants.DIFF_SHOW_LINE_INFO));
modes.set(BCOConstants.F_SHOW_VARIABLES, store.getBoolean(BCOConstants.DIFF_SHOW_VARIABLES));
modes.set(BCOConstants.F_SHOW_ASMIFIER_CODE, store.getBoolean(BCOConstants.DIFF_SHOW_ASMIFIER_CODE));
modes.set(BCOConstants.F_SHOW_ANALYZER, store.getBoolean(BCOConstants.SHOW_ANALYZER));
modes.set(BCOConstants.F_SHOW_STACKMAP, store.getBoolean(BCOConstants.SHOW_STACKMAP));
modes.set(BCOConstants.F_EXPAND_STACKMAP, store.getBoolean(BCOConstants.EXPAND_STACKMAP));
modes.set(BCOConstants.F_SHOW_STACKMAP, store.getBoolean(BCOConstants.DIFF_SHOW_STACKMAP));
modes.set(BCOConstants.F_EXPAND_STACKMAP, store.getBoolean(BCOConstants.DIFF_EXPAND_STACKMAP));
return modes;
}
......
......@@ -10,7 +10,6 @@ package de.loskutov.bco.ui.actions;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import de.loskutov.bco.BytecodeOutlinePlugin;
......@@ -23,44 +22,48 @@ import de.loskutov.bco.BytecodeOutlinePlugin;
* event name.
* @author Andrei
*/
public class DefaultToggleAction extends Action {
public abstract class DefaultToggleAction extends Action {
private static final String ACTION = "action";
private boolean isChecked;
public DefaultToggleAction(String id, IPropertyChangeListener listener) {
public DefaultToggleAction(String id) {
super();
setId(id);
init();
IPreferenceStore store = BytecodeOutlinePlugin.getDefault().getPreferenceStore();
isChecked = store.getBoolean(id);
boolean isChecked = store.getBoolean(id);
setChecked(isChecked);
// as last action, after setChecked(), to prevent unexpected listener
// events during initialization
addPropertyChangeListener(listener);
}
private void init(){
String myId = getId();
if(myId != null && myId.startsWith("diff_")) {
myId = myId.substring("diff_".length());
}
setImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(
BytecodeOutlinePlugin.getDefault().getBundle()
.getSymbolicName(),
BytecodeOutlinePlugin
.getResourceString(ACTION + "." + getId() + "." + IMAGE)));
.getResourceString(ACTION + "." + myId + "." + IMAGE)));
setText(BytecodeOutlinePlugin
.getResourceString(ACTION + "." + getId() + "." + TEXT));
.getResourceString(ACTION + "." + myId + "." + TEXT));
setToolTipText(BytecodeOutlinePlugin
.getResourceString(ACTION + "." + getId() + "." + TOOL_TIP_TEXT));
.getResourceString(ACTION + "." + myId + "." + TOOL_TIP_TEXT));
}
/**
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
isChecked = !isChecked;
setChecked(isChecked);
public final void run() {
boolean isChecked = isChecked();
IPreferenceStore store = BytecodeOutlinePlugin.getDefault().getPreferenceStore();
store.setValue(getId(), isChecked);
run(isChecked);
}
public abstract void run(boolean newState);
}
/*****************************************************************************************
* Copyright (c) 2007 Andrei Loskutov. All rights reserved. This program and the
* accompanying materials are made available under the terms of the BSD License which
* accompanies this distribution, and is available at
* http://www.opensource.org/licenses/bsd-license.php Contributor: Andrei Loskutov -
* initial API and implementation
****************************************************************************************/
package de.loskutov.bco.views;
import java.util.ArrayList;
......@@ -109,4 +116,4 @@ class BCOViewSelectionProvider implements IPostSelectionProvider {
}
}
}
\ No newline at end of file
}
/*
* Copyright area
*/
/*****************************************************************************************
* Copyright (c) 2007 Andrei Loskutov. All rights reserved. This program and the
* accompanying materials are made available under the terms of the BSD License which
* accompanies this distribution, and is available at
* http://www.opensource.org/licenses/bsd-license.php
* Contributor: Eugene Kuleshov - initial API and implementation
****************************************************************************************/
package de.loskutov.bco.views;
import java.net.URL;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.help.internal.appserver.WebappManager;
import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
......@@ -33,6 +33,7 @@ import org.eclipse.ui.part.ViewPart;
import org.objectweb.asm.util.AbstractVisitor;
import de.loskutov.bco.BytecodeOutlinePlugin;
import de.loskutov.bco.editors.BytecodeClassFileEditor;
import de.loskutov.bco.preferences.BCOConstants;
import de.loskutov.bco.ui.actions.DefaultToggleAction;
......@@ -42,52 +43,53 @@ public class BytecodeReferenceView extends ViewPart implements IPartListener2, I
private static final String NLS_PREFIX = "BytecodeReferenceView.";
private Browser browser;
private DefaultToggleAction linkWithViewAction;
private boolean linkWithView = true;
private boolean linkWithView;
public BytecodeReferenceView() {
super();
}
public void createPartControl(Composite parent) {
browser = new Browser(parent, SWT.BORDER);
browser.setText(BytecodeOutlinePlugin.getResourceString(NLS_PREFIX
+ "empty.selection.text"));
final IWorkbenchWindow workbenchWindow = getSite().getWorkbenchWindow();
workbenchWindow.getPartService().addPartListener(this);
linkWithViewAction = new DefaultToggleAction(BCOConstants.LINK_VIEW_TO_EDITOR,
new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (IAction.CHECKED.equals(event.getProperty())) {
linkWithView = Boolean.TRUE == event.getNewValue();
if(linkWithView){
ISelectionService selectionService = workbenchWindow
.getSelectionService();
try {
IViewPart part = workbenchWindow.getActivePage().showView("de.loskutov.bco.views.BytecodeOutlineView");
ISelection selection = selectionService
.getSelection("de.loskutov.bco.views.BytecodeOutlineView");
selectionChanged(part, selection);
} catch (PartInitException e) {
BytecodeOutlinePlugin.log(e, IStatus.ERROR);
}
}
linkWithView = BytecodeOutlinePlugin.getDefault().getPreferenceStore()
.getBoolean(BCOConstants.LINK_REF_VIEW_TO_EDITOR);
linkWithViewAction = new DefaultToggleAction(BCOConstants.LINK_REF_VIEW_TO_EDITOR){
public void run(boolean newState) {
linkWithView = newState;
if(linkWithView){
ISelectionService selectionService = workbenchWindow
.getSelectionService();
try {
IViewPart part = workbenchWindow.getActivePage()
.showView(
"de.loskutov.bco.views.BytecodeOutlineView");
ISelection selection = selectionService
.getSelection("de.loskutov.bco.views.BytecodeOutlineView");
selectionChanged(part, selection);
} catch (PartInitException e) {
BytecodeOutlinePlugin.log(e, IStatus.ERROR);
}
}
});
}
};
final IActionBars bars = getViewSite().getActionBars();
final IToolBarManager tmanager = bars.getToolBarManager();
tmanager.add(linkWithViewAction);
// TODO run this in background!
BaseHelpSystem.ensureWebappRunning();
shouDefaultEmptyPage();
workbenchWindow.getPartService().addPartListener(this);
}
public void dispose() {
getSite().getWorkbenchWindow().getPartService().removePartListener(this);
browser.dispose();
browser = null;
linkWithViewAction = null;
super.dispose();
}
public void setFocus() {
/* nothing to do */
browser.setFocus();
}
public void partActivated(IWorkbenchPartReference partRef) {
......@@ -115,7 +117,7 @@ public class BytecodeReferenceView extends ViewPart implements IPartListener2, I
public void partHidden(IWorkbenchPartReference partRef) {
if (partRef.getId().equals(getSite().getId())) {
getSite().getWorkbenchWindow().getSelectionService()
.removePostSelectionListener(BytecodeOutlineView.class.getName(), this);
.removePostSelectionListener(this);
}
}
......@@ -125,7 +127,8 @@ public class BytecodeReferenceView extends ViewPart implements IPartListener2, I
ISelectionService selectionService = workbenchWindow
.getSelectionService();
String partId = BytecodeOutlineView.class.getName();
selectionService.addPostSelectionListener(partId, this);
selectionService.addPostSelectionListener(this);
// perform initialization with already existing selection (if any)
ISelection selection = selectionService.getSelection(partId);
......@@ -144,7 +147,9 @@ public class BytecodeReferenceView extends ViewPart implements IPartListener2, I
}
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if(!linkWithView || !(part instanceof BytecodeOutlineView)){
boolean isViewSelection = part instanceof BytecodeOutlineView;
if (!linkWithView || !(isViewSelection
|| part instanceof BytecodeClassFileEditor)) {
return;
}
int line = -1;
......@@ -160,7 +165,12 @@ public class BytecodeReferenceView extends ViewPart implements IPartListener2, I
}
if(line >= 0){
int opcode = ((BytecodeOutlineView)part).getBytecodeInstructionAtLine(line);
int opcode;
if(isViewSelection) {
opcode = ((BytecodeOutlineView)part).getBytecodeInstructionAtLine(line);
} else {
opcode = ((BytecodeClassFileEditor)part).getBytecodeInstructionAtLine(line);
}
if (opcode != -1) {
opcodeName = AbstractVisitor.OPCODES[opcode];
}
......@@ -173,15 +183,18 @@ public class BytecodeReferenceView extends ViewPart implements IPartListener2, I
if (url != null) {
browser.setUrl(url.toString());
} else {
browser.setText(BytecodeOutlinePlugin.getResourceString(NLS_PREFIX
+ "empty.selection.text"));
shouDefaultEmptyPage();
}
} else {
browser.setText(BytecodeOutlinePlugin.getResourceString(NLS_PREFIX
+ "empty.selection.text"));
shouDefaultEmptyPage();
}
}
private void shouDefaultEmptyPage() {
browser.setText(BytecodeOutlinePlugin.getResourceString(NLS_PREFIX
+ "empty.selection.text"));
}
private String checkOpcodeName(String opcodeName) {
opcodeName = opcodeName.toLowerCase();
/*
......@@ -212,18 +225,10 @@ public class BytecodeReferenceView extends ViewPart implements IPartListener2, I
private URL getHelpResource(String name) {
try {
// BaseHelpSystem.resolve() method is not awailable in 3.0
String host = WebappManager.getHost();
int port = WebappManager.getPort();
String href = "/"
+ BytecodeOutlinePlugin.getDefault().getBundle()
.getSymbolicName() + "/doc/ref-" + name + ".html";
return new URL("http://" + host + ":" + port + "/help/nftopic"
+ href);
// return BaseHelpSystem.resolve( href, true);
// return new File(
// BytecodeOutlinePlugin.PLUGIN_PATH+"/doc/ref-"+name.toLowerCase()+".html").toURL();
return BaseHelpSystem.resolve(href, true);
} catch (Exception e) {
return null;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment