本文整理汇总了Java中org.hawk.emfresource.HawkResource类的典型用法代码示例。如果您正苦于以下问题:Java HawkResource类的具体用法?Java HawkResource怎么用?Java HawkResource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HawkResource类属于org.hawk.emfresource包,在下文中一共展示了HawkResource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: greedySerialize
import org.hawk.emfresource.HawkResource; //导入依赖的package包/类
protected Serializer greedySerialize(final HawkResource resource, IProgressMonitor monitor)
throws Exception, IfcModelInterfaceException {
final int total = resource.getContents().size();
/*
* Greedy loading modes are simple: we already have everything in the
* model, so we can use the standard EMF facilities.
*/
final Serializer serializer = createSerializer(resource);
long oid = 0;
int current = 0, offset = 0;
for (TreeIterator<EObject> it = resource.getAllContents(); it.hasNext();) {
final EObject eo = it.next();
oid = addToSerializer(serializer, oid, eo);
++current;
if (current == REPORTING_BATCH_SIZE) {
offset += current;
current = 0;
monitor.subTask(String.format("Populating IFC serializer (%d/%d)", offset, total));
}
}
return serializer;
}
示例2: getResource
import org.hawk.emfresource.HawkResource; //导入依赖的package包/类
protected HawkResource getResource()
{
return new LocalHawkResourceImpl(URI.createURI("hawk://"),
getHawkModel().getIndexer(), false,
Collections.singletonList(request.getRepositoryPattern()),
request.getFilePatterns());
}
示例3: exportToSTEP
import org.hawk.emfresource.HawkResource; //导入依赖的package包/类
protected void exportToSTEP(final File dest, final IProgressMonitor monitor)
throws IOException, FileNotFoundException, Exception, IfcModelInterfaceException, SerializerException,
CoreException {
monitor.beginTask("Exporting " + getHawkModel().getName() + " to " + dest.getName(), 4);
monitor.subTask("Loading Hawk resource");
final ResourceSet rs = new ResourceSetImpl();
final HawkResource resource = getResource();
try {
rs.getResources().add(resource);
monitor.worked(1);
if (monitor.isCanceled()) {
return;
}
monitor.subTask("Populating IFC serializer");
Serializer serializer = greedySerialize(resource, monitor);
serializer.getModel().generateMinimalExpressIds();
monitor.worked(1);
if (monitor.isCanceled()) {
return;
}
monitor.subTask("Writing STEP file");
serializer.writeToFile(dest, new ProgressReporter() {
@Override
public void update(long progress, long max) {
monitor.subTask(String.format("Writing STEP file (%d/%d)", progress, max));
}
});
monitor.worked(1);
if (monitor.isCanceled()) {
return;
}
} finally {
// TODO: ask Will - why don't we unload the resource here?
//resource.unload();
}
}
示例4: createSerializer
import org.hawk.emfresource.HawkResource; //导入依赖的package包/类
private Serializer createSerializer(final HawkResource resource) throws Exception {
Serializer serializer = null;
for (TreeIterator<EObject> it = EcoreUtil.getAllContents(resource, false); it.hasNext()
&& serializer == null;) {
EObject eo = it.next();
if (eo instanceof IdEObject) {
serializer = createSerializer(eo.eClass().getEPackage().getNsURI());
}
}
return serializer;
}
示例5: fetchNode
import org.hawk.emfresource.HawkResource; //导入依赖的package包/类
@Override
public EObject fetchNode(HawkResource containerResource, String uriFragment, boolean fetchAttributes) throws Exception {
if (!(containerResource instanceof HawkFileResourceImpl)) {
return null;
}
final HawkFileResourceImpl r = (HawkFileResourceImpl)containerResource;
final FileNode fileNode = uriToFileNode.get(r.getURI().toString());
LOGGER.warn("Iterating over the contents of {}{} to find fragment {}: inefficient!",
fileNode.getRepositoryURL(), fileNode.getFilePath(), uriFragment);
String nodeId = null;
try (IGraphTransaction tx = fileNode.getNode().getGraph().beginTransaction()) {
for (ModelElementNode me : fileNode.getModelElements()) {
final String fragment = me.getElementId();
final String currentNodeId = me.getNodeId();
if (uriFragment.equals(fragment)) {
nodeId = currentNodeId;
}
}
}
if (nodeId != null) {
return fetchNode(nodeId, fetchAttributes);
} else {
return null;
}
}
示例6: generateCustomizerActions
import org.hawk.emfresource.HawkResource; //导入依赖的package包/类
@Override
public Collection<IAction> generateCustomizerActions(ISelection selection) {
if (selection instanceof IStructuredSelection) {
final IStructuredSelection ssel = (IStructuredSelection)selection;
if (ssel.getFirstElement() instanceof HawkResource) {
final HawkResource r = (HawkResource)ssel.getFirstElement();
final List<IAction> actions = new ArrayList<>();
final Action fetchByEClass = new FetchByEClassAction(r);
fetchByEClass.setText("Fetch by EClass");
actions.add(fetchByEClass);
return actions;
}
}
return Collections.emptyList();
}
示例7: fetchNode
import org.hawk.emfresource.HawkResource; //导入依赖的package包/类
@Override
public EObject fetchNode(HawkResource containerResource, String uriFragment, boolean mustFetchAttributes) throws Exception {
// TODO We need to extend the Thrift API to support this, and it'd be an inefficient operation right now.
throw new UnsupportedOperationException();
}
示例8: HawkQueryRuntimeContext
import org.hawk.emfresource.HawkResource; //导入依赖的package包/类
public HawkQueryRuntimeContext(final HawkResource hawkResource, final Logger logger) {
super(null, logger, null);
this.hawkResource = hawkResource;
}
示例9: LazyResolver
import org.hawk.emfresource.HawkResource; //导入依赖的package包/类
public LazyResolver(HawkResource resource) {
this.resource = resource;
}
示例10: HawkFileResourceImpl
import org.hawk.emfresource.HawkResource; //导入依赖的package包/类
/**
* Creates a resource as a subordinate of another. Used to indicate the
* repository URL and file of an {@link EObject}.
*/
public HawkFileResourceImpl(final URI uri, final HawkResource mainResource) {
super(uri);
this.mainResource = mainResource;
}
示例11: fetchNode
import org.hawk.emfresource.HawkResource; //导入依赖的package包/类
@Override
public EObject fetchNode(HawkResource containerResource, String uriFragment, boolean mustFetchAttributes) throws Exception {
return mainResource.fetchNode(containerResource, uriFragment, mustFetchAttributes);
}
示例12: FetchByEClassAction
import org.hawk.emfresource.HawkResource; //导入依赖的package包/类
public FetchByEClassAction(HawkResource r) {
this.resource = r;
}
示例13: hasChildren
import org.hawk.emfresource.HawkResource; //导入依赖的package包/类
@Override
public boolean hasChildren(Resource r, EObject eob) {
final HawkResource hawkResource = (HawkResource)r;
return hawkResource.hasChildren(eob);
}
示例14: isEnabledFor
import org.hawk.emfresource.HawkResource; //导入依赖的package包/类
@Override
public boolean isEnabledFor(Resource r) {
return r instanceof HawkResource;
}
示例15: EClassSelectionDialog
import org.hawk.emfresource.HawkResource; //导入依赖的package包/类
EClassSelectionDialog(Shell parentShell, HawkResource hawkResource) {
super(parentShell);
this.resource = hawkResource;
}