Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » ScrollBar Position(ScrollBar Position-TextEditor)
ScrollBar Position [message #498904] Thu, 19 November 2009 06:05 Go to next message
Ashok  is currently offline Ashok Friend
Messages: 8
Registered: November 2009
Junior Member
I have files from remote system displayed onto a TextEditor. Only 300 lines of text will be displayed in the Editor at a given time and on demand next set of records will be fetched. I wanted to control to scroll position relative to the actual size of the file.

Say for example if the file has 1000 lines text the scroll bar should position in the editor for 1000 lines. Now the scrollbar is set to 300 lines and when you reach to 299 line the scrollbar reaches to end of file area and when the next set of records are fetched, the scrollbar posistion get reset to the new content. The scroll bar should reach to the end of the text area only when it reaches to 1000th line.

Any help in this regard will be of great help.
Re: ScrollBar Position [message #499040 is a reply to message #498904] Thu, 19 November 2009 15:45 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi,

TextEditor comes from the eclipse ui level, so you should ask this in the
eclipse.plaform newsgroup.

If you wanted to be a bit lighter-weight than using TextEditor then you
could achieve something similar with StyledText. The snippet below
demonstrates the basic implementation of what you want, it retrieves each
line of text on an as-needed basis. You'll notice that text editing does
not work though because most of the required methods are just left as empty
stubs.

public static void main(String[] args) {
final Display display = new Display();
Shell shell = new Shell(display);
shell.setBounds(200,200,200,200);
shell.setLayout(new FillLayout());
StyledText text = new StyledText(shell, SWT.MULTI | SWT.H_SCROLL |
SWT.V_SCROLL);
text.setContent(new StyledTextContent() {
public void setText(String text) {
// TODO Auto-generated method stub
}
public void replaceTextRange(int start, int replaceLength, String
text) {
// TODO Auto-generated method stub
}
public void removeTextChangeListener(TextChangeListener listener) {
// TODO Auto-generated method stub
}
public String getTextRange(int start, int length) {
// TODO Auto-generated method stub
return null;
}
public int getOffsetAtLine(int lineIndex) {
// TODO Auto-generated method stub
return 0;
}
public String getLineDelimiter() {
// TODO Auto-generated method stub
return null;
}
public int getLineCount() { // <---------
return 1000;
}
public int getLineAtOffset(int offset) {
// TODO Auto-generated method stub
return 0;
}
public String getLine(int lineIndex) { // <---------
// TODO Auto-generated method stub
return "line " + lineIndex;
}
public int getCharCount() {
// TODO Auto-generated method stub
return 0;
}
public void addTextChangeListener(TextChangeListener listener) {
// TODO Auto-generated method stub
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
shell.dispose();
display.dispose();
}

Grant


"Ashok" <Ashok.Velladurai@unisys.com> wrote in message
news:he2n83$hsd$1@build.eclipse.org...
> I have files from remote system displayed onto a TextEditor. Only 300
lines of text will be displayed in the Editor at a given time and on demand
next set of records will be fetched. I wanted to control to scroll position
relative to the actual size of the file.
>
> Say for example if the file has 1000 lines text the scroll bar should
position in the editor for 1000 lines. Now the scrollbar is set to 300 lines
and when you reach to 299 line the scrollbar reaches to end of file area and
when the next set of records are fetched, the scrollbar posistion get reset
to the new content. The scroll bar should reach to the end of the text area
only when it reaches to 1000th line.
>
> Any help in this regard will be of great help.
Previous Topic:Image BMP Binary with SWT
Next Topic:Where is the Online Javadoc of SWT?
Goto Forum:
  


Current Time: Thu Apr 25 11:07:43 GMT 2024

Powered by FUDForum. Page generated in 0.03521 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top