Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » creating markers
creating markers [message #46694] Mon, 04 April 2005 11:11 Go to next message
Eclipse UserFriend
Originally posted by: rakedash.in.ibm.com

hi,

i am getting problems in creating markers for an existing text document.i
am aiming at creating markers at specified line of a given text
doc(test.txt).but my code is throwing exception and it seems is not
getting the workspace.note the text.txt really exits.following is the code
for creating markers..
please let me know what could be the problem because of which it throws
exception and how to avoid this exception to create the markers..

import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
import org.eclipse.core.resources.IMarker;
public class Test{
Test(){

}

public static void main(String[] args) throws CoreException{

new Test();
try{


IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
IProject project = root.getProject("project");
if(project.isOpen()){
System.out.println("opened");
}
/*IFolder folder = project.getFolder("Folder1");
IFile file = folder.getFile("test.txt");*/
IFile file= project.getFile("test.txt");
if (!project.exists()) project.create(null);
if (!project.isOpen()) project.open(null);


IResource res=file;
IMarker marker=res.createMarker(IMarker.PROBLEM);
if(marker.exists())
{
System.out.println("trace");
marker.setAttribute(IMarker.LINE_NUMBER,2);
marker.setAttribute(IMarker.MESSAGE,"test marker");

}
else{
System.out.println("marker ");
}


}
catch(Exception e){ System.out.println("error");
e.printStackTrace();}
}

}


please reply soon..
bye..
Rakesh
Re: creating markers [message #46944 is a reply to message #46694] Mon, 04 April 2005 18:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: john.eclipsefaq.org

You can't write a standalone Java application like this that makes use
of Eclipse APIs. Most Eclipse plugins, including
org.eclipse.core.resources, require that the Eclipse platform be up and
running before you can do anything with them. I suggest rewriting the
code below as a plugin.
--

Rakesh wrote:
> hi,
>
> i am getting problems in creating markers for an existing text
> document.i am aiming at creating markers at specified line of a given
> text doc(test.txt).but my code is throwing exception and it seems is not
> getting the workspace.note the text.txt really exits.following is the
> code for creating markers..
> please let me know what could be the problem because of which it throws
> exception and how to avoid this exception to create the markers..
>
> import org.eclipse.core.resources.*;
> import org.eclipse.core.runtime.*;
> import org.eclipse.core.resources.IMarker;
> public class Test{
> Test(){
>
> }
>
> public static void main(String[] args) throws CoreException{
>
> new Test();
> try{
>
> IWorkspace workspace =
> ResourcesPlugin.getWorkspace(); IWorkspaceRoot
> root = workspace.getRoot();
> IProject project = root.getProject("project");
> if(project.isOpen()){
> System.out.println("opened");
> }
> /*IFolder folder = project.getFolder("Folder1");
> IFile file = folder.getFile("test.txt");*/
> IFile file= project.getFile("test.txt");
> if (!project.exists()) project.create(null);
> if (!project.isOpen()) project.open(null);
>
> IResource res=file;
> IMarker marker=res.createMarker(IMarker.PROBLEM);
> if(marker.exists())
> {
> System.out.println("trace");
> marker.setAttribute(IMarker.LINE_NUMBER,2);
> marker.setAttribute(IMarker.MESSAGE,"test marker");
>
> }
> else{
> System.out.println("marker ");
> }
>
> }
> catch(Exception e){ System.out.println("error");
> e.printStackTrace();}
> }
> }
>
>
> please reply soon..
> bye..
> Rakesh
>
creating markers as plug-in [message #47212 is a reply to message #46944] Tue, 05 April 2005 06:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rakedash.in.ibm.com

hi,

thanks for your advice.i tried creating markers as plug-in.but no marker
is created at the specified line of the text.i created a resource in the
run time workbench where i was intending a marker.but nothing came.can you
suggest me what could have been the problem with this.i guess there is no
such exception now as it wa showing prior to implementing as a plug-in.but
where is the markers.Am i doing anything wrong here.please help me out
with this...

bye..
rakesh
Re: creating markers as plug-in [message #48888 is a reply to message #47212] Thu, 07 April 2005 22:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: SamMesh.gmail.com

Please see https://bugs.eclipse.org/bugs/show_bug.cgi?id=84917

Dunno why eclipsefaq are not available anymore.

--
Sam Mesh

Rakesh wrote:
> hi,
>
> thanks for your advice.i tried creating markers as plug-in.but no marker
> is created at the specified line of the text.i created a resource in the
> run time workbench where i was intending a marker.but nothing came.can
> you suggest me what could have been the problem with this.i guess there
> is no such exception now as it wa showing prior to implementing as a
> plug-in.but where is the markers.Am i doing anything wrong here.please
> help me out with this...
simple working example of markers [message #50381 is a reply to message #48888] Mon, 11 April 2005 05:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rakedash.in.ibm.com

Hi,
Thanks for replying my doubt.but i am unable to follow why this is not
working.Can you just give me any working simple example of markers.

i was unable to follow the link to bugs.

i would be grateful if you can help me with this.

bye..
rakesh
Re: simple working example of markers [message #52178 is a reply to message #50381] Thu, 14 April 2005 18:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Chris_Laffra.ca.ibm.com

Sam,

Actually, we can sue you. Even Google's cache contains the following
fragment:

Copyright 2004, Pearson Education, Inc.,
All Rights Reserved. The material is from
Official Eclipse 3.0 FAQs, published by
Addison-Wesley. No part of this
publication may be reproduced, stored
in a retrieval system, or transmitted,
in any form, or by any means, electronic,
mechanical, photocopying, recording,
or otherwise, without the prior
consent of the publisher.

I am not a lawyer, just a book author, but if you copy text from a book at
verbatim and submit it to a newsgroup while removing the copyright you
violate the above restriction, I think.

Mmm, let's say there are 10,000 readers to this newsgroup. The book has 361
FAQs @ $36.
Multiple 10,000 readers by the cost of one FAQ @ $0.10 => $1,000.
I think we could ask you to send us a check for that amount, but I have to
check with my lawyer.

--
Chris Laffra, http://eclipsefaq.org


"Sam Mesh" <SamMesh@gmail.com> wrote in message
news:d3e55c$59b$1@news.eclipse.org...
>
> This in an excerpt from
> <http://www.eclipsefaq.org/chris/faq/html/faq304.html>:
> (Chris and John, you can sue Google for caching it! :)
> *****************************
> Text editors in Eclipse can display markers in a number of ways. Most
> commonly, they appear as icons in the vertical rule on the left-hand
> side of the editor pane. Markers can also optionally be displayed as
> squiggly underlays in the text and in the overview ruler on the
> right-hand side of the editor. How each type of marker is displayed is
> chosen by the user on the editor preference pages (Workbench > Editors >
> Text Editor > Annotations and Java > Editor > Annotations). The IMarker
> interface declares a number of frequently used marker types. Any created
> marker that has either the LINE_NUMBER or CHAR_START and CHAR_END
> attributes set will be displayed by editors. These attributes must exist
> when the marker is created for the marker to appear in an editor. The
> most common mistake is to create the marker and then add the attributes
> in a separate operation. The text framework provides a utility class
> called MarkerUtilities to make this easier for you. Here is a sample
> snippet that adds a marker correctly:
>
>
> int lineNumber = ...;
> HashMap map = new HashMap();
> MarkerUtilities.setLineNumber(map, lineNumber);
> MarkerUtilities.createMarker(resource, map, IMarker.TEXT);
> *****************************
>
>
> > i was unable to follow the link to bugs.
>
> Please try again. You will definitely solve a lot of your problems
> accessing <https://bugs.eclipse.org>. Do not hesitate to ask guys in
> your domain - it's *ibm* or what?.. :)
>
> --
> HTH,
> Sam Mesh
Re: simple working example of markers [message #53157 is a reply to message #52178] Sun, 17 April 2005 16:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: SamMesh.gmail.com

Thanks for the lesson, Chris!

Please be advised that I consider my citation inappropriate
and I already removed (canceled) my newsgroup article with this citation.

Please notify me about any occurrences of my inappropriate post and I'll
do my best to destroy them.

Also I'll do my best to receive "prior consent of the publisher" in the
future. I regret that such consent can not be received in this case.

I truly believe that good will should be tried before any legal actions
and hope we're on the same page in this question.

PS. Google treats legal issues seriously. This faq is not in cache anymore.

--
Sincerely,
Sam Mesh

Chris Laffra wrote:
> Sam,
>
> Actually, we can sue you. Even Google's cache contains the following
> fragment:
>
> Copyright 2004, Pearson Education, Inc.,
> All Rights Reserved. The material is from
> Official Eclipse 3.0 FAQs, published by
> Addison-Wesley. No part of this
> publication may be reproduced, stored
> in a retrieval system, or transmitted,
> in any form, or by any means, electronic,
> mechanical, photocopying, recording,
> or otherwise, without the prior
> consent of the publisher.
>
> I am not a lawyer, just a book author, but if you copy text from a book at
> verbatim and submit it to a newsgroup while removing the copyright you
> violate the above restriction, I think.
>
> Mmm, let's say there are 10,000 readers to this newsgroup. The book has 361
> FAQs @ $36.
> Multiple 10,000 readers by the cost of one FAQ @ $0.10 => $1,000.
> I think we could ask you to send us a check for that amount, but I have to
> check with my lawyer.
>
Re: simple working example of markers [message #53181 is a reply to message #53157] Sun, 17 April 2005 17:40 Go to previous message
Eclipse UserFriend
Originally posted by: Chris_Laffra.ca.ibm.com

Hi Sam,

We were not planning on sueing you for this particular action, don't worry.
I just wanted to make a point. I appreciate your apology. Thanks.

Furthermore, I don't believe Google reacts to legal issues from two simple
book authors. They just update their cache when the original pages gets
updated by the prospective publisher, which is what we did. I scarcely think
Googles scans pages to see if they contain legal statements.

--
Chris Laffra, http://eclipsefaq.org


"Sam Mesh" <SamMesh@gmail.com> wrote in message
news:d3u29n$pi2$1@news.eclipse.org...
> Thanks for the lesson, Chris!
>
> Please be advised that I consider my citation inappropriate
> and I already removed (canceled) my newsgroup article with this citation.
>
> Please notify me about any occurrences of my inappropriate post and I'll
> do my best to destroy them.
>
> Also I'll do my best to receive "prior consent of the publisher" in the
> future. I regret that such consent can not be received in this case.
>
> I truly believe that good will should be tried before any legal actions
> and hope we're on the same page in this question.
>
> PS. Google treats legal issues seriously. This faq is not in cache
anymore.
>
> --
> Sincerely,
> Sam Mesh
>
> Chris Laffra wrote:
> > Sam,
> >
> > Actually, we can sue you. Even Google's cache contains the following
> > fragment:
> >
> > Copyright 2004, Pearson Education, Inc.,
> > All Rights Reserved. The material is from
> > Official Eclipse 3.0 FAQs, published by
> > Addison-Wesley. No part of this
> > publication may be reproduced, stored
> > in a retrieval system, or transmitted,
> > in any form, or by any means, electronic,
> > mechanical, photocopying, recording,
> > or otherwise, without the prior
> > consent of the publisher.
> >
> > I am not a lawyer, just a book author, but if you copy text from a book
at
> > verbatim and submit it to a newsgroup while removing the copyright you
> > violate the above restriction, I think.
> >
> > Mmm, let's say there are 10,000 readers to this newsgroup. The book has
361
> > FAQs @ $36.
> > Multiple 10,000 readers by the cost of one FAQ @ $0.10 => $1,000.
> > I think we could ask you to send us a check for that amount, but I have
to
> > check with my lawyer.
> >
Previous Topic:I'm new to eclipse!
Next Topic:Undefined reference in C
Goto Forum:
  


Current Time: Wed Jan 15 12:09:27 GMT 2025

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

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

Back to the top