Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Java Editor Stand-alone Widget
Java Editor Stand-alone Widget [message #545820] Fri, 09 July 2010 09:41 Go to next message
Tempo Fify is currently offline Tempo FifyFriend
Messages: 4
Registered: July 2010
Junior Member
Hi,
I am looking for the Java Editor functionality (particularly syntax highlighting, code completion and error markers) as a stand-alone widget, which can be placed on other arbitrary controls. I want to use the widget, for example in a view, a dialog or even within another FormEditor.

Do you know how something similar could be done? Any hints would be helpful.

I hope there is a way to do it, without having to implement all the functionality using SourceViewer Controls
Re: Java Editor Stand-alone Widget [message #545828 is a reply to message #545820] Fri, 09 July 2010 10:18 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Tempo Fify wrote:
> Hi,
> I am looking for the Java Editor functionality (particularly syntax
> highlighting, code completion and error markers) as a stand-alone
> widget, which can be placed on other arbitrary controls. I want to use
> the widget, for example in a view, a dialog or even within another
> FormEditor.
> Do you know how something similar could be done? Any hints would be
> helpful.
>
> I hope there is a way to do it, without having to implement all the
> functionality using SourceViewer Controls
Use a SourceViewer and configure it using
org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration. However, you need
to wire most of the actions yourself.

Dani
Re: Java Editor Stand-alone Widget [message #546393 is a reply to message #545828] Mon, 12 July 2010 15:50 Go to previous messageGo to next message
Tempo Fify is currently offline Tempo FifyFriend
Messages: 4
Registered: July 2010
Junior Member

Thanks a lot Dani.

JavaSourceViewerConfiguration requires an ITextEditor.. which I don't have, when working in a dialog or a view.

The JavaSourceViewerConfiguration seems to be applicable only to proper editors and not to SourceViewers.

Am I missing any important clue here?

TF

Re: Java Editor Stand-alone Widget [message #546482 is a reply to message #546393] Tue, 13 July 2010 06:05 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Tempo Fify wrote:
>
> Thanks a lot Dani.
>
> JavaSourceViewerConfiguration requires an ITextEditor..
No, it does not.

Dani
> which I don't have, when working in a dialog or a view.
> The JavaSourceViewerConfiguration seems to be applicable only to
> proper editors and not to SourceViewers.
> Am I missing any important clue here?
> TF
>
>
Re: Java Editor Stand-alone Widget [message #550208 is a reply to message #546482] Thu, 29 July 2010 14:23 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 7
Registered: July 2010
Junior Member
I am also thinking about this topic. What I want to do is to integrate Java Editor into my IDE and only one method body is shown every time.
Some has been done as below.
//Create a JavaEditor ,since internal class is used, I am find some new solution. So far the answer is NO


private void createJavaEditor(Composite parent){
//Java editor part
javaEditor = new CompilationUnitEditor();
try{
javaEditor.init(this.getEditorSite(),this.getEditorInput());
}catch(Exception e){
e.printStackTrace();
}
Composite composite = new Composite(parent, javaEditor.getOrientation());
composite .setLayout(new FillLayout());
composite .setLayoutData(new GridData(GridData.FILL_BOTH));
javaEditor.createPartControl(composite );
}
Re: Java Editor Stand-alone Widget [message #550360 is a reply to message #550208] Fri, 30 July 2010 05:38 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
jamie0828@163.com wrote:
> I am also thinking about this topic. What I want to do is to integrate
> Java Editor into my IDE and only one method body is shown every time.
The Java editor already supports this out of the box (Java > Editor: [x]
Only show the selected Java element.

Dani
> Some has been done as below.
> //Create a JavaEditor ,since internal class is used, I am find some
> new solution. So far the answer is NO
>
>
> private void createJavaEditor(Composite parent){
> //Java editor part
> javaEditor = new CompilationUnitEditor();
> try{
> javaEditor.init(this.getEditorSite(),this.getEditorInput());
> }catch(Exception e){
> e.printStackTrace();
> }
> Composite composite = new Composite(parent,
> javaEditor.getOrientation());
> composite .setLayout(new FillLayout());
> composite .setLayoutData(new GridData(GridData.FILL_BOTH));
> javaEditor.createPartControl(composite );
> }
Re: Java Editor Stand-alone Widget [message #550400 is a reply to message #546482] Fri, 30 July 2010 09:31 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Dani,

I'm pretty sure it expects an ITextEditor in its constructor. Basically
any interesting method is guarded with if (getEditor() != null) ..
How can I use a JavaSourceViewerConfiguration without an editor?

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


Am 13.07.10 08:05, schrieb Daniel Megert:
> Tempo Fify wrote:
>>
>> Thanks a lot Dani.
>>
>> JavaSourceViewerConfiguration requires an ITextEditor..
> No, it does not.
>
> Dani
>> which I don't have, when working in a dialog or a view.
>> The JavaSourceViewerConfiguration seems to be applicable only to
>> proper editors and not to SourceViewers.
>> Am I missing any important clue here?
>> TF
>>
>>
Re: Java Editor Stand-alone Widget [message #550416 is a reply to message #550400] Fri, 30 July 2010 10:06 Go to previous messageGo to next message
Tempo Fify is currently offline Tempo FifyFriend
Messages: 4
Registered: July 2010
Junior Member
I am on the side of Florian. I still can't figure out how Dani wanted us to create a JavaSourceViewerConfiguration without a proper editor.

Would it be possible to have a code snippet of using the java editor in a dialog?

regards
TF

Re: Java Editor Stand-alone Widget [message #550473 is a reply to message #550400] Fri, 30 July 2010 13:41 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Sebastian Zarnekow wrote:
> Hi Dani,
>
> I'm pretty sure it expects an ITextEditor in its constructor.
* @param editor the editor in which the configured viewer(s) will
reside, or <code>null</code> if none
*/
public JavaSourceViewerConfiguration(IColorManager colorManager,
IPreferenceStore preferenceStore, ITextEditor editor, String partitioning) {

Which part of this Javadoc don't you get? I didn't say that all
functionality will be available but it gives you basic Java viewer
functionality which is e.g. also used in the JDT preference previews.

Dani

> Basically any interesting method is guarded with if (getEditor() !=
> null) ..
> How can I use a JavaSourceViewerConfiguration without an editor?
>
> Regards,
> Sebastian
Re: Java Editor Stand-alone Widget [message #550617 is a reply to message #550473] Sat, 31 July 2010 12:05 Go to previous message
Tempo Fify is currently offline Tempo FifyFriend
Messages: 4
Registered: July 2010
Junior Member
Hi Dani,
Thanks for the clue about the JDT preference pages. I could get the previewer functionality by copying a few lines from:

org.eclipse.jdt.internal.ui.preferences.formatter.JavaPrevie w

regards
TF
Previous Topic:Increase the available heap memory?
Next Topic:SearchPattern for called methods
Goto Forum:
  


Current Time: Mon Sep 23 14:19:38 GMT 2024

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

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

Back to the top