com.siteview.mde.ui.launcher.BundlesTab.java Source code

Java tutorial

Introduction

Here is the source code for com.siteview.mde.ui.launcher.BundlesTab.java

Source

/*******************************************************************************
 * Copyright (c) 2006, 2011 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package com.siteview.mde.ui.launcher;

import com.siteview.mde.internal.ui.*;
import com.siteview.mde.internal.ui.launcher.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.PlatformUI;

/**
 * A launch configuration tab that customizes the list of bundles to launch with,
 * their start level and their auto-start attributes.
 * <p>
 * This class may be instantiated, but it is not intended to be subclassed by clients.
 * </p>
 * @since 3.3
 * 
 * @noextend This class is not intended to be subclassed by clients.
 */
public class BundlesTab extends AbstractLauncherTab {

    private Image fImage;
    private BlockAdapter fBlock;
    OSGiFrameworkBlock fFrameworkBlock;

    private static final int PLUGIN_SELECTION = 1;
    private static final int FEATURE_SELECTION = 2;

    /**
     * Constructor to create a new bundle tab
     */
    public BundlesTab() {
        fImage = MDEPluginImages.DESC_PLUGINS_FRAGMENTS.createImage();
        fBlock = new BlockAdapter(new OSGiBundleBlock(this), new FeatureBlock(this));
        fFrameworkBlock = new OSGiFrameworkBlock(this, fBlock);
    }

    /**
     * Dispose images
     * @see org.eclipse.debug.ui.ILaunchConfigurationTab#dispose()
     */
    public void dispose() {
        fBlock.dispose();
        fImage.dispose();
        super.dispose();
    }

    /*
     * (non-Javadoc)
     * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
     */
    public void createControl(Composite parent) {
        Composite composite = new Composite(parent, SWT.NONE);
        composite.setLayout(new GridLayout(2, false));

        fFrameworkBlock.createControl(composite);
        fBlock.createControl(composite, 2, 5);

        setControl(composite);
        Dialog.applyDialogFont(composite);
        PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.LAUNCHER_ADVANCED);
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
     */
    public void initializeFrom(ILaunchConfiguration config) {
        try {
            int index = PLUGIN_SELECTION;
            if (config.getAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES, false)) {
                index = FEATURE_SELECTION;
            } else {
                index = PLUGIN_SELECTION;
            }
            fBlock.setActiveBlock(index);
            fFrameworkBlock.initializeFrom(config);
            fBlock.initializeFrom(config);
        } catch (CoreException e) {
            MDEPlugin.log(e);
        }
    }

    /*
     * (non-Javadoc)
     * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
     */
    public void setDefaults(ILaunchConfigurationWorkingCopy config) {
        fBlock.setDefaults(config);
    }

    /*
     * (non-Javadoc)
     * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
     */
    public void performApply(ILaunchConfigurationWorkingCopy config) {
        fFrameworkBlock.performApply(config);
        fBlock.performApply(config);
    }

    /*
     * (non-Javadoc)
     * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
     */
    public String getName() {
        return MDEUIMessages.BundlesTab_title;
    }

    /*
     * (non-Javadoc)
     * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
     */
    public Image getImage() {
        return fImage;
    }

    /*
    /* (non-Javadoc)
     * @see org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
     */
    public void activated(ILaunchConfigurationWorkingCopy config) {
    }

    /*
     * (non-Javadoc)
     * @see com.siteview.mde.ui.launcher.AbstractLauncherTab#validateTab()
     */
    public void validateTab() {
    }

    /* (non-Javadoc)
     * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#getId()
     */
    public String getId() {
        return IPDELauncherConstants.TAB_BUNDLES_ID;
    }
}