use of org.eclipse.ui.forms.events.ExpansionEvent in project tdq-studio-se by Talend.
the class BusinessRuleAnalysisResultPage method createResultDataComposite.
private void createResultDataComposite(final Composite comp, final TableIndicator tableIndicator) {
if (tableIndicator.getIndicators().length != 0) {
final NamedColumnSet set = tableIndicator.getColumnSet();
IRunnableWithProgress rwp = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(DefaultMessagesImpl.getString("TableAnalysisResultPage.createPreview", set.getName()), // $NON-NLS-1$
IProgressMonitor.UNKNOWN);
Display.getDefault().asyncExec(new Runnable() {
public void run() {
Map<EIndicatorChartType, List<TableIndicatorUnit>> indicatorComposite = CompositeIndicator.getInstance().getTableIndicatorComposite(tableIndicator);
for (EIndicatorChartType chartType : indicatorComposite.keySet()) {
List<TableIndicatorUnit> units = indicatorComposite.get(chartType);
if (!units.isEmpty()) {
// create UI
ExpandableComposite subComp = createSubWholeComposite(comp, chartType);
final Composite composite = createCompositeForTableAndChart(subComp);
Composite tableTopComp = createTableComposite(composite);
Analysis analysis = masterPage.getAnalysisHandler().getAnalysis();
ITableTypeStates tableTypeState = TableTypeStatesFactory.getInstance().getTableStateForRule(chartType, units, tableIndicator);
// create table for RownCountIndicator
createTableViewerForRowCount(chartType, units, tableTopComp, analysis, tableTypeState);
// create table for WhereRuleIndicator
createTableForWhereRule(chartType, tableTopComp, analysis, tableTypeState, units);
Composite chartTopComp = createTableComposite(composite);
if (canShowChartForResultPage()) {
createChartsForRules(tableIndicator, chartType, units, analysis, chartTopComp);
}
subComp.setClient(composite);
subComp.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent e) {
form.reflow(true);
}
});
}
}
}
/**
* DOC yyin Comment method "createChartsForRules".
*
* @param tableIndicator
* @param chartType
* @param units
* @param analysis
* @param chartTopComp
*/
private void createChartsForRules(final TableIndicator tableIndicator, EIndicatorChartType chartType, List<TableIndicatorUnit> units, Analysis analysis, Composite chartTopComp) {
IChartTypeStates chartTypeState = ChartTypeStatesFactory.getChartStateOfTableAna(chartType, units, tableIndicator);
// get all indicator lists separated by chart, and only
// WhereRuleStatisticsStateTable can get not-null charts
List<List<Indicator>> pagedIndicators = ((WhereRuleStatisticsStateTable) chartTypeState).getPagedIndicators();
// Added TDQ-9241: for each list(for each chart), check if the current
// list has been registered dynamic event
List<Object> datasets = new ArrayList<Object>();
for (List<Indicator> oneChart : pagedIndicators) {
IEventReceiver event = EventManager.getInstance().findRegisteredEvent(oneChart.get(0), EventEnum.DQ_DYMANIC_CHART, 0);
if (event != null) {
// get the dataset from the event
Object dataset = ((TableDynamicChartEventReceiver) event).getDataset();
// one running)
if (dataset != null) {
datasets.add(dataset);
}
}
// ~
}
// create chart
List<Object> charts = null;
if (datasets.size() > 0) {
charts = chartTypeState.getChartList(datasets);
} else {
charts = chartTypeState.getChartList();
datasets = ((WhereRuleStatisticsStateTable) chartTypeState).getTempDatasetList();
}
if (charts != null) {
int index = 0;
for (int i = 0; i < charts.size(); i++) {
Object chart2 = charts.get(i);
Object chartComp = TOPChartUtils.getInstance().createChartCompositeWithSpecialSize(chartTopComp, SWT.NONE, chart2, true, 250, 550);
// Added TDQ-8787 20140707 yyin: create and store the dynamic model for
// each chart
DynamicIndicatorModel dyModel = AnalysisUtils.createDynamicModel(chartType, pagedIndicators.get(index++), chart2);
dynamicList.add(dyModel);
// ~
// one dataset <--> one chart
addMenuToChartComp(chartComp, chartTypeState.getDataExplorer(), analysis, ((ICustomerDataset) datasets.get(i)).getDataEntities());
}
}
}
/**
* DOC yyin Comment method "createTableForWhereRule".
*
* @param chartType
* @param tableTopComp
* @param analysis
* @param tableTypeState
* @param units
* @return
*/
private void createTableForWhereRule(EIndicatorChartType chartType, Composite tableTopComp, Analysis analysis, ITableTypeStates tableTypeState, List<TableIndicatorUnit> units) {
TableWithData chartData = new TableWithData(chartType, tableTypeState.getDataEntity());
TableViewer tableviewer = tableTypeState.getTableForm(tableTopComp);
tableviewer.setInput(chartData);
ChartTableFactory.addMenuAndTip(tableviewer, tableTypeState.getDataExplorer(), analysis);
// Added TDQ-8787 20140707 yyin: create and store the dynamic model
List<Indicator> allRules = new ArrayList<Indicator>();
List<TableIndicatorUnit> removeRowCountUnit = ((WhereRuleStatisticsTableState) tableTypeState).removeRowCountUnit(units);
for (TableIndicatorUnit indUnit : removeRowCountUnit) {
allRules.add(indUnit.getIndicator());
}
DynamicIndicatorModel dyModel = AnalysisUtils.createDynamicModel(chartType, allRules, null);
dyModel.setTableViewer(tableviewer);
dynamicList.add(dyModel);
}
/**
* DOC yyin Comment method "createTableViewerForRowCount".
*
* @param chartType
* @param units
* @param tableTopComp
* @param analysis
* @param tableTypeState
*/
private void createTableViewerForRowCount(EIndicatorChartType chartType, List<TableIndicatorUnit> units, Composite tableTopComp, Analysis analysis, ITableTypeStates tableTypeState) {
WhereRuleStatisticsTableState tableWhereRule = (WhereRuleStatisticsTableState) tableTypeState;
TableWithData chartDataRowCount = new TableWithData(chartType, tableWhereRule.getDataEntityOfRowCount());
TableViewer tableviewerRowCount = tableWhereRule.getTableFormRowCount(tableTopComp);
tableviewerRowCount.setInput(chartDataRowCount);
ChartTableFactory.addMenuAndTip(tableviewerRowCount, tableTypeState.getDataExplorer(), analysis);
// Added TDQ-8787 20140707 yyin: create and store the dynamic model for row
// count's table
List<Indicator> rowCount = new ArrayList<Indicator>();
rowCount.add(tableWhereRule.getRownCountUnit(units).getIndicator());
DynamicIndicatorModel dyModel = AnalysisUtils.createDynamicModel(chartType, rowCount, null);
dyModel.setTableViewer(tableviewerRowCount);
dynamicList.add(dyModel);
}
/**
* DOC yyin Comment method "createTableComposite".
*
* @param composite
* @return
*/
private Composite createTableComposite(final Composite composite) {
Composite tableTopComp = toolkit.createComposite(composite, SWT.NULL);
tableTopComp.setLayout(new GridLayout(1, false));
tableTopComp.setLayoutData(new GridData(GridData.FILL_BOTH));
return tableTopComp;
}
/**
* DOC yyin Comment method "createCompositeForTableAndChart".
*
* @param subComp
* @return
*/
private Composite createCompositeForTableAndChart(ExpandableComposite subComp) {
final Composite composite = toolkit.createComposite(subComp, SWT.NULL);
composite.setLayout(new GridLayout(2, false));
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
return composite;
}
/**
* DOC yyin Comment method "createSubWholeComposite".
*
* @param comp
* @param chartType
* @return
*/
private ExpandableComposite createSubWholeComposite(final Composite comp, EIndicatorChartType chartType) {
ExpandableComposite subComp = toolkit.createExpandableComposite(comp, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.EXPANDED);
subComp.setText(chartType.getLiteral());
subComp.setLayoutData(new GridData(GridData.FILL_BOTH));
subComp.setExpanded(EditorPreferencePage.isUnfoldingIndicatorsResultPage());
return subComp;
}
});
monitor.done();
}
};
try {
new ProgressMonitorDialog(this.getEditorSite().getShell()).run(true, false, rwp);
} catch (Exception ex) {
log.error(ex, ex);
}
}
}
use of org.eclipse.ui.forms.events.ExpansionEvent in project subclipse by subclipse.
the class MergeWizardBestPracticesPage method refreshPage.
private void refreshPage(boolean needsRedraw, boolean usePreviousExpansionState) {
if (needsRedraw) {
Control[] children = outerContainer.getChildren();
for (int i = 0; i < children.length; i++) children[i].dispose();
if (needsChecks)
performChecks(false);
}
Composite composite = toolkit.createComposite(outerContainer, SWT.NONE);
GridLayout innerLayout = new GridLayout();
innerLayout.numColumns = 2;
composite.setLayout(innerLayout);
TableWrapData td = new TableWrapData(TableWrapData.FILL);
composite.setLayoutData(td);
// $NON-NLS-1$
Label modsLabel = toolkit.createLabel(composite, "");
if (localMods) {
modsLabel.setImage(Activator.getImage(Activator.IMAGE_PROBLEM));
} else {
modsLabel.setImage(Activator.getImage(Activator.IMAGE_CHECK));
}
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_BEGINNING);
modsLabel.setLayoutData(gd);
Section modsSection = toolkit.createSection(composite, Section.TWISTIE);
gd = new GridData(GridData.FILL_BOTH);
modsSection.setLayoutData(gd);
modsSection.setText(Messages.MergeWizardBestPracticesPage_noUncommitted);
Composite modsSectionClient = toolkit.createComposite(modsSection);
GridLayout modsLayout = new GridLayout();
modsLayout.numColumns = 1;
modsSectionClient.setLayout(modsLayout);
modsSection.setClient(modsSectionClient);
modsSection.addExpansionListener(new ExpansionAdapter() {
public void expansionStateChanged(ExpansionEvent e) {
form.reflow(true);
modsSectionExpanded = e.getState();
}
});
Composite modsComposite = toolkit.createComposite(modsSectionClient);
GridLayout modsCompositeLayout = new GridLayout();
modsCompositeLayout.numColumns = 4;
modsComposite.setLayout(modsCompositeLayout);
if (localMods) {
Label modsLabel1 = toolkit.createLabel(modsComposite, Messages.MergeWizardBestPracticesPage_noUncommitted2, SWT.NONE);
gd = new GridData();
gd.horizontalSpan = 4;
modsLabel1.setLayoutData(gd);
Hyperlink modsCommitLink = toolkit.createHyperlink(modsComposite, Messages.MergeWizardBestPracticesPage_commit, SWT.NONE);
modsCommitLink.addHyperlinkListener(new HyperlinkAdapter() {
public void linkActivated(HyperlinkEvent e) {
needsChecks = true;
commit();
}
});
toolkit.createLabel(modsComposite, Messages.MergeWizardBestPracticesPage_or);
Hyperlink modsRevertLink = toolkit.createHyperlink(modsComposite, Messages.MergeWizardBestPracticesPage_revert, SWT.NONE);
modsRevertLink.addHyperlinkListener(new HyperlinkAdapter() {
public void linkActivated(HyperlinkEvent e) {
needsChecks = true;
revert();
}
});
toolkit.createLabel(modsComposite, Messages.MergeWizardBestPracticesPage_revert2);
} else {
Label modsLabel1 = toolkit.createLabel(modsComposite, Messages.MergeWizardBestPracticesPage_noLocalMods, SWT.NONE);
gd = new GridData();
gd.horizontalSpan = 4;
modsLabel1.setLayoutData(gd);
}
// $NON-NLS-1$
Label mixedRevisionsLabel = toolkit.createLabel(composite, "");
if (mixedRevisions) {
mixedRevisionsLabel.setImage(Activator.getImage(Activator.IMAGE_PROBLEM));
} else {
mixedRevisionsLabel.setImage(Activator.getImage(Activator.IMAGE_CHECK));
}
gd = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_BEGINNING);
mixedRevisionsLabel.setLayoutData(gd);
Section mixedRevisionsSection = toolkit.createSection(composite, Section.TWISTIE);
gd = new GridData(GridData.FILL_BOTH);
mixedRevisionsSection.setLayoutData(gd);
mixedRevisionsSection.setText(Messages.MergeWizardBestPracticesPage_singleRevision);
Composite mixedRevisionsSectionClient = toolkit.createComposite(mixedRevisionsSection);
GridLayout mixedRevisionsLayout = new GridLayout();
mixedRevisionsLayout.numColumns = 1;
mixedRevisionsSectionClient.setLayout(mixedRevisionsLayout);
mixedRevisionsSection.setClient(mixedRevisionsSectionClient);
mixedRevisionsSection.addExpansionListener(new ExpansionAdapter() {
public void expansionStateChanged(ExpansionEvent e) {
form.reflow(true);
mixedRevisionsSectionExpanded = e.getState();
}
});
Composite mixedRevisionsComposite = toolkit.createComposite(mixedRevisionsSectionClient);
GridLayout mixedRevisionsCompositeLayout = new GridLayout();
mixedRevisionsCompositeLayout.numColumns = 2;
mixedRevisionsComposite.setLayout(mixedRevisionsCompositeLayout);
gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
mixedRevisionsComposite.setLayoutData(gd);
if (mixedRevisions) {
Label mixedRevisionsLabel1 = toolkit.createLabel(mixedRevisionsComposite, Messages.MergeWizardBestPracticesPage_singleRevision2, SWT.NONE);
gd = new GridData();
gd.horizontalSpan = 2;
mixedRevisionsLabel1.setLayoutData(gd);
Hyperlink mixedRevisionsUpdateLink = toolkit.createHyperlink(mixedRevisionsComposite, Messages.MergeWizardBestPracticesPage_update, SWT.NONE);
mixedRevisionsUpdateLink.addHyperlinkListener(new HyperlinkAdapter() {
public void linkActivated(HyperlinkEvent e) {
needsChecks = true;
if (updateResourceSelectionTree == null) {
IResource[] mixedArray = new IResource[mixedRevisionsList.size()];
mixedRevisionsList.toArray(mixedArray);
update(mixedArray, true);
} else
update(updateResourceSelectionTree.getSelectedResources(), true);
}
});
toolkit.createLabel(mixedRevisionsComposite, Messages.MergeWizardBestPracticesPage_update2);
if (((MergeWizard) getWizard()).getResources().length > 1) {
IResource[] mixedArray = new IResource[mixedRevisionsList.size()];
mixedRevisionsList.toArray(mixedArray);
updateResourceSelectionTree = new ResourceSelectionTree(mixedRevisionsComposite, SWT.NONE, Messages.MergeWizardBestPracticesPage_itemsToUpdate, mixedArray, new HashMap(), null, false, null, null);
gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
gd.horizontalSpan = 2;
gd.heightHint = 100;
updateResourceSelectionTree.setLayoutData(gd);
} else
updateResourceSelectionTree = null;
} else {
Label mixedRevisionsLabel1 = toolkit.createLabel(mixedRevisionsComposite, Messages.MergeWizardBestPracticesPage_atSingleRevision, SWT.NONE);
gd = new GridData();
gd.horizontalSpan = 2;
mixedRevisionsLabel1.setLayoutData(gd);
}
// $NON-NLS-1$
Label switchedChildrenLabel = toolkit.createLabel(composite, "");
if (switchedChildren) {
switchedChildrenLabel.setImage(Activator.getImage(Activator.IMAGE_PROBLEM));
} else {
switchedChildrenLabel.setImage(Activator.getImage(Activator.IMAGE_CHECK));
}
gd = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_BEGINNING);
switchedChildrenLabel.setLayoutData(gd);
Section switchedChildrenSection = toolkit.createSection(composite, Section.TWISTIE);
gd = new GridData(GridData.FILL_BOTH);
switchedChildrenSection.setLayoutData(gd);
switchedChildrenSection.setText(Messages.MergeWizardBestPracticesPage_noSwitched);
Composite switchedChildrenSectionClient = toolkit.createComposite(switchedChildrenSection);
GridLayout switchedChildrenLayout = new GridLayout();
switchedChildrenLayout.numColumns = 1;
switchedChildrenSectionClient.setLayout(switchedChildrenLayout);
switchedChildrenSection.setClient(switchedChildrenSectionClient);
switchedChildrenSection.addExpansionListener(new ExpansionAdapter() {
public void expansionStateChanged(ExpansionEvent e) {
form.reflow(true);
switchedChildrenSectionExpanded = e.getState();
}
});
Composite switchedChildrenComposite = toolkit.createComposite(switchedChildrenSectionClient);
GridLayout switchedChildrenCompositeLayout = new GridLayout();
switchedChildrenCompositeLayout.numColumns = 2;
switchedChildrenComposite.setLayout(switchedChildrenCompositeLayout);
if (switchedChildren) {
Label switchedChildrenDescriptionLabel1 = toolkit.createLabel(switchedChildrenComposite, Messages.MergeWizardBestPracticesPage_noSwitched2, SWT.NONE);
gd = new GridData();
gd.horizontalSpan = 2;
switchedChildrenDescriptionLabel1.setLayoutData(gd);
Hyperlink switchedChildrenUpdateLink = toolkit.createHyperlink(switchedChildrenComposite, Messages.MergeWizardBestPracticesPage_switch, SWT.NONE);
switchedChildrenUpdateLink.addHyperlinkListener(new HyperlinkAdapter() {
public void linkActivated(HyperlinkEvent e) {
needsChecks = true;
switchChildren(switchResourceSelectionTree.getSelectedResources());
}
});
toolkit.createLabel(switchedChildrenComposite, Messages.MergeWizardBestPracticesPage_switch2);
IResource[] switchedArray = new IResource[switchedChildrenList.size()];
switchedChildrenList.toArray(switchedArray);
switchResourceSelectionTree = new ResourceSelectionTree(switchedChildrenComposite, SWT.NONE, Messages.MergeWizardBestPracticesPage_itemsToSwitch, switchedArray, new HashMap(), null, false, null, null);
gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
gd.horizontalSpan = 2;
gd.heightHint = 100;
switchResourceSelectionTree.setLayoutData(gd);
} else {
Label switchedChildrenDescriptionLabel1 = toolkit.createLabel(switchedChildrenComposite, Messages.MergeWizardBestPracticesPage_hasNoSwitched, SWT.NONE);
gd = new GridData();
gd.horizontalSpan = 2;
switchedChildrenDescriptionLabel1.setLayoutData(gd);
}
// $NON-NLS-1$
Label completeLabel = toolkit.createLabel(composite, "");
gd = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_BEGINNING);
completeLabel.setLayoutData(gd);
if (incompleteWorkingCopy) {
completeLabel.setImage(Activator.getImage(Activator.IMAGE_PROBLEM));
} else {
completeLabel.setImage(Activator.getImage(Activator.IMAGE_CHECK));
}
Section completeSection = toolkit.createSection(composite, Section.TWISTIE);
gd = new GridData(GridData.FILL_BOTH);
completeSection.setLayoutData(gd);
completeSection.setText(Messages.MergeWizardBestPracticesPage_completeWorkingCopy);
Composite completeSectionClient = toolkit.createComposite(completeSection);
GridLayout completeLayout = new GridLayout();
completeLayout.numColumns = 1;
completeSectionClient.setLayout(completeLayout);
completeSection.setClient(completeSectionClient);
completeSection.addExpansionListener(new ExpansionAdapter() {
public void expansionStateChanged(ExpansionEvent e) {
form.reflow(true);
completeSectionExpanded = e.getState();
}
});
Composite completeComposite = toolkit.createComposite(completeSectionClient);
GridLayout completeCompositeLayout = new GridLayout();
completeCompositeLayout.numColumns = 3;
completeComposite.setLayout(completeCompositeLayout);
Label completeDescriptionLabel1 = toolkit.createLabel(completeComposite, Messages.MergeWizardBestPracticesPage_completeWorkingCopy2, SWT.NONE);
gd = new GridData();
gd.horizontalSpan = 3;
completeDescriptionLabel1.setLayoutData(gd);
toolkit.createLabel(completeComposite, Messages.MergeWizardBestPracticesPage_completeWorkingCopy3, SWT.WRAP);
Hyperlink completeUpdateLink = toolkit.createHyperlink(completeComposite, Messages.MergeWizardBestPracticesPage_update3, SWT.NONE);
completeUpdateLink.addHyperlinkListener(new HyperlinkAdapter() {
public void linkActivated(HyperlinkEvent e) {
needsChecks = true;
IResource[] incompleteArray = new IResource[incompleteList.size()];
incompleteList.toArray(incompleteArray);
update(incompleteArray, ISVNCoreConstants.DEPTH_INFINITY, true, true);
}
});
toolkit.createLabel(completeComposite, Messages.MergeWizardBestPracticesPage_update4, SWT.WRAP);
if (needsRedraw && usePreviousExpansionState) {
if (modsSectionExpanded)
modsSection.setExpanded(true);
if (mixedRevisionsSectionExpanded)
mixedRevisionsSection.setExpanded(true);
if (switchedChildrenSectionExpanded)
switchedChildrenSection.setExpanded(true);
if (completeSectionExpanded)
completeSection.setExpanded(true);
outerContainer.layout(true);
outerContainer.redraw();
} else {
if (localMods) {
modsSection.setExpanded(true);
modsSectionExpanded = true;
}
if (mixedRevisions) {
mixedRevisionsSection.setExpanded(true);
mixedRevisionsSectionExpanded = true;
}
if (switchedChildren) {
switchedChildrenSection.setExpanded(true);
switchedChildrenSectionExpanded = true;
}
if (incompleteWorkingCopy) {
completeSection.setExpanded(true);
completeSectionExpanded = true;
}
}
}
use of org.eclipse.ui.forms.events.ExpansionEvent in project eclipse.platform.ui by eclipse-platform.
the class ExpandableCompositeTest method createExtendableComposite.
private void createExtendableComposite(String text, int flags) {
ec = new ExpandableCompositeForTest(shell, SWT.NONE, flags);
ec.setFont(font);
ec.setText(text);
ec.setBackground(display.getSystemColor(SWT.COLOR_GRAY));
ec.addExpansionListener(new IExpansionListener() {
@Override
public void expansionStateChanging(ExpansionEvent e) {
}
@Override
public void expansionStateChanged(ExpansionEvent e) {
ec.getParent().layout(true);
}
});
}
use of org.eclipse.ui.forms.events.ExpansionEvent in project eclipse.platform.ui by eclipse-platform.
the class FormsPerformanceTest method createPartControl.
public void createPartControl(Composite parent, FormToolkit toolkit) {
// Label l = new Label(parent, SWT.NULL);
// l.setText ("a label");
ScrolledForm form;
form = toolkit.createScrolledForm(parent);
form.setText("Hello, Eclipse Forms");
TableWrapLayout layout = new TableWrapLayout();
form.getBody().setLayout(layout);
Hyperlink link = toolkit.createHyperlink(form.getBody(), "Click here.", SWT.WRAP);
link.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
System.out.println("Link activated!");
}
});
link.setText("This is an example of a form that is much longer and will need to wrap.");
layout.numColumns = 2;
TableWrapData td = new TableWrapData();
td.colspan = 2;
link.setLayoutData(td);
toolkit.createLabel(form.getBody(), "Text field label:");
Text text = toolkit.createText(form.getBody(), "");
td = new TableWrapData(TableWrapData.FILL_GRAB);
text.setLayoutData(td);
Button button = toolkit.createButton(form.getBody(), "An example of a checkbox in a form", SWT.CHECK);
td = new TableWrapData();
td.colspan = 2;
button.setLayoutData(td);
ImageHyperlink ih = toolkit.createImageHyperlink(form.getBody(), SWT.NULL);
ih.setText("Image link with no image");
ih = toolkit.createImageHyperlink(form.getBody(), SWT.NULL);
// ih.setImage(ExamplesPlugin.getDefault().getImageRegistry().get(ExamplesPlugin.IMG_SAMPLE));
ih.setText("Link with image and text");
ExpandableComposite ec = toolkit.createExpandableComposite(form.getBody(), ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT);
ImageHyperlink eci = toolkit.createImageHyperlink(ec, SWT.NULL);
// eci.setImage(ExamplesPlugin.getDefault().getImageRegistry().get(ExamplesPlugin.IMG_SAMPLE));
ec.setTextClient(eci);
ec.setText("Expandable Composite title");
String ctext = "We will now create a somewhat long text so that " + "we can use it as content for the expandable composite. " + "Expandable composite is used to hide or show the text using the " + "toggle control";
Label client = toolkit.createLabel(ec, ctext, SWT.WRAP);
ec.setClient(client);
td = new TableWrapData();
td.colspan = 2;
ec.setLayoutData(td);
ec.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent e) {
// form.reflow(true);
}
});
Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION | Section.TWISTIE | Section.EXPANDED);
td = new TableWrapData(TableWrapData.FILL);
td.colspan = 2;
section.setLayoutData(td);
section.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent e) {
// form.reflow(true);
}
});
section.setText("Section title");
toolkit.createCompositeSeparator(section);
section.setDescription("This is the description that goes below the title");
Composite sectionClient = toolkit.createComposite(section);
sectionClient.setLayout(new GridLayout());
button = toolkit.createButton(sectionClient, "Radio 1", SWT.RADIO);
button = toolkit.createButton(sectionClient, "Radio 2", SWT.RADIO);
section.setClient(sectionClient);
StringBuilder buf = new StringBuilder();
buf.append("<form>");
buf.append("<p>");
buf.append("Here is some plain text for the text to render; ");
buf.append("this text is at <a href=\"http://www.eclipse.org\" nowrap=\"true\">http://www.eclipse.org</a> web site.");
buf.append("</p>");
buf.append("<p>");
buf.append("<span color=\"header\" font=\"header\">This text is in header font.</span>");
buf.append("</p>");
buf.append("<p>This line will contain some <b>bold</b> and some <span font=\"code\">source</span> text. ");
buf.append("We can also add <img href=\"image\"/> an image. ");
buf.append("</p>");
buf.append("<li>A default (bulleted) list item.</li>");
buf.append("<li>Another bullet list item.</li>");
buf.append("<li style=\"text\" value=\"1.\">A list item with text.</li>");
buf.append("<li style=\"text\" value=\"2.\">Another list item with text</li>");
buf.append("<li style=\"image\" value=\"image\">List item with an image bullet</li>");
buf.append("<li style=\"text\" bindent=\"20\" indent=\"40\" value=\"3.\">A list item with text.</li>");
buf.append("<li style=\"text\" bindent=\"20\" indent=\"40\" value=\"4.\">A list item with text.</li>");
buf.append("<p> leading blanks; more white \n\n new lines <br/><br/><br/> \n more <b> bb </b> white . </p>");
buf.append("</form>");
FormText rtext = toolkit.createFormText(form.getBody(), false);
// rtext.setWhitespaceNormalized(false);
td = new TableWrapData(TableWrapData.FILL);
td.colspan = 2;
rtext.setLayoutData(td);
// rtext.setImage("image", ExamplesPlugin.getDefault().getImageRegistry().get(ExamplesPlugin.IMG_SAMPLE));
// rtext.setColor("header", JFaceColors.getErrorText(display));
rtext.setFont("header", JFaceResources.getHeaderFont());
rtext.setFont("code", JFaceResources.getTextFont());
rtext.setText(buf.toString(), true, false);
rtext.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
System.out.println("Link active: " + e.getHref());
}
});
/* layout.numColumns = 3;
Label label;
TableWrapData td;
label = toolkit.createLabel(form.getBody(), "Some text to put in the first column", SWT.WRAP);
label = toolkit.createLabel(form.getBody() ,"Some text to put in the second column and make it a bit longer so that we can see what happens with column distribution. This text must be the longest so that it can get more space allocated to the columns it belongs to.", SWT.WRAP);
td = new TableWrapData();
td.colspan = 2;
label.setLayoutData(td);
label = toolkit.createLabel(form.getBody(), "This text will span two rows and should not grow the column.", SWT.WRAP);
td = new TableWrapData();
td.rowspan = 2;
label.setLayoutData(td);
label = toolkit.createLabel(form.getBody(), "This text goes into column 2 and consumes only one cell", SWT.WRAP);
label.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
label = toolkit.createLabel(form.getBody(), "This text goes into column 3 and consumes only one cell too", SWT.WRAP);
label.setLayoutData(new TableWrapData(TableWrapData.FILL));
label = toolkit.createLabel(form.getBody(), "This text goes into column 2 and consumes only one cell", SWT.WRAP);
label.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
label = toolkit.createLabel(form.getBody(), "This text goes into column 3 and consumes only one cell too", SWT.WRAP);
label.setLayoutData(new TableWrapData(TableWrapData.FILL));
form.getBody().setBackground(form.getBody().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));*/
toolkit.paintBordersFor(form.getBody());
}
use of org.eclipse.ui.forms.events.ExpansionEvent in project eclipse.platform.ui by eclipse-platform.
the class SectionFactoryTest method addsSectionExpandingListener.
@Test
public void addsSectionExpandingListener() {
final ExpansionEvent[] raisedEvents = new ExpansionEvent[1];
Section section = SectionFactory.newSection(Section.TWISTIE).onExpanding(e -> raisedEvents[0] = e).create(shell);
Control twistie = section.getChildren()[0];
assertTrue("Expected a twistie", twistie instanceof Twistie);
click(twistie);
assertNotNull(raisedEvents[0]);
}
Aggregations