use of org.eclipse.ui.forms.events.ExpansionAdapter in project knime-core by knime.
the class PreferredRendererPreferencePage method createFieldEditors.
/**
* {@inheritDoc}
*/
@Override
protected void createFieldEditors() {
Map<String, List<ExtensibleUtilityFactory>> groupedUtilityFactories = new HashMap<String, List<ExtensibleUtilityFactory>>();
// TODO retrieve the utility factories from the data type extension point once we have it
for (ExtensibleUtilityFactory fac : ExtensibleUtilityFactory.getAllFactories()) {
List<ExtensibleUtilityFactory> groupList = groupedUtilityFactories.get(fac.getGroupName());
if (groupList == null) {
groupList = new ArrayList<ExtensibleUtilityFactory>(16);
groupedUtilityFactories.put(fac.getGroupName(), groupList);
}
groupList.add(fac);
}
List<String> groupNames = new ArrayList<String>(groupedUtilityFactories.keySet());
Collections.sort(groupNames);
for (String group : groupNames) {
final Section sectionExpander = new Section(getFieldEditorParent(), ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
sectionExpander.setText(group);
final Composite section = new Composite(sectionExpander, SWT.NONE);
sectionExpander.setClient(section);
sectionExpander.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(final ExpansionEvent e) {
Composite comp = section;
while (!(comp instanceof ScrolledComposite)) {
comp = comp.getParent();
}
// this is to fix a bug in Eclipse, no scrollbar is shown when this is true
((ScrolledComposite) comp).setExpandVertical(false);
comp = section;
while (!(comp instanceof ScrolledComposite)) {
comp.setSize(comp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
comp.layout();
comp = comp.getParent();
}
}
});
List<ExtensibleUtilityFactory> utilityFactories = groupedUtilityFactories.get(group);
Collections.sort(utilityFactories, utilityFactoryComparator);
for (ExtensibleUtilityFactory utilFac : utilityFactories) {
List<DataValueRendererFactory> rendererFactories = new ArrayList<DataValueRendererFactory>(utilFac.getAvailableRenderers());
Collections.sort(rendererFactories, rendererFactoryComparator);
String[][] comboEntries = new String[utilFac.getAvailableRenderers().size()][2];
int i = 0;
for (DataValueRendererFactory rendFac : rendererFactories) {
comboEntries[i++] = new String[] { rendFac.getDescription(), rendFac.getId() };
}
ComboFieldEditor c = new ComboFieldEditor(utilFac.getPreferenceKey(), utilFac.getName(), comboEntries, section);
c.setEnabled(comboEntries.length > 1, section);
addField(c);
m_fieldEditors.put(utilFac.getPreferenceKey(), c);
}
// add a dummy control which occupies the second column so that the next expander is in a new row
new Label(getFieldEditorParent(), SWT.NONE);
}
DefaultScope.INSTANCE.getNode(FrameworkUtil.getBundle(DataValueRendererFactory.class).getSymbolicName()).addPreferenceChangeListener(this);
}
use of org.eclipse.ui.forms.events.ExpansionAdapter in project egit by eclipse.
the class CreateTagDialog method createAdvancedSection.
private void createAdvancedSection(final Composite composite) {
if (commitId != null)
return;
ExpandableComposite advanced = new ExpandableComposite(composite, ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT);
advanced.setText(UIText.CreateTagDialog_advanced);
advanced.setToolTipText(UIText.CreateTagDialog_advancedToolTip);
advanced.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
Composite advancedComposite = new Composite(advanced, SWT.WRAP);
advancedComposite.setLayout(GridLayoutFactory.swtDefaults().create());
advancedComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
Label advancedLabel = new Label(advancedComposite, SWT.WRAP);
advancedLabel.setText(UIText.CreateTagDialog_advancedMessage);
advancedLabel.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
commitCombo = new CommitCombo(advancedComposite, SWT.NORMAL);
commitCombo.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(300, SWT.DEFAULT).create());
advanced.setClient(advancedComposite);
advanced.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent e) {
// fill the Combo lazily to improve UI responsiveness
if (((Boolean) e.data).booleanValue() && commitCombo.getItemCount() == 0) {
final Collection<RevCommit> commits = new ArrayList<>();
try {
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
getRevCommits(commits);
}
});
} catch (InvocationTargetException e1) {
Activator.logError(e1.getMessage(), e1);
} catch (InterruptedException e1) {
// ignore here
}
for (RevCommit revCommit : commits) commitCombo.add(revCommit);
// Set combo selection if a tag is selected
if (existingTag != null)
commitCombo.setSelectedElement(existingTag.getObject());
}
composite.layout(true);
composite.getShell().pack();
}
});
}
use of org.eclipse.ui.forms.events.ExpansionAdapter in project egit by eclipse.
the class SimpleConfigurePushDialog method createAdditionalUriArea.
@Override
protected Control createAdditionalUriArea(Composite parent) {
ExpandableComposite pushUriArea = new ExpandableComposite(parent, ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT);
GridDataFactory.fillDefaults().grab(true, false).applyTo(pushUriArea);
pushUriArea.setExpanded(!getConfig().getPushURIs().isEmpty());
pushUriArea.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent e) {
parent.layout(true, true);
parent.getShell().pack();
}
});
pushUriArea.setText(UIText.SimpleConfigurePushDialog_PushUrisLabel);
final Composite pushUriDetails = new Composite(pushUriArea, SWT.NONE);
pushUriArea.setClient(pushUriDetails);
pushUriDetails.setLayout(new GridLayout(2, false));
GridDataFactory.fillDefaults().grab(true, true).applyTo(pushUriDetails);
uriViewer = new TableViewer(pushUriDetails, SWT.BORDER | SWT.MULTI);
GridDataFactory.fillDefaults().grab(true, true).minSize(SWT.DEFAULT, 30).applyTo(uriViewer.getTable());
uriViewer.setContentProvider(ArrayContentProvider.getInstance());
final Composite uriButtonArea = new Composite(pushUriDetails, SWT.NONE);
GridLayoutFactory.fillDefaults().applyTo(uriButtonArea);
GridDataFactory.fillDefaults().grab(false, true).applyTo(uriButtonArea);
Button addUri = new Button(uriButtonArea, SWT.PUSH);
addUri.setText(UIText.SimpleConfigurePushDialog_AddPushUriButton);
GridDataFactory.fillDefaults().applyTo(addUri);
addUri.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
SelectUriWizard wiz = new SelectUriWizard(false);
if (new WizardDialog(getShell(), wiz).open() == Window.OK) {
getConfig().addPushURI(wiz.getUri());
updateControls();
}
}
});
final Button changeUri = new Button(uriButtonArea, SWT.PUSH);
changeUri.setText(UIText.SimpleConfigurePushDialog_ChangePushUriButton);
GridDataFactory.fillDefaults().applyTo(changeUri);
changeUri.setEnabled(false);
changeUri.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
URIish uri = (URIish) ((IStructuredSelection) uriViewer.getSelection()).getFirstElement();
SelectUriWizard wiz = new SelectUriWizard(false, uri.toPrivateString());
if (new WizardDialog(getShell(), wiz).open() == Window.OK) {
getConfig().removePushURI(uri);
getConfig().addPushURI(wiz.getUri());
updateControls();
}
}
});
final Button deleteUri = new Button(uriButtonArea, SWT.PUSH);
deleteUri.setText(UIText.SimpleConfigurePushDialog_DeletePushUriButton);
GridDataFactory.fillDefaults().applyTo(deleteUri);
deleteUri.setEnabled(false);
deleteUri.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
URIish uri = (URIish) ((IStructuredSelection) uriViewer.getSelection()).getFirstElement();
getConfig().removePushURI(uri);
updateControls();
}
});
uriViewer.addSelectionChangedListener(event -> {
deleteUri.setEnabled(!uriViewer.getSelection().isEmpty());
changeUri.setEnabled(((IStructuredSelection) uriViewer.getSelection()).size() == 1);
});
return pushUriArea;
}
use of org.eclipse.ui.forms.events.ExpansionAdapter in project tdq-studio-se by Talend.
the class CorrelationAnalysisResultPage method createBubbleOrGanttChart.
private void createBubbleOrGanttChart(final ScrolledForm sForm, final Composite composite, final ColumnSetMultiValueIndicator columnSetMultiValueIndicator) {
List<Composite> previewChartList = new ArrayList<Composite>();
List<ModelElement> bubOrGanttColumnList = new ArrayList<ModelElement>();
if (columnSetMultiValueIndicator instanceof CountAvgNullIndicator) {
bubOrGanttColumnList = columnSetMultiValueIndicator.getNumericColumns();
} else {
bubOrGanttColumnList = columnSetMultiValueIndicator.getDateColumns();
}
for (ModelElement column : bubOrGanttColumnList) {
final MetadataColumn tdColumn = (MetadataColumn) column;
final ExpandableComposite exComp = toolkit.createExpandableComposite(composite, ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT);
// $NON-NLS-1$
exComp.setText(DefaultMessagesImpl.getString("ColumnMasterDetailsPage.column", tdColumn.getName()));
exComp.setLayout(new GridLayout());
exComp.setData(columnSetMultiValueIndicator);
previewChartList.add(exComp);
final Composite comp = toolkit.createComposite(exComp);
comp.setLayout(new GridLayout(2, false));
comp.setLayoutData(new GridData(GridData.FILL_BOTH));
if (tdColumn != null) {
IRunnableWithProgress rwp = new IRunnableWithProgress() {
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(DefaultMessagesImpl.getString("ColumnCorrelationNominalIntervalResultPage.CreatePreview", tdColumn.getName()), // $NON-NLS-1$
IProgressMonitor.UNKNOWN);
Display.getDefault().asyncExec(new Runnable() {
public void run() {
HideSeriesChartComposite hcc = new HideSeriesChartComposite(comp, getAnalysisHandler().getAnalysis(), columnSetMultiValueIndicator, tdColumn, true);
GridData gd = new GridData();
gd.widthHint = 800;
gd.heightHint = 450;
hcc.setLayoutData(gd);
}
});
monitor.done();
}
};
try {
new ProgressMonitorDialog(getSite().getShell()).run(true, false, rwp);
} catch (Exception ex) {
log.error(ex, ex);
}
}
exComp.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent e) {
getChartComposite().layout();
sForm.reflow(true);
}
});
exComp.setExpanded(true);
exComp.setClient(comp);
}
if (!previewChartList.isEmpty()) {
this.previewChartCompsites = previewChartList.toArray(new Composite[previewChartList.size()]);
}
}
use of org.eclipse.ui.forms.events.ExpansionAdapter in project tdq-studio-se by Talend.
the class MasterPaginationInfo method render.
@Override
protected void render() {
// refresh analysis tree
if (treeViewer != null) {
treeViewer.setElements(modelElementIndicators.toArray(new ModelElementIndicator[modelElementIndicators.size()]), false);
}
// chart composite don't display So need't consider it.
if (previewChartList == null || uiPagination.getChartComposite() == null) {
return;
}
previewChartList.clear();
clearDynamicList();
if (EditorPreferencePage.isHideGraphicsSectionForSettingsPage() || !TOPChartUtils.getInstance().isTOPChartInstalled()) {
return;
}
for (ModelElementIndicator modelElementIndicator : modelElementIndicators) {
final ExpandableComposite exComp = uiPagination.getToolkit().createExpandableComposite(uiPagination.getChartComposite(), ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT);
needDispostWidgets.add(exComp);
exComp.setText(DefaultMessagesImpl.getString("ColumnMasterDetailsPage.column", // $NON-NLS-1$
modelElementIndicator.getElementName()));
exComp.setLayout(new GridLayout());
exComp.setData(modelElementIndicator);
previewChartList.add(exComp);
Composite comp = uiPagination.getToolkit().createComposite(exComp);
comp.setLayout(new GridLayout());
comp.setLayoutData(new GridData(GridData.FILL_BOTH));
Map<EIndicatorChartType, List<IndicatorUnit>> indicatorComposite = CompositeIndicator.getInstance().getIndicatorComposite(modelElementIndicator);
for (EIndicatorChartType chartType : indicatorComposite.keySet()) {
List<IndicatorUnit> units = indicatorComposite.get(chartType);
if (!units.isEmpty()) {
if (chartType == EIndicatorChartType.UDI_FREQUENCY) {
for (IndicatorUnit unit : units) {
List<IndicatorUnit> specialUnit = new ArrayList<IndicatorUnit>();
specialUnit.add(unit);
createChart(comp, chartType, specialUnit);
}
} else {
createChart(comp, chartType, units);
}
}
}
exComp.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent e) {
uiPagination.getChartComposite().layout();
form.reflow(true);
if (e.getState()) {
exComp.setExpanded(e.getState());
exComp.getParent().pack();
}
}
});
exComp.setExpanded(true);
exComp.setClient(comp);
uiPagination.getChartComposite().layout();
}
}
Aggregations