Search in sources :

Example 81 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project google-cloud-eclipse by GoogleCloudPlatform.

the class AppEngineDeployPreferencesPanel method createAdvancedSection.

protected void createAdvancedSection() {
    createExpandableComposite();
    Composite advancedSection = new Composite(expandableComposite, SWT.NONE);
    populateAdvancedSection(advancedSection);
    GridLayoutFactory.swtDefaults().applyTo(advancedSection);
    expandableComposite.setClient(advancedSection);
    expandableComposite.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent event) {
            layoutChangedHandler.run();
        }
    });
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 82 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project eclipse.pde by eclipse-pde.

the class PDECompilersConfigurationBlock method createExpansibleComposite.

/**
 * Creates an {@link ExpandableComposite} with a client composite and a default grid layout
 * @param parent
 * @param title
 * @return a new expandable composite
 */
private Composite createExpansibleComposite(Composite parent, String title) {
    ExpandableComposite ecomp = SWTFactory.createExpandibleComposite(parent, title, 1, GridData.FILL_HORIZONTAL);
    ecomp.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            Object obj = e.getSource();
            handleExpand(getScrollingParent(obj));
        }
    });
    ecomp.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
    fExpComps.add(ecomp);
    Composite client = SWTFactory.createComposite(ecomp, 2, 1, GridData.FILL_BOTH);
    ecomp.setClient(client);
    return client;
}
Also used : ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 83 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project org.eclipse.rap by eclipse-rap.

the class ViewItem method addItem.

// Adds the item to the main composite.
private void addItem() {
    // $NON-NLS-1$
    CheatSheetStopWatch.startStopWatch("ViewItem.addItem()");
    // $NON-NLS-1$ //$NON-NLS-2$
    CheatSheetStopWatch.printLapTime("ViewItem.addItem()", "Time in addItem() after getBannerBackground: ");
    // Set up the main composite for the item.******************************************
    // $NON-NLS-1$
    checkDoneLabel = page.getToolkit().createLabel(parent, " ");
    // $NON-NLS-1$ //$NON-NLS-2$
    CheatSheetStopWatch.printLapTime("ViewItem.addItem()", "Time in addItem() after create checkDoneLabel: ");
    mainItemComposite = page.getToolkit().createSection(parent, ExpandableComposite.TWISTIE | ExpandableComposite.COMPACT);
    mainItemComposite.setBackground(itemColor);
    mainItemComposite.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
    String title = item.getTitle();
    if (title != null) {
        mainItemComposite.setText(ViewUtilities.escapeForLabel(title));
    }
    // $NON-NLS-1$ //$NON-NLS-2$
    CheatSheetStopWatch.printLapTime("ViewItem.addItem()", "Time in addItem() after create mainItemComposite: ");
    mainItemComposite.addExpansionListener(new ExpansionAdapter() {

        public void expansionStateChanged(ExpansionEvent e) {
            page.getForm().reflow(true);
        }
    });
    // $NON-NLS-1$ //$NON-NLS-2$
    CheatSheetStopWatch.printLapTime("ViewItem.addItem()", "Time in addItem() after addExpansionListener: ");
    // handle item extensions here
    // check number of extensions for this item and adjust layout accordingly
    int number = 0;
    ArrayList itemExts = item.getItemExtensions();
    if ((itemExts != null && itemExts.size() > 0) || item.getContextId() != null || item.getHref() != null) {
        // Set up the title composite for the item.
        titleComposite = page.getToolkit().createComposite(mainItemComposite);
        titleComposite.setBackground(itemColor);
    }
    if (itemExts != null) {
        for (int g = 0; g < itemExts.size(); g++) {
            AbstractItemExtensionElement[] eea = (AbstractItemExtensionElement[]) itemExts.get(g);
            number += eea.length;
            for (int x = 0; x < eea.length; x++) {
                eea[x].createControl(titleComposite);
            }
        }
    }
    // $NON-NLS-1$ //$NON-NLS-2$
    CheatSheetStopWatch.printLapTime("ViewItem.addItem()", "Time in addItem() after create item extensions: ");
    // don't add the help icon unless there is a context id or help link
    if (item.getContextId() != null || item.getHref() != null) {
        // adjust the layout count
        number++;
        ImageHyperlink helpButton = createButton(titleComposite, CheatSheetPlugin.getPlugin().getImage(ICheatSheetResource.CHEATSHEET_ITEM_HELP), this, itemColor, Messages.get().HELP_BUTTON_TOOLTIP);
        helpButton.addHyperlinkListener(new HyperlinkAdapter() {

            public void linkActivated(HyperlinkEvent e) {
                // If we have a context id, handle this first and ignore an hrefs
                if (item.getContextId() != null) {
                    openInfopop(e.widget);
                } else {
                    // We only have an href, so let's open it in the help system
                    openHelpTopic();
                }
            }
        });
    }
    // $NON-NLS-1$ //$NON-NLS-2$
    CheatSheetStopWatch.printLapTime("ViewItem.addItem()", "Time in addItem() after create help button: ");
    if (number > 0) {
        mainItemComposite.setTextClient(titleComposite);
        GridLayout layout = new GridLayout(number, false);
        GridData data = new GridData(GridData.FILL_BOTH);
        titleComposite.setLayout(layout);
        titleComposite.setLayoutData(data);
        layout.marginWidth = 0;
        layout.marginHeight = 0;
        layout.verticalSpacing = 0;
    }
    // $NON-NLS-1$ //$NON-NLS-2$
    CheatSheetStopWatch.printLapTime("ViewItem.addItem()", "Time in addItem() after setTextClient: ");
    // Body wrapper here.   this composite will be hidden and shown as appropriate.
    bodyWrapperComposite = page.getToolkit().createComposite(mainItemComposite);
    mainItemComposite.setClient(bodyWrapperComposite);
    TableWrapLayout wrapperLayout = new TableWrapLayout();
    bodyWrapperComposite.setLayout(wrapperLayout);
    bodyWrapperComposite.setBackground(itemColor);
    // $NON-NLS-1$ //$NON-NLS-2$
    CheatSheetStopWatch.printLapTime("ViewItem.addItem()", "Time in addItem() after create bodyWrapperComposite: ");
    bodyText = page.getToolkit().createFormText(bodyWrapperComposite, false);
    // RAP [if] Clipboard
    // bodyText.addSelectionListener(new SelectionAdapter() {
    // public void widgetSelected(SelectionEvent e) {
    // Action copyAction = viewer.getCopyAction();
    // if (copyAction!=null)
    // copyAction.setEnabled(bodyText.canCopy());
    // }
    // });
    // bodyText.addFocusListener(new FocusListener() {
    // public void focusGained(FocusEvent e) {
    // Action copyAction = viewer.getCopyAction();
    // if (copyAction!=null)
    // copyAction.setEnabled(bodyText.canCopy());
    // }
    // public void focusLost(FocusEvent e) {
    // Action copyAction = viewer.getCopyAction();
    // if (copyAction!=null)
    // copyAction.setEnabled(false);
    // }
    // });
    // bodyText = toolkit.createLabel(bodyWrapperComposite, item.getDescription(), SWT.WRAP);
    bodyText.setText(item.getDescription(), item.getDescription().startsWith(IParserTags.FORM_START_TAG), false);
    // Set up the body text portion here.
    bodyText.setBackground(itemColor);
    bodyText.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
    // $NON-NLS-1$ //$NON-NLS-2$
    CheatSheetStopWatch.printLapTime("ViewItem.addItem()", "Time in addItem() after create FormText: ");
    if (!item.isDynamic()) {
        handleButtons();
    }
    // $NON-NLS-1$ //$NON-NLS-2$
    CheatSheetStopWatch.printLapTime("ViewItem.addItem()", "Time in addItem() after handleButtons(): ");
    setButtonsVisible(false);
    setCollapsed();
    // $NON-NLS-1$ //$NON-NLS-2$
    CheatSheetStopWatch.printLapTime("ViewItem.addItem()", "Time in addItem() after setting buttons and item collapsed: ");
    boldFont = mainItemComposite.getFont();
    FontData[] fontDatas = boldFont.getFontData();
    // RAP [if] FontData#setStyle is not supported
    // for (int i = 0; i < fontDatas.length; i++) {
    // fontDatas[i].setStyle(fontDatas[i].getStyle() ^ SWT.BOLD);
    // }
    // RAP [if] We supports only fontData arrays with one element
    // regularFont = new Font(mainItemComposite.getDisplay(), fontDatas);
    regularFont = Graphics.getFont(fontDatas[0].getName(), fontDatas[0].getHeight(), fontDatas[0].getStyle() ^ SWT.BOLD);
    // $NON-NLS-1$ //$NON-NLS-2$
    CheatSheetStopWatch.printLapTime("ViewItem.addItem()", "Time in addItem() after font initlization: ");
    setBold(false);
    // $NON-NLS-1$ //$NON-NLS-2$
    CheatSheetStopWatch.printLapTime("ViewItem.addItem()", "Time in addItem() after setBold: ");
}
Also used : AbstractItemExtensionElement(org.eclipse.ui.cheatsheets.AbstractItemExtensionElement) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) FontData(org.eclipse.swt.graphics.FontData) ArrayList(java.util.ArrayList) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) Point(org.eclipse.swt.graphics.Point) TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) GridLayout(org.eclipse.swt.layout.GridLayout) TableWrapLayout(org.eclipse.ui.forms.widgets.TableWrapLayout) GridData(org.eclipse.swt.layout.GridData) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 84 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project windowbuilder by eclipse.

the class ViewerColumnsUiContentProvider method createContent.

@Override
public void createContent(final Composite parent, int columns) {
    // create expandable composite
    m_expandableComposite = new ExpandableComposite(parent, SWT.NONE);
    m_expandableComposite.setText(Messages.ViewerColumnsUiContentProvider_viewerColumns);
    m_expandableComposite.setExpanded(true);
    GridDataFactory.create(m_expandableComposite).fillH().grabH().spanH(columns);
    m_expandableComposite.addExpansionListener(new IExpansionListener() {

        @Override
        public void expansionStateChanging(ExpansionEvent e) {
            m_settings.put(SETTING_KEY, !m_expandableComposite.isExpanded());
            if (m_expandableComposite.isExpanded()) {
                m_expandableComposite.setText(Messages.ViewerColumnsUiContentProvider_viewerColumnsDots);
            } else {
                m_expandableComposite.setText(Messages.ViewerColumnsUiContentProvider_viewerColumns);
            }
        }

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            parent.layout();
        }
    });
    // create sub content providers
    Composite clientComposite = new Composite(m_expandableComposite, SWT.NONE);
    GridLayoutFactory.create(clientComposite).columns(2).noMargins();
    m_expandableComposite.setClient(clientComposite);
    // buttons
    Composite toolbar = new Composite(clientComposite, SWT.NONE);
    GridLayoutFactory.create(toolbar).noMargins();
    // edit
    m_editButton = new Button(toolbar, SWT.NONE);
    GridDataFactory.create(m_editButton).fillH().grabH();
    m_editButton.setText(Messages.ViewerColumnsUiContentProvider_editButton);
    m_editButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            configureEditingSupport();
        }
    });
    // delete
    m_deleteButton = new Button(toolbar, SWT.NONE);
    GridDataFactory.create(m_deleteButton).fillH().grabH();
    m_deleteButton.setText(Messages.ViewerColumnsUiContentProvider_deleteButton);
    m_deleteButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            deleteEditingSupport();
        }
    });
    // viewer for supports
    m_tableViewer = new TableViewer(clientComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
    GridDataFactory.create(m_tableViewer.getTable()).fillH().grabH().hintVC(7);
    m_tableViewer.setContentProvider(new ArrayContentProvider());
    m_tableViewer.setLabelProvider(new EditingSupportLabelProvider());
    m_tableViewer.addPostSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            calculateButtons();
        }
    });
    m_tableViewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            if (!event.getSelection().isEmpty()) {
                configureEditingSupport();
            }
        }
    });
    // 
    TableFactory factory = TableFactory.modify(m_tableViewer).headerVisible(true).linesVisible(true);
    factory.newColumn().text(Messages.ViewerColumnsUiContentProvider_viewerColumn).width(250);
    factory.newColumn().text(Messages.ViewerColumnsUiContentProvider_cellEditorColumn).width(300);
    factory.newColumn().text(Messages.ViewerColumnsUiContentProvider_elementPropertyColumn).width(300);
}
Also used : IExpansionListener(org.eclipse.ui.forms.events.IExpansionListener) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TableFactory(org.eclipse.wb.internal.core.utils.ui.TableFactory) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 85 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project windowbuilder by eclipse.

the class UpdateStrategyPropertiesUiContentProvider method createContent.

@Override
public void createContent(final Composite parent, int columns) {
    // create expandable composite
    m_expandableComposite = new ExpandableComposite(parent, SWT.NONE);
    m_expandableComposite.setExpanded(true);
    GridDataFactory.create(m_expandableComposite).fillH().grabH().spanH(columns);
    m_expandableComposite.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            compositeExpansionStateChanging();
            parent.layout();
        }
    });
    // calculate columns
    int subColumns = 0;
    for (IUiContentProvider provider : m_providers) {
        subColumns = Math.max(subColumns, provider.getNumberOfControls());
    }
    // create sub content providers
    Composite clientComposite = new Composite(m_expandableComposite, SWT.NONE);
    GridLayoutFactory.create(clientComposite).columns(subColumns).noMargins();
    m_expandableComposite.setClient(clientComposite);
    // 
    for (IUiContentProvider provider : m_providers) {
        provider.createContent(clientComposite, subColumns);
    }
    compositeExpansionStateChanging();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) IUiContentProvider(org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider)

Aggregations

ExpansionEvent (org.eclipse.ui.forms.events.ExpansionEvent)94 ExpansionAdapter (org.eclipse.ui.forms.events.ExpansionAdapter)73 Composite (org.eclipse.swt.widgets.Composite)71 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)70 GridData (org.eclipse.swt.layout.GridData)62 GridLayout (org.eclipse.swt.layout.GridLayout)56 Section (org.eclipse.ui.forms.widgets.Section)45 IExpansionListener (org.eclipse.ui.forms.events.IExpansionListener)18 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)16 Label (org.eclipse.swt.widgets.Label)16 SelectionEvent (org.eclipse.swt.events.SelectionEvent)15 Point (org.eclipse.swt.graphics.Point)14 TableViewer (org.eclipse.jface.viewers.TableViewer)12 ArrayList (java.util.ArrayList)11 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)10 Button (org.eclipse.swt.widgets.Button)10 SelectionListener (org.eclipse.swt.events.SelectionListener)9 FormToolkit (org.eclipse.ui.forms.widgets.FormToolkit)9 List (java.util.List)8 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)8