本文整理汇总了Java中org.eclipse.core.resources.IMarker.setAttributes方法的典型用法代码示例。如果您正苦于以下问题:Java IMarker.setAttributes方法的具体用法?Java IMarker.setAttributes怎么用?Java IMarker.setAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.resources.IMarker
的用法示例。
在下文中一共展示了IMarker.setAttributes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openInEditor
import org.eclipse.core.resources.IMarker; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "deprecation", "rawtypes" })
public static void openInEditor(IFile file, int startpos, int length) {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
HashMap map = new HashMap();
map.put(IMarker.CHAR_START, new Integer(startpos));
map.put(IMarker.CHAR_END, new Integer(startpos+length));
map.put(IWorkbenchPage.EDITOR_ID_ATTR,
"org.eclipse.ui.DefaultTextEditor");
try {
IMarker marker = file.createMarker(IMarker.TEXT);
marker.setAttributes(map);
IDE.openEditor(page, marker);
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: internalCreateMarker
import org.eclipse.core.resources.IMarker; //导入方法依赖的package包/类
/**
* Creates a marker on the given resource with the given type and
* attributes.
* <p>
* This method modifies the workspace (progress is not reported to the
* user).
* </p>
*
* @param resource
* the resource
* @param attributes
* the attribute map
* @param markerType
* the type of marker
* @throws CoreException
* if this method fails
* @see IResource#createMarker(java.lang.String)
*/
private void internalCreateMarker(final IResource resource, final Map<String, Object> attributes,
final String markerType) throws CoreException {
IWorkspaceRunnable r = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
IMarker marker = resource.createMarker(markerType);
marker.setAttributes(attributes);
handleMarkerAdded(marker);
}
};
resource.getWorkspace().run(r, null, IWorkspace.AVOID_UPDATE, null);
}