Search in sources :

Example 86 with GridData

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);
}
Also used : GridData(org.eclipse.swt.layout.GridData) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Example 87 with GridData

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));
}
Also used : Control(org.eclipse.swt.widgets.Control) GridData(org.eclipse.swt.layout.GridData)

Example 88 with GridData

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);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Button(org.eclipse.swt.widgets.Button) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) Combo(org.eclipse.swt.widgets.Combo) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Text(org.eclipse.swt.widgets.Text) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 89 with GridData

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);
}
Also used : Calendar(java.util.Calendar) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text) SimpleDateFormat(java.text.SimpleDateFormat) DateTime(org.eclipse.swt.widgets.DateTime)

Example 90 with GridData

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);
            }
        }
    }
}
Also used : ExportFilterComponentBean(net.heartsome.cat.database.bean.ExportFilterComponentBean) Control(org.eclipse.swt.widgets.Control) GridData(org.eclipse.swt.layout.GridData) Point(org.eclipse.swt.graphics.Point)

Aggregations

GridData (org.eclipse.swt.layout.GridData)2385 GridLayout (org.eclipse.swt.layout.GridLayout)1659 Composite (org.eclipse.swt.widgets.Composite)1448 Label (org.eclipse.swt.widgets.Label)982 Button (org.eclipse.swt.widgets.Button)732 SelectionEvent (org.eclipse.swt.events.SelectionEvent)719 Text (org.eclipse.swt.widgets.Text)578 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)577 Group (org.eclipse.swt.widgets.Group)509 Combo (org.eclipse.swt.widgets.Combo)234 ModifyListener (org.eclipse.swt.events.ModifyListener)225 ModifyEvent (org.eclipse.swt.events.ModifyEvent)214 SelectionListener (org.eclipse.swt.events.SelectionListener)213 Table (org.eclipse.swt.widgets.Table)196 Point (org.eclipse.swt.graphics.Point)167 TableViewer (org.eclipse.jface.viewers.TableViewer)162 FillLayout (org.eclipse.swt.layout.FillLayout)134 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)118 Control (org.eclipse.swt.widgets.Control)117 Image (org.eclipse.swt.graphics.Image)114