Search in sources :

Example 46 with Bundle

use of org.osgi.framework.Bundle in project KaiZen-OpenAPI-Editor by RepreZen.

the class Activator method start.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework. BundleContext)
     */
public void start(BundleContext context) throws Exception {
    super.start(context);
    plugin = this;
    if (Display.getCurrent() != null && PlatformUI.isWorkbenchRunning()) {
        Bundle bundle = Platform.getBundle(PLUGIN_ID);
        // for quick outline, add icons from YEdit
        bundle = Platform.getBundle(org.dadacoalition.yedit.Activator.PLUGIN_ID);
        addImage(bundle, Icons.outline_document.name(), "icons/outline_document.gif");
        addImage(bundle, Icons.outline_mapping.name(), "icons/outline_mapping.gif");
        addImage(bundle, Icons.outline_scalar.name(), "icons/outline_scalar.gif");
        addImage(bundle, Icons.outline_mapping_scalar.name(), "icons/outline_mappingscalar.gif");
        addImage(bundle, Icons.outline_sequence.name(), "icons/outline_sequence.png");
    }
}
Also used : Bundle(org.osgi.framework.Bundle)

Example 47 with Bundle

use of org.osgi.framework.Bundle in project cubrid-manager by CUBRID.

the class ApplicationActionBarAdvisor method fillCoolBar.

/**
	 * Fills the cool bar with the main toolbars for the window.
	 *
	 * @param coolBar the cool bar manager
	 */
protected void fillCoolBar(ICoolBarManager coolBarManager) {
    ActionManager manager = ActionManager.getInstance();
    coolBarManager.setLockLayout(true);
    IToolBarManager toolbarManager = new ToolBarManager(SWT.FLAT | SWT.WRAP | SWT.BOTTOM);
    coolBarManager.add(new ToolBarContributionItem(toolbarManager, IActionConstants.TOOL_NEW1));
    Bundle cqbBundle = Platform.getBundle(ApplicationUtil.CQB_PLUGIN_ID);
    /* Active the CQB plugin */
    if (cqbBundle != null) {
        try {
            cqbBundle.start();
        } catch (Exception e) {
            LOGGER.error(e.getMessage());
        }
    }
    Bundle cmBundle = Platform.getBundle(ApplicationUtil.CM_PLUGIN_ID);
    /* Active the CM plugin */
    if (cmBundle != null) {
        try {
            cmBundle.start();
        } catch (Exception e) {
            LOGGER.error(e.getMessage());
        }
    }
    // Change view actions
    if (cqbBundle != null) {
        DropDownAction viewAction = new DropDownAction(Messages.modeActionBig, IAction.AS_DROP_DOWN_MENU, CubridManagerAppPlugin.getImageDescriptor("icons/cubridmanager32.gif"));
        viewAction.setDisabledImageDescriptor(CubridManagerAppPlugin.getImageDescriptor("icons/cubridmanager32.gif"));
        MenuManager viewActionManager = viewAction.getMenuManager();
        viewActionManager.add(manager.getAction(OpenCMPerspectiveAction.ID));
        viewActionManager.add(manager.getAction(OpenCQBPerspectiveAction.ID));
        ActionContributionItem viewItems = new ActionContributionItem(viewAction);
        viewItems.setMode(ActionContributionItem.MODE_FORCE_TEXT);
        viewItems.setId(IPerspectiveConstance.PERSPECTIVE_ACTION_CONTRIBUTION_ID);
        toolbarManager.add(viewItems);
        toolbarManager.add(new Separator());
    }
    /*TOOLS-3988 There still is the install option after installing cmt plugin.*/
    Bundle bundle = Platform.getBundle(ApplicationUtil.CMT_PLUGIN_ID);
    if (bundle == null) {
        toolbarManager.add(new Separator());
        IAction action = ActionManager.getInstance().getAction(InstallMigrationToolkitAction.ID);
        if (action != null) {
            ActionContributionItem item = new ActionContributionItem(action);
            item.setMode(ActionContributionItem.MODE_FORCE_TEXT);
            toolbarManager.add(item);
            item.setId(IPerspectiveConstance.MIGRATION_ACTION_CONTRIBUTION_ID);
        }
    } else {
        /*Active the CMT plugin */
        try {
            bundle.start();
        } catch (Exception e) {
            LOGGER.error(e.getMessage());
        }
    }
    // Help
    toolbarManager.add(new Separator());
    DropDownAction helpDropAction = new DropDownAction(Messages.helpActionNameBig, IAction.AS_DROP_DOWN_MENU, CubridManagerUIPlugin.getImageDescriptor("icons/action/help_big.png"));
    helpDropAction.setDisabledImageDescriptor(CubridManagerUIPlugin.getImageDescriptor("icons/action/help_big.png"));
    MenuManager helpActionManager = helpDropAction.getMenuManager();
    helpActionManager.add(manager.getAction(HelpDocumentAction.ID));
    if ("ko".equals(Messages.language)) {
        helpActionManager.add(newFeatureAction);
    }
    helpActionManager.add(new Separator());
    helpActionManager.add(createItem(ReportBugAction.ID));
    helpActionManager.add(new Separator());
    helpActionManager.add(manager.getAction(ViewServerVersionAction.ID));
    helpActionManager.add(clientVersionAction);
    ActionContributionItem helpItems = new ActionContributionItem(helpDropAction);
    helpItems.setMode(ActionContributionItem.MODE_FORCE_TEXT);
    helpItems.setId(IPerspectiveConstance.HELP_ACTION_CONTRIBUTION_ID);
    toolbarManager.add(helpItems);
    ControlContribution searchContribution = new ControlContribution(SearchContributionComposite.class.getName()) {

        protected Control createControl(Composite parent) {
            return new SearchContributionComposite(parent, SWT.None);
        }
    };
    searchContribution.setId(IPerspectiveConstance.SEARCH_ACTION_CONTRIBUTION_ID);
    toolbarManager.add(new Separator());
    toolbarManager.add(searchContribution);
}
Also used : IAction(org.eclipse.jface.action.IAction) SearchContributionComposite(com.cubrid.common.ui.common.control.SearchContributionComposite) Composite(org.eclipse.swt.widgets.Composite) Bundle(org.osgi.framework.Bundle) ControlContribution(org.eclipse.jface.action.ControlContribution) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager) ActionManager(com.cubrid.common.ui.spi.action.ActionManager) ToolBarContributionItem(org.eclipse.jface.action.ToolBarContributionItem) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) DropDownAction(com.cubrid.common.ui.common.action.DropDownAction) IToolBarManager(org.eclipse.jface.action.IToolBarManager) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) SearchContributionComposite(com.cubrid.common.ui.common.control.SearchContributionComposite) Separator(org.eclipse.jface.action.Separator)

Example 48 with Bundle

use of org.osgi.framework.Bundle in project cubrid-manager by CUBRID.

the class SetupEnvTestCase method getFilePathInPlugin.

/**
	 * This method is to find the file's path in a fragment or a plugin.
	 *
	 * @param filepath the file path in the fragment or a plugin
	 * @return the absolute file path
	 */
public String getFilePathInPlugin(String filepath) {
    URL fileUrl = null;
    if (CubridManagerCorePlugin.getDefault() == null) {
        fileUrl = this.getClass().getResource(filepath);
    } else {
        Bundle bundle = CubridManagerCorePlugin.getDefault().getBundle();
        URL url = bundle.getResource(filepath);
        try {
            fileUrl = FileLocator.toFileURL(url);
        } catch (IOException e) {
            return null;
        }
    }
    return fileUrl == null ? null : fileUrl.getPath();
}
Also used : Bundle(org.osgi.framework.Bundle) IOException(java.io.IOException) URL(java.net.URL)

Example 49 with Bundle

use of org.osgi.framework.Bundle in project cubrid-manager by CUBRID.

the class CubridClassLoaderPoolTest method getFilePathInPlugin.

public String getFilePathInPlugin(String filepath) {
    URL fileUrl = null;
    if (CubridManagerCorePlugin.getDefault() == null) {
        fileUrl = this.getClass().getResource(filepath);
    } else {
        Bundle bundle = CubridManagerCorePlugin.getDefault().getBundle();
        URL url = bundle.getResource(filepath);
        try {
            fileUrl = FileLocator.toFileURL(url);
        } catch (IOException e) {
            return null;
        }
    }
    return fileUrl == null ? null : fileUrl.getPath();
}
Also used : Bundle(org.osgi.framework.Bundle) IOException(java.io.IOException) URL(java.net.URL)

Example 50 with Bundle

use of org.osgi.framework.Bundle in project EnrichmentMapApp by BaderLab.

the class Em21Handler method isEM21Installed.

private static boolean isEM21Installed(BundleContext bc) {
    for (Bundle bundle : bc.getBundles()) {
        String name = bundle.getSymbolicName();
        Version version = bundle.getVersion();
        if (name.equals("org.baderlab.csplugins.enrichmentmap") && version.equals(new Version(2, 1, 0))) {
            return true;
        }
    }
    return false;
}
Also used : Version(org.osgi.framework.Version) Bundle(org.osgi.framework.Bundle)

Aggregations

Bundle (org.osgi.framework.Bundle)2490 Test (org.junit.Test)659 URL (java.net.URL)388 BundleContext (org.osgi.framework.BundleContext)311 File (java.io.File)298 ArrayList (java.util.ArrayList)292 IOException (java.io.IOException)278 BundleException (org.osgi.framework.BundleException)270 HashMap (java.util.HashMap)149 ServiceReference (org.osgi.framework.ServiceReference)145 Path (org.eclipse.core.runtime.Path)126 Hashtable (java.util.Hashtable)124 HashSet (java.util.HashSet)95 InputStream (java.io.InputStream)94 IStatus (org.eclipse.core.runtime.IStatus)86 Status (org.eclipse.core.runtime.Status)82 List (java.util.List)80 Map (java.util.Map)74 BundleWiring (org.osgi.framework.wiring.BundleWiring)74 Version (org.osgi.framework.Version)73