Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/355.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在标尺上添加标记?_Java_Eclipse_Eclipse Plugin - Fatal编程技术网

Java 如何在标尺上添加标记?

Java 如何在标尺上添加标记?,java,eclipse,eclipse-plugin,Java,Eclipse,Eclipse Plugin,我试图在Eclipse中的垂直标尺上添加一个标记/图标。我使用了下面的代码 IEditorPart editor = PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getActivePage().getActiveEditor(); IFileEditorInput input = (IFileEditorInput)editor.getEditorInput() ; IFile file

我试图在Eclipse中的垂直标尺上添加一个标记/图标。我使用了下面的代码

     IEditorPart editor = PlatformUI.getWorkbench()
        .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
     IFileEditorInput input = (IFileEditorInput)editor.getEditorInput() ;
     IFile file = input.getFile();
     IProject activeProject = file.getProject();
     IResource res = (IResource) activeProject;

     IMarker m;
     try {
            m = res.createMarker("com.examples.problem");
            m.setAttribute(IMarker.LOCATION, offset);
            m.setAttribute(IMarker.MESSAGE, "Hello");
            m.setAttribute(IMarker.LINE_NUMBER, offset);
      } catch (CoreException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
其中offset是我想要标记的行号。
这段代码是一个标记,但不是在标尺上,而是在Console和Error log旁边的Problems视图上。你知道我怎么修吗?另外,如果有任何其他方法可以在标尺上添加切换/图标/标记,请给出建议。

您应该在编辑器中打开的文件上创建标记,而不是在项目上。

您应该在编辑器中打开的文件上创建标记,而不是在项目上。

您应该使用MarkerNotationSpecification扩展点。这用于使用指定的格式自动定义标记和编辑器注释之间的映射


请参阅我的博客文章了解更多详细信息:

您应该使用MarkerNotationSpecification扩展点。这用于使用指定的格式自动定义标记和编辑器注释之间的映射


查看我的博客帖子了解更多详情:

非常感谢你。。。这很有帮助。非常感谢你。。。这有帮助。