本文整理匯總了Java中org.eclipse.emf.common.EMFPlugin類的典型用法代碼示例。如果您正苦於以下問題:Java EMFPlugin類的具體用法?Java EMFPlugin怎麽用?Java EMFPlugin使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EMFPlugin類屬於org.eclipse.emf.common包,在下文中一共展示了EMFPlugin類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: startCDOServer
import org.eclipse.emf.common.EMFPlugin; //導入依賴的package包/類
@BeforeClass
public static void startCDOServer() throws IOException, CommitException {
server = new CDOServer(false);
server.start();
IConnector connector = M2DocCDOUtils
.getConnector(CDOServer.PROTOCOL + "://" + CDOServer.IP + ":" + CDOServer.PORT);
CDOSession session = M2DocCDOUtils.openSession(connector, CDOServer.REPOSITORY_NAME, CDOServer.USER_NAME,
CDOServer.PASSWORD);
final CDOTransaction transaction = M2DocCDOUtils.openTransaction(session);
final CDOResource resource = transaction.createResource("anydsl.ecore");
final ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
final Resource anyDSLResource = resourceSet.getResource(URI.createFileURI("resources/anydsl.ecore"), true);
resource.getContents().addAll(anyDSLResource.getContents());
resource.save(null);
transaction.commit();
transaction.close();
session.close();
connector.close();
if (!EMFPlugin.IS_ECLIPSE_RUNNING) {
ConfigurationProviderService.getInstance().register(CONFIGURATION_PROVIDER);
M2DocUtils.registerServicesConfigurator(SERVICES_CONFIGURATOR_DESCRIPTOR);
}
}
示例2: startCDOServer
import org.eclipse.emf.common.EMFPlugin; //導入依賴的package包/類
@BeforeClass
public static void startCDOServer() throws IOException, CommitException {
server = new CDOServer(true);
server.start();
IConnector connector = M2DocCDOUtils
.getConnector(CDOServer.PROTOCOL + "://" + CDOServer.IP + ":" + CDOServer.PORT);
CDOSession session = M2DocCDOUtils.openSession(connector, CDOServer.REPOSITORY_NAME, CDOServer.USER_NAME,
CDOServer.PASSWORD);
final CDOTransaction transaction = M2DocCDOUtils.openTransaction(session);
final CDOResource resource = transaction.createResource("anydsl.ecore");
final ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
final Resource anyDSLResource = resourceSet.getResource(URI.createFileURI("resources/anydsl.ecore"), true);
resource.getContents().addAll(anyDSLResource.getContents());
resource.save(null);
transaction.commit();
transaction.close();
session.close();
connector.close();
if (!EMFPlugin.IS_ECLIPSE_RUNNING) {
ConfigurationProviderService.getInstance().register(CONFIGURATION_PROVIDER);
M2DocUtils.registerServicesConfigurator(SERVICES_CONFIGURATOR_DESCRIPTOR);
}
}
示例3: getUri
import org.eclipse.emf.common.EMFPlugin; //導入依賴的package包/類
/**
*
* @param anyResource
* any resource is just to
* @param resourcePath
* the Java NIO path of the resource to load as a
* `platform:/resource/` if the Eclipse platform is running,
* otherwise loads it as a file resource.
*/
private URI getUri(Resource anyResource, java.nio.file.Path resourcePath) {
Preconditions.checkArgument(anyResource instanceof XtextResource,
"Expected an Xtext resource. Got: " + anyResource);
if (EMFPlugin.IS_ECLIPSE_RUNNING) {
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
java.nio.file.Path workspaceRootPath = Paths.get(workspaceRoot.getLocationURI());
java.nio.file.Path relativePath = workspaceRootPath.relativize(resourcePath);
Path relativeResourcePath = new Path(relativePath.toString());
return URI.createPlatformResourceURI(relativeResourcePath.toOSString(), true);
} else {
final PathToFileUriConverter uriConverter = getUriConverter(anyResource);
return uriConverter.createFileUri(resourcePath);
}
}
示例4: findModuleURL
import org.eclipse.emf.common.EMFPlugin; //導入依賴的package包/類
/**
*
* @param moduleName
* @param clazz
* @return
*/
@SuppressWarnings("restriction")
private URL findModuleURL(String moduleName, Class<?> clazz) {
URL moduleURL = null;
if (EMFPlugin.IS_ECLIPSE_RUNNING)
try {
moduleURL = org.eclipse.acceleo.common.internal.utils.workspace.AcceleoWorkspaceUtil.getResourceURL(
clazz, moduleName);
} catch (IOException e) {
// Swallow this, we'll try and locate the module through the
// class loader
}
if (moduleURL == null)
moduleURL = clazz.getResource(moduleName);
return moduleURL;
}
示例5: WorkingSetManagerBrokerImpl
import org.eclipse.emf.common.EMFPlugin; //導入依賴的package包/類
/**
* Creates a new working set broker instance with the given injector and status helper arguments. The injector is
* used to inject members into the available contributions. Also restores its most recent state from the preference
* store.
*
* @param injector
* the injector for initializing the contributions.
* @param statusHelper
* convenient way to create {@link IStatus status} instances.
*
*/
@Inject
private WorkingSetManagerBrokerImpl(final Injector injector, final StatusHelper statusHelper) {
this.injector = injector;
this.statusHelper = statusHelper;
this.activeWorkingSetManager = new AtomicReference<>();
this.workingSetTopLevel = new AtomicBoolean(false);
this.alreadyQueuedNavigatorRefresh = new AtomicBoolean(false);
this.contributions = initContributions();
topLevelElementChangeListeners = newHashSet();
workingSetManagerStateChangeListeners = newHashSet();
restoreState(new NullProgressMonitor());
if (EMFPlugin.IS_ECLIPSE_RUNNING) {
final String pluginId = N4JSActivator.getInstance().getBundle().getSymbolicName();
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
workspace.addSaveParticipant(pluginId, new SaveParticipantAdapter() {
@Override
public void saving(final ISaveContext context) throws CoreException {
saveState(new NullProgressMonitor());
}
});
} catch (final CoreException e) {
LOGGER.error("Error occurred while attaching save participant to workspace.", e);
}
}
}
示例6: stopCDOServer
import org.eclipse.emf.common.EMFPlugin; //導入依賴的package包/類
@AfterClass
public static void stopCDOServer() {
server.stop();
if (!EMFPlugin.IS_ECLIPSE_RUNNING) {
ConfigurationProviderService.getInstance().getProviders().remove(CONFIGURATION_PROVIDER);
M2DocUtils.unregisterServicesConfigurator(SERVICES_CONFIGURATOR_DESCRIPTOR);
}
}
示例7: initialize
import org.eclipse.emf.common.EMFPlugin; //導入依賴的package包/類
public static void initialize(Consumer<UnitTestEnvironmentSetupDelegate> initializer) throws IllegalAccessException {
BasicConfigurator.resetConfiguration();
BasicConfigurator.configure(new ConsoleAppender(new PatternLayout("%m%n")));
if (!EMFPlugin.IS_ECLIPSE_RUNNING) {
final Set<URI> baseURIs = new HashSet<>();
initializer.accept(new UnitTestEnvironmentSetupDelegate() {
@Override
public void registerQVTOResolutionURIs(URI uriToRegister) {
baseURIs.add(uriToRegister);
}
@Override
public void registerPlatformUris(String platformID, URI uri) {
EcorePlugin.getPlatformResourceMap().put(platformID, uri);
}
});
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
OCL.initialize(null);
NotationPackage.eINSTANCE.eClass();
StylePackage.eINSTANCE.eClass();
TextualCommonsPackage.eINSTANCE.eClass();
org.eclipse.papyrus.infra.gmfdiag.style.StylePackage.eINSTANCE.eClass();
@SuppressWarnings("unchecked")
List<UnitResolverFactory> fFactories = (List<UnitResolverFactory>)
FieldUtils.readField(UnitResolverFactory.Registry.INSTANCE, "fFactories", true);
fFactories.clear();
fFactories.add(new MockUnitResolverFactory(new ArrayList<>(baseURIs)));
BlackboxRegistry.INSTANCE.registerModule(CooperateLibrary.class,
"de.cooperateproject.qvtoutils.CooperateLibrary", "CooperateLibrary",
new String[] { EcorePackage.eNS_URI });
}
}
示例8: toEmfUri
import org.eclipse.emf.common.EMFPlugin; //導入依賴的package包/類
/**
* Returns with the EMF URI of the resource given as the absolute FS path string.
* <p>
* If the Eclipse platform is up and available, then creates a platform resource URI,
* otherwise creates an EMF URI with the {@code file} scheme.
*/
public static URI toEmfUri(String absoluteFilePath) {
if (EMFPlugin.IS_ECLIPSE_RUNNING) {
File file = new File(absoluteFilePath);
java.nio.file.Path path = Paths.get(file.toURI());
java.nio.file.Path relativePath = Paths.get(getWorkspaceRoot().getLocationURI()).relativize(path);
return URI.createPlatformResourceURI(relativePath.toString(), true);
} else {
return URI.createFileURI(absoluteFilePath);
}
}
示例9: close
import org.eclipse.emf.common.EMFPlugin; //導入依賴的package包/類
/**
* {@inheritDoc}
*
* @see org.eclipse.acceleo.engine.generation.writers.AbstractAcceleoWriter#close()
*/
@Override
public void close() throws IOException {
if (!EMFPlugin.IS_ECLIPSE_RUNNING || this.delegate instanceof BufferedWriter) {
delegate.close();
} else {
Writer writer = null;
OutputStream fileOutputStream = null;
OutputStreamWriter fileWriter = null;
try {
if (selectedCharset == null) {
writer = new BufferedWriter(new FileWriter(new File(targetPath)));
} else {
fileOutputStream = new FileOutputStream(new File(targetPath));
fileWriter = new OutputStreamWriter(fileOutputStream, selectedCharset);
writer = new BufferedWriter(fileWriter);
}
writer.append(toString());
writer.flush();
} catch (Exception e) {
Activator
.getDefault()
.getLog()
.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
"An exception occurred while writing to writer", e));
} finally {
if (writer != null) {
writer.close();
}
if (fileWriter != null) {
fileWriter.close();
}
if (fileOutputStream != null) {
fileOutputStream.close();
}
}
}
}
示例10: getProperties
import org.eclipse.emf.common.EMFPlugin; //導入依賴的package包/類
/**
* If the module(s) called by this launcher require properties files, return
* their qualified path from here.Take note that the first added properties
* files will take precedence over subsequent ones if they contain
* conflicting keys.
*
* @return The list of properties file we need to add to the generation
* context.
* @see java.util.ResourceBundle#getBundle(String) @generated
*/
@Override
public List<String> getProperties() {
/*
* If you want to change the content of this method, do NOT forget to change the "@generated"
* tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
* of the Acceleo module with the main template that has caused the creation of this class will
* revert your modifications.
*/
/*
* TODO if your generation module requires access to properties files, add their qualified path to the list here.
*
* Properties files can be located in an Eclipse plug-in or in the file system (all Acceleo projects are Eclipse
* plug-in). In order to use properties files located in an Eclipse plugin, you need to add the path of the properties
* files to the "propertiesFiles" list:
*
* final String prefix = "platform:/plugin/";
* final String pluginName = "org.eclipse.acceleo.module.sample";
* final String packagePath = "/org/eclipse/acceleo/module/sample/properties/";
* final String fileName = "default.properties";
* propertiesFiles.add(prefix + pluginName + packagePath + fileName);
*
* With this mechanism, you can load properties files from your plugin or from another plugin.
*
* You may want to load properties files from the file system, for that you need to add the absolute path of the file:
*
* propertiesFiles.add("C:\Users\MyName\MyFile.properties");
*
* If you want to let your users add properties files located in the same folder as the model:
**/
if (EMFPlugin.IS_ECLIPSE_RUNNING && model != null && model.eResource() != null) {
propertiesFiles.addAll(AcceleoEngineUtils.getPropertiesFilesNearModel(model.eResource()));
}
/*
* To learn more about Properties Files, have a look at the Acceleo documentation (Help -> Help Contents).
*/
return propertiesFiles;
}
示例11: start
import org.eclipse.emf.common.EMFPlugin; //導入依賴的package包/類
@Override
public void start(BundleContext context) throws Exception {
if (EMFPlugin.IS_ECLIPSE_RUNNING) {
initializeResourceServiceProviderRegistry(context);
}
}
示例12: createGlobalRegistry
import org.eclipse.emf.common.EMFPlugin; //導入依賴的package包/類
/**
* Creates the {@link EPackage.Registry#INSTANCE instance} of the global registry.
* If a {@link System#getSecurityManager() security manager} is active,
* and <code>"classLoader"</code> {@link RuntimePermission permission} is not granted,
* a secure delegator instance is created,
* i.e., a private registry implementation that securely accesses class loaders
* and keeps them private, will be used.
*/
public static EPackage.Registry createGlobalRegistry()
{
try
{
String className = System.getProperty("org.eclipse.emf.ecore.EPackage.Registry.INSTANCE");
if (className == null)
{
if (EcorePlugin.getDefaultRegistryImplementation() != null)
{
return EcorePlugin.getDefaultRegistryImplementation();
}
else if (!EMFPlugin.IS_ECLIPSE_RUNNING)
{
try
{
SecurityManager securityManager = System.getSecurityManager();
if (securityManager != null)
{
securityManager.checkPermission(new RuntimePermission("classLoader"));
}
return new Delegator();
}
catch (Throwable throwable)
{
return new SecureDelegator();
}
}
else
{
return new EPackageRegistryImpl();
}
}
else
{
return (EPackage.Registry)Class.forName(className).newInstance();
}
}
catch (Exception exception)
{
EcorePlugin.INSTANCE.log(exception);
return new EPackageRegistryImpl();
}
}