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();
}
});
}
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;
}
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: ");
}
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);
}
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();
}
Aggregations