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
......@@ -8,6 +8,8 @@
package de.loskutov.bco.compare;
import java.lang.reflect.Field;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.CompareEditorInput;
import org.eclipse.compare.CompareUI;
......@@ -18,11 +20,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IReusableEditor;
......@@ -58,63 +57,54 @@ public class BytecodeCompare extends CompareEditorInput {
super(new CompareConfiguration());
this.left = left;
this.right = right;
toggleAsmifierModeAction = new DefaultToggleAction(
BCOConstants.DIFF_SHOW_ASMIFIER_CODE) {
toggleAsmifierModeAction = new DefaultToggleAction(BCOConstants.SHOW_ASMIFIER_CODE,
new IPropertyChangeListener(){
public void propertyChange(PropertyChangeEvent event) {
if(IAction.CHECKED.equals(event.getProperty())){
boolean asmifier = Boolean.TRUE == event.getNewValue();
toggleMode(BCOConstants.F_SHOW_ASMIFIER_CODE, asmifier, asmifier);
}
}
});
hideLineInfoAction = new DefaultToggleAction(BCOConstants.SHOW_LINE_INFO, new IPropertyChangeListener(){
public void propertyChange(PropertyChangeEvent event) {
if(IAction.CHECKED.equals(event.getProperty())){
toggleMode(
BCOConstants.F_SHOW_LINE_INFO,
Boolean.TRUE == event.getNewValue(),
toggleAsmifierModeAction.isChecked());
}
}
});
hideLocalsAction = new DefaultToggleAction(BCOConstants.SHOW_VARIABLES,
new IPropertyChangeListener(){
public void propertyChange(PropertyChangeEvent event) {
if(IAction.CHECKED.equals(event.getProperty())){
toggleMode(
BCOConstants.F_SHOW_VARIABLES,
Boolean.TRUE == event.getNewValue(),
toggleAsmifierModeAction.isChecked());
}
}
});
hideStackMapAction = new DefaultToggleAction(BCOConstants.SHOW_STACKMAP,
new IPropertyChangeListener(){
public void propertyChange(PropertyChangeEvent event) {
if(IAction.CHECKED.equals(event.getProperty())){
toggleMode(
BCOConstants.F_SHOW_STACKMAP,
Boolean.TRUE == event.getNewValue(),
toggleAsmifierModeAction.isChecked());
}
}
});
expandStackMapAction = new DefaultToggleAction(BCOConstants.EXPAND_STACKMAP,
new IPropertyChangeListener(){
public void propertyChange(PropertyChangeEvent event) {
if(IAction.CHECKED.equals(event.getProperty())){
toggleMode(
BCOConstants.F_EXPAND_STACKMAP,
Boolean.TRUE == event.getNewValue(),
toggleAsmifierModeAction.isChecked());
}
}
});
public void run(boolean newState) {
toggleMode(
BCOConstants.F_SHOW_ASMIFIER_CODE, newState, newState);
}
};
hideLineInfoAction = new DefaultToggleAction(
BCOConstants.DIFF_SHOW_LINE_INFO) {
public void run(boolean newState) {
toggleMode(
BCOConstants.F_SHOW_LINE_INFO, newState,
toggleAsmifierModeAction.isChecked());
}
};
hideLocalsAction = new DefaultToggleAction(
BCOConstants.DIFF_SHOW_VARIABLES) {
public void run(boolean newState) {
toggleMode(
BCOConstants.F_SHOW_VARIABLES, newState,
toggleAsmifierModeAction.isChecked());
}
};
hideStackMapAction = new DefaultToggleAction(
BCOConstants.DIFF_SHOW_STACKMAP) {
public void run(boolean newState) {
toggleMode(
BCOConstants.F_SHOW_STACKMAP, newState,
toggleAsmifierModeAction.isChecked());
}
};
expandStackMapAction = new DefaultToggleAction(
BCOConstants.DIFF_EXPAND_STACKMAP) {
public void run(boolean newState) {
toggleMode(
BCOConstants.F_EXPAND_STACKMAP, newState,
toggleAsmifierModeAction.isChecked());
}
};
}
/** @see CompareEditorInput#prepareInput(IProgressMonitor) */
......@@ -160,13 +150,51 @@ public class BytecodeCompare extends CompareEditorInput {
+ left.getElementName() + " - " + right.getElementName()); //$NON-NLS-1$
}
public CompareViewerSwitchingPane getInputPane() {
try {
Field field = CompareEditorInput.class.getDeclaredField("fContentInputPane");
field.setAccessible(true);
Object object = field.get(this);
if(object instanceof CompareViewerSwitchingPane) {
return (CompareViewerSwitchingPane) object;
}
} catch (Exception e) {
// ignore
}
// does not work after changing content: this is a bug in CompareEditorInput, because
// navigator instance holds old (not up to date) instance of the input pane
// ICompareNavigator navigator = getNavigator();
// if(navigator instanceof CompareNavigator) {
// CompareNavigator compareNavigator = (CompareNavigator) navigator;
// try {
// Method method = compareNavigator.getClass().getDeclaredMethod(
// "getPanes", null);
// method.setAccessible(true);
// Object object = method.invoke(compareNavigator, null);
// if(object instanceof Object[]) {
// Object[] panes = (Object[]) object;
// if(panes.length == 4 && panes[3] instanceof CompareViewerSwitchingPane) {
// // there are 4 panels, last one is the input pane that we search for
// // see org.eclipse.compare.CompareEditorInput.getNavigator()
// return (CompareViewerSwitchingPane) panes[3];
// }
// }
// } catch (Exception e) {
// // ignore.
// }
// }
return null;
}
/**
* @see org.eclipse.compare.CompareEditorInput#createContents(org.eclipse.swt.widgets.Composite)
*/
public Control createContents(Composite parent) {
Object obj = parent.getData();
if(obj == null) {
obj = parent.getParent().getData();
}
// dirty hook on this place to get reference to editor
// CompareEditor extends EditorPart implements IReusableEditor
if(obj instanceof IReusableEditor){
......@@ -175,72 +203,65 @@ public class BytecodeCompare extends CompareEditorInput {
Control control = super.createContents(parent);
// dirty hook on this place to get reference to CompareViewerPane
// from CompareEditorInput: see field
// private CompareViewerSwitchingPane fContentInputPane;
// see also CompareEditorInput.createContents:
// fComposite.setData("Nav", //$NON-NLS-1$
Object obj2 = control.getData("Nav"); //$NON-NLS-1$
if (obj2 instanceof CompareViewerSwitchingPane[]) {
// there are 4 panels, last one is the input pane that we search for
CompareViewerSwitchingPane[] panels = (CompareViewerSwitchingPane[])obj2;
if(panels.length > 0){
Composite comparePane = panels[panels.length-1];
ToolBarManager toolBarManager2 = CompareViewerPane
.getToolBarManager(comparePane);
boolean separatorExist = false;
if (toolBarManager2.find(hideLineInfoAction.getId()) == null) {
if(!separatorExist) {
separatorExist = true;
toolBarManager2.insert(0, new Separator("bco")); //$NON-NLS-1$
}
toolBarManager2.insertBefore("bco", hideLineInfoAction); //$NON-NLS-1$
toolBarManager2.update(true);
CompareViewerSwitchingPane inputPane = getInputPane();
if (inputPane != null) {
ToolBarManager toolBarManager2 = CompareViewerPane
.getToolBarManager(inputPane);
if(toolBarManager2 == null) {
return control;
}
boolean separatorExist = false;
if (toolBarManager2.find(hideLineInfoAction.getId()) == null) {
if(!separatorExist) {
separatorExist = true;
toolBarManager2.insert(0, new Separator("bco")); //$NON-NLS-1$
}
if (toolBarManager2.find(hideLocalsAction.getId()) == null) {
if(!separatorExist) {
separatorExist = true;
toolBarManager2.insert(0, new Separator("bco")); //$NON-NLS-1$
}
toolBarManager2.insertBefore("bco", hideLocalsAction); //$NON-NLS-1$
toolBarManager2.update(true);
toolBarManager2.insertBefore("bco", hideLineInfoAction); //$NON-NLS-1$
// toolBarManager2.update(true);
}
if (toolBarManager2.find(hideLocalsAction.getId()) == null) {
if(!separatorExist) {
separatorExist = true;
toolBarManager2.insert(0, new Separator("bco")); //$NON-NLS-1$
}
toolBarManager2.insertBefore("bco", hideLocalsAction); //$NON-NLS-1$
// toolBarManager2.update(true);
}
if (toolBarManager2.find(hideStackMapAction.getId()) == null) {
if(!separatorExist) {
separatorExist = true;
toolBarManager2.insert(0, new Separator("bco")); //$NON-NLS-1$
}
toolBarManager2.insertBefore("bco", hideStackMapAction); //$NON-NLS-1$
toolBarManager2.update(true);
if (toolBarManager2.find(hideStackMapAction.getId()) == null) {
if(!separatorExist) {
separatorExist = true;
toolBarManager2.insert(0, new Separator("bco")); //$NON-NLS-1$
}
if (toolBarManager2.find(expandStackMapAction.getId()) == null) {
if(!separatorExist) {
separatorExist = true;
toolBarManager2.insert(0, new Separator("bco")); //$NON-NLS-1$
}
toolBarManager2.insertBefore("bco", expandStackMapAction); //$NON-NLS-1$
toolBarManager2.update(true);
toolBarManager2.insertBefore("bco", hideStackMapAction); //$NON-NLS-1$
// toolBarManager2.update(true);
}
if (toolBarManager2.find(expandStackMapAction.getId()) == null) {
if(!separatorExist) {
separatorExist = true;
toolBarManager2.insert(0, new Separator("bco")); //$NON-NLS-1$
}
toolBarManager2.insertBefore("bco", expandStackMapAction); //$NON-NLS-1$
// toolBarManager2.update(true);
}
if (toolBarManager2.find(toggleAsmifierModeAction.getId()) == null) {
if(!separatorExist) {
toolBarManager2.insert(0, new Separator("bco")); //$NON-NLS-1$
separatorExist = true;
}
toolBarManager2.insertBefore("bco", toggleAsmifierModeAction); //$NON-NLS-1$
toolBarManager2.update(true);
}
try {
toolBarManager2.getControl().getParent().layout(true);
toolBarManager2.getControl().getParent().update();
} catch (NullPointerException e) {
// ignore, i'm just curios why we need this code in 3.2 and expect
// some unwanted side effects...
if (toolBarManager2.find(toggleAsmifierModeAction.getId()) == null) {
if(!separatorExist) {
toolBarManager2.insert(0, new Separator("bco")); //$NON-NLS-1$
separatorExist = true;
}
toolBarManager2.insertBefore("bco", toggleAsmifierModeAction); //$NON-NLS-1$
// toolBarManager2.update(true);
}
try {
toolBarManager2.update(true);
toolBarManager2.getControl().getParent().layout(true);
toolBarManager2.getControl().getParent().update();
} catch (NullPointerException e) {
// ignore, i'm just curios why we need this code in 3.2 and expect
// some unwanted side effects...
}
}
return control;
}
......@@ -256,6 +277,10 @@ public class BytecodeCompare extends CompareEditorInput {
right.setMode(mode, value);
right.setMode(BCOConstants.F_SHOW_ASMIFIER_CODE, isASMifierMode);
right.setType(contentType);
CompareUI.reuseCompareEditor(this, myEditor);
// createDiffViewer.refresh();
// myEditor.setInput(this);
CompareUI.reuseCompareEditor(new BytecodeCompare(left, right), myEditor);
// CompareUI.reuseCompareEditor(this, myEditor);
}
}
\ No newline at end of file
}
/* $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