diff options
author | hyukmin kwon <hyukmin0530.kwon@samsung.com> | 2012-11-01 20:02:31 +0900 |
---|---|---|
committer | hyukmin kwon <hyukmin0530.kwon@samsung.com> | 2012-11-01 20:02:31 +0900 |
commit | 5fff9c4e3982ec2a71e6f577de75faa86cb36c6c (patch) | |
tree | 771e20eeaa2f5fb9d907d156d6bfec0a280407a0 | |
parent | f16be004142ee0c81c64368dafd033e97207d51f (diff) | |
download | jsdt-extension-eplugin-5fff9c4e3982ec2a71e6f577de75faa86cb36c6c.tar.gz jsdt-extension-eplugin-5fff9c4e3982ec2a71e6f577de75faa86cb36c6c.tar.bz2 jsdt-extension-eplugin-5fff9c4e3982ec2a71e6f577de75faa86cb36c6c.zip |
[Title] Advanced Declaration View: Showing line number feature is added.
[Desc.] Showing line number feature is added.
[Issue] REDMINE-7022
-rw-r--r-- | org.tizen.web.advanceddeclarationview/fragment.xml | 19 | ||||
-rw-r--r-- | org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/AdvancedDeclarationView.java | 116 | ||||
-rw-r--r-- | org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/InfoViewMessages.java | 8 | ||||
-rw-r--r-- | org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/InfoViewMessages.properties | 10 | ||||
-rw-r--r-- | org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/ToggleLineNumberActionDelegate.java | 25 | ||||
-rw-r--r-- | org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/ToggleLockActionDelegate.java (renamed from org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/ToggleLockAction.java) | 6 | ||||
-rw-r--r-- | org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/ViewHandler.java | 2 |
7 files changed, 159 insertions, 27 deletions
diff --git a/org.tizen.web.advanceddeclarationview/fragment.xml b/org.tizen.web.advanceddeclarationview/fragment.xml index a1d3254..d8657d5 100644 --- a/org.tizen.web.advanceddeclarationview/fragment.xml +++ b/org.tizen.web.advanceddeclarationview/fragment.xml @@ -24,7 +24,7 @@ id="org.tizen.web.advanceddeclarationview.viewContribution" targetID="org.tizen.web.advanceddeclarationview.ui.AdvancedDeclarationView"> <action - class="org.tizen.web.advanceddeclarationview.ui.ToggleLockAction" + class="org.tizen.web.advanceddeclarationview.ui.ToggleLockActionDelegate" definitionId="org.tizen.web.advanceddeclarationview.ui.LockView" icon="icons/locked.gif" id="org.tizen.web.advanceddeclarationview.lockAction" @@ -32,7 +32,7 @@ state="false" style="toggle" toolbarPath="additions" - tooltip="Lock (Alt+L)"> + tooltip="Lock"> </action> </viewContribution> </extension> @@ -83,5 +83,20 @@ defaultHandler="org.tizen.web.advanceddeclarationview.ui.ViewHandler"> </command> </extension> + <extension + point="org.eclipse.ui.viewActions"> + <viewContribution + id="org.tizen.web.advanceddeclarationview.viewContribution1" + targetID="org.tizen.web.advanceddeclarationview.ui.AdvancedDeclarationView"> + <action + class="org.tizen.web.advanceddeclarationview.ui.ToggleLineNumberActionDelegate" + id="org.tizen.web.advanceddeclarationview.togglelinenumberaction" + label="Show Line Number" + state="true" + style="toggle" + tooltip="Show Line Number"> + </action> + </viewContribution> + </extension> </fragment> diff --git a/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/AdvancedDeclarationView.java b/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/AdvancedDeclarationView.java index 6dc30d2..5b5825e 100644 --- a/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/AdvancedDeclarationView.java +++ b/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/AdvancedDeclarationView.java @@ -18,6 +18,7 @@ import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.resource.ColorRegistry; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.BadLocationException; @@ -26,6 +27,10 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextPresentationListener; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.text.TextPresentation; +import org.eclipse.jface.text.source.CompositeRuler; +import org.eclipse.jface.text.source.ISharedTextColors; +import org.eclipse.jface.text.source.IVerticalRuler; +import org.eclipse.jface.text.source.LineNumberRulerColumn; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; @@ -60,7 +65,9 @@ import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartReference; import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.editors.text.EditorsUI; import org.eclipse.ui.part.ViewPart; +import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; import org.eclipse.wst.jsdt.core.ICodeAssist; import org.eclipse.wst.jsdt.core.IJavaScriptElement; import org.eclipse.wst.jsdt.core.ILocalVariable; @@ -147,6 +154,14 @@ public class AdvancedDeclarationView extends ViewPart implements ISelectionListe private Label fElementInfoLabel; /** This view's result info label */ private Label fResultInfoLabel; + /** The viewer's vertical ruler */ + private CompositeRuler fVerticalRuler; + /** The viewer's showing line number flag */ + private boolean fShowLineNumber = true; + /** The viewer's line number column */ + private LineNumberRulerColumn fLineNumberColumn; + /** The toggle line number ruler action */ + private IAction fToggleLineNumberAction; /** The viewer's font properties change listener. */ private IPropertyChangeListener fFontPropertyChangeListener= new FontPropertyChangeListener(); @@ -193,6 +208,9 @@ public class AdvancedDeclarationView extends ViewPart implements ISelectionListe fViewerConfiguration.handlePropertyChangeEvent(event); fSrcViewer.invalidateTextPresentation(); } + if (event.getProperty().equals(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR)) { + updateLineNumberColumnPresentation(true); + } } } @@ -461,6 +479,41 @@ public class AdvancedDeclarationView extends ViewPart implements ISelectionListe public IAction getLockAction() { return fToggleLockAction; } + + /** + * set Show Line Number flag. + * @param flag + */ + public void setLineNumberStatus(boolean flag) { + fShowLineNumber = flag; + updateLineNumberRuler(); + } + + /** + * set toggle line number action. + * @param ac + */ + public void setToggleLineNumberAction(IAction ac) { + fToggleLineNumberAction = ac; + } + + /** + * get toggle line number action. + * @return + */ + public IAction getToggleLineNumberAction() { + return fToggleLineNumberAction; + } + + /** + * Returns Show Line Number flag. + * + * @return the fShowLineNumber flag + * + */ + public boolean getLineNumberStatus() { + return fShowLineNumber; + } /* * @see IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) @@ -529,7 +582,8 @@ public class AdvancedDeclarationView extends ViewPart implements ISelectionListe fResultInfoLabel = new Label(parent, SWT.LEFT); fResultInfoLabel.setText(""); - fSrcViewer = new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL, store); + fVerticalRuler = new CompositeRuler(); + fSrcViewer = new JavaSourceViewer(parent, fVerticalRuler, null, false, SWT.V_SCROLL | SWT.H_SCROLL, store); fViewerConfiguration= new SimpleJavaSourceViewerConfiguration(JavaScriptPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, IJavaScriptPartitions.JAVA_PARTITIONING, false); fSrcViewer.configure(fViewerConfiguration); fSrcViewer.setEditable(false); @@ -564,6 +618,8 @@ public class AdvancedDeclarationView extends ViewPart implements ISelectionListe formData.top = new FormAttachment(fComboViewer.getControl(), margin); formData.bottom = new FormAttachment(fElementInfoLabel, -margin); fSrcViewer.getControl().setLayoutData(formData); + + updateLineNumberRuler(); } private void inititalizeColors() { @@ -598,8 +654,8 @@ public class AdvancedDeclarationView extends ViewPart implements ISelectionListe MenuManager menuManager= new MenuManager("#PopupMenu"); //$NON-NLS-1$ menuManager.setRemoveAllWhenShown(true); menuManager.addMenuListener(this); - Menu contextMenu= menuManager.createContextMenu(getControl()); - getControl().setMenu(contextMenu); + Menu contextMenu= menuManager.createContextMenu(fSrcViewer.getTextWidget()); + fSrcViewer.getTextWidget().setMenu(contextMenu); getSite().registerContextMenu(menuManager, getSelectionProvider()); } @@ -609,7 +665,7 @@ public class AdvancedDeclarationView extends ViewPart implements ISelectionListe protected void createActions() { fGotoInputAction= new GotoInputAction(this); fGotoInputAction.setEnabled(false); - + // Setup OpenAction fOpen= new OpenAction(getViewSite()) { /* @@ -697,6 +753,9 @@ public class AdvancedDeclarationView extends ViewPart implements ISelectionListe if (fToggleLockAction != null) menu.appendToGroup(IContextMenuConstants.GROUP_ADDITIONS, fToggleLockAction); + + if (fToggleLineNumberAction != null) + menu.appendToGroup(IContextMenuConstants.GROUP_ADDITIONS, fToggleLineNumberAction); } /** @@ -1034,4 +1093,53 @@ public class AdvancedDeclarationView extends ViewPart implements ISelectionListe styledText.setFont(font); } } + + /** + * Updates the line number ruler. + */ + private void updateLineNumberRuler() + { + if (fVerticalRuler !=null) { + if(!fShowLineNumber){ + if(fLineNumberColumn!=null){ + fVerticalRuler.removeDecorator(fLineNumberColumn); + } + } else { + if(fLineNumberColumn==null){ + fLineNumberColumn = new LineNumberRulerColumn(); + updateLineNumberColumnPresentation(false); + } + fVerticalRuler.addDecorator(0, fLineNumberColumn); + } + } + } + + private void updateLineNumberColumnPresentation(boolean refresh) { + if (fLineNumberColumn == null) + return; + RGB rgb= getColorFromStore(EditorsUI.getPreferenceStore(), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR); + if (rgb == null) + rgb= new RGB(0, 0, 0); + ISharedTextColors sharedColors= getSharedColors(); + fLineNumberColumn.setForeground(sharedColors.getColor(rgb)); + if (refresh) { + fLineNumberColumn.redraw(); + } + } + + private ISharedTextColors getSharedColors() { + return EditorsUI.getSharedTextColors(); + } + + private RGB getColorFromStore(IPreferenceStore store, String key) { + RGB rgb= null; + if (store.contains(key)) { + if (store.isDefault(key)) + rgb= PreferenceConverter.getDefaultColor(store, key); + else + rgb= PreferenceConverter.getColor(store, key); + } + return rgb; + } } + diff --git a/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/InfoViewMessages.java b/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/InfoViewMessages.java index 68cf546..bcfb0f9 100644 --- a/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/InfoViewMessages.java +++ b/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/InfoViewMessages.java @@ -26,14 +26,6 @@ final class InfoViewMessages extends NLS { public static String GotoInputAction_label; public static String GotoInputAction_tooltip; public static String GotoInputAction_description; - public static String CopyToClipboard_error_title; - public static String CopyToClipboard_error_message; - public static String LockAction_label; - public static String LockAction_tooltip; - public static String LockAction_description; - public static String UnlockAction_label; - public static String UnlockAction_tooltip; - public static String UnlockAction_description; static { NLS.initializeMessages(BUNDLE_NAME, InfoViewMessages.class); diff --git a/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/InfoViewMessages.properties b/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/InfoViewMessages.properties index 99167a3..deb39dc 100644 --- a/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/InfoViewMessages.properties +++ b/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/InfoViewMessages.properties @@ -10,14 +10,6 @@ ############################################################################### -LockAction_label= Lock -LockAction_tooltip= Lock -LockAction_description= Lock - -UnlockAction_label= Unlock -UnlockAction_tooltip= Unlock -UnlockAction_description= Unlock - GotoInputAction_label= Open &Input GotoInputAction_tooltip= Open Input -GotoInputAction_description= Open Input +GotoInputAction_description= Open Input
\ No newline at end of file diff --git a/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/ToggleLineNumberActionDelegate.java b/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/ToggleLineNumberActionDelegate.java new file mode 100644 index 0000000..ad1dd2c --- /dev/null +++ b/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/ToggleLineNumberActionDelegate.java @@ -0,0 +1,25 @@ +package org.tizen.web.advanceddeclarationview.ui; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IViewActionDelegate; +import org.eclipse.ui.IViewPart; + +public class ToggleLineNumberActionDelegate implements IViewActionDelegate { + private AdvancedDeclarationView targetPart; + @Override + public void run(IAction action) { + targetPart.setLineNumberStatus(!targetPart.getLineNumberStatus()); + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + targetPart.setToggleLineNumberAction(action); + } + + @Override + public void init(IViewPart view) { + targetPart = (AdvancedDeclarationView)view; + } + +} diff --git a/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/ToggleLockAction.java b/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/ToggleLockActionDelegate.java index 03bce9f..ee04a87 100644 --- a/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/ToggleLockAction.java +++ b/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/ToggleLockActionDelegate.java @@ -5,9 +5,9 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
-public class ToggleLockAction implements IViewActionDelegate {
+public class ToggleLockActionDelegate implements IViewActionDelegate {
private AdvancedDeclarationView targetPart;
- private static ToggleLockAction lockAction;
+ private static ToggleLockActionDelegate lockAction;
@Override
public void run(IAction action) {
@@ -27,7 +27,7 @@ public class ToggleLockAction implements IViewActionDelegate { lockAction = this;
}
- public static ToggleLockAction getDefault() {
+ public static ToggleLockActionDelegate getDefault() {
return lockAction;
}
diff --git a/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/ViewHandler.java b/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/ViewHandler.java index 4ca3a94..cfa44da 100644 --- a/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/ViewHandler.java +++ b/org.tizen.web.advanceddeclarationview/src/org/tizen/web/advanceddeclarationview/ui/ViewHandler.java @@ -33,7 +33,7 @@ public class ViewHandler extends AbstractHandler { } catch (PartInitException e) { } } else if (identifier.equals("org.tizen.web.advanceddeclarationview.ui.LockView")) { - ToggleLockAction lockAction = ToggleLockAction.getDefault(); + ToggleLockActionDelegate lockAction = ToggleLockActionDelegate.getDefault(); IAction action = lockAction.getTarget().getLockAction(); action.setChecked(!lockAction.getTarget().isLocked()); |