本文整理匯總了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);
}