use of org.eclipse.ui.forms.events.ExpansionAdapter in project tdq-studio-se by Talend.
the class ResultPaginationInfo method render.
@Override
protected void render() {
clearDynamicList();
allExpandableCompositeList.clear();
columnCompositeMap.clear();
for (ModelElementIndicator modelElementIndicator : modelElementIndicators) {
ExpandableComposite exComp = uiPagination.getToolkit().createExpandableComposite(uiPagination.getChartComposite(), ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.EXPANDED | ExpandableComposite.LEFT_TEXT_CLIENT_ALIGNMENT);
needDispostWidgets.add(exComp);
allExpandableCompositeList.add(exComp);
// MOD klliu add more information about the column belongs to which table/view.
IRepositoryNode modelElementRepositoryNode = modelElementIndicator.getModelElementRepositoryNode();
IRepositoryNode parentNodeForColumnNode = RepositoryNodeHelper.getParentNodeForColumnNode(modelElementRepositoryNode);
String label = parentNodeForColumnNode.getObject().getLabel();
if (label != null && !label.equals("")) {
// $NON-NLS-1$
// $NON-NLS-1$
label = label.concat(".").concat(modelElementIndicator.getElementName());
} else {
label = modelElementIndicator.getElementName();
}
// ~
// $NON-NLS-1$
exComp.setText(DefaultMessagesImpl.getString("ColumnAnalysisResultPage.Column", label));
exComp.setLayout(new GridLayout());
exComp.setLayoutData(new GridData(GridData.FILL_BOTH));
// MOD xqliu 2009-06-23 bug 7481
exComp.setExpanded(EditorPreferencePage.isUnfoldingAnalyzedEelementsResultPage());
// ~
// TDQ-11525 msjian : Add "expand all" and "fold all" icon buttons in the "Analysis Results" section
Composite collapseExpandComposite = uiPagination.getToolkit().createComposite(exComp);
GridLayout gdLayout = new GridLayout();
gdLayout.numColumns = 2;
collapseExpandComposite.setLayout(gdLayout);
createCollapseAllLink(collapseExpandComposite, label);
createExpandAllLink(collapseExpandComposite, label);
exComp.setTextClient(collapseExpandComposite);
// TDQ-11525~
Composite comp = uiPagination.getToolkit().createComposite(exComp);
comp.setLayout(new GridLayout());
comp.setLayoutData(new GridData(GridData.FILL_BOTH));
exComp.setClient(comp);
createResultDataComposite(comp, modelElementIndicator);
columnCompositeMap.put(label, comp);
exComp.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent e) {
uiPagination.getChartComposite().layout();
form.reflow(true);
}
});
uiPagination.getChartComposite().layout();
masterPage.registerSection(exComp);
}
}
use of org.eclipse.ui.forms.events.ExpansionAdapter in project tdq-studio-se by Talend.
the class ResultPaginationInfo method createChart.
/**
* DOC bZhou Comment method "createChart".
*
* @param comp
* @param chartType
* @param units
*/
private void createChart(Composite comp, EIndicatorChartType chartType, List<IndicatorUnit> units) {
DynamicIndicatorModel dyModel = new DynamicIndicatorModel();
// MOD TDQ-8787 20140618 yyin: to let the chart and table use the same dataset
Object chart = null;
Object dataset = null;
// Added TDQ-8787 20140722 yyin:(when first switch from master to result) if there is some dynamic event for the
// current indicator, use its dataset directly (TDQ-9241)
IEventReceiver event = EventManager.getInstance().findRegisteredEvent(units.get(0).getIndicator(), EventEnum.DQ_DYMANIC_CHART, 0);
// get the dataset from the event
if (event != null) {
dataset = ((DynamicChartEventReceiver) event).getDataset();
}
// ~
// Added TDQ-8787 2014-06-18 yyin: add the current units and dataset into the list
List<Indicator> indicators = null;
dyModel.setChartType(chartType);
this.dynamicList.add(dyModel);
if (EIndicatorChartType.SUMMARY_STATISTICS.equals(chartType)) {
// for the summary indicators, the table show 2 more than the bar chart
dyModel.setSummaryIndicators(getIndicatorsForTable(units, true));
}
// create UI
ExpandableComposite subComp = uiPagination.getToolkit().createExpandableComposite(comp, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.EXPANDED);
subComp.setText(chartType.getLiteral());
subComp.setLayoutData(new GridData(GridData.FILL_BOTH));
// MOD xqliu 2009-06-23 bug 7481
subComp.setExpanded(EditorPreferencePage.isUnfoldingIndicatorsResultPage());
// ~
final Composite composite = uiPagination.getToolkit().createComposite(subComp, SWT.NULL);
composite.setLayout(new GridLayout(2, false));
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
Analysis analysis = masterPage.getAnalysisHandler().getAnalysis();
// create table viewer firstly
ITableTypeStates tableTypeState = TableTypeStatesFactory.getInstance().getTableState(chartType, units);
ChartDataEntity[] dataEntities = tableTypeState.getDataEntity();
TableWithData chartData = new TableWithData(chartType, dataEntities);
TableViewer tableviewer = tableTypeState.getTableForm(composite);
tableviewer.setInput(chartData);
tableviewer.getTable().pack();
dyModel.setTableViewer(tableviewer);
DataExplorer dataExplorer = tableTypeState.getDataExplorer();
ChartTableFactory.addMenuAndTip(tableviewer, dataExplorer, analysis);
if (EIndicatorChartType.TEXT_STATISTICS.equals(chartType) && dataEntities != null && dataEntities.length > 0) {
// only text indicator need
indicators = getIndicators(dataEntities);
} else {
indicators = getIndicators(units);
}
dyModel.setIndicatorList(indicators);
// create chart
try {
if (!EditorPreferencePage.isHideGraphicsForResultPage() && TOPChartUtils.getInstance().isTOPChartInstalled()) {
IChartTypeStates chartTypeState = ChartTypeStatesFactory.getChartState(chartType, units);
boolean isPattern = chartTypeState instanceof PatternStatisticsState;
if (event == null) {
chart = chartTypeState.getChart();
if (chart != null && isSQLMode) {
// chart is null for MODE. Get the dataset by this way for SQL mode
if (EIndicatorChartType.BENFORD_LAW_STATISTICS.equals(chartType)) {
dataset = TOPChartUtils.getInstance().getDatasetFromChart(chart, 2);
if (dataset == null) {
dataset = TOPChartUtils.getInstance().getDatasetFromChart(chart, 1);
}
dyModel.setSecondDataset(TOPChartUtils.getInstance().getDatasetFromChart(chart, 0));
} else {
dataset = TOPChartUtils.getInstance().getDatasetFromChart(chart, 1);
if (dataset == null) {
dataset = TOPChartUtils.getInstance().getDatasetFromChart(chart, -1);
}
}
}
} else {
chart = chartTypeState.getChart(dataset);
}
dyModel.setDataset(dataset);
if (chart != null) {
if (!isPattern) {
// need not to decorate the chart of Pattern(Regex/Sql/UdiMatch)
TOPChartUtils.getInstance().decorateChart(chart, false);
} else {
TOPChartUtils.getInstance().decoratePatternMatching(chart);
}
Object chartComposite = TOPChartUtils.getInstance().createTalendChartComposite(composite, SWT.NONE, chart, true);
dyModel.setBawParentChartComp(chartComposite);
Map<String, Object> menuMap = createMenuForAllDataEntity((Composite) chartComposite, dataExplorer, analysis, ((ICustomerDataset) chartTypeState.getDataset()).getDataEntities());
// call chart service to create related mouse listener
if (EIndicatorChartType.BENFORD_LAW_STATISTICS.equals(chartType) || EIndicatorChartType.FREQUENCE_STATISTICS.equals(chartType)) {
TOPChartUtils.getInstance().addMouseListenerForChart(chartComposite, menuMap, false);
} else {
TOPChartUtils.getInstance().addMouseListenerForChart(chartComposite, menuMap, true);
}
}
}
// TDQ-11886 add these 2 catches.make it continue to work even if encounter some problems.
} catch (Error e) {
// $NON-NLS-1$
log.error(DefaultMessagesImpl.getString("IndicatorPaginationInfo.FailToCreateChart"), e);
} catch (Exception exp) {
// $NON-NLS-1$
log.error(DefaultMessagesImpl.getString("IndicatorPaginationInfo.FailToCreateChart"), exp);
}
subComp.setClient(composite);
subComp.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent e) {
form.reflow(true);
}
});
masterPage.registerSection(subComp);
}
use of org.eclipse.ui.forms.events.ExpansionAdapter in project tdq-studio-se by Talend.
the class BusinessRuleAnalysisResultPage method createResultSection.
@Override
protected void createResultSection(Composite parent) {
// ADD gdbu 2011-3-4 bug 19242
AbstractPagePart treeViewer = masterPage.getTreeViewer();
if (treeViewer != null && treeViewer instanceof AnalysisTableTreeViewer) {
tableTreeViewer = (AnalysisTableTreeViewer) treeViewer;
}
// ~
// $NON-NLS-1$
resultSection = createSection(form, parent, DefaultMessagesImpl.getString("TableAnalysisResultPage.analysisResult"), null);
sectionClient = toolkit.createComposite(resultSection);
sectionClient.setLayout(new GridLayout());
sectionClient.setLayoutData(new GridData(GridData.FILL_BOTH));
dynamicList.clear();
for (final TableIndicator tableIndicator : tableTreeViewer.getTableIndicator()) {
ExpandableComposite exComp = toolkit.createExpandableComposite(sectionClient, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.EXPANDED);
// bug 10541 fix by zshen,Change some character set to be proper to add view in the table anasys
if (tableIndicator.isTable()) {
exComp.setText(DefaultMessagesImpl.getString("TableAnalysisResultPage.table", // $NON-NLS-1$
tableIndicator.getColumnSet().getName()));
} else {
exComp.setText(DefaultMessagesImpl.getString("TableAnalysisResultPage.view", // $NON-NLS-1$
tableIndicator.getColumnSet().getName()));
}
exComp.setLayout(new GridLayout());
exComp.setLayoutData(new GridData(GridData.FILL_BOTH));
// MOD xqliu 2009-06-23 bug 7481
exComp.setExpanded(EditorPreferencePage.isUnfoldingAnalyzedEelementsResultPage());
// ~
final Composite comp = toolkit.createComposite(exComp);
comp.setLayout(new GridLayout());
comp.setLayoutData(new GridData(GridData.FILL_BOTH));
exComp.setClient(comp);
createResultDataComposite(comp, tableIndicator);
exComp.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent e) {
form.reflow(true);
}
});
}
resultSection.setClient(sectionClient);
}
use of org.eclipse.ui.forms.events.ExpansionAdapter in project tdq-studio-se by Talend.
the class AbstractFormPage method createSection.
/**
* DOC bZhou Comment method "createSection".
*
* @param form
* @param parent
* @param title
* @param description
* @return
*/
public Section createSection(final ScrolledForm form, Composite parent, String title, String description) {
int style = Section.DESCRIPTION | Section.TWISTIE | Section.TITLE_BAR | Section.LEFT_TEXT_CLIENT_ALIGNMENT;
if (description == null) {
style = Section.TWISTIE | Section.TITLE_BAR | Section.LEFT_TEXT_CLIENT_ALIGNMENT;
}
Section section = toolkit.createSection(parent, style);
section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
section.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent e) {
form.reflow(true);
}
});
section.setText(title);
section.setDescription(description);
section.setExpanded(getExpandedStatus(title));
registerSection(section);
sectionCount++;
return section;
}
use of org.eclipse.ui.forms.events.ExpansionAdapter in project titan.EclipsePlug-ins by eclipse.
the class ComponentsSubPage method createComponentsSection.
void createComponentsSection(final Composite parent, final ScrolledForm form, final FormToolkit toolkit) {
Section section = toolkit.createSection(parent, Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
section.setActiveToggleColor(toolkit.getHyperlinkGroup().getActiveForeground());
section.setToggleColor(toolkit.getColors().getColor(IFormColors.SEPARATOR));
Composite client = toolkit.createComposite(section, SWT.WRAP);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
client.setLayout(layout);
toolkit.paintBordersFor(client);
componentsTable = toolkit.createTable(client, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
componentsTable.setEnabled(componentsSectionHandler != null);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 100;
gd.heightHint = 200;
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.verticalAlignment = SWT.FILL;
componentsTable.setLayoutData(gd);
componentsTable.setLinesVisible(true);
componentsTable.setHeaderVisible(true);
TableColumn column = new TableColumn(componentsTable, SWT.LEFT, 0);
column.setText("Component name");
column.setWidth(130);
column.setMoveable(false);
column = new TableColumn(componentsTable, SWT.LEFT, 1);
column.setText("Host name");
column.setWidth(100);
column.setMoveable(false);
componentsTableViewer = new TableViewer(componentsTable);
componentsTableViewer.setContentProvider(new ComponentsDataContentProvider());
componentsTableViewer.setLabelProvider(new ComponentsDataLabelProvider());
componentsTableViewer.setInput(componentsSectionHandler);
componentsTableViewer.setColumnProperties(COLUMN_NAMES);
final TextCellEditor[] cellEditors = new TextCellEditor[] { new TextCellEditor(componentsTable), new TextCellEditor(componentsTable) };
componentsTableViewer.setCellEditors(cellEditors);
componentsTableViewer.setCellModifier(new ICellModifier() {
@Override
public boolean canModify(final Object element, final String property) {
return true;
}
@Override
public String getValue(final Object element, final String property) {
int columnIndex = Arrays.asList(COLUMN_NAMES).indexOf(property);
ComponentsDataLabelProvider labelProvider = (ComponentsDataLabelProvider) componentsTableViewer.getLabelProvider();
return labelProvider.getColumnText(element, columnIndex);
}
@Override
public void modify(final Object element, final String property, final Object value) {
int columnIndex = Arrays.asList(COLUMN_NAMES).indexOf(property);
if (element != null && element instanceof TableItem && value instanceof String) {
Component component = (Component) ((TableItem) element).getData();
switch(columnIndex) {
case 0:
ConfigTreeNodeUtilities.setText(component.getComponentName(), ((String) value).trim());
break;
case 1:
ConfigTreeNodeUtilities.setText(component.getHostName(), ((String) value).trim());
break;
default:
break;
}
componentsTableViewer.refresh(component);
editor.setDirty();
}
}
});
Composite buttons = toolkit.createComposite(client);
buttons.setLayout(new GridLayout());
buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.GRAB_VERTICAL));
add = toolkit.createButton(buttons, "Add...", SWT.PUSH);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
add.setLayoutData(gd);
add.setEnabled(componentsSectionHandler != null);
add.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (componentsSectionHandler == null) {
return;
}
if (componentsSectionHandler.getLastSectionRoot() == null) {
createNewComponentsSection();
}
Component newComponent = createNewComponent();
if (newComponent == null) {
return;
}
ConfigTreeNodeUtilities.addChild(componentsSectionHandler.getLastSectionRoot(), newComponent.getRoot());
componentsSectionHandler.getComponents().add(newComponent);
internalRefresh();
componentsTable.select(componentsSectionHandler.getComponents().size() - 1);
componentsTable.showSelection();
editor.setDirty();
}
});
remove = toolkit.createButton(buttons, "Remove", SWT.PUSH);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
remove.setLayoutData(gd);
remove.setEnabled(componentsSectionHandler != null);
remove.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (componentsTableViewer == null || componentsSectionHandler == null) {
return;
}
removeSelectedComponents();
if (componentsSectionHandler.getComponents().isEmpty()) {
removeComponentsSection();
}
internalRefresh();
editor.setDirty();
}
});
totalComponentsLabel = toolkit.createLabel(buttons, "Total: 0");
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
totalComponentsLabel.setLayoutData(gd);
section.setText("Components");
section.setDescription("Specify the list of remote components for this configuration.");
section.setClient(client);
section.setExpanded(true);
section.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(final ExpansionEvent e) {
form.reflow(false);
}
});
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
section.setLayoutData(gd);
final ComponentItemTransfer instance = ComponentItemTransfer.getInstance();
componentsTableViewer.addDragSupport(DND.DROP_COPY | DND.DROP_MOVE, new Transfer[] { instance }, new ComponentSectionDragSourceListener(this, componentsTableViewer));
componentsTableViewer.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_DEFAULT, new Transfer[] { instance }, new ComponentSectionDropTargetListener(componentsTableViewer, editor));
internalRefresh();
}
Aggregations