org.eclipse.core.runtime.Platform Java Examples

The following examples show how to use org.eclipse.core.runtime.Platform. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
private IJavadocCompletionProcessor[] getContributedProcessors() {
	if (fSubProcessors == null) {
		try {
			IExtensionRegistry registry= Platform.getExtensionRegistry();
			IConfigurationElement[] elements=	registry.getConfigurationElementsFor(JavaUI.ID_PLUGIN, PROCESSOR_CONTRIBUTION_ID);
			IJavadocCompletionProcessor[] result= new IJavadocCompletionProcessor[elements.length];
			for (int i= 0; i < elements.length; i++) {
				result[i]= (IJavadocCompletionProcessor) elements[i].createExecutableExtension("class"); //$NON-NLS-1$
			}
			fSubProcessors= result;
		} catch (CoreException e) {
			JavaPlugin.log(e);
			fSubProcessors= new IJavadocCompletionProcessor[0];
		}
	}
	return fSubProcessors;
}
 
Example #2
Source Project: birt   Author: eclipse   File: OpenJavaSourceAction.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private String getPath( String fileName )
{
	Bundle bundle = Platform.getBundle( ChartExamplesPlugin.ID );
	Path relativePath = new Path( "/src/org/eclipse/birt/chart/examples/view/models/" + fileName + JAVA_EXTENSION ); //$NON-NLS-1$
	URL relativeURL = FileLocator.find( bundle, relativePath, null );

	String absolutePath = null;
	try
	{
		URL absoluteURL = FileLocator.toFileURL( relativeURL );
		String tmp = absoluteURL.getPath( );
		absolutePath = tmp.substring( 0, tmp.lastIndexOf( "/" ) ); //$NON-NLS-1$		
	}
	catch ( IOException io )
	{
		io.printStackTrace( );
	}
	return absolutePath;
}
 
Example #3
Source Project: bonita-studio   Author: bonitasoft   File: CustomPopupMenuExtender.java    License: GNU General Public License v2.0 6 votes vote down vote up
public CustomPopupMenuExtender(final String id, final MenuManager menu,
        final ISelectionProvider prov, final IWorkbenchPart part, IEclipseContext context,
        final boolean includeEditorInput) {
    super();
    this.menu = menu;
    this.selProvider = prov;
    this.part = part;
    this.context = context;
    this.modelPart = part.getSite().getService(MPart.class);
    if (includeEditorInput) {
        bitSet |= INCLUDE_EDITOR_INPUT;
    }
    menu.addMenuListener(this);
    if (!menu.getRemoveAllWhenShown()) {
        menuWrapper = new SubMenuManager(menu);
        menuWrapper.setVisible(true);
    }
    createModelFor(id);
    addMenuId(id);

    Platform.getExtensionRegistry().addRegistryChangeListener(this);
}
 
Example #4
Source Project: tesb-studio-se   Author: Talend   File: ExtensionPointsReader.java    License: Apache License 2.0 6 votes vote down vote up
private void readRegisteredBundleClasspaths() {
    final IConfigurationElement[] configurationElements = Platform.getExtensionRegistry()
        .getConfigurationElementsFor(BUNDLE_CLASSPATH_EXT);
    for (IConfigurationElement e : configurationElements) {
        final String cmpName = e.getAttribute(NAME);
        final ExBundleClasspath bc =
            new ExBundleClasspath(e.getAttribute(PARAMETER), Boolean.parseBoolean(e.getAttribute(OPTIONAL)));
        parsePredicates(bc, e);

        Collection<ExBundleClasspath> attributeSet = componentBundleClasspaths.get(cmpName);
        if (attributeSet == null) {
            attributeSet = new ArrayList<ExBundleClasspath>();
            componentBundleClasspaths.put(cmpName, attributeSet);
        }
        attributeSet.add(bc);
    }
}
 
Example #5
Source Project: dartboard   Author: eclipse   File: PubListener.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Retrieves all registered PubService extensions
 * 
 * All services that have the priority attribute set to true, are at the
 * beginning of the resulting list.
 * 
 * @return a List of all PubService extensions
 */
public static LinkedList<IPubService> getPubServices() {
	LinkedList<IPubService> pubServices = new LinkedList<IPubService>();
	IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
	for (IConfigurationElement e : extensionRegistry.getExtensionPoint(GlobalConstants.PUB_SERVICE_EXTENSION_POINT)
			.getConfigurationElements()) {
		try {
			IPubService pubService = (IPubService) e.createExecutableExtension(EXTENSION_CLASS);
			boolean priority = Boolean.valueOf(e.getAttribute(EXTENSION_PRIORITY));
			if (priority) {
				pubServices.add(0, pubService);
			} else {
				pubServices.add(pubService);
			}
		} catch (CoreException e1) {
			e1.printStackTrace();
		}
	}
	return pubServices;
}
 
Example #6
Source Project: translationstudio8   Author: heartsome   File: AbstractSelfHelpUI.java    License: GNU General Public License v2.0 6 votes vote down vote up
private boolean useExternalBrowser(String url) {
	// On non Windows platforms, use external when modal window is displayed
	if (!Constants.OS_WIN32.equalsIgnoreCase(Platform.getOS())) {
		Display display = Display.getCurrent();
		if (display != null) {
			if (insideModalParent(display))
				return true;
		}
	}

	// Use external when no help frames are to be displayed, otherwise no
	// navigation buttons.
	if (url != null) {
		if (url.indexOf("?noframes=true") > 0 //$NON-NLS-1$
				|| url.indexOf("&noframes=true") > 0) { //$NON-NLS-1$
			return true;
		}
	}
	return false;
}
 
Example #7
Source Project: tmxeditor8   Author: heartsome   File: TmImporter.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 加载记忆库匹配实现 ;
 */
private void runExtension() {
	IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(
			TMIMPORTER_EXTENSION_ID);
	try {
		for (IConfigurationElement e : config) {
			final Object o = e.createExecutableExtension("class");
			if (o instanceof ITmImporter) {
				ISafeRunnable runnable = new ISafeRunnable() {

					public void handleException(Throwable exception) {
						logger.error(Messages.getString("importer.TmImporter.logger1"), exception);
					}

					public void run() throws Exception {
						tmImporter = (ITmImporter) o;
					}
				};
				SafeRunner.run(runnable);
			}
		}
	} catch (CoreException ex) {
		logger.error(Messages.getString("importer.TmImporter.logger1"), ex);
	}
}
 
Example #8
Source Project: erflute   Author: dbflute-session   File: ExtendPopupMenu.java    License: Apache License 2.0 6 votes vote down vote up
public static List<ExtendPopupMenu> loadExtensions(MainDiagramEditor editor) throws CoreException {
    final List<ExtendPopupMenu> extendPopupMenuList = new ArrayList<>();

    final IExtensionRegistry registry = Platform.getExtensionRegistry();
    final IExtensionPoint extensionPoint = registry.getExtensionPoint(EXTENSION_POINT_ID);

    if (extensionPoint != null) {
        for (final IExtension extension : extensionPoint.getExtensions()) {
            for (final IConfigurationElement configurationElement : extension.getConfigurationElements()) {
                final ExtendPopupMenu extendPopupMenu = ExtendPopupMenu.createExtendPopupMenu(configurationElement, editor);
                if (extendPopupMenu != null) {
                    extendPopupMenuList.add(extendPopupMenu);
                }
            }
        }
    }
    return extendPopupMenuList;
}
 
Example #9
Source Project: EasyShell   Author: anb0s   File: Resource.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public String getFullQualifiedName() {
    if (resource != null) {
        Bundle bundle = Platform.getBundle("org.eclipse.jdt.core");
        if (bundle != null) {
            IJavaElement element = JavaCore.create(resource);
            if (element instanceof IPackageFragment) {
                return ((IPackageFragment)element).getElementName();
            } else if (element instanceof ICompilationUnit) {
                IType type = ((ICompilationUnit)element).findPrimaryType();
                if (type != null) {
                    return type.getFullyQualifiedName();
                }
            }
        }
    }
    return getFullQualifiedPathName();
}
 
Example #10
Source Project: wildwebdeveloper   Author: eclipse   File: IsNodeProjectPropertyTester.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
	if (IS_NODE_RESOURCE_PROPERTY.equals(property)) {
		IResource resource = Adapters.adapt(receiver, IResource.class);
		if (resource == null) {
			return false;
		}
		if (resource instanceof IFile) {
			IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
			IContentType jsContentType = contentTypeManager.getContentType("org.eclipse.wildwebdeveloper.js");
			IContentType tsContentType = contentTypeManager.getContentType("org.eclipse.wildwebdeveloper.ts");
			try (
				InputStream content = ((IFile) resource).getContents();
			) {
				List<IContentType> contentTypes = Arrays.asList(contentTypeManager.findContentTypesFor(content, resource.getName()));
				return contentTypes.contains(jsContentType) || contentTypes.contains(tsContentType);
			} catch (Exception e) {
				return false;
			}
		}
	}
	return false;
}
 
Example #11
Source Project: wildwebdeveloper   Author: eclipse   File: Utils.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Provisions a project that's part of the "testProjects"
 * @param folderName the folderName under "testProjects" to provision from
 * @return the provisioned project
 * @throws CoreException
 * @throws IOException
 */
public static IProject provisionTestProject(String folderName) throws CoreException, IOException {
	URL url = FileLocator.find(Platform.getBundle("org.eclipse.wildwebdeveloper.tests"),
			Path.fromPortableString("testProjects/" + folderName), null);
	url = FileLocator.toFileURL(url);
	File folder = new File(url.getFile());
	if (folder.exists()) {
		IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("testProject" + System.nanoTime());
		project.create(null);
		project.open(null);
		java.nio.file.Path sourceFolder = folder.toPath();
		java.nio.file.Path destFolder = project.getLocation().toFile().toPath();

		Files.walk(sourceFolder).forEach(source -> {
			try {
				Files.copy(source, destFolder.resolve(sourceFolder.relativize(source)), StandardCopyOption.REPLACE_EXISTING);
			} catch (IOException e) {
				e.printStackTrace();
			}
		});
		project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
		return project;
	}
	return null;
}
 
Example #12
Source Project: APICloud-Studio   Author: apicloudcom   File: EclipseUtil.java    License: GNU General Public License v3.0 6 votes vote down vote up
public boolean accept(File dir, String name)
{
	IPath path = Path.fromOSString(dir.getAbsolutePath()).append(name);
	name = path.removeFileExtension().lastSegment();
	String ext = path.getFileExtension();
	if (Platform.OS_MACOSX.equals(Platform.getOS()))
	{
		if (!"app".equals(ext)) //$NON-NLS-1$
		{
			return false;
		}
	}
	for (String launcherName : LAUNCHER_NAMES)
	{
		if (launcherName.equalsIgnoreCase(name))
		{
			return true;
		}
	}
	return false;
}
 
Example #13
Source Project: elexis-3-core   Author: elexis   File: ExternalContributions.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private static void instantiate(){
	IConfigurationElement[] config =
		Platform.getExtensionRegistry().getConfigurationElementsFor(
			Activator.PLUGIN_ID + ".ExternalMaintenance");
	if (config.length == 0)
		return;
	for (IConfigurationElement e : config) {
		try {
			Object o = e.createExecutableExtension("MaintenanceCode");
			if (o instanceof ExternalMaintenance) {
				ext.add((ExternalMaintenance) o);
			}
		} catch (CoreException e1) {
			Status status =
				new Status(IStatus.WARNING, Activator.PLUGIN_ID, e1.getLocalizedMessage());
			StatusManager.getManager().handle(status, StatusManager.SHOW);
		}
		
	}
	
}
 
Example #14
Source Project: gemfirexd-oss   Author: gemxd   File: DerbyClasspathContainer.java    License: Apache License 2.0 6 votes vote down vote up
public DerbyClasspathContainer() {
    List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
    Bundle bundle = Platform.getBundle(CommonNames.CORE_PATH);
    Enumeration en = bundle.findEntries("/", "*.jar", true);
    String rootPath = null;
    try { 
        rootPath = FileLocator.resolve(FileLocator.find(bundle, new Path("/"), null)).getPath();
    } catch(IOException e) {
        Logger.log(e.getMessage(), IStatus.ERROR);
    }
    while(en.hasMoreElements()) {
        IClasspathEntry cpe = JavaCore.newLibraryEntry(new Path(rootPath+'/'+((URL)en.nextElement()).getFile()), null, null);
        entries.add(cpe);
    }    
    IClasspathEntry[] cpes = new IClasspathEntry[entries.size()];
    _entries = (IClasspathEntry[])entries.toArray(cpes);
}
 
Example #15
Source Project: eclipsegraphviz   Author: abstratt   File: LogUtils.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public static void log(Supplier<IStatus> statusSupplier) {
    IStatus status = statusSupplier.get();
    if (!Platform.isRunning()) {
        System.err.println(status.getMessage());
        if (status.getException() != null)
            status.getException().printStackTrace();
        if (status.isMultiStatus())
            for (IStatus child : status.getChildren())
                log(child);
        return;
    }
    Bundle bundle = Platform.getBundle(status.getPlugin());
    if (bundle == null) {
        String thisPluginId = LogUtils.class.getPackage().getName();
        bundle = Platform.getBundle(thisPluginId);
        Platform.getLog(bundle).log(
                new Status(IStatus.WARNING, thisPluginId, "Could not find a plugin " + status.getPlugin()
                        + " for logging as"));
    }
    Platform.getLog(bundle).log(status);
}
 
Example #16
Source Project: APICloud-Studio   Author: apicloudcom   File: UIPlugin.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void updateInitialPerspectiveVersion()
{
	// updates the initial stored version so that user won't get a prompt on a new workspace
	boolean hasStartedBefore = Platform.getPreferencesService().getBoolean(PLUGIN_ID,
			IPreferenceConstants.IDE_HAS_LAUNCHED_BEFORE, false, null);
	if (!hasStartedBefore)
	{
		IEclipsePreferences prefs = (EclipseUtil.instanceScope()).getNode(PLUGIN_ID);
		prefs.putInt(IPreferenceConstants.PERSPECTIVE_VERSION, WebPerspectiveFactory.VERSION);
		prefs.putBoolean(IPreferenceConstants.IDE_HAS_LAUNCHED_BEFORE, true);
		try
		{
			prefs.flush();
		}
		catch (BackingStoreException e)
		{
			IdeLog.logError(getDefault(), Messages.UIPlugin_ERR_FailToSetPref, e);
		}
	}
}
 
Example #17
Source Project: tmxeditor8   Author: heartsome   File: AbstractSelfHelpUI.java    License: GNU General Public License v2.0 6 votes vote down vote up
private boolean useExternalBrowser(String url) {
	// On non Windows platforms, use external when modal window is displayed
	if (!Constants.OS_WIN32.equalsIgnoreCase(Platform.getOS())) {
		Display display = Display.getCurrent();
		if (display != null) {
			if (insideModalParent(display))
				return true;
		}
	}

	// Use external when no help frames are to be displayed, otherwise no
	// navigation buttons.
	if (url != null) {
		if (url.indexOf("?noframes=true") > 0 //$NON-NLS-1$
				|| url.indexOf("&noframes=true") > 0) { //$NON-NLS-1$
			return true;
		}
	}
	return false;
}
 
Example #18
Source Project: tracecompass   Author: tracecompass   File: GdbTrace.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void initTrace(IResource resource, String path, Class<? extends ITmfEvent> type) throws TmfTraceException {
    try {
        String tracedExecutable = resource.getPersistentProperty(EXEC_KEY);
        if (tracedExecutable == null) {
            throw new TmfTraceException(Messages.GdbTrace_ExecutableNotSet);
        }

        String defaultGdbCommand = Platform.getPreferencesService().getString(GdbPlugin.PLUGIN_ID,
                IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND,
                IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT, null);

        fGdbTpRef = new DsfGdbAdaptor(this, defaultGdbCommand, path, tracedExecutable);
        fNbFrames = getNbFrames();
    } catch (CoreException e) {
        throw new TmfTraceException(Messages.GdbTrace_FailedToInitializeTrace, e);
    }

    super.initTrace(resource, path, type);
}
 
Example #19
Source Project: APICloud-Studio   Author: apicloudcom   File: ProjectContentsLocationArea.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Return the location for the project. If we are using defaults then return the workspace root so that core creates
 * it with default values.
 * 
 * @return String
 */
public String getProjectLocation()
{
	if (isDefault())
	{
		return Platform.getLocation().toOSString();
	}
	return locationPathField.getText();
}
 
Example #20
Source Project: APICloud-Studio   Author: apicloudcom   File: PreferenceUtils.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param direction
 *            indicates if this is for upload or download permissions
 * @return true if the new files and folders should update their permissions to specific permissions after
 *         transferring, false if they should maintain the source permissions
 */
public static boolean getSpecificPermissions(PermissionDirection direction)
{
	switch (direction)
	{
		case UPLOAD:
			return Platform.getPreferencesService().getBoolean(CoreIOPlugin.PLUGIN_ID,
					IPreferenceConstants.UPLOAD_SPECIFIC_PERMISSIONS, true, null);
		case DOWNLOAD:
			return Platform.getPreferencesService().getBoolean(CoreIOPlugin.PLUGIN_ID,
					IPreferenceConstants.DOWNLOAD_SPECIFIC_PERMISSIONS, true, null);
	}
	return true;
}
 
Example #21
Source Project: dawnsci   Author: eclipse   File: PlottingFactory.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private static final <T> IPlottingSystem<T> createPlottingSystem(final String plottingSystemId) throws CoreException {
	
       IConfigurationElement[] systems = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.dawnsci.plotting.api.plottingClass");
       for (IConfigurationElement ia : systems) {
		if (ia.getAttribute("id").equals(plottingSystemId)) return (IPlottingSystem<T>)ia.createExecutableExtension("class");
	}
	
       return null;
}
 
Example #22
Source Project: birt   Author: eclipse   File: CategoryPageGenerator.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public CategoryPageGenerator( )
{
	if ( factory == null )
	{
		factory = (ICategoryProviderFactory) Platform.getAdapterManager( )
				.getAdapter( this, ICategoryProviderFactory.class );
		if ( factory == null )
		{
			factory = CategoryProviderFactory.getInstance( );
		}
	}
}
 
Example #23
Source Project: thym   Author: eclipse   File: HybridUI.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public static List<PlatformImage> getPlatformImages(){
  	IConfigurationElement[] configurationElements = Platform.getExtensionRegistry().getConfigurationElementsFor(PlatformImage.EXTENSION_POINT_ID);
  	List<PlatformImage> images = new ArrayList<PlatformImage>();
  	for (int i = 0; i < configurationElements.length; i++) {
	PlatformImage image = new PlatformImage(configurationElements[i]);
	images.add(image);
}
  	return images;
  }
 
Example #24
Source Project: http4e   Author: nextinterfaces   File: ResourceUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static InputStream getBundleResourceStream2( String pluginID, String uri) throws IOException{
   if (Utils.isIDE()) {
      return FileLocator.openStream(Platform.getBundle(pluginID), new Path(uri), false);
   } else {
      return new FileInputStream(uri);
   }
}
 
Example #25
Source Project: Pydev   Author: fabioz   File: NewProjectNameAndLocationWizardPage.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a new project creation wizard page.
 *
 * @param pageName the name of this page
 */
public NewProjectNameAndLocationWizardPage(String pageName) {
    super(pageName);
    setTitle("PyDev Project");
    setDescription("Create a new PyDev Project.");
    setPageComplete(false);
    initialLocationFieldValue = Platform.getLocation();
    customLocationFieldValue = ""; //$NON-NLS-1$

    fWorkingSetGroup = new WorkingSetGroup();
    setWorkingSets(new IWorkingSet[0]);
}
 
Example #26
Source Project: ADT_Frontend   Author: abapGit   File: AbapGitStagingLabelProvider.java    License: MIT License 5 votes vote down vote up
/**
 * Method to overlay an image with another
 */
private Image decorateImage(Image baseImage, String overlayImagePath) {
	Bundle bundle = Platform.getBundle(AbapGitUIPlugin.PLUGIN_ID);
	URL fullPathString = BundleUtility.find(bundle, overlayImagePath);
	DecorationOverlayIcon doi = new DecorationOverlayIcon(//
			baseImage, ImageDescriptor.createFromURL(fullPathString), IDecoration.BOTTOM_RIGHT);
	return doi.createImage();
}
 
Example #27
Source Project: APICloud-Studio   Author: apicloudcom   File: BuildContext.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected IContentType[] getContentTypes() throws CoreException
{
	// TODO Cache this?
	IProject theProject = getProject();
	if (theProject != null)
	{
		IContentTypeMatcher matcher = theProject.getContentTypeMatcher();
		return matcher.findContentTypesFor(getName());
	}

	IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
	if (ArrayUtil.isEmpty(projects))
	{
		return Platform.getContentTypeManager().findContentTypesFor(getName());
	}

	for (IProject project : projects)
	{
		try
		{
			IContentType[] type = project.getContentTypeMatcher().findContentTypesFor(getName());
			if (type != null)
			{
				return type;
			}
		}
		catch (CoreException e)
		{
			IdeLog.logError(IndexPlugin.getDefault(), e);
		}
	}
	return NO_CONTENT_TYPES;
}
 
Example #28
Source Project: tlaplus   Author: tlaplus   File: ToolboxIntroPart.java    License: MIT License 5 votes vote down vote up
@Override
public void widgetSelected(SelectionEvent se) {

	final String spec = (String) se.widget.getData(specKey);
	final String zip = (String) se.widget.getData(zipKey);

	final URL resource = StandaloneActivator.getDefault().getBundle().getResource(zip);
	final Location instanceLocation = Platform.getInstanceLocation();

	try {
		// Force-open the getting started guide that new users should read.
		final Map<String, String> params = new HashMap<>();
		params.put("org.lamport.tla.toolbox.doc.contents.param",
				"/org.lamport.tla.toolbox.doc/html/gettingstarted/gettingstarted.html");
		runCommand("org.lamport.tla.toolbox.doc.contents", params);
		
		// TODO If the zip is large, this will block the main/UI thread.
		final File destDir = ZipUtil.unzip(resource.openStream(),
				new File(instanceLocation.getURL().getFile() + File.separator + spec.replaceFirst(".tla$", "")),
				true);

		params.clear();
		params.put("toolbox.command.spec.new.param", destDir.getAbsolutePath() + File.separator + spec);
		runCommand("toolbox.command.spec.new", params);
		
	} catch (IOException ex) {
		StandaloneActivator.getDefault().logError(ex.getMessage(), ex);
	}
}
 
Example #29
Source Project: APICloud-Studio   Author: apicloudcom   File: BuildPathManager.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void processElement(IConfigurationElement element)
{
	// get extension pt's bundle
	IExtension extension = element.getDeclaringExtension();
	String pluginId = extension.getNamespaceIdentifier();
	Bundle bundle = Platform.getBundle(pluginId);

	// grab the item's display name
	String name = element.getAttribute(ATTR_NAME);

	// get the item's URI, resolved to a local file
	String resource = element.getAttribute(ATTR_PATH);
	URL url = FileLocator.find(bundle, new Path(resource), null);

	// add item to master list
	URI localFileURI = ResourceUtil.resourcePathToURI(url);

	if (localFileURI != null)
	{
		addBuildPath(name, localFileURI);
	}
	else
	{
		// @formatter:off
		String message = MessageFormat.format(
			Messages.BuildPathManager_UnableToConvertURLToURI,
			url.toString(),
			ELEMENT_BUILD_PATH,
			BUILD_PATHS_ID,
			pluginId
		);
		// @formatter:on

		IdeLog.logError(BuildPathCorePlugin.getDefault(), message);
	}
}
 
Example #30
Source Project: tesb-studio-se   Author: Talend   File: WSDLPopulationUtilTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Test method for {@link org.talend.repository.services.utils.WSDLPopulationUtil#loadWSDL(java.lang.String)}.
 *
 * To validate an imported XSD/WSDL type files. TESB-19040
 */
@Test
public void testLoadWSDL() {
    Bundle b = Platform.getBundle("org.talend.esb.repository.services.test");
    try {
        URL url = FileLocator.toFileURL(FileLocator.find(b, new Path("resources"), null)); //$NON-NLS-1$
        WSDLPopulationUtil wsdlPopulationUtil = new WSDLPopulationUtil();
        wsdlPopulationUtil.loadWSDL("file://" + url.getPath() + "/client_wsdl/cliente-v1_1.wsdl");
        Assert.assertNotNull(wsdlPopulationUtil
                .getXSDSchemaFromNamespace("http://www.supervielle.com.ar/xsd/Integracion/common/commonTypes-v1"));
    } catch (IOException e) {
        e.printStackTrace();
        fail("Test testGetTemplateURL() method failure.");
    }
}