Search in sources :

Example 6 with PixelConverter

use of org.eclipse.jface.layout.PixelConverter in project eclipse.platform.text by eclipse.

the class ScopePart method createPart.

/**
 * Creates this scope part.
 *
 * @param parent a widget which will be the parent of the new instance (cannot be null)
 * @return Returns the created part control
 */
public Composite createPart(Composite parent) {
    fPart = new Group(parent, SWT.NONE);
    fPart.setText(SearchMessages.ScopePart_group_text);
    GridLayout layout = new GridLayout();
    layout.numColumns = 4;
    fPart.setLayout(layout);
    fPart.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fUseWorkspace = new Button(fPart, SWT.RADIO);
    fUseWorkspace.setData(Integer.valueOf(ISearchPageContainer.WORKSPACE_SCOPE));
    fUseWorkspace.setText(SearchMessages.ScopePart_workspaceScope_text);
    fUseSelection = new Button(fPart, SWT.RADIO);
    fUseSelection.setData(Integer.valueOf(ISearchPageContainer.SELECTION_SCOPE));
    fUseSelection.setText(getSelectedResurcesButtonText());
    boolean canSearchInSelection = canSearchInSelection();
    fUseSelection.setEnabled(canSearchInSelection);
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gd.horizontalIndent = 8;
    fUseSelection.setLayoutData(gd);
    fUseProject = new Button(fPart, SWT.RADIO);
    fUseProject.setData(Integer.valueOf(ISearchPageContainer.SELECTED_PROJECTS_SCOPE));
    fUseProject.setText(getEnclosingProjectsButtonText());
    fUseProject.setEnabled(fSearchDialog.getEnclosingProjectNames().length > 0);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gd.horizontalSpan = 2;
    gd.horizontalIndent = 8;
    fUseProject.setLayoutData(gd);
    if (!fCanSearchEnclosingProjects)
        fUseProject.setVisible(false);
    fUseWorkingSet = new Button(fPart, SWT.RADIO);
    fUseWorkingSet.setData(Integer.valueOf(ISearchPageContainer.WORKING_SET_SCOPE));
    fUseWorkingSet.setText(SearchMessages.ScopePart_workingSetScope_text);
    fWorkingSetText = new Text(fPart, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
    fWorkingSetText.getAccessible().addAccessibleListener(new AccessibleAdapter() {

        @Override
        public void getName(AccessibleEvent e) {
            e.result = SearchMessages.ScopePart_workingSetText_accessible_label;
        }
    });
    Button chooseWorkingSet = new Button(fPart, SWT.PUSH);
    chooseWorkingSet.setLayoutData(new GridData());
    chooseWorkingSet.setText(SearchMessages.ScopePart_workingSetChooseButton_text);
    SWTUtil.setButtonDimensionHint(chooseWorkingSet);
    chooseWorkingSet.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (handleChooseWorkingSet()) {
                setSelectedScope(ISearchPageContainer.WORKING_SET_SCOPE);
            }
        }
    });
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalIndent = 8;
    gd.horizontalSpan = 2;
    gd.widthHint = new PixelConverter(fWorkingSetText).convertWidthInCharsToPixels(30);
    fWorkingSetText.setLayoutData(gd);
    // Add scope change listeners
    SelectionAdapter scopeChangedLister = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            handleScopeChanged(e);
        }
    };
    fUseWorkspace.addSelectionListener(scopeChangedLister);
    fUseSelection.addSelectionListener(scopeChangedLister);
    fUseProject.addSelectionListener(scopeChangedLister);
    fUseWorkingSet.addSelectionListener(scopeChangedLister);
    // Set initial scope
    setSelectedScope(fScope);
    // Set initial working set
    if (fWorkingSets != null)
        fWorkingSetText.setText(toString(fWorkingSets));
    return fPart;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) PixelConverter(org.eclipse.jface.layout.PixelConverter) Text(org.eclipse.swt.widgets.Text) AccessibleAdapter(org.eclipse.swt.accessibility.AccessibleAdapter) AccessibleEvent(org.eclipse.swt.accessibility.AccessibleEvent)

Example 7 with PixelConverter

use of org.eclipse.jface.layout.PixelConverter in project eclipse.platform.text by eclipse.

the class AbstractTemplatesPage method createTemplateTree.

/**
 * Create the tree to display templates.
 *
 * @param parent the parent composite
 */
private void createTemplateTree(Composite parent) {
    Composite treeComposite = new Composite(parent, SWT.NONE);
    GridData data = new GridData(GridData.FILL_BOTH);
    treeComposite.setLayoutData(data);
    TreeColumnLayout columnLayout = new TreeColumnLayout();
    treeComposite.setLayout(columnLayout);
    fTemplatesTree = new Tree(treeComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
    fTemplatesTree.setHeaderVisible(true);
    fTemplatesTree.setLinesVisible(true);
    PixelConverter pixelConverter = new PixelConverter(fTemplatesTree);
    TreeColumn columnName = new TreeColumn(fTemplatesTree, SWT.NONE);
    columnName.setText(TemplatesMessages.TemplatesPage_column_name);
    int minWidth = fPreferenceStore.getInt(COLUMN_NAME_WIDTH_PREF_ID);
    if (minWidth == 0) {
        minWidth = pixelConverter.convertWidthInCharsToPixels(30);
    }
    columnLayout.setColumnData(columnName, new ColumnPixelData(minWidth, true));
    columnName.addControlListener(new ControlListener() {

        @Override
        public void controlMoved(ControlEvent e) {
        }

        @Override
        public void controlResized(ControlEvent e) {
            int nameWidth = ((TreeColumn) e.getSource()).getWidth();
            fPreferenceStore.setValue(COLUMN_NAME_WIDTH_PREF_ID, nameWidth);
        }
    });
    TreeColumn columnDescription = new TreeColumn(fTemplatesTree, SWT.NONE);
    columnDescription.setText(TemplatesMessages.TemplatesPage_column_description);
    minWidth = fPreferenceStore.getInt(COLUMN_DESCRIPTION_WIDTH_PREF_ID);
    if (minWidth == 0) {
        minWidth = pixelConverter.convertWidthInCharsToPixels(45);
    }
    columnLayout.setColumnData(columnDescription, new ColumnPixelData(minWidth, false));
    columnDescription.addControlListener(new ControlListener() {

        @Override
        public void controlMoved(ControlEvent e) {
        }

        @Override
        public void controlResized(ControlEvent e) {
            int descriptionWidth = ((TreeColumn) e.getSource()).getWidth();
            fPreferenceStore.setValue(COLUMN_DESCRIPTION_WIDTH_PREF_ID, descriptionWidth);
        }
    });
    createTreeViewer(fTemplatesTree);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) TreeColumnLayout(org.eclipse.jface.layout.TreeColumnLayout) TreeColumn(org.eclipse.swt.widgets.TreeColumn) GridData(org.eclipse.swt.layout.GridData) PixelConverter(org.eclipse.jface.layout.PixelConverter) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) Tree(org.eclipse.swt.widgets.Tree) ControlListener(org.eclipse.swt.events.ControlListener) ControlEvent(org.eclipse.swt.events.ControlEvent) Point(org.eclipse.swt.graphics.Point)

Example 8 with PixelConverter

use of org.eclipse.jface.layout.PixelConverter in project eclipse.platform.text by eclipse.

the class TextEditorDefaultsPreferencePage method addFiller.

private void addFiller(Composite composite, int horizontalSpan) {
    PixelConverter pixelConverter = new PixelConverter(composite);
    Label filler = new Label(composite, SWT.LEFT);
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = horizontalSpan;
    gd.heightHint = pixelConverter.convertHeightInCharsToPixels(1) / 2;
    filler.setLayoutData(gd);
}
Also used : PixelConverter(org.eclipse.jface.layout.PixelConverter) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData)

Example 9 with PixelConverter

use of org.eclipse.jface.layout.PixelConverter in project eclipse.platform.text by eclipse.

the class SWTUtil method getButtonWidthHint.

/**
 * Returns a width hint for the given button.
 *
 * @param button the button
 * @return the width hint for the button
 */
public static int getButtonWidthHint(Button button) {
    button.setFont(JFaceResources.getDialogFont());
    PixelConverter converter = new PixelConverter(button);
    int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
}
Also used : PixelConverter(org.eclipse.jface.layout.PixelConverter)

Example 10 with PixelConverter

use of org.eclipse.jface.layout.PixelConverter in project translationstudio8 by heartsome.

the class SelectGrantFileDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite tparent = (Composite) super.createDialogArea(parent);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 10;
    layout.marginTop = 10;
    tparent.setLayout(layout);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(tparent);
    Composite compNav = new Composite(tparent, SWT.NONE);
    GridLayout navLayout = new GridLayout();
    compNav.setLayout(navLayout);
    createNavigation(compNav);
    Group groupFile = new Group(tparent, SWT.NONE);
    groupFile.setText(Messages.getString("license.SelectGrantFileDialog.grantfile"));
    GridDataFactory.fillDefaults().grab(true, true).applyTo(groupFile);
    GridLayout layoutGroup = new GridLayout(3, false);
    layoutGroup.marginWidth = 5;
    layoutGroup.marginHeight = 100;
    groupFile.setLayout(layoutGroup);
    Label label = new Label(groupFile, SWT.NONE);
    label.setText(Messages.getString("license.SelectGrantFileDialog.grantfile1"));
    textPath = new Text(groupFile, SWT.BORDER);
    textPath.setEditable(false);
    GridData pathData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
    pathData.widthHint = new PixelConverter(textPath).convertWidthInCharsToPixels(25);
    textPath.setLayoutData(pathData);
    // browse button
    btnScan = new Button(groupFile, SWT.PUSH);
    btnScan.setText(Messages.getString("license.SelectGrantFileDialog.scan"));
    setButtonLayoutData(btnScan);
    btnScan.addSelectionListener(new SelectionAdapter() {

        /*
			 * (non-Javadoc)
			 * 
			 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse .swt.events.SelectionEvent)
			 */
        public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(textPath.getShell(), SWT.SHEET);
            dialog.setFilterExtensions(FILE_IMPORT_MASK);
            dialog.setText(Messages.getString("license.SelectGrantFileDialog.selectgrantfile"));
            String fileName = textPath.getText().trim();
            if (fileName.length() != 0) {
                File path = new File(fileName).getParentFile();
                if (path != null && path.exists()) {
                    dialog.setFilterPath(path.toString());
                }
            }
            String path = dialog.open();
            if (path != null) {
                textPath.setText(path);
            }
        }
    });
    return tparent;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) PixelConverter(org.eclipse.jface.layout.PixelConverter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File)

Aggregations

PixelConverter (org.eclipse.jface.layout.PixelConverter)19 GridData (org.eclipse.swt.layout.GridData)13 Label (org.eclipse.swt.widgets.Label)10 GridLayout (org.eclipse.swt.layout.GridLayout)8 Composite (org.eclipse.swt.widgets.Composite)8 SelectionEvent (org.eclipse.swt.events.SelectionEvent)6 Button (org.eclipse.swt.widgets.Button)5 Text (org.eclipse.swt.widgets.Text)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionListener (org.eclipse.swt.events.SelectionListener)3 Point (org.eclipse.swt.graphics.Point)3 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)2 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)2 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)2 FocusAdapter (org.eclipse.swt.events.FocusAdapter)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2 ModifyListener (org.eclipse.swt.events.ModifyListener)2 Container (java.awt.Container)1 Dimension (java.awt.Dimension)1 Frame (java.awt.Frame)1