List of usage examples for org.eclipse.jface.layout GridDataFactory grab
public GridDataFactory grab(boolean horizontal, boolean vertical)
From source file:com.amazonaws.eclipse.android.sdk.newproject.AndroidProjectWizardPage.java
License:Open Source License
public void createControl(Composite parent) { final Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(2, false)); setControl(composite);// w ww . ja v a 2 s. c om GridDataFactory factory = GridDataFactory.fillDefaults(); factory.grab(true, false); new Label(composite, SWT.NONE).setText("Project Name:"); projectNameText = new Text(composite, SWT.BORDER); factory.applyTo(projectNameText); new Label(composite, SWT.NONE).setText("Java Package Name:"); packageNameText = new Text(composite, SWT.BORDER); factory.applyTo(packageNameText); sampleCodeButton = new Button(composite, SWT.CHECK); sampleCodeButton.setText("Start with sample application"); sampleCodeButton.setSelection(true); factory.copy().span(2, 1).applyTo(packageNameText); androidTargetSelectorComposite = new Composite(composite, SWT.NONE); androidTargetSelectorComposite.setLayout(new GridLayout()); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false); gridData.horizontalSpan = 2; gridData.heightHint = 200; androidTargetSelectorComposite.setLayoutData(gridData); sdkTargetSelector = new SdkTargetSelector(androidTargetSelectorComposite, null); IAndroidTarget[] targets = new IAndroidTarget[0]; if (Sdk.getCurrent() != null) { targets = Sdk.getCurrent().getTargets(); } sdkTargetSelector.setTargets(targets); // Check to see if we have an SDK. If we don't, we need to wait before // continuing AndroidSdkManager sdkManager = AndroidSdkManager.getInstance(); synchronized (sdkManager) { AndroidSdkInstall defaultSDKInstall = sdkManager.getDefaultSdkInstall(); if (defaultSDKInstall != null) { sdkInstalled = true; } else { setPageComplete(false); Job installationJob = sdkManager.getInstallationJob(); if (installationJob == null) { JavaSdkPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, JavaSdkPlugin.PLUGIN_ID, "Unable to check status of AWS SDK for Android download")); return; } final Composite pleaseWait = new Composite(composite, SWT.None); pleaseWait.setLayout(new GridLayout(1, false)); GridData layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.horizontalSpan = 2; pleaseWait.setLayoutData(layoutData); Label label = new Label(pleaseWait, SWT.None); label.setText("The AWS SDK for Android is currently downloading. Please wait while it completes."); label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); ProgressBar progressBar = new ProgressBar(pleaseWait, SWT.INDETERMINATE); progressBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); installationJob.addJobChangeListener(new JobChangeAdapter() { @Override public void done(IJobChangeEvent event) { Display.getDefault().syncExec(new Runnable() { public void run() { sdkInstalled = true; pleaseWait.dispose(); composite.getParent().layout(); composite.getShell().pack(true); composite.getParent().redraw(); updateErrorMessage(); } }); } }); } } bindControls(); updateErrorMessage(); }
From source file:com.aptana.editor.js.validator.JSLintValidatorPreferenceCompositeFactory.java
License:Open Source License
public Composite createPreferenceComposite(Composite parent, final IBuildParticipantWorkingCopy participant) { Composite master = new Composite(parent, SWT.NONE); master.setLayout(GridLayoutFactory.fillDefaults().create()); GridDataFactory fillHoriz = GridDataFactory.fillDefaults().grab(true, false); // JSON Options Group group = new Group(master, SWT.BORDER); group.setText(Messages.JSLintValidatorPreferenceCompositeFactory_OptionsTitle); group.setLayout(new GridLayout()); group.setLayoutData(fillHoriz.create()); Label label = new Label(group, SWT.WRAP); label.setText(Messages.JSLintValidatorPreferenceCompositeFactory_OptionsMsg); fillHoriz.applyTo(label);//from ww w.j av a 2 s. c o m final Text text = new Text(group, SWT.MULTI | SWT.V_SCROLL); final ControlDecoration decoration = new ControlDecoration(text, SWT.LEFT | SWT.TOP); decoration.setDescriptionText(Messages.JSLintValidatorPreferenceCompositeFactory_OptionsParseError); decoration .setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_DEC_FIELD_ERROR)); decoration.hide(); text.setText(participant.getPreferenceString(IPreferenceConstants.JS_LINT_OPTIONS)); fillHoriz.hint(SWT.DEFAULT, 100).applyTo(text); text.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { decoration.hide(); try { String optionsAsJSON = text.getText(); JSON.parse(optionsAsJSON); participant.setPreference(IPreferenceConstants.JS_LINT_OPTIONS, text.getText()); } catch (IllegalStateException e1) { decoration.show(); } } }); // Filters Composite filtersGroup = new ValidatorFiltersPreferenceComposite(master, participant); filtersGroup.setLayoutData(fillHoriz.grab(true, true).hint(SWT.DEFAULT, 150).create()); return master; }
From source file:com.aptana.editor.js.validator.JSParserValidatorPreferenceCompositeFactory.java
License:Open Source License
public Composite createPreferenceComposite(Composite parent, final IBuildParticipantWorkingCopy participant) { Composite master = new Composite(parent, SWT.NONE); master.setLayout(GridLayoutFactory.fillDefaults().create()); GridDataFactory fillHoriz = GridDataFactory.fillDefaults().grab(true, false); // Options//ww w . j av a 2 s .c o m Group group = new Group(master, SWT.BORDER); group.setText(Messages.JSParserValidatorPreferenceCompositeFactory_OptionsGroup); group.setLayout(new GridLayout()); group.setLayoutData(fillHoriz.create()); Composite pairs = new Composite(group, SWT.NONE); pairs.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create()); Label label = new Label(pairs, SWT.WRAP); label.setText(Messages.JSParserValidatorPreferenceCompositeFactory_MissingSemicolons); Combo combo = new Combo(pairs, SWT.READ_ONLY | SWT.SINGLE); for (IProblem.Severity severity : IProblem.Severity.values()) { combo.add(severity.label()); combo.setData(severity.label(), severity); } String severityValue = participant .getPreferenceString(IPreferenceConstants.PREF_MISSING_SEMICOLON_SEVERITY); combo.setText(IProblem.Severity.create(severityValue).label()); combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Combo c = ((Combo) e.widget); int index = c.getSelectionIndex(); String text = c.getItem(index); IProblem.Severity s = (Severity) c.getData(text); participant.setPreference(IPreferenceConstants.PREF_MISSING_SEMICOLON_SEVERITY, s.id()); } }); fillHoriz.applyTo(pairs); // Filters Composite filtersGroup = new ValidatorFiltersPreferenceComposite(master, participant); filtersGroup.setLayoutData(fillHoriz.grab(true, true).hint(SWT.DEFAULT, 150).create()); return master; }
From source file:org.bonitasoft.studio.connector.model.definition.wizard.PageComponentSwitchBuilder.java
License:Open Source License
public Label createFieldLabel(final Composite composite, final int verticalAlignment, final String id, final boolean isMandatory) { final Composite labelContainer = getParentCompositeForLabel(composite); final Label fieldLabel = new Label(labelContainer, SWT.WRAP); setText(id, isMandatory, fieldLabel); final GridDataFactory factory = GridDataFactory.fillDefaults().align(SWT.END, verticalAlignment); if (hasFixedSize()) { factory.grab(true, false); }/*from w w w. ja va 2 s .co m*/ fieldLabel.setLayoutData(factory.create()); return fieldLabel; }
From source file:org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationBlock.java
License:Open Source License
/** * Creates the "working set configurations" pane in the upper part of the sash form. * //from w w w . j ava 2s. c om * @param parent * the parent composite * @param layoutFactory * a layout-factory to use to lay out the composite in a grid, possibly pre-configured. Its use * is optional * * @return the working set configurations pane */ protected Composite createWorkingSetConfigsArea(Composite parent, GridLayoutFactory layoutFactory) { Composite result = new Composite(parent, SWT.NONE); layoutFactory.numColumns(2).applyTo(result); GridDataFactory layoutDataFactory = GridDataFactory.fillDefaults(); Label label = new Label(result, SWT.NONE); label.setText(WorkingSetMessages.WSConfigDialog_wsTree_label); layoutDataFactory.span(2, 1).applyTo(label); controller = new WorkingSetConfigsController(workspace, initialSelection); TreeViewer tree = new TreeViewer(result); layoutDataFactory.span(1, 1).align(SWT.FILL, SWT.FILL).grab(true, true).hint(250, SWT.DEFAULT) .applyTo(tree.getControl()); tree.setContentProvider(new WSConfigsContentProvider()); tree.setLabelProvider(new WSConfigsLabelProvider(tree)); controller.setTreeViewer(tree); tree.setComparator(new ViewerComparator() { @Override public int category(Object element) { if (element instanceof IWorkingSetConfiguration.ISnapshot) { IWorkingSetConfiguration.ISnapshot config = (IWorkingSetConfiguration.ISnapshot) element; if (config.isReadOnly()) { return 0; } } return 1; } }); tree.getTree().getAccessible().addAccessibleListener(new AccessibleAdapter() { @Override public void getName(AccessibleEvent e) { e.result = WorkingSetMessages.WSConfigDialog_wsTree_accessible_name; } }); Composite buttons = new Composite(result, SWT.NONE); layoutDataFactory.grab(false, false).hint(SWT.DEFAULT, SWT.DEFAULT).applyTo(buttons); layoutFactory.numColumns(1).extendedMargins(0, 0, 0, 0).applyTo(buttons); Button button = new Button(buttons, SWT.PUSH); layoutDataFactory.align(SWT.FILL, SWT.BEGINNING).applyTo(button); button.setText(WorkingSetMessages.WSConfigDialog_add_label); controller.setAddButton(button); button = new Button(buttons, SWT.PUSH); layoutDataFactory.applyTo(button); button.setText(WorkingSetMessages.WSConfigDialog_remove_label); controller.setRemoveButton(button); button = new Button(buttons, SWT.PUSH); layoutDataFactory.applyTo(button); button.setText(WorkingSetMessages.WSConfigDialog_rename_label); controller.setRenameButton(button); button = new Button(buttons, SWT.PUSH); layoutDataFactory.applyTo(button); button.setText(WorkingSetMessages.WSConfigDialog_activate_label); controller.setActivateButton(button); button = new Button(buttons, SWT.PUSH); layoutDataFactory.applyTo(button); button.setText(WorkingSetMessages.WSConfigDialog_build_label); controller.setBuildButton(button); return result; }
From source file:org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaPeoplePart.java
License:Open Source License
@Override protected GridDataFactory createLayoutData(AbstractAttributeEditor editor) { GridDataFactory dataFactory = super.createLayoutData(editor); if (editor.getTaskAttribute().getId().equals(BugzillaAttribute.CC.getKey())) { dataFactory.grab(true, true).align(SWT.FILL, SWT.FILL).hint(130, 95); }// ww w .j a v a 2 s . co m return dataFactory; }
From source file:org.eclipse.rap.ui.internal.launch.tab.MainTab.java
License:Open Source License
private void createBrowserModeSection(final Composite parent) { Group group = new Group(parent, SWT.NONE); group.setLayoutData(fillHorizontal.create()); group.setText(LaunchMessages.MainTab_Browser); group.setLayout(new GridLayout(2, false)); cbOpenBrowser = new Button(group, SWT.CHECK); GridDataFactory grab = GridDataFactory.swtDefaults(); grab.grab(true, false); cbOpenBrowser.setLayoutData(grab.create()); cbOpenBrowser.setText(LaunchMessages.MainTab_OpenApplicationIn); cbOpenBrowser.addSelectionListener(selectionListener); Link lnkBrowserPrefs = new Link(group, SWT.NONE); lnkBrowserPrefs.setText(LaunchMessages.MainTab_ConfigureBrowsers); lnkBrowserPrefs.addSelectionListener(new SelectionAdapter() { public void widgetSelected(final SelectionEvent event) { handleBrowserPrefsLink();/*from w w w.j a v a 2 s. c om*/ } }); rbInternalBrowser = new Button(group, SWT.RADIO); rbInternalBrowser.setLayoutData(spanHorizontal(2, 17)); rbInternalBrowser.setText(LaunchMessages.MainTab_InternalBrowser); rbInternalBrowser.addSelectionListener(selectionListener); rbExternalBrowser = new Button(group, SWT.RADIO); rbExternalBrowser.setLayoutData(spanHorizontal(2, 17)); rbExternalBrowser.setText(LaunchMessages.MainTab_ExternalBrowser); rbExternalBrowser.addSelectionListener(selectionListener); cbOpenBrowser.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean openBrowser = cbOpenBrowser.getSelection(); rbInternalBrowser.setEnabled(openBrowser); rbExternalBrowser.setEnabled(openBrowser); } }); }
From source file:org.springsource.ide.eclipse.commons.livexp.ui.ChooseOneSectionCombo.java
License:Open Source License
@Override public void createContents(Composite page) { Composite field = new Composite(page, SWT.NONE); GridLayout layout = GridLayoutFactory.fillDefaults().numColumns(2).create(); field.setLayout(layout);/* w ww. ja v a 2 s . c om*/ GridDataFactory.fillDefaults().grab(true, false).applyTo(field); Label fieldNameLabel = new Label(field, SWT.NONE); fieldNameLabel.setText(label); GridDataFactory labelGridData = GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER); if (useFieldLabelWidthHint) { labelGridData.hint(UIConstants.fieldLabelWidthHint(fieldNameLabel), SWT.DEFAULT); } labelGridData.applyTo(fieldNameLabel); final Combo combo = new Combo(field, inputParser == null ? SWT.READ_ONLY : SWT.NONE); options.addListener(new ValueListener<T[]>() { public void gotValue(org.springsource.ide.eclipse.commons.livexp.core.LiveExpression<T[]> exp, T[] value) { if (combo != null) { String oldText = combo.getText(); combo.setItems(getLabels()); //This will clear the selection sometimes combo_setText(combo, oldText); } }; }); GridDataFactory gridData = GridDataFactory.fillDefaults(); if (inputParser != null) { gridData = gridData.hint(FIELD_TEXT_AREA_WIDTH, SWT.DEFAULT).minSize(FIELD_TEXT_AREA_WIDTH, SWT.DEFAULT); } if (grabHorizontal) { gridData = gridData.grab(grabHorizontal, false); } gridData.applyTo(combo); combo.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { handleModifyText(combo); } }); selection.selection.addListener(UIValueListener.from((exp, newSelection) -> { if (newSelection != null && !combo.isDisposed()) { //Technically, not entirely correct. This might // select the wrong element if more than one option // has the same label text. String newText = labelProvider.getText(newSelection); combo_setText(combo, newText); if (!combo.getText().equals(newText)) { //widget rejected the selection. To avoid widget state // and model state getting out-of-sync, refelct current // widget state back to the model: handleModifyText(combo); } } })); }