use of org.eclipse.swt.layout.GridData in project translationstudio8 by heartsome.
the class TSWizardDialog method setButtonLayoutData.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.Dialog#setButtonLayoutData(org.eclipse.swt.widgets.Button)
*/
protected void setButtonLayoutData(Button button) {
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
// On large fonts this can make this dialog huge
widthHint = Math.min(widthHint, button.getDisplay().getBounds().width / 5);
Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
data.widthHint = Math.max(widthHint, minSize.x);
button.setLayoutData(data);
}
use of org.eclipse.swt.layout.GridData in project translationstudio8 by heartsome.
the class ExportFilterComposite method addComponent.
/**
* 增加一个组件
* @param parent
* 组件容器
* @param bean
* {@link ExportFilterComponentBean};
*/
public void addComponent(Composite parent, ExportFilterComponentBean bean) {
Integer number = (Integer) parent.getData("currentNumber") + 1;
parent.setData("currentNumber", number);
if (number == 2) {
Control c = parent.getChildren()[0];
if (c instanceof ExportFilterComposite) {
ExportFilterComposite temp = (ExportFilterComposite) c;
temp.setDeleteButtonEnabled(true);
}
}
ExportFilterComposite tempComponent = new ExportFilterComposite(parent, SWT.None, this.ruleType, bean);
tempComponent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
}
use of org.eclipse.swt.layout.GridData in project translationstudio8 by heartsome.
the class ExportFilterComposite method createContent.
/** 创建控件 */
private void createContent() {
setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
GridLayout gridLayout = new GridLayout(5, false);
gridLayout.horizontalSpacing = 2;
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 0;
setLayout(gridLayout);
conditionComboViewer = new ComboViewer(this, SWT.NONE | SWT.READ_ONLY);
Combo conditionCombo = conditionComboViewer.getCombo();
GridData gdConditionCombo = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
gdConditionCombo.widthHint = 200;
conditionCombo.setLayoutData(gdConditionCombo);
conditionComboViewer.setContentProvider(new ArrayContentProvider());
conditionComboViewer.setInput(filterNames);
conditionComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
if (sel.isEmpty()) {
return;
}
baseDataBean.setOptionName((String) sel.getFirstElement());
handlerFilterChangedEvent();
opratorComboViewer.setInput(baseDataBean.getCurrentFilterExpressions());
// 默认选中第一个
opratorComboViewer.getCombo().select(0);
baseDataBean.setCurrentExpression(opratorComboViewer.getCombo().getText());
}
});
opratorComboViewer = new ComboViewer(this, SWT.NONE | SWT.READ_ONLY);
Combo opratorCombo = opratorComboViewer.getCombo();
GridData gd_opratorCombo = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
gd_opratorCombo.widthHint = 100;
opratorCombo.setLayoutData(gd_opratorCombo);
opratorComboViewer.setContentProvider(new ArrayContentProvider());
opratorComboViewer.setInput(this.baseDataBean.getCurrentFilterExpressions());
opratorComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
if (sel.isEmpty()) {
return;
}
baseDataBean.setCurrentExpression((String) sel.getFirstElement());
}
});
dynaComposite = new Composite(this, SWT.NONE);
dynaComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
GridLayout gldynaComposite = new GridLayout(1, false);
gldynaComposite.marginWidth = 0;
gldynaComposite.marginHeight = 0;
dynaComposite.setLayout(gldynaComposite);
valueText = new Text(dynaComposite, SWT.BORDER);
valueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
addButton = new Button(this, SWT.NONE);
GridData gdAddButton = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gdAddButton.widthHint = 25;
addButton.setLayoutData(gdAddButton);
addButton.setText("+");
addButton.addListener(SWT.Selection, this);
deleteButton = new Button(this, SWT.NONE);
GridData gdDeletebutton = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gdDeletebutton.widthHint = 25;
deleteButton.setLayoutData(gdDeletebutton);
deleteButton.setText("-");
deleteButton.addListener(SWT.Selection, this);
}
use of org.eclipse.swt.layout.GridData in project translationstudio8 by heartsome.
the class ExportFilterComposite method handlerFilterChangedEvent.
/**
* 处理过滤条件发生变化时动态创建组件 ;
*/
private void handlerFilterChangedEvent() {
String optionName = baseDataBean.getOptionName();
String value = baseDataBean.getFilterVlaue();
if (optionName.equals(Messages.getString("dialog.ExportFilterComposite.creationDate")) || optionName.equals(Messages.getString("dialog.ExportFilterComposite.changeDate"))) {
if (!valueText.isDisposed()) {
valueText.dispose();
}
DateTime valueTextDateTime = new DateTime(dynaComposite, SWT.DATE | SWT.BORDER);
if (value != null) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
try {
Calendar c = Calendar.getInstance();
c.setTime(df.parse(value));
valueTextDateTime.setDate(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DATE));
} catch (Exception ex) {
ex.printStackTrace();
}
}
valueText = valueTextDateTime;
} else {
if (!valueText.isDisposed()) {
valueText.dispose();
}
valueText = new Text(dynaComposite, SWT.BORDER);
if (value != null) {
((Text) valueText).setText(value);
}
}
valueText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
dynaComposite.layout(true);
}
use of org.eclipse.swt.layout.GridData in project translationstudio8 by heartsome.
the class ExportFilterSettingDialog method initData.
private void initData() {
if (this.currentFilter != null) {
Control[] c = dynaComposite.getChildren();
for (int i = 0; i < c.length; i++) {
c[i].dispose();
}
filterNameText.setText(currentFilter.getFilterName());
String filterConnector = currentFilter.getFilterConnector();
if (filterConnector.equals("AND")) {
isAllCbtn.setSelection(true);
isAnyCbtn.setSelection(false);
} else {
isAllCbtn.setSelection(false);
isAnyCbtn.setSelection(true);
}
List<ExportFilterComponentBean> optionList = currentFilter.getFilterOption();
if (optionList.size() > 0) {
ExportFilterComponentBean bean = optionList.get(0);
ExportFilterComposite exportFilterComponent = new ExportFilterComposite(dynaComposite, SWT.None, ruleType, bean);
exportFilterComponent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
exportFilterComponent.setDeleteButtonEnabled(false);
dynaComposite.setData("currentNumber", 1);
for (int i = 1; i < optionList.size(); i++) {
bean = optionList.get(i);
exportFilterComponent.addComponent(dynaComposite, bean);
}
}
}
}
Aggregations