Example usage for org.eclipse.jface.layout GridDataFactory createFrom

List of usage examples for org.eclipse.jface.layout GridDataFactory createFrom

Introduction

In this page you can find the example usage for org.eclipse.jface.layout GridDataFactory createFrom.

Prototype

public static GridDataFactory createFrom(GridData data) 

Source Link

Document

Creates a new GridDataFactory that creates copies of the given GridData by default.

Usage

From source file:bndtools.BundleSettingsWizardPage.java

License:Open Source License

public void createControl(Composite parent) {
    // Create controls
    Composite composite = new Composite(parent, SWT.NONE);

    // Basic Group
    Group grpBasic = new Group(composite, SWT.NONE);
    grpBasic.setText("Basic Settings");
    new Label(grpBasic, SWT.NONE).setText("Symbolic Name:");
    txtSymbolicName = new Text(grpBasic, SWT.BORDER);
    new Label(grpBasic, SWT.NONE).setText("Version:");
    txtVersion = new Text(grpBasic, SWT.BORDER);

    // Activator Group
    Group grpActivator = new Group(composite, SWT.NONE);
    grpActivator.setText("Activator");
    new Label(grpActivator, SWT.NONE).setText("Bundle Activator:");
    txtActivator = new Text(grpActivator, SWT.SINGLE | SWT.LEAD | SWT.BORDER);

    // Load initial values
    if (symbolicName != null) {
        txtSymbolicName.setText(symbolicName);
    }/* w  w  w.  j  av a 2 s  . c o  m*/
    if (version != null) {
        txtVersion.setText(version.toString());
    }

    setPageComplete(symbolicName != null && version != null);

    // Add listeners
    ModifyListener modifyListener = new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            updateFields();
        }
    };
    txtSymbolicName.addModifyListener(modifyListener);
    txtVersion.addModifyListener(modifyListener);

    // Layout
    GridDataFactory horizontalFill = GridDataFactory.createFrom(new GridData(SWT.FILL, SWT.FILL, true, false));

    composite.setLayout(new GridLayout(1, false));
    grpBasic.setLayoutData(horizontalFill.create());

    grpBasic.setLayout(new GridLayout(2, false));
    txtSymbolicName.setLayoutData(horizontalFill.create());
    txtVersion.setLayoutData(horizontalFill.create());

    // Set control
    setControl(composite);
}

From source file:ca.uvic.chisel.javasketch.ui.internal.presentation.properties.GeneralDetailsPropertySection.java

License:Open Source License

/**
 * /*ww w  .ja va 2  s .c om*/
 */
public GeneralDetailsPropertySection() {
    labelFactory = GridDataFactory.createFrom(new GridData(SWT.FILL, SWT.FILL, false, false));
    labelTextFactory = GridDataFactory.createFrom(new GridData(SWT.FILL, SWT.FILL, true, false));
}

From source file:ca.uvic.chisel.logging.eclipse.internal.ui.UploadWizardPage1.java

License:Open Source License

private Composite createCategoriesArea(Composite parent) {
    Composite categoriesArea = new Composite(parent, SWT.NONE);
    categoriesArea.setLayout(new GridLayout(2, false));

    //create a list viewer that will display all of the 
    //different loggers

    viewer = CheckboxTableViewer.newCheckList(categoriesArea, SWT.BORDER | SWT.SINGLE);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new LoggingCategoryLabelProvider());
    viewer.setInput(WorkbenchLoggingPlugin.getDefault().getCategoryManager().getCategories());
    //set all of the enabled categories to the checked state
    for (ILoggingCategory category : WorkbenchLoggingPlugin.getDefault().getCategoryManager().getCategories()) {
        selectedCategories.add(category.getCategoryID());
    }//from   ww w  .j a  v a2  s . c  o  m
    viewer.setAllChecked(true);
    viewer.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            if (event.getElement() instanceof ILoggingCategory) {
                ILoggingCategory category = (ILoggingCategory) event.getElement();
                if (event.getChecked()) {
                    selectedCategories.add(category.getCategoryID());
                } else {
                    selectedCategories.remove(category.getCategoryID());
                }
            }
        }
    });
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            if (aboutButton != null && !aboutButton.isDisposed()) {
                aboutButton.setEnabled(!event.getSelection().isEmpty());
            }
        }
    });

    viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    //create a button area
    Composite buttonArea = new Composite(categoriesArea, SWT.NONE);
    buttonArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    buttonArea.setLayout(new GridLayout());

    GridDataFactory gdf = GridDataFactory.createFrom(new GridData(SWT.FILL, SWT.FILL, true, false));
    Button selectAll = new Button(buttonArea, SWT.PUSH);
    selectAll.setText("Select All");
    selectAll.setLayoutData(gdf.create());
    selectAll.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            viewer.setAllChecked(true);
            for (ILoggingCategory category : WorkbenchLoggingPlugin.getDefault().getCategoryManager()
                    .getCategories()) {
                selectedCategories.add(category.getCategoryID());
            }
        }
    });

    Button selectNone = new Button(buttonArea, SWT.PUSH);
    selectNone.setText("Select None");
    selectNone.setLayoutData(gdf.create());
    selectNone.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            viewer.setAllChecked(false);
            selectedCategories.clear();
        }
    });

    Control spacer = new Composite(buttonArea, SWT.NONE);
    GridData d = gdf.create();
    d.heightHint = 40;
    spacer.setLayoutData(d);

    aboutButton = new Button(buttonArea, SWT.PUSH);
    aboutButton.setText("Disclaimer...");
    aboutButton.setLayoutData(gdf.create());
    aboutButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            ISelection selection = viewer.getSelection();
            if (selection instanceof IStructuredSelection) {
                IStructuredSelection ss = (IStructuredSelection) selection;
                if (!ss.isEmpty() && ss.getFirstElement() instanceof ILoggingCategory) {
                    AboutCategoryDialog dialog = new AboutCategoryDialog(getShell(),
                            (ILoggingCategory) ss.getFirstElement());
                    dialog.open();
                }
            }
        }
    });
    aboutButton.setEnabled(false);
    return categoriesArea;
}

From source file:ca.uvic.chisel.logging.eclipse.internal.ui.WorkbenchLoggerPreferencePage.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {
    Composite page = new Composite(parent, SWT.NONE);
    page.setLayout(new GridLayout(2, false));

    // create a list viewer that will display all of the
    // different loggers

    viewer = CheckboxTableViewer.newCheckList(page, SWT.BORDER | SWT.SINGLE);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new LoggingCategoryLabelProvider());
    viewer.setInput(WorkbenchLoggingPlugin.getDefault().getCategoryManager().getCategories());
    // set all of the enabled categories to the checked state
    boolean stale = false;
    for (ILoggingCategory category : WorkbenchLoggingPlugin.getDefault().getCategoryManager().getCategories()) {
        if (category.isEnabled()) {
            enabledCategories.add(category.getCategoryID());
            viewer.setChecked(category, true);
        }// w ww  .  ja v  a2s.  c  o  m
        // also set the stale state... used for enabling the upload button.
        stale |= ((LoggingCategory) category).isStale();
    }
    viewer.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            if (event.getElement() instanceof ILoggingCategory) {
                ILoggingCategory category = (ILoggingCategory) event.getElement();
                if (event.getChecked()) {
                    enabledCategories.add(category.getCategoryID());
                } else {
                    enabledCategories.remove(category.getCategoryID());
                }
            }
        }
    });
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            if (aboutButton != null && !aboutButton.isDisposed()) {
                aboutButton.setEnabled(!event.getSelection().isEmpty());
            }
        }
    });

    viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    // create a button area
    Composite buttonArea = new Composite(page, SWT.NONE);
    buttonArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    buttonArea.setLayout(new GridLayout());

    GridDataFactory gdf = GridDataFactory.createFrom(new GridData(SWT.FILL, SWT.FILL, true, false));
    Button selectAll = new Button(buttonArea, SWT.PUSH);
    selectAll.setText("Select All");
    selectAll.setLayoutData(gdf.create());
    selectAll.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            viewer.setAllChecked(true);
            for (ILoggingCategory category : WorkbenchLoggingPlugin.getDefault().getCategoryManager()
                    .getCategories()) {
                enabledCategories.add(category.getCategoryID());
            }
        }
    });

    Button selectNone = new Button(buttonArea, SWT.PUSH);
    selectNone.setText("Select None");
    selectNone.setLayoutData(gdf.create());
    selectNone.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            viewer.setAllChecked(false);
            enabledCategories.clear();
        }
    });

    Control spacer = new Composite(buttonArea, SWT.NONE);
    GridData d = gdf.create();
    d.heightHint = 40;
    spacer.setLayoutData(d);

    aboutButton = new Button(buttonArea, SWT.PUSH);
    aboutButton.setText("About...");
    aboutButton.setLayoutData(gdf.create());
    aboutButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            ISelection selection = viewer.getSelection();
            if (selection instanceof IStructuredSelection) {
                IStructuredSelection ss = (IStructuredSelection) selection;
                if (!ss.isEmpty() && ss.getFirstElement() instanceof ILoggingCategory) {
                    AboutCategoryDialog dialog = new AboutCategoryDialog(getShell(),
                            (ILoggingCategory) ss.getFirstElement());
                    dialog.open();
                }
            }
        }
    });
    aboutButton.setEnabled(false);

    spacer = new Composite(buttonArea, SWT.NONE);
    d = gdf.create();
    d.heightHint = 40;
    spacer.setLayoutData(d);

    Button uploadButton = new Button(buttonArea, SWT.PUSH);
    uploadButton.setText("Upload Now...");
    uploadButton.setLayoutData(gdf.create());
    uploadButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            WizardDialog dialog = new WizardDialog(getShell(), new UploadWizard());
            dialog.open();
        }
    });
    uploadButton.setEnabled(stale);
    Composite intervalComposite = new Composite(page, SWT.NONE);
    GridData gd = gdf.create();
    gd.grabExcessVerticalSpace = false;
    gd.grabExcessHorizontalSpace = true;
    intervalComposite.setLayoutData(gd);
    intervalComposite.setLayout(new GridLayout(2, false));
    Label intervalLabel = new Label(intervalComposite, SWT.NONE);
    intervalLabel.setText("Upload Interval: ");
    gd = gdf.create();
    gd.grabExcessVerticalSpace = false;
    gd.grabExcessHorizontalSpace = false;
    intervalLabel.setLayoutData(gd);
    intervalViewer = new ComboViewer(intervalComposite, SWT.BORDER | SWT.SINGLE);
    Long[] intervals = new Long[] { UploadJob.UPLOAD_INTERVAL_DAILY, UploadJob.UPLOAD_INTERVAL_WEEKLY,
            UploadJob.UPLOAD_INTERVAL_MONTHLY };
    intervalViewer.setContentProvider(new ArrayContentProvider());
    intervalViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            if (element instanceof Long) {
                long interval = (Long) element;
                if (interval == UploadJob.UPLOAD_INTERVAL_DAILY) {
                    return "Daily";
                } else if (interval == UploadJob.UPLOAD_INTERVAL_WEEKLY) {
                    return "Every Seven Days";
                } else if (interval == UploadJob.UPLOAD_INTERVAL_MONTHLY) {
                    return "Every Thirty Days";
                }
            }
            return super.getText(element);
        }
    });
    intervalViewer.setInput(intervals);
    long interval = WorkbenchLoggingPlugin.getDefault().getPreferenceStore()
            .getLong(UploadJob.UPLOAD_INTERVAL_KEY);
    if (interval <= 0) {
        interval = WorkbenchLoggingPlugin.getDefault().getPreferenceStore()
                .getDefaultLong(UploadJob.UPLOAD_INTERVAL_KEY);
    }
    intervalViewer.setSelection(new StructuredSelection(interval));
    intervalViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    spacer = new Composite(page, SWT.NONE);
    gd = gdf.create();
    gd.grabExcessVerticalSpace = false;
    gd.grabExcessHorizontalSpace = false;
    gd.heightHint = 2;
    spacer.setLayoutData(gd);
    Composite uidComposite = new Composite(page, SWT.NONE);
    uidComposite.setLayout(new GridLayout(2, false));
    gd = gdf.create();
    gd.grabExcessVerticalSpace = false;
    gd.grabExcessHorizontalSpace = false;
    gd.horizontalSpan = 2;
    uidComposite.setLayoutData(gd);
    Label uidLabel = new Label(uidComposite, SWT.NONE);
    uidLabel.setText("User ID:");
    gd = gdf.create();
    gd.grabExcessVerticalSpace = false;
    gd.grabExcessHorizontalSpace = false;
    uidLabel.setLayoutData(gd);
    final Text uidText = new Text(uidComposite, SWT.SINGLE | SWT.READ_ONLY);
    uidText.setText(WorkbenchLoggingPlugin.getDefault().getLocalUser());
    uidText.addMouseListener(new MouseAdapter() {
        /* (non-Javadoc)
         * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
         */
        @Override
        public void mouseUp(MouseEvent e) {
            uidText.selectAll();
        }
    });
    MenuManager manager = new MenuManager();
    Menu menu = manager.createContextMenu(uidText);
    uidText.setMenu(menu);
    CommandContributionItemParameter parameters = new CommandContributionItemParameter(
            WorkbenchLoggingPlugin.getDefault().getWorkbench(), null, EDIT_COPY, SWT.PUSH);
    manager.add(new CommandContributionItem(parameters));
    return page;
}

From source file:ca.uvic.cs.tagsea.monitoring.internal.ui.MonitoringPreferencePage.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {
    Composite page = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    GridDataFactory fill = GridDataFactory.fillDefaults();
    GridDataFactory but = GridDataFactory.createFrom(new GridData(SWT.CENTER, SWT.CENTER, false, false));
    page.setLayout(layout);//w w w.  j a v  a2s  .  com
    GridData data = fill.create();
    data.widthHint = 300;
    page.setLayoutData(data);
    Text intro = new Text(page, SWT.WRAP | SWT.MULTI | SWT.READ_ONLY);
    //intro.setEditable(false);
    //@tag incomplete
    intro.setText("Some monitors have been contributed to the TagSEA plugin. The following pages will "
            + "present you with agreements to allow TagSEA to monitor your interactions with it. Please "
            + "read the agreement carefully. If you do not agree, TagSEA will not use the monitor to monitor "
            + "your usage of TagSEA.");
    data = fill.create();
    data.horizontalSpan = 2;
    data.grabExcessHorizontalSpace = false;
    data.widthHint = 300;
    intro.setLayoutData(data);
    String[] keys = Monitoring.getDefault().getPreferenceKeys();
    editors = new ArrayList<BooleanFieldEditor>();
    IPreferenceStore store = TagSEAPlugin.getDefault().getPreferenceStore();
    for (String key : keys) {
        ITagSEAMonitor mon = Monitoring.getDefault().getMonitorForPreference(key);
        if (mon != null) {
            Composite editorParent = new Composite(page, SWT.NONE);
            editorParent.setLayoutData(fill.create());
            BooleanFieldEditor editor = new BooleanStringFieldEditor(key, mon.getName(),
                    BooleanFieldEditor.DEFAULT, editorParent);
            editor.setPreferenceStore(store);
            editors.add(editor);
            Button agreement = new Button(page, SWT.PUSH);
            agreement.setText("Agreement...");
            agreement.addSelectionListener(new AgreementSelection(mon));
            agreement.setLayoutData(but.create());
        }
    }
    loadEditors();
    return page;
}

From source file:cn.dockerfoundry.ide.eclipse.server.ui.internal.wizards.DockerFoundryDeploymentWizardPage.java

License:Open Source License

protected void makeStartDeploymentControlsVisible(boolean makeVisible) {
    if (runDebugOptions != null && !runDebugOptions.isDisposed()) {
        GridData data = (GridData) runDebugOptions.getLayoutData();

        // If hiding, exclude from layout as to not take up space when it is
        // made invisible
        GridDataFactory.createFrom(data).exclude(!makeVisible).applyTo(runDebugOptions);

        runDebugOptions.setVisible(makeVisible);

        // Recalculate layout if run debug options are excluded
        runDebugOptions.getParent().layout(true, true);

    }//ww w .ja  v a  2s .  c  om
}

From source file:com.amazonaws.eclipse.dynamodb.editor.AttributeValueEditor.java

License:Apache License

/**
 * Swaps the display of the two controls given when either is selected.
 *///from   www  . j ava  2 s . com
static void configureDataTypeControlSwap(final Button dataTypeButton, final Combo dataTypeCombo,
        final Composite parent) {
    dataTypeButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            parent.setRedraw(false);
            dataTypeButton.setVisible(false);
            GridDataFactory.createFrom((GridData) dataTypeButton.getLayoutData()).exclude(true)
                    .applyTo(dataTypeButton);

            dataTypeCombo.setVisible(true);
            GridDataFactory.createFrom((GridData) dataTypeCombo.getLayoutData()).exclude(false)
                    .applyTo(dataTypeCombo);

            parent.layout();
            dataTypeCombo.setListVisible(true);
            parent.setRedraw(true);
        }
    });

    dataTypeCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            parent.setRedraw(false);
            dataTypeCombo.setVisible(false);
            GridDataFactory.createFrom((GridData) dataTypeCombo.getLayoutData()).exclude(true)
                    .applyTo(dataTypeCombo);

            dataTypeButton.setVisible(true);
            GridDataFactory.createFrom((GridData) dataTypeButton.getLayoutData()).exclude(false)
                    .applyTo(dataTypeButton);

            if (dataTypeCombo.getSelectionIndex() == STRING) {
                dataTypeButton
                        .setImage(DynamoDBPlugin.getDefault().getImageRegistry().get(DynamoDBPlugin.IMAGE_A));
            } else {
                dataTypeButton
                        .setImage(DynamoDBPlugin.getDefault().getImageRegistry().get(DynamoDBPlugin.IMAGE_ONE));
            }

            parent.layout();
            parent.setRedraw(true);
        }
    });
}

From source file:com.amazonaws.eclipse.dynamodb.editor.ScanConditionRow.java

License:Apache License

/**
 * Configures the editor row based on the current comparison, hiding and
 * showing editor elements as necessary.
 *//* w w w.  j ava  2  s. com*/
private void configureComparisonEditorFields() {
    clearAttributes(comparisonValue);

    setRedraw(false);

    betweenTextOne.setText("");
    betweenTextTwo.setText("");
    listValueEditor.setText("");
    singleValueEditor.setText("");

    List<Control> toHide = new LinkedList<Control>();
    toHide.addAll(conditionallyShownControls);
    toHide.add(dataTypeCombo);
    for (Control c : toHide) {
        c.setVisible(false);
        GridDataFactory.createFrom((GridData) c.getLayoutData()).exclude(true).applyTo(c);
    }

    Collection<Control> toShow = new LinkedList<Control>();
    switch (comparisonOperator) {
    case BEGINS_WITH:
        toShow.add(singleValueEditor);
        dataType = S;
        break;
    case BETWEEN:
        toShow.add(betweenTextOne);
        toShow.add(betweenTextLabel);
        toShow.add(betweenTextTwo);
        toShow.add(dataTypeButton);
        switch (dataType) {
        case N:
        case NS:
            dataType = N;
            break;
        case S:
        case SS:
            dataType = S;
            break;
        }
        break;
    case IN:
        toShow.add(dataTypeButton);
        toShow.add(multiValueEditorButton);
        toShow.add(listValueEditor);
        switch (dataType) {
        case N:
        case NS:
            dataType = NS;
            break;
        case S:
        case SS:
            dataType = SS;
            break;
        }
        break;
    case EQ:
    case GE:
    case GT:
    case LE:
    case LT:
    case NE:
    case CONTAINS:
    case NOT_CONTAINS:
        toShow.add(dataTypeButton);
        toShow.add(singleValueEditor);
        switch (dataType) {
        case N:
        case NS:
            dataType = N;
            break;
        case S:
        case SS:
            dataType = S;
            break;
        }
        break;
    case NOT_NULL:
    case NULL:
        break;
    default:
        throw new RuntimeException("Unknown comparison " + comparisonOperator);
    }

    for (Control c : toShow) {
        c.setVisible(true);
        GridDataFactory.createFrom((GridData) c.getLayoutData()).exclude(false).applyTo(c);
    }

    layout();

    setRedraw(true);
}

From source file:com.buglabs.dragonfly.ui.wizards.bugProject.NewProjectMainPage.java

License:Open Source License

public void createControl(Composite parent) {
    Composite top = new Composite(parent, SWT.NONE);

    GridLayout layout = new GridLayout(2, false);
    top.setLayout(layout);/* w w w  .  ja  v  a2s. c  o m*/

    GridData gdFillH = new GridData(GridData.FILL_HORIZONTAL);
    GridData spanAll = new GridData(GridData.FILL_HORIZONTAL);
    spanAll.horizontalSpan = layout.numColumns;

    GridData spanAllFillBoth = new GridData(GridData.FILL_BOTH);
    spanAllFillBoth.horizontalSpan = layout.numColumns;

    GridData gdFillBoth = GridDataFactory.createFrom(gdFillH).create();

    Composite comp = new Composite(top, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));
    GridData compData = new GridData(GridData.FILL_HORIZONTAL);
    compData.horizontalSpan = layout.numColumns;
    compData.minimumHeight = 100;
    comp.setLayoutData(compData);
    Label lblName = new Label(comp, SWT.NONE);
    lblName.setText(Messages.getString("NewProjectMainPage.8")); //$NON-NLS-1$

    txtName = new Text(comp, SWT.BORDER);
    txtName.setLayoutData(gdFillH);
    txtName.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            pinfo.setProjectName(((Text) e.widget).getText());

            String activator = ProjectUtils.formatNameToPackage(pinfo.getProjectName());

            /*char[] charArray = activator.toCharArray();
            charArray[0] = Character.toUpperCase(charArray[0]);
            activator = new String(charArray);*/

            pinfo.setActivator(activator + ".Activator");
            pinfo.setSymbolicName(ProjectUtils.formatName(pinfo.getProjectName()));
            setPageComplete(true);
        }
    });

    Label lblAuthorName = new Label(comp, SWT.NONE);
    lblAuthorName.setText("Author:");

    txtAuthorName = new Text(comp, SWT.BORDER);
    txtAuthorName.setLayoutData(gdFillH);
    AuthenticationData authData = DragonflyActivator.getDefault().getAuthenticationData();
    txtAuthorName.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            pinfo.setVendor(((Text) e.widget).getText());
            setPageComplete(true);
        }
    });

    if (authData != null) {
        String username = authData.getUsername();
        if (username != null) {
            txtAuthorName.setText(username);
        }
    }

    Label lblDescription = new Label(comp, SWT.NONE);
    lblDescription.setText("Description:");

    txtDescription = new Text(comp, SWT.BORDER);
    txtDescription.setLayoutData(gdFillH);
    txtDescription.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            pinfo.setDescription(((Text) e.widget).getText());
            setPageComplete(true);
        }
    });

    txtName.setFocus();

    setControl(top);
}

From source file:com.buglabs.dragonfly.ui.wizards.bugProject.OSGiServiceBindingPage.java

License:Open Source License

/**
 * Creates TableViewer that has all BUGs currently available in MyBUGs view
 * /*from   w w w.  ja  v  a  2  s  . c  om*/
 * @param composite
 */
private void createTargetArea(final Composite parent) {
    Group composite = new Group(parent, SWT.NONE);
    composite.setText(TARGET_BUG_TITLE);
    composite.setLayout(new GridLayout(2, false));

    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.grabExcessHorizontalSpace = true;

    composite.setLayoutData(gridData);

    GridData gdLabel = new GridData(GridData.FILL_HORIZONTAL);
    gdLabel.horizontalSpan = 2;

    Label label = new Label(composite, SWT.NONE);
    label.setText(TARGET_BUG_INSTRUCTIONS);
    label.setLayoutData(gdLabel);

    GridData fillHorizontal = new GridData(GridData.FILL_HORIZONTAL);
    GridData gdViewer = GridDataFactory.createFrom(fillHorizontal).create();
    gdViewer.heightHint = BUGS_VIEWER_HEIGHT_HINT;
    bugsViewer = new TableViewer(composite, SWT.BORDER | SWT.V_SCROLL);
    bugsViewer.getTable().setLayoutData(gdViewer);

    // set up change listener
    bugsViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(final SelectionChangedEvent event) {
            // not sure why this would be the case, but return if nothing there
            if (((BaseTreeNode) bugsViewer.getInput()).getChildren().size() == 0)
                return;

            // don't do anything if it's the same as the previous selection
            ISelection selection = event.getSelection();
            if (currentBugSelection != null && currentBugSelection.equals(selection))
                return;

            if (!reloadListDialog(parent.getShell())) {
                if (currentBugSelection != null)
                    event.getSelectionProvider().setSelection(currentBugSelection);
                return;
            }

            // Make sure we can connect to the given BUG
            final BugConnection connection = (BugConnection) ((StructuredSelection) event.getSelection())
                    .getFirstElement();
            if (connection == null)
                return;

            // set the saved currentBugSelection to the selection
            currentBugSelection = selection;

            // prepare to launch refresh services job
            refreshServiceDefintions.setEnabled(true);

            // clear selections
            clearSelections();

            launchRefreshServicesJob(connection);
        }

    });

    bugsViewer.setContentProvider(new MyBugsViewContentProvider() {
        public Object[] getChildren(Object parentElement) {
            if (parentElement instanceof BaseTreeNode) {
                return ((BaseTreeNode) parentElement).getChildren().toArray();
            }
            return new Object[0];
        }
    });

    bugsViewer.setLabelProvider(new LabelProvider() {
        public String getText(Object element) {
            if (element instanceof BugConnection) {
                return ((BugConnection) element).getName();
            } else {
                return super.getText(element);
            }
        }

        public Image getImage(Object element) {
            if (element instanceof BugConnection) {
                return Activator.getDefault().getImageRegistry().get(Activator.IMAGE_COLOR_UPLOAD);
            }
            return super.getImage(element);
        }
    });

    BaseTreeNode root = (BaseTreeNode) BugConnectionManager.getInstance().getBugConnectionsRoot();
    bugsViewer.setInput(root);

    btnStartVBUG = new Button(composite, SWT.PUSH);
    btnStartVBUG.setText(START_VIRTUAL_BUG_LABEL);
    btnStartVBUG.setToolTipText(START_VIRTUAL_BUG_TOOLTIP);
    GridData gdButton = new GridData();
    gdButton.verticalAlignment = SWT.TOP;
    btnStartVBUG.setLayoutData(gdButton);
    btnStartVBUG.addSelectionListener(((SelectionListener) new StartVBUGSelectionListener()));

    setPageMessage(root.getChildren().size());
}