use of org.eclipse.ui.forms.events.IExpansionListener in project translationstudio8 by heartsome.
the class ConcordanceSearchDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
tparent = (Composite) super.createDialogArea(parent);
GridLayoutFactory.swtDefaults().spacing(0, 0).extendedMargins(SWT.DEFAULT, SWT.DEFAULT, 0, 0).applyTo(tparent);
// tparent.setLayout(new GridLayout());
GridData parentData = new GridData(GridData.FILL_BOTH);
parentData.widthHint = 1058;
tparent.setLayoutData(parentData);
Group groupSearch = new Group(tparent, SWT.NONE);
GridLayoutFactory.swtDefaults().margins(5, 5).numColumns(3).equalWidth(false).applyTo(groupSearch);
GridDataFactory.fillDefaults().grab(true, false).applyTo(groupSearch);
groupSearch.setText(Messages.getString("dialog.ConcordanceSearchDialog.groupSearch"));
Label lblSearch = new Label(groupSearch, SWT.NONE);
lblSearch.setText(Messages.getString("dialog.ConcordanceSearchDialog.lblSearch"));
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lblSearch);
cmbSearch = new Combo(groupSearch, SWT.BORDER | SWT.DROP_DOWN);
cmbSearch.setText(strSearchText == null ? "" : InnerTagUtil.resolveTag(strSearchText));
GridData txtData = new GridData();
// 解决在 Windows 下文本框高度太小的问题
// txtData.heightHint = 20;
txtData.widthHint = 610;
cmbSearch.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnSearch = new Button(groupSearch, SWT.PUSH);
btnSearch.setText(Messages.getString("dialog.ConcordanceSearchDialog.btnSearch"));
new Label(groupSearch, SWT.NONE);
Composite compCondition = new Composite(groupSearch, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).applyTo(compCondition);
GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(compCondition);
btnIsCaseSensitive = new Button(compCondition, SWT.CHECK);
btnIsCaseSensitive.setText(Messages.getString("dialog.ConcordanceSearchDialog.btnIsCaseSensitive"));
GridDataFactory.swtDefaults().applyTo(btnIsCaseSensitive);
btnIsIgnoreMark = new Button(compCondition, SWT.CHECK);
btnIsIgnoreMark.setText(Messages.getString("dialog.ConcordanceSearchDialog.btnIsIgnoreMark"));
btnIsIgnoreMark.setSelection(true);
GridDataFactory.swtDefaults().applyTo(btnIsIgnoreMark);
btnApplyRegularExpression = new Button(compCondition, SWT.CHECK);
btnApplyRegularExpression.setText(Messages.getString("dialog.ConcordanceSearchDialog.btnApplyRegularExpression"));
GridDataFactory.swtDefaults().applyTo(btnApplyRegularExpression);
Label lblTM = new Label(groupSearch, SWT.NONE);
lblTM.setText(Messages.getString("dialog.ConcordanceSearchDialog.lblDB"));
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lblTM);
Composite compDB = new Composite(groupSearch, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(compDB);
GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(compDB);
cmbDatabase = new Combo(compDB, SWT.READ_ONLY);
GridDataFactory.swtDefaults().hint(150, SWT.DEFAULT).applyTo(cmbDatabase);
initDatabaseCombo();
btnSelectLang = new Button(compDB, SWT.RIGHT);
// GridData data = new GridData();
// data.widthHint = 150;
// data.heightHint = 27;
// btnSelectLang.setLayoutData(data);
// btnSelectLang.setImage(Activator.getImageDescriptor(ImageConstants.CONCORDANCE_SELECT_LANG).createImage());
// btnSelectLang.addPaintListener(new PaintListener() {
// public void paintControl(PaintEvent e) {
// e.gc.drawText(Messages.getString("dialog.ConcordanceSearchDialog.btnSelectLang"), 5, 5,
// SWT.DRAW_TRANSPARENT);
// }
// });
btnSelectLang.setText(Messages.getString("dialog.ConcordanceSearchDialog.btnSelectLang"));
initLanguageMenu();
FormToolkit toolkit = new FormToolkit(parent.getDisplay());
Group groupFilter = new Group(tparent, SWT.None);
GridLayoutFactory.swtDefaults().margins(5, 5).applyTo(groupFilter);
GridDataFactory.fillDefaults().grab(true, false).applyTo(groupFilter);
groupFilter.setText(Messages.getString("dialog.ConcordanceSearchDialog.groupFilter"));
cmpExpandableFilter = toolkit.createExpandableComposite(groupFilter, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE);
cmpExpandableFilter.setText(Messages.getString("dialog.ConcordanceSearchDialog.cmpExpandableFilter"));
Composite cmpFilter = toolkit.createComposite(cmpExpandableFilter);
cmpFilter.setLayout(new GridLayout(3, false));
GridDataFactory.fillDefaults().grab(true, false).applyTo(cmpFilter);
cmpExpandableFilter.setBackground(tparent.getBackground());
cmpExpandableFilter.setClient(cmpFilter);
cmpFilter.setBackground(tparent.getBackground());
cmbSrcOrTgt = new Combo(cmpFilter, SWT.READ_ONLY);
GridDataFactory.swtDefaults().hint(100, SWT.DEFAULT).applyTo(cmbSrcOrTgt);
cmbSrcOrTgt.setItems(new String[] { Messages.getString("dialog.ConcordanceSearchDialog.cmbSrcOrTgt1"), Messages.getString("dialog.ConcordanceSearchDialog.cmbSrcOrTgt2") });
cmbSrcOrTgt.setData(Messages.getString("dialog.ConcordanceSearchDialog.cmbSrcOrTgt1"), strSrcLang);
cmbSrcOrTgt.setData(Messages.getString("dialog.ConcordanceSearchDialog.cmbSrcOrTgt2"), strTgtLang);
cmbContain = new Combo(cmpFilter, SWT.READ_ONLY);
GridDataFactory.swtDefaults().hint(100, SWT.DEFAULT).applyTo(cmbContain);
cmbContain.setItems(new String[] { Messages.getString("dialog.ConcordanceSearchDialog.cmbContain1"), Messages.getString("dialog.ConcordanceSearchDialog.cmbContain2") });
cmbContain.setData(Messages.getString("dialog.ConcordanceSearchDialog.cmbContain1"), "LIKE");
cmbContain.setData(Messages.getString("dialog.ConcordanceSearchDialog.cmbContain2"), "NOT LIKE");
cmbFilter = new Combo(cmpFilter, SWT.BORDER | SWT.DROP_DOWN);
GridDataFactory.swtDefaults().hint(410, SWT.DEFAULT).applyTo(cmbFilter);
cmpExpandableFilter.setExpanded(false);
groupTable = new Group(tparent, SWT.None);
GridLayoutFactory.swtDefaults().margins(5, 5).spacing(0, 2).numColumns(1).equalWidth(false).applyTo(groupTable);
GridDataFactory.fillDefaults().hint(740, 450).applyTo(groupTable);
groupTable.setText(Messages.getString("dialog.ConcordanceSearchDialog.groupTable"));
groupTable.setBackground(groupTable.getParent().getBackground());
groupTable.setBackgroundMode(SWT.INHERIT_FORCE);
cmpExpandableFilter.addExpansionListener(new IExpansionListener() {
public void expansionStateChanging(ExpansionEvent e) {
layoutExpandable();
}
public void expansionStateChanged(ExpansionEvent e) {
layoutExpandable();
}
});
jTable = new JaretTable(groupTable, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL) {
public void rowSelectionAdded(IRow row) {
super.rowSelectionAdded(row);
// XPropRow propRow = (XPropRow) row;
// HashMap<String, String> map = (HashMap<String, String>) propRow.getDataMap();
// String strChangeDate = map.get("changeDate");
// // strChangeDate = checkString(strChangeDate == null || strChangeDate.equals("") ? "" :
// CommonFunctions
// // .retGMTdate(strChangeDate));
// strChangeDate = checkString(strChangeDate == null || strChangeDate.equals("") ? "" : strChangeDate);
// String strChangeId = checkString(map.get("changeId"));
// String strDbInfo = checkString(map.get("dbType")) + "/" + checkString(map.get("severName")) + "/"
// + checkString(map.get("dbName"));
// String strProjectInfo = checkString(map.get("projectRef"));
// String strJobInfo = checkString(map.get("jobRef"));
// MessageFormat mf = new MessageFormat(strMsg);
// lblInfo.setText(mf.format(new String[] { strChangeDate, strChangeId, strDbInfo, strProjectInfo,
// strJobInfo }));
}
};
jTable.setLayoutData(new GridData(GridData.FILL_BOTH));
((DefaultTableHeaderRenderer) jTable.getHeaderRenderer()).setAlignment(DefaultTableHeaderRenderer.Alignment.LEFT);
jTable.setHeaderResizeAllowed(false);
jTable.setAllowSorting(false);
jTable.registerCellEditor(String.class, new ReadOnlyTextCellEditor(true));
PropListeningTableModel model = new PropListeningTableModel();
ListPropCol colTag = new ListPropCol("Flag", Messages.getString("dialog.ConcordanceSearchDialog.colTag"), "Flag", -1);
model.addColumn(colTag);
jTable.getTableViewState().setColumnWidth(colTag, 55);
if (strSrcLang != null) {
PropCol ct1 = new PropCol("Source", strSrcLang, "Source");
ct1.setEditable(false);
model.addColumn(ct1);
jTable.getTableViewState().setColumnWidth(ct1, 325);
}
if (strTgtLang != null) {
PropCol col = new PropCol("Target", strTgtLang, "Target");
model.addColumn(col);
jTable.getTableViewState().setColumnWidth(col, 325);
}
for (int i = 0; i < lstLangs.size(); i++) {
String strLang = lstLangs.get(i);
ListPropCol col = new ListPropCol("Target", strLang, "LstTarget", i);
col.setEditable(true);
model.addColumn(col);
jTable.getTableViewState().setColumnWidth(col, 0);
}
PropCol attrCol = new PropCol("Attribute", "Attribute", "Attribute");
attrCol.setEditable(false);
model.addColumn(attrCol);
jTable.getTableViewState().setColumnWidth(attrCol, 325);
tableModel = model;
jTable.setHeaderHeight(20);
jTable.setTableModel(tableModel);
jTable.setDrawHeader(true);
// jTable.getTableViewState().setRowHeightMode(ITableViewState.RowHeightMode.VARIABLE);
jTable.registerCellRenderer(tableModel.getColumn(2), new TextCellRenderer());
colCount = jTable.getColumnCount();
for (int colNum = colCount - 2; colNum >= 3; colNum--) {
IColumn column = jTable.getColumn(colNum);
jTable.registerCellRenderer(tableModel.getColumn(colNum), new TextCellRenderer());
jTable.getTableViewState().setColumnVisible(column, false);
}
ImageCellRender imgRender = new ImageCellRender();
// 表示需要删除标记(记录有标记时要显示的图片)
imgRender.addImageDescriptorMapping(Boolean.FALSE, "1", Activator.getImageDescriptor(ImageConstants.TAG_DELETE));
// 表示需要添加标记(记录有标记时要显示的图片)
imgRender.addImageDescriptorMapping(Boolean.TRUE, "2", Activator.getImageDescriptor(ImageConstants.TAG_ADD));
jTable.registerCellRenderer(tableModel.getColumn(0), imgRender);
jTable.getSelectionModel().setOnlyRowSelectionAllowed(true);
jTable.getSelectionModel().setMultipleSelectionAllowed(false);
Composite cmpPage = new Composite(groupTable, SWT.NONE);
GridLayoutFactory.fillDefaults().spacing(3, 0).extendedMargins(0, 5, 0, 0).numColumns(3).equalWidth(false).applyTo(cmpPage);
cmpPage.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
cmpPage.setBackground(cmpPage.getParent().getBackground());
cmpPage.setBackgroundMode(SWT.INHERIT_FORCE);
new Label(cmpPage, SWT.None).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
ToolBar toolBar = new ToolBar(cmpPage, SWT.NO_FOCUS | SWT.FLAT);
btnFirst = new ToolItem(toolBar, SWT.PUSH);
btnFirst.setImage(firstImage);
btnPre = new ToolItem(toolBar, SWT.NONE);
btnPre.setImage(preImage);
btnNext = new ToolItem(toolBar, SWT.NONE);
btnNext.setImage(nextImage);
btnLast = new ToolItem(toolBar, SWT.NONE);
btnLast.setImage(lastImage);
txtPage = new Text(cmpPage, SWT.BORDER);
GridDataFactory.fillDefaults().hint(80, SWT.DEFAULT).applyTo(txtPage);
readDialogSettings();
updateCombo(cmbSearch, lstSearchHistory);
updateCombo(cmbFilter, lstFilterHistory);
if (!strSearchText.equals("")) {
cmbSearch.setText(strSearchText);
} else if (lstSearchHistory != null && lstSearchHistory.size() > 0) {
cmbSearch.setText(lstSearchHistory.get(0));
}
cmbSearch.setSelection(new Point(0, cmbSearch.getText().length()));
if (lstFilterHistory != null && lstFilterHistory.size() > 0) {
cmbFilter.setText(lstFilterHistory.get(0));
cmbFilter.setSelection(new Point(0, cmbFilter.getText().length()));
}
initListener();
return parent;
}
use of org.eclipse.ui.forms.events.IExpansionListener in project eclipse-integration-commons by spring-projects.
the class ExpandableSection method createContents.
@Override
public void createContents(final Composite page) {
final ExpandableComposite comp = new ExpandableComposite(page, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, false).applyTo(comp);
comp.setText(title);
comp.setLayout(new FillLayout());
comp.addExpansionListener(new IExpansionListener() {
public void expansionStateChanging(ExpansionEvent e) {
}
@Override
public void expansionStateChanged(ExpansionEvent e) {
expansionState.setValue(comp.isExpanded());
reflow(owner, comp);
}
});
expansionState.addListener(new ValueListener<Boolean>() {
public void gotValue(LiveExpression<Boolean> exp, Boolean value) {
if (value != null && comp != null && !comp.isDisposed()) {
boolean newState = value;
boolean currentState = comp.isExpanded();
if (currentState != newState) {
comp.setExpanded(newState);
reflow(owner, comp);
}
}
}
});
visibleState.addListener(new ValueListener<Boolean>() {
@Override
public void gotValue(LiveExpression<Boolean> exp, Boolean value) {
if (value != null && comp != null && !comp.isDisposed()) {
boolean newState = value;
comp.setVisible(newState);
GridData data = (GridData) comp.getLayoutData();
data.exclude = !newState;
reflow(owner, comp);
}
}
});
Composite client = new Composite(comp, SWT.NONE);
client.setLayout(new GridLayout());
child.createContents(client);
comp.setClient(client);
}
use of org.eclipse.ui.forms.events.IExpansionListener in project netxms by netxms.
the class AlarmDetails method createDataSection.
/**
* Create data section
*/
private void createDataSection() {
final Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR | Section.EXPANDED | Section.TWISTIE | Section.COMPACT);
section.setText(Messages.get().AlarmDetails_LastValues);
final GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
section.setLayoutData(gd);
section.addExpansionListener(new IExpansionListener() {
@Override
public void expansionStateChanging(ExpansionEvent e) {
gd.grabExcessVerticalSpace = e.getState();
}
@Override
public void expansionStateChanged(ExpansionEvent e) {
}
});
dataArea = toolkit.createComposite(section);
section.setClient(dataArea);
dataArea.setLayout(new FillLayout());
}
use of org.eclipse.ui.forms.events.IExpansionListener in project netxms by netxms.
the class AlarmDetails method createEventsSection.
/**
* Create events section
*/
private void createEventsSection() {
final Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR | Section.EXPANDED | Section.TWISTIE | Section.COMPACT);
section.setText(Messages.get().AlarmDetails_RelatedEvents);
final GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
section.setLayoutData(gd);
section.addExpansionListener(new IExpansionListener() {
@Override
public void expansionStateChanging(ExpansionEvent e) {
gd.grabExcessVerticalSpace = e.getState();
}
@Override
public void expansionStateChanged(ExpansionEvent e) {
}
});
final Composite content = toolkit.createComposite(section);
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
content.setLayout(layout);
section.setClient(content);
final String[] names = { Messages.get().AlarmDetails_Column_Severity, Messages.get().AlarmDetails_Column_Source, Messages.get().AlarmDetails_Column_Name, Messages.get().AlarmDetails_Column_Message, Messages.get().AlarmDetails_Column_Timestamp };
final int[] widths = { 130, 160, 160, 400, 150 };
eventViewer = new SortableTreeViewer(content, names, widths, EV_COLUMN_TIMESTAMP, SWT.DOWN, SWT.BORDER | SWT.FULL_SELECTION);
eventViewer.setContentProvider(new EventTreeContentProvider());
eventViewer.setLabelProvider(new EventTreeLabelProvider());
eventViewer.setComparator(new EventTreeComparator());
eventViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
final IDialogSettings settings = Activator.getDefault().getDialogSettings();
// $NON-NLS-1$
WidgetHelper.restoreTreeViewerSettings(eventViewer, settings, "AlarmDetails.Events");
eventViewer.getControl().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
// $NON-NLS-1$
WidgetHelper.saveTreeViewerSettings(eventViewer, settings, "AlarmDetails.Events");
}
});
}
use of org.eclipse.ui.forms.events.IExpansionListener in project jbosstools-openshift by jbosstools.
the class BuildConfigWizardPage method doCreateControls.
@Override
protected void doCreateControls(Composite parent, DataBindingContext dbc) {
GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(parent);
GridLayoutFactory.fillDefaults().applyTo(parent);
Group buildConfigsGroup = new Group(parent, SWT.NONE);
buildConfigsGroup.setText("Existing Build Configs:");
GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).applyTo(buildConfigsGroup);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(buildConfigsGroup);
// build configs tree
TreeViewer buildConfigsViewer = createBuildConfigsViewer(new Tree(buildConfigsGroup, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL), model, dbc);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(SWT.DEFAULT, 200).span(1, 2).applyTo(buildConfigsViewer.getControl());
final IObservableValue selectedItem = BeanProperties.value(IBuildConfigPageModel.PROPERTY_SELECTED_ITEM).observe(model);
Binding selectedBuildConfigBinding = ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(buildConfigsViewer)).converting(new ObservableTreeItem2ModelConverter()).to(selectedItem).converting(new Model2ObservableTreeItemConverter()).in(dbc);
dbc.addValidationStatusProvider(new MultiValidator() {
@Override
protected IStatus validate() {
if (!(selectedItem.getValue() instanceof IBuildConfig)) {
return ValidationStatus.cancel("Please select the existing build config that you want to import");
} else {
return ValidationStatus.ok();
}
}
});
IObservableValue connectionObservable = BeanProperties.value(IBuildConfigPageModel.PROPERTY_CONNECTION).observe(model);
DataBindingUtils.addDisposableValueChangeListener(onConnectionChanged(buildConfigsViewer, model), connectionObservable, buildConfigsViewer.getTree());
ControlDecorationSupport.create(selectedBuildConfigBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
// refresh button
Button refreshButton = new Button(buildConfigsGroup, SWT.PUSH);
refreshButton.setText("&Refresh");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(100, SWT.DEFAULT).applyTo(refreshButton);
refreshButton.addSelectionListener(onRefresh(buildConfigsViewer, model));
// filler
Label fillerLabel = new Label(buildConfigsGroup, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(false, true).applyTo(fillerLabel);
// details
ExpandableComposite expandable = new ExpandableComposite(buildConfigsGroup, SWT.None);
GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, false).hint(SWT.DEFAULT, 150).applyTo(expandable);
expandable.setText("Build config Details");
expandable.setExpanded(true);
GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).spacing(0, 0).applyTo(expandable);
GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, false).hint(SWT.DEFAULT, 150).applyTo(expandable);
Composite detailsContainer = new Composite(expandable, SWT.NONE);
GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, false).hint(SWT.DEFAULT, 150).applyTo(detailsContainer);
IObservableValue selectedService = new WritableValue();
ValueBindingBuilder.bind(selectedItem).to(selectedService).notUpdatingParticipant().in(dbc);
new BuildConfigDetailViews(selectedService, detailsContainer, dbc).createControls();
expandable.setClient(detailsContainer);
expandable.addExpansionListener(new IExpansionListener() {
@Override
public void expansionStateChanging(ExpansionEvent e) {
}
@Override
public void expansionStateChanged(ExpansionEvent e) {
buildConfigsGroup.update();
buildConfigsGroup.layout(true);
}
});
loadBuildConfigs(model);
}
Aggregations