Search in sources :

Example 36 with Composite

use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.

the class TableCombo method popupEvent.

/**
	 * Handles Popup Events
	 * @param event
	 */
private void popupEvent(Event event) {
    switch(event.type) {
        case SWT.Paint:
            // draw rectangle around table
            Rectangle tableRect = table.getBounds();
            event.gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));
            event.gc.drawRectangle(0, 0, tableRect.width + 1, tableRect.height + 1);
            break;
        case SWT.Close:
            event.doit = false;
            dropDown(false);
            break;
        case SWT.Deactivate:
            /*
			 * Bug in GTK. When the arrow button is pressed the popup control receives a deactivate event and then the
			 * arrow button receives a selection event. If we hide the popup in the deactivate event, the selection
			 * event will show it again. To prevent the popup from showing again, we will let the selection event of the
			 * arrow button hide the popup. In Windows, hiding the popup during the deactivate causes the deactivate to
			 * be called twice and the selection event to be disappear.
			 */
            if (!"carbon".equals(SWT.getPlatform())) {
                Point point = arrow.toControl(getDisplay().getCursorLocation());
                Point size = arrow.getSize();
                Rectangle rect = new Rectangle(0, 0, size.x, size.y);
                if (!rect.contains(point))
                    dropDown(false);
            } else {
                dropDown(false);
            }
            break;
        case SWT.Help:
            if (isDropped()) {
                dropDown(false);
            }
            Composite comp = TableCombo.this;
            do {
                if (comp.getListeners(event.type) != null && comp.getListeners(event.type).length > 0) {
                    comp.notifyListeners(event.type, event);
                    break;
                }
                comp = comp.getParent();
            } while (null != comp);
            break;
    }
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point)

Example 37 with Composite

use of org.eclipse.swt.widgets.Composite 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 38 with Composite

use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.

the class BrowserViewPart method createPartControl.

/**
	 * Create contents of the view part.
	 * @param parent
	 */
@Override
public void createPartControl(Composite parent) {
    urls = WebSearchPreferencStore.getIns().getUseredConfig();
    WebSearchPreferencStore.getIns().addProperChangeListener(urlChangelistener);
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.verticalSpacing = 0;
    container.setLayout(gridLayout);
    Composite seachArea = new Composite(container, SWT.NONE);
    createSearchArea(seachArea);
    Composite separatorCmp = new Composite(container, SWT.NONE);
    createSeparatorArea(separatorCmp);
    Composite displayArea = new Composite(container, SWT.NONE);
    createBrowserArea(displayArea);
    refreshContentJob = new ResfreshCurentTab();
    refreshContentJob.start();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite)

Example 39 with Composite

use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.

the class BrowserTab method createTabFolderPage.

public Composite createTabFolderPage(CTabFolder tabFolder) {
    tabFolderPage = new Composite(tabFolder, SWT.NONE);
    tabFolderPage.setLayout(new FillLayout());
    browser = new Browser(tabFolderPage, SWT.NONE);
    hookOpenListner();
    return tabFolderPage;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) FillLayout(org.eclipse.swt.layout.FillLayout) Browser(org.eclipse.swt.browser.Browser)

Example 40 with Composite

use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.

the class AddSearchEntryDialog method createDialogArea.

/**
	 * Create contents of the dialog.
	 * @param parent
	 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);
    container.setLayout(new GridLayout(1, false));
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = SWT.DEFAULT;
    gridData.widthHint = 450;
    container.setLayoutData(gridData);
    Composite nameSetArea = new Composite(container, SWT.NONE);
    GridLayout gridLayout = new GridLayout(2, false);
    nameSetArea.setLayout(gridLayout);
    nameSetArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Label nameLable = new Label(nameSetArea, SWT.NONE);
    GridData gd_nameLable = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_nameLable.widthHint = 38;
    nameLable.setLayoutData(gd_nameLable);
    nameLable.setText(Messages.getString("Websearch.AddSearchEntryDialog.NameLable"));
    nameText = new Text(nameSetArea, SWT.BORDER);
    nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    if (style == EDIT) {
        nameText.setText(searEntry.getSearchName());
    }
    nameText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            setOkState();
        }
    });
    Composite urlSetArea = new Composite(container, SWT.NONE);
    GridLayout gridLayout2 = new GridLayout(2, false);
    urlSetArea.setLayout(gridLayout2);
    urlSetArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Label urlLable = new Label(urlSetArea, SWT.NONE);
    GridData gd_urlLable = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_urlLable.widthHint = 38;
    urlLable.setLayoutData(gd_urlLable);
    urlLable.setText("URL");
    urlText = new Text(urlSetArea, SWT.BORDER);
    if (style == EDIT) {
        urlText.setText(searEntry.getSearchUrl());
    }
    urlText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    urlText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            setOkState();
        }
    });
    Composite setArea = new Composite(container, SWT.NONE);
    setArea.setLayout(new GridLayout(1, true));
    setArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Group group = new Group(setArea, SWT.NONE);
    group.setLayout(new GridLayout(2, true));
    group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    group.setText(Messages.getString("Websearch.AddSearchEntryDialog.GroupTitle"));
    btnYesRadioButton = new Button(group, SWT.RADIO);
    btnYesRadioButton.setText(Messages.getString("Websearch.AddSearchEntryDialog.GroupYes"));
    btnYesRadioButton.setSelection(true);
    btnYesRadioButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    btnNoRadioButton = new Button(group, SWT.RADIO);
    btnNoRadioButton.setText(Messages.getString("Websearch.AddSearchEntryDialog.GroupNo"));
    btnNoRadioButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    if (style == EDIT) {
        btnYesRadioButton.setSelection(searEntry.isChecked());
        btnNoRadioButton.setSelection(!searEntry.isChecked());
    }
    return container;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text)

Aggregations

Composite (org.eclipse.swt.widgets.Composite)2054 GridData (org.eclipse.swt.layout.GridData)1441 GridLayout (org.eclipse.swt.layout.GridLayout)1419 Label (org.eclipse.swt.widgets.Label)853 Button (org.eclipse.swt.widgets.Button)694 SelectionEvent (org.eclipse.swt.events.SelectionEvent)577 Text (org.eclipse.swt.widgets.Text)519 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)463 Group (org.eclipse.swt.widgets.Group)305 Combo (org.eclipse.swt.widgets.Combo)210 Point (org.eclipse.swt.graphics.Point)198 FillLayout (org.eclipse.swt.layout.FillLayout)188 ModifyListener (org.eclipse.swt.events.ModifyListener)186 SelectionListener (org.eclipse.swt.events.SelectionListener)183 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)182 ModifyEvent (org.eclipse.swt.events.ModifyEvent)168 Table (org.eclipse.swt.widgets.Table)159 TableViewer (org.eclipse.jface.viewers.TableViewer)153 Control (org.eclipse.swt.widgets.Control)149 ArrayList (java.util.ArrayList)107