Commit 615f4870 authored by andrei's avatar andrei

Added preferences/page/initial selections

parent 657a9998
......@@ -17,18 +17,19 @@
id="de.loskutov.bco.views.BytecodeReferenceView"/>
</extension>
<!-- <extension
point="org.eclipse.ui.editors">
<editor
class="de.loskutov.bco.editors.BytecodeClassFileEditor"
icon="icons/bytecodeview.gif"
contributorClass="de.loskutov.bco.editors.BytecodeActionBarContributor"
name="Class File Bytecode Viewer"
id="de.loskutov.bco.editors.BytecodeClassFileEditor"
extensions="class,java">
</editor>
</extension> -->
<extension
point="org.eclipse.ui.preferencePages">
<page
category="org.eclipse.jdt.ui.preferences.JavaBasePreferencePage"
class="de.loskutov.bco.preferences.BCOPreferencePage"
id="BCOPreferencePage"
name="Bytecode Outline">
</page>
</extension>
<extension point="org.eclipse.core.runtime.preferences">
<initializer class="de.loskutov.bco.preferences.BCOPreferenceInitializer"/>
</extension>
<extension
point="org.eclipse.ui.popupMenus">
......
......@@ -30,3 +30,27 @@ BytecodeOutlineView.toggle.horizontal.label=&Horizontal View Orientation
BytecodeOutlineView.toggle.automatic.label=&Automatic View Orientation
BytecodeReferenceView.empty.selection.text=<html><head><title>Bytecode reference</title></head><body bgcolor='#D3D3D3'>Please select any bytecode instruction in the bytecode outline view.</body></html>
BCOPreferencePage.defaultsGroup=Default selections for Bytecode Outline view
BCOPreferencePage.expandStackMap=Expand stack map
BCOPreferencePage.recalculateStackMap=Recalculate stack map
BCOPreferencePage.showVariables=Show Variables
BCOPreferencePage.showLineInfo=Show line info
BCOPreferencePage.showRawBytecode=Show raw bytecode
BCOPreferencePage.showAnalyzer=Show analyzer pane
BCOPreferencePage.showAsmifierCode=Show ASMifier code
BCOPreferencePage.showOnlySelected=Show bytecode for selected element only
BCOPreferencePage.linkViewToEditor=Link bytecode view to editor
#TODO add meaningful tooltips for default settings checkboxes
BCOPreferencePage.defaultsGroupTip=Default selections for Bytecode Outline view
BCOPreferencePage.expandStackMapTip=Expand stack map
BCOPreferencePage.recalculateStackMapTip=Recalculate stack map
BCOPreferencePage.showVariablesTip=Show Variables
BCOPreferencePage.showLineInfoTip=Show line info
BCOPreferencePage.showRawBytecodeTip=Show raw bytecode
BCOPreferencePage.showAnalyzerTip=Show analyzer pane
BCOPreferencePage.showAsmifierCodeTip=Show ASMifier code
BCOPreferencePage.showOnlySelectedTip=Show bytecode for selected element only
BCOPreferencePage.linkViewToEditorTip=Link bytecode view to editor
/*******************************************************************************
* Copyright (c) 2006 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.preferences;
/**
* Keys for preferences store used in BCO
* @author Andrei
*/
public interface BCOConstants {
/**
* toggle "view content/selection follows editor selection"
*/
String LINK_VIEW_TO_EDITOR = "linkViewToEditor";
/**
* show bytecode only for selected element in editor
*/
String SHOW_ONLY_SELECTED_ELEMENT = "showOnlySelectedElement";
/**
* show ASMifier java code instead of bytecode
*/
String SHOW_ASMIFIER_CODE = "showASMifierCode";
/**
* show raw bytecode (without any additional help like readable class names etc)
*/
String SHOW_RAW_BYTECODE = "showRawBytecode";
/**
* show line information (if available)
*/
String SHOW_LINE_INFO = "showLineInfo";
/**
* show variables information (if available)
*/
String SHOW_VARIABLES = "showVariables";
/**
* recalculate stackmap (to see computed frames, works for all classes even before MUSTANG)
*/
String RECALCULATE_STACKMAP = "recalculateStackmap";
/**
* expand stackmap frames
*/
String EXPAND_STACKMAP = "expandStackmap";
/**
* show "analyzer" - LVT and stack tables (for current bytecode selection)
*/
String SHOW_ANALYZER = "showAnalyzer";
}
/*******************************************************************************
* Copyright (c) 2006 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.preferences;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
import de.loskutov.bco.BytecodeOutlinePlugin;
/**
* Inializer of default values for BCO preferences
* @author Andrei
*/
public class BCOPreferenceInitializer extends AbstractPreferenceInitializer {
/* (non-Javadoc)
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
*/
public void initializeDefaultPreferences() {
IPreferenceStore store = BytecodeOutlinePlugin.getDefault().getPreferenceStore();
store.setDefault(BCOConstants.EXPAND_STACKMAP, false);
store.setDefault(BCOConstants.LINK_VIEW_TO_EDITOR, true);
store.setDefault(BCOConstants.RECALCULATE_STACKMAP, false);
store.setDefault(BCOConstants.SHOW_ASMIFIER_CODE, false);
store.setDefault(BCOConstants.SHOW_ANALYZER, false);
store.setDefault(BCOConstants.SHOW_LINE_INFO, true);
store.setDefault(BCOConstants.SHOW_ONLY_SELECTED_ELEMENT, true);
store.setDefault(BCOConstants.SHOW_RAW_BYTECODE, false);
store.setDefault(BCOConstants.SHOW_VARIABLES, true);
}
}
/*******************************************************************************
* Copyright (c) 2006 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.preferences;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
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.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import de.loskutov.bco.BytecodeOutlinePlugin;
/**
*
*/
public class BCOPreferencePage extends PreferencePage
implements
IWorkbenchPreferencePage,
SelectionListener {
private static final String TOOLTIP_SUFFIX = "Tip";
private Button expandStackMapCheck;
private Button showAnalyzerCheck;
private Button recalculateStackMapCheck;
private Button showVariablesCheck;
private Button showLineInfoCheck;
private Button showRawBytecodeCheck;
private Button showAsmifierCodeCheck;
private Button showOnlySelectedCheck;
private Button linkViewToEditorCheck;
public BCOPreferencePage() {
super();
setPreferenceStore(BytecodeOutlinePlugin.getDefault()
.getPreferenceStore());
}
/*
* @see PreferencePage#createControl(Composite)
*/
public void createControl(Composite parent) {
super.createControl(parent);
}
/*
* @see PreferencePage#createContents(Composite)
*/
protected Control createContents(Composite parent) {
Composite composite = createContainer(parent);
GridLayout gridLayout = new GridLayout();
gridLayout.marginHeight = 0;
gridLayout.marginWidth = 0;
composite.setLayout(gridLayout);
Composite defPanel = new Composite(composite, SWT.NONE);
GridLayout layout = new GridLayout();
defPanel.setLayout(layout);
GridData gridData = new GridData(GridData.FILL_BOTH
| GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
defPanel.setLayoutData(gridData);
// -------------------------------------------------------------------------------
Group defaultsComposite = new Group(defPanel, SWT.SHADOW_ETCHED_IN);
layout = new GridLayout();
defaultsComposite.setLayout(layout);
gridData = new GridData(GridData.FILL_HORIZONTAL
| GridData.GRAB_HORIZONTAL);
defaultsComposite.setLayoutData(gridData);
defaultsComposite.setText(BytecodeOutlinePlugin
.getResourceString("BCOPreferencePage.defaultsGroup"));
expandStackMapCheck = createLabeledCheck(
"BCOPreferencePage.expandStackMap", getPreferenceStore()
.getBoolean(BCOConstants.EXPAND_STACKMAP), defaultsComposite);
recalculateStackMapCheck = createLabeledCheck(
"BCOPreferencePage.recalculateStackMap", getPreferenceStore()
.getBoolean(BCOConstants.RECALCULATE_STACKMAP),
defaultsComposite);
showVariablesCheck = createLabeledCheck(
"BCOPreferencePage.showVariables", getPreferenceStore().getBoolean(
BCOConstants.SHOW_VARIABLES), defaultsComposite);
showLineInfoCheck = createLabeledCheck(
"BCOPreferencePage.showLineInfo", getPreferenceStore().getBoolean(
BCOConstants.SHOW_LINE_INFO), defaultsComposite);
showRawBytecodeCheck = createLabeledCheck(
"BCOPreferencePage.showRawBytecode", getPreferenceStore()
.getBoolean(BCOConstants.SHOW_RAW_BYTECODE), defaultsComposite);
showAnalyzerCheck = createLabeledCheck(
"BCOPreferencePage.showAnalyzer", getPreferenceStore()
.getBoolean(BCOConstants.SHOW_ANALYZER), defaultsComposite);
showAsmifierCodeCheck = createLabeledCheck(
"BCOPreferencePage.showAsmifierCode", getPreferenceStore()
.getBoolean(BCOConstants.SHOW_ASMIFIER_CODE), defaultsComposite);
showOnlySelectedCheck = createLabeledCheck(
"BCOPreferencePage.showOnlySelected", getPreferenceStore()
.getBoolean(BCOConstants.SHOW_ONLY_SELECTED_ELEMENT), defaultsComposite);
linkViewToEditorCheck = createLabeledCheck(
"BCOPreferencePage.linkViewToEditor", getPreferenceStore()
.getBoolean(BCOConstants.LINK_VIEW_TO_EDITOR), defaultsComposite);
return composite;
}
private Composite createContainer(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL
| GridData.HORIZONTAL_ALIGN_FILL));
return composite;
}
/*
* @see IWorkbenchPreferencePage#init(IWorkbench)
*/
public void init(IWorkbench workbench) {
// ignored
}
/*
* @see SelectionListener#widgetDefaultSelected(SelectionEvent)
*/
public void widgetDefaultSelected(SelectionEvent selectionEvent) {
widgetSelected(selectionEvent);
}
/*
* @see SelectionListener#widgetSelected(SelectionEvent)
*/
public void widgetSelected(SelectionEvent selectionEvent) {
// ignored
}
public boolean performOk() {
IPreferenceStore store = getPreferenceStore();
store.setValue(BCOConstants.SHOW_ANALYZER, showAnalyzerCheck
.getSelection());
store.setValue(BCOConstants.EXPAND_STACKMAP, expandStackMapCheck
.getSelection());
store.setValue(
BCOConstants.RECALCULATE_STACKMAP, recalculateStackMapCheck
.getSelection());
store.setValue(BCOConstants.SHOW_VARIABLES, showVariablesCheck
.getSelection());
store.setValue(BCOConstants.SHOW_LINE_INFO, showLineInfoCheck
.getSelection());
store.setValue(BCOConstants.SHOW_RAW_BYTECODE, showRawBytecodeCheck
.getSelection());
store.setValue(BCOConstants.SHOW_ASMIFIER_CODE, showAsmifierCodeCheck
.getSelection());
store.setValue(
BCOConstants.SHOW_ONLY_SELECTED_ELEMENT, showOnlySelectedCheck
.getSelection());
store.setValue(
BCOConstants.LINK_VIEW_TO_EDITOR, linkViewToEditorCheck
.getSelection());
return true;
}
private Button createLabeledCheck(String titleId, boolean value,
Composite defPanel) {
Button fButton = new Button(defPanel, SWT.CHECK | SWT.LEFT);
GridData data = new GridData();
fButton.setLayoutData(data);
fButton.setText(BytecodeOutlinePlugin.getResourceString(titleId));
fButton.setSelection(value);
fButton.setToolTipText(BytecodeOutlinePlugin.getResourceString(titleId
+ TOOLTIP_SUFFIX));
return fButton;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.PreferencePage#performDefaults()
*/
protected void performDefaults() {
super.performDefaults();
IPreferenceStore store = getPreferenceStore();
showAnalyzerCheck.setSelection(store
.getDefaultBoolean(BCOConstants.SHOW_ANALYZER));
expandStackMapCheck.setSelection(store
.getDefaultBoolean(BCOConstants.EXPAND_STACKMAP));
recalculateStackMapCheck.setSelection(store
.getDefaultBoolean(BCOConstants.RECALCULATE_STACKMAP));
showVariablesCheck.setSelection(store
.getDefaultBoolean(BCOConstants.SHOW_VARIABLES));
showLineInfoCheck.setSelection(store
.getDefaultBoolean(BCOConstants.SHOW_LINE_INFO));
showRawBytecodeCheck.setSelection(store
.getDefaultBoolean(BCOConstants.SHOW_RAW_BYTECODE));
showAsmifierCodeCheck.setSelection(store
.getDefaultBoolean(BCOConstants.SHOW_ASMIFIER_CODE));
showOnlySelectedCheck.setSelection(store
.getDefaultBoolean(BCOConstants.SHOW_ONLY_SELECTED_ELEMENT));
linkViewToEditorCheck.setSelection(store
.getDefaultBoolean(BCOConstants.LINK_VIEW_TO_EDITOR));
}
public void dispose() {
if (showAnalyzerCheck != null) {
showAnalyzerCheck.dispose();
expandStackMapCheck.dispose();
recalculateStackMapCheck.dispose();
showVariablesCheck.dispose();
showLineInfoCheck.dispose();
showRawBytecodeCheck.dispose();
showAsmifierCodeCheck.dispose();
showOnlySelectedCheck.dispose();
linkViewToEditorCheck.dispose();
}
super.dispose();
}
}
\ No newline at end of file
......@@ -33,6 +33,7 @@ import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.StatusLineManager;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
......@@ -95,6 +96,7 @@ import de.loskutov.bco.BytecodeOutlinePlugin;
import de.loskutov.bco.asm.DecompiledClass;
import de.loskutov.bco.asm.DecompilerClassVisitor;
import de.loskutov.bco.compare.actions.ToggleASMifierModeAction;
import de.loskutov.bco.preferences.BCOConstants;
import de.loskutov.bco.ui.EclipseUtils;
import de.loskutov.bco.ui.JdtUtils;
......@@ -510,9 +512,10 @@ public class BytecodeOutlineView extends ViewPart {
.setToolTipText(BytecodeOutlinePlugin
.getResourceString(NLS_PREFIX + "linkWithEditorText.tooltip"));
// TODO get preference from store
linkWithEditorAction.setChecked(true);
doLinkWithEditor = true;
IPreferenceStore store = BytecodeOutlinePlugin.getDefault().getPreferenceStore();
doLinkWithEditor = store.getBoolean(BCOConstants.LINK_VIEW_TO_EDITOR);
linkWithEditorAction.setChecked(doLinkWithEditor);
showSelectedOnlyAction = new Action() {
public void run() {
......@@ -529,9 +532,9 @@ public class BytecodeOutlineView extends ViewPart {
.setToolTipText(BytecodeOutlinePlugin
.getResourceString(NLS_PREFIX + "showOnlySelection.tooltip"));
// TODO get preference from store
showSelectedOnlyAction.setChecked(true);
selectedOnly = true;
selectedOnly = store
.getBoolean(BCOConstants.SHOW_ONLY_SELECTED_ELEMENT);
showSelectedOnlyAction.setChecked(selectedOnly);
setRawModeAction = new Action() {
public void run() {
......@@ -545,9 +548,9 @@ public class BytecodeOutlineView extends ViewPart {
.getResourceString(NLS_PREFIX + "enableRawMode.label"));
setRawModeAction.setToolTipText(BytecodeOutlinePlugin
.getResourceString(NLS_PREFIX + "enableRawMode.tooltip"));
// TODO get preference from store
setRawModeAction.setChecked(false);
showQualifiedNames = false;
showQualifiedNames = store.getBoolean(BCOConstants.SHOW_RAW_BYTECODE);
setRawModeAction.setChecked(showQualifiedNames);
toggleASMifierModeAction = new ToggleASMifierModeAction();
toggleASMifierModeAction
......@@ -558,9 +561,9 @@ public class BytecodeOutlineView extends ViewPart {
}
}
});
// TODO get preference from store
toggleASMifierModeAction.setChecked(false);
isASMifierMode = false;
isASMifierMode = store.getBoolean(BCOConstants.SHOW_ASMIFIER_CODE);
toggleASMifierModeAction.setChecked(isASMifierMode);
toggleVerifierAction = new Action() {
public void run() {
......@@ -582,13 +585,12 @@ public class BytecodeOutlineView extends ViewPart {
.imageDescriptorFromPlugin(BytecodeOutlinePlugin.getDefault()
.getBundle().getSymbolicName(), "icons/verify.gif"));
// TODO get preference from store
toggleVerifierAction.setChecked(false);
verifyCode = store.getBoolean(BCOConstants.SHOW_ANALYZER);
toggleVerifierAction.setChecked(verifyCode);
toggleVerifierAction.setText(BytecodeOutlinePlugin
.getResourceString(NLS_PREFIX + "enableVerifier.label"));
toggleVerifierAction.setToolTipText(BytecodeOutlinePlugin
.getResourceString(NLS_PREFIX + "enableVerifier.tooltip"));
verifyCode = false;
IActionBars bars = getViewSite().getActionBars();
......@@ -599,7 +601,7 @@ public class BytecodeOutlineView extends ViewPart {
mmanager.add(toggleASMifierModeAction);
mmanager.add(toggleVerifierAction);
mmanager.add( new Separator());
mmanager.add(new Separator());
toggleOrientationActions = new ToggleOrientationAction[] {
new ToggleOrientationAction(this, VIEW_ORIENTATION_VERTICAL),
......
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