Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 2368 Details for
Bug 25961
Selected lines count shown
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
implements the proposal
25961.txt (text/plain), 7.20 KB, created by
Sebastian Davids
on 2002-11-10 21:58:21 EST
(
hide
)
Description:
implements the proposal
Filename:
MIME Type:
Creator:
Sebastian Davids
Created:
2002-11-10 21:58:21 EST
Size:
7.20 KB
patch
obsolete
>Index: AbstractTextEditor.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java,v >retrieving revision 1.17 >diff -u -r1.17 AbstractTextEditor.java >--- AbstractTextEditor.java 1 Nov 2002 09:10:27 -0000 1.17 >+++ AbstractTextEditor.java 11 Nov 2002 02:55:55 -0000 >@@ -1124,9 +1124,11 @@ > /** The error message shown in the status line in case of failed information look up. */ > protected final String fErrorLabel= EditorMessages.getString("Editor.statusline.error.label"); //$NON-NLS-1$ > private final String fPositionLabelPattern= EditorMessages.getString("Editor.statusline.position.pattern"); //$NON-NLS-1$ >+ private final String fSelectionLabelPattern= EditorMessages.getString("Editor.statusline.selection.pattern"); >+ private final PositionLabelValue fNumOfLinesLabel= new PositionLabelValue(); > private final PositionLabelValue fLineLabel= new PositionLabelValue(); > private final PositionLabelValue fColumnLabel= new PositionLabelValue(); >- private final Object[] fPositionLabelPatternArguments= new Object[] { fLineLabel, fColumnLabel }; >+ private final Object[] fPositionLabelPatternArguments= new Object[] { fLineLabel, fColumnLabel, fNumOfLinesLabel }; > > > >@@ -3721,25 +3723,36 @@ > if (document == null) > return fErrorLabel; > >- try { >- >- int line= document.getLineOfOffset(caret); >+ ITextSelection selection = (ITextSelection) getSelectionProvider().getSelection(); >+ >+ if (selection == null || selection.getLength() == 0) { >+ try { >+ int line= document.getLineOfOffset(caret); >+ >+ int lineOffset= document.getLineOffset(line); >+ int tabWidth= styledText.getTabs(); >+ int column= 0; >+ for (int i= lineOffset; i < caret; i++) >+ if ('\t' == document.getChar(i)) >+ column += tabWidth - (column % tabWidth); >+ else >+ column++; >+ >+ fLineLabel.fValue= line + 1; >+ fColumnLabel.fValue= column + 1; >+ return MessageFormat.format(fPositionLabelPattern, fPositionLabelPatternArguments); >+ } catch (BadLocationException x) { >+ return fErrorLabel; >+ } >+ } else { >+ int start= selection.getStartLine(); >+ int end= selection.getEndLine(); > >- int lineOffset= document.getLineOffset(line); >- int tabWidth= styledText.getTabs(); >- int column= 0; >- for (int i= lineOffset; i < caret; i++) >- if ('\t' == document.getChar(i)) >- column += tabWidth - (column % tabWidth); >- else >- column++; >- >- fLineLabel.fValue= line + 1; >- fColumnLabel.fValue= column + 1; >- return MessageFormat.format(fPositionLabelPattern, fPositionLabelPatternArguments); >- >- } catch (BadLocationException x) { >- return fErrorLabel; >+ fLineLabel.fValue= start + 1; >+ fColumnLabel.fValue= end + 1; >+ fNumOfLinesLabel.fValue= end - start + 1; >+ >+ return MessageFormat.format(fSelectionLabelPattern, fPositionLabelPatternArguments); > } > } > >Index: BasicTextEditorActionContributor.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java,v >retrieving revision 1.2 >diff -u -r1.2 BasicTextEditorActionContributor.java >--- BasicTextEditorActionContributor.java 25 Sep 2002 14:11:24 -0000 1.2 >+++ BasicTextEditorActionContributor.java 11 Nov 2002 02:55:55 -0000 >@@ -73,7 +73,17 @@ > ITextEditorActionConstants.STATUS_CATEGORY_INPUT_MODE, > ITextEditorActionConstants.STATUS_CATEGORY_INPUT_POSITION > }; >- >+ >+ /** >+ * The sizes of the status fields to be set to the editor >+ * @since 2.1 >+ */ >+ private final static int[] STATUSFIELDS_SIZES= { >+ 9, >+ 9, >+ 14 >+ }; >+ > /** The active editor part */ > private IEditorPart fActiveEditorPart; > /** >@@ -121,7 +131,7 @@ > > fStatusFields= new HashMap(3); > for (int i= 0; i < STATUSFIELDS.length; i++) >- fStatusFields.put(STATUSFIELDS[i], new StatusLineContributionItem(STATUSFIELDS[i])); >+ fStatusFields.put(STATUSFIELDS[i], new StatusLineContributionItem(STATUSFIELDS[i], STATUSFIELDS_SIZES[i])); > } > > /** >Index: EditorMessages.properties >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorMessages.properties,v >retrieving revision 1.4 >diff -u -r1.4 EditorMessages.properties >--- EditorMessages.properties 7 Nov 2002 17:11:45 -0000 1.4 >+++ EditorMessages.properties 11 Nov 2002 02:55:55 -0000 >@@ -239,6 +239,7 @@ > Editor.statusline.mode.insert.label=Insert > Editor.statusline.mode.overwrite.label=Overwrite > Editor.statusline.position.pattern={0} : {1} >+Editor.statusline.selection.pattern={0} : {1} - {2} line(s) > Editor.statusline.error.label=? > > ## Others ## >Index: StatusLineContributionItem.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/StatusLineContributionItem.java,v >retrieving revision 1.1 >diff -u -r1.1 StatusLineContributionItem.java >--- StatusLineContributionItem.java 24 Sep 2002 16:56:43 -0000 1.1 >+++ StatusLineContributionItem.java 11 Nov 2002 02:55:56 -0000 >@@ -44,13 +44,20 @@ > * Creates a new status line label. > * @param parent parent control > * @param style the swt style bits >+ * @param numOfChars the maximum number of characters this label can >+ * show > */ >- public StatusLineLabel(Composite parent, int style) { >+ public StatusLineLabel(Composite parent, int style, int numOfChars) { > super(parent, style); > >+ char[] chs = new char[numOfChars]; >+ >+ for (int i = numOfChars - 1; i >= 0; i--) >+ chs[i] = 'M'; >+ > GC gc= new GC(parent); > gc.setFont(parent.getFont()); >- Point extent= gc.textExtent("MMMMMMMMM"); //$NON-NLS-1$ >+ Point extent= gc.textExtent(new String(chs)); //$NON-NLS-1$ > gc.dispose(); > > fFixedSize= new Point(extent.x + INDENT * 2, 10); >@@ -71,13 +78,34 @@ > /** The status line label widget */ > private StatusLineLabel fLabel; > >+ /** The number of characters this status line contribution will show. */ >+ private int fNumOfChars; >+ >+ /** Default: 9 characters will be shown. */ >+ private static int DEFAULT_NUM_OF_CHARS = 9; >+ > /** > * Creates a new item with the given id. > * > * @param id the item's id > */ > public StatusLineContributionItem(String id) { >+ this(id, DEFAULT_NUM_OF_CHARS); >+ } >+ >+ /** >+ * Creates a new item with the given id and number of characters to be >+ * shown. >+ * >+ * @param id the item's id >+ * @param numOfChars the maximum number of characters this lable can show >+ * @since 2.1 >+ * >+ */ >+ public StatusLineContributionItem(String id, int numOfChars) { > super(id); >+ >+ fNumOfChars= (numOfChars < 1) ? DEFAULT_NUM_OF_CHARS : numOfChars; > } > > /* >@@ -104,7 +132,7 @@ > * @see IContributionItem#fill(Composite) > */ > public void fill(Composite parent) { >- fLabel= new StatusLineLabel(parent, SWT.SHADOW_IN); >+ fLabel= new StatusLineLabel(parent, SWT.SHADOW_IN, fNumOfChars); > fLabel.setData(this); > > if (fText != null)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 25961
:
2366
|
2367
| 2368