List of usage examples for org.eclipse.jface.layout GridLayoutFactory applyTo
public void applyTo(Composite c)
From source file:com.aptana.editor.common.outline.CommonQuickOutlinePage.java
License:Open Source License
/** * createComposite//from ww w .ja v a 2s .c om * * @param parent * @return Composite */ private Composite createComposite(Composite parent) { GridLayoutFactory factory = GridLayoutFactory.fillDefaults().spacing(0, 0); Composite result = new Composite(parent, SWT.NONE); factory.applyTo(result); GridDataFactory.fillDefaults().grab(true, true).applyTo(result); return result; }
From source file:com.nokia.carbide.cpp.internal.pi.button.ui.BupProfileEditDialog.java
License:Open Source License
public Control createDialogArea(Composite parent) { getShell().setText(//ww w. jav a 2 s . c om Messages.getString("BupProfileEditDialog.editingProfile") + profileForThisEdit.getProfileId()); //$NON-NLS-1$ setTitleImage(ButtonPlugin.getImageDescriptor("icons/PI_Meter_20x20.png").createImage()); //$NON-NLS-1$ setTitle(Messages.getString("BupProfileEditDialog.profile") + profileForThisEdit.getProfileId()); //$NON-NLS-1$ GridLayoutFactory layoutExpandBoth = GridLayoutFactory.fillDefaults(); GridDataFactory gridDataExpandBoth = GridDataFactory.fillDefaults().grab(true, true); GridLayoutFactory gridLayoutButton = GridLayoutFactory.swtDefaults(); GridDataFactory gridDataButton = GridDataFactory.swtDefaults(); content = new Composite(parent, SWT.NONE); layoutExpandBoth.applyTo(content); gridDataExpandBoth.applyTo(content); PlatformUI.getWorkbench().getHelpSystem().setHelp(content, ComNokiaCarbidePiButtonHelpIDs.PI_PROFILE_EDIT_DIALOG); localeMappingGroup = new Group(content, SWT.NONE); layoutExpandBoth.applyTo(localeMappingGroup); gridDataExpandBoth.applyTo(localeMappingGroup); mappingComposite = new Composite(localeMappingGroup, SWT.NONE); layoutExpandBoth.copy().numColumns(2).applyTo(mappingComposite); gridDataExpandBoth.applyTo(mappingComposite); mappingTableViewer = new BupMapTableViewer(mappingComposite, true); Table mappingTable = mappingTableViewer.getTable(); // enable the edit button only when a single file filter is selected mappingTable.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { handleViewerSelection(); } }); int maxWidth; buttonComposite = new Composite(mappingComposite, SWT.NONE); gridLayoutButton.applyTo(buttonComposite); gridDataButton.copy().align(SWT.CENTER, SWT.FILL).grab(false, true).applyTo(buttonComposite); addButton = new Button(buttonComposite, SWT.NONE); addButton.setText(Messages.getString("BupProfileEditDialog.add")); //$NON-NLS-1$ addButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { handleAdd(); } }); maxWidth = buttonComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT).x; editButton = new Button(buttonComposite, SWT.NONE); editButton.setText(Messages.getString("BupProfileEditDialog.edit")); //$NON-NLS-1$ editButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { handleEdit(); } }); maxWidth = Math.max(maxWidth, editButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).x); removeButton = new Button(buttonComposite, SWT.NONE); removeButton.setText(Messages.getString("BupProfileEditDialog.remove")); //$NON-NLS-1$ removeButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { handleRemove(); } }); maxWidth = Math.max(maxWidth, removeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).x); //dummy label as divider new Label(buttonComposite, SWT.NONE); new Label(buttonComposite, SWT.NONE); new Label(buttonComposite, SWT.NONE); new Label(buttonComposite, SWT.NONE); new Label(buttonComposite, SWT.NONE); clearButton = new Button(buttonComposite, SWT.NONE); clearButton.setText(Messages.getString("BupProfileEditDialog.clearProfile")); //$NON-NLS-1$ clearButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) { } public void widgetSelected(SelectionEvent arg0) { if (MessageDialog.openQuestion(getShell(), Messages.getString("BupProfileEditDialog.clearProfile"), //$NON-NLS-1$ Messages.getString("BupProfileEditDialog.clearAllConfirm"))) { //$NON-NLS-1$ Set<Integer> keySet = cachedMap.getKeyCodeSet(); Integer[] keyCodes = keySet.toArray(new Integer[keySet.size()]); for (Integer keyCode : keyCodes) { cachedMap.removeMapping(keyCode); } refreshTable(); } } }); maxWidth = Math.max(maxWidth, clearButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).x); gridDataButton.hint(maxWidth, addButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).y).applyTo(addButton); gridDataButton.hint(maxWidth, removeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).y).applyTo(removeButton); gridDataButton.hint(maxWidth, editButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).y).applyTo(editButton); gridDataButton.hint(maxWidth, clearButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).y).applyTo(clearButton); initialize(); return content; }
From source file:com.nokia.carbide.cpp.internal.pi.button.ui.ButtonPreferencePage.java
License:Open Source License
@Override protected Control createContents(Composite parent) { GridLayoutFactory layoutExpandBoth = GridLayoutFactory.fillDefaults(); GridDataFactory gridDataExpandBoth = GridDataFactory.fillDefaults().grab(true, true); content = new Composite(parent, SWT.NONE); layoutExpandBoth.applyTo(content); gridDataExpandBoth.applyTo(content); buttonTabFolder = new TabFolder(content, SWT.TOP); layoutExpandBoth.applyTo(buttonTabFolder); gridDataExpandBoth.applyTo(buttonTabFolder); buttonTabPage = new ButtonTabPage(buttonTabFolder); buttonTab = new TabItem(buttonTabFolder, SWT.NONE, BUTTON_TAB_INDEX); buttonTab.setText(Messages.getString("ButtonPreferencePage.0")); //$NON-NLS-1$ buttonTab.setToolTipText(Messages.getString("ButtonPreferencePage.1")); //$NON-NLS-1$ buttonTab.setControl(buttonTabPage); getPageStoredValues();/*from w w w.j a va 2s.c om*/ return content; }
From source file:com.nokia.carbide.cpp.internal.pi.button.ui.ButtonTabPage.java
License:Open Source License
public ButtonTabPage(Composite parent) { super(parent, SWT.NONE); PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ComNokiaCarbidePiButtonHelpIDs.PI_BUTTON_MAP_PREF_TAB); GridLayoutFactory layoutExpandBoth = GridLayoutFactory.fillDefaults(); GridDataFactory gridDataExpandBoth = GridDataFactory.fillDefaults().grab(true, true); GridLayoutFactory layoutExpandHorizontal = GridLayoutFactory.swtDefaults(); GridDataFactory gridDataExpandHorizontal = GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER) .grab(true, false);/*from w ww .ja v a2 s . co m*/ GridDataFactory gridDataButton = GridDataFactory.swtDefaults(); layoutExpandBoth.applyTo(this); gridDataExpandBoth.applyTo(this); content = new Composite(this, SWT.NONE); layoutExpandBoth.applyTo(content); gridDataExpandBoth.applyTo(content); profileGroup = new Group(content, SWT.NONE); layoutExpandHorizontal.applyTo(profileGroup); gridDataExpandHorizontal.applyTo(profileGroup); profileGroup.setText(Messages.getString("ButtonTabPage.manageProfiles")); //$NON-NLS-1$ profileCombo = new Combo(profileGroup, SWT.READ_ONLY); layoutExpandHorizontal.applyTo(profileCombo); gridDataExpandHorizontal.applyTo(profileCombo); profileCombo.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) { } public void widgetSelected(SelectionEvent arg0) { refreshTableToCombo(); } }); profileButtonComposite = new Composite(profileGroup, SWT.NONE); layoutExpandHorizontal.copy().numColumns(3).applyTo(profileButtonComposite); gridDataExpandHorizontal.applyTo(profileButtonComposite); int maxWidth; profileNewButton = new Button(profileButtonComposite, SWT.NONE); profileNewButton.setText(Messages.getString("ButtonTabPage.duplicate")); //$NON-NLS-1$ profileNewButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) { } public void widgetSelected(SelectionEvent arg0) { BupProfileDuplicateDialog dialog = new BupProfileDuplicateDialog(getShell(), profiles.get(profileCombo.getSelectionIndex())); if (dialog.open() == BupProfileDuplicateDialog.OK) { refreshCombo(); profileCombo.select(BupEventMapManager.getInstance().getProfilesFromWorkspacePref().size() - 1); // we cheat a bit by knowing addToWorkspace always append to the end refreshTableToCombo(); // current profile had been removed; } } }); maxWidth = profileNewButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).x; profileEditButton = new Button(profileButtonComposite, SWT.NONE); profileEditButton.setText(Messages.getString("ButtonTabPage.Edit")); //$NON-NLS-1$ profileEditButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) { } public void widgetSelected(SelectionEvent arg0) { IBupEventMapProfile profile = profiles.get(profileCombo.getSelectionIndex()); if (profile != null) { new BupProfileEditDialog(getShell(), profile).open(); refreshTableToCombo(); // current profile may had changed } } }); maxWidth = Math.max(maxWidth, profileEditButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).x); profileRemoveButton = new Button(profileButtonComposite, SWT.NONE); profileRemoveButton.setText(Messages.getString("ButtonTabPage.remove")); //$NON-NLS-1$ profileRemoveButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) { } public void widgetSelected(SelectionEvent arg0) { IBupEventMapProfile profile = profiles.get(profileCombo.getSelectionIndex()); if (profile != null) { if (MessageDialog.openQuestion(getShell(), Messages.getString("ButtonTabPage.confirmRemovalHeading"), //$NON-NLS-1$ Messages.getString("ButtonTabPage.profile") + profile.getProfileId() //$NON-NLS-1$ + Messages.getString("ButtonTabPage.confirmRemoval"))) { //$NON-NLS-1$ //$NON-NLS-3$ if (BupEventMapManager.getInstance().canRemoveProfile(profile)) { BupEventMapManager.getInstance().removeFromWorkspace(profile); refreshCombo(); refreshTableToCombo(); // current profile had been removed; } else { MessageDialog.openInformation(getShell(), Messages.getString("ButtonTabPage.cannotRemoveProfile"), //$NON-NLS-1$ Messages.getString("ButtonTabPage.profile") + profile.getProfileId() //$NON-NLS-1$ + Messages.getString("ButtonTabPage.isStillOpen")); //$NON-NLS-1$ //$NON-NLS-3$ } } } } }); maxWidth = Math.max(maxWidth, profileRemoveButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).x); importExportButtonComposite = new Composite(content, SWT.NONE); layoutExpandHorizontal.copy().numColumns(2).applyTo(importExportButtonComposite); gridDataExpandHorizontal.applyTo(importExportButtonComposite); profileImportLink = new Link(importExportButtonComposite, SWT.NONE); profileImportLink.setText(Messages.getString("ButtonTabPage.importHref")); //$NON-NLS-1$ profileImportLink.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) { } public void widgetSelected(SelectionEvent arg0) { importXML(); } }); profileExportLink = new Link(importExportButtonComposite, SWT.NONE); profileExportLink.setText(Messages.getString("ButtonTabPage.exportHref")); //$NON-NLS-1$ profileExportLink.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) { } public void widgetSelected(SelectionEvent arg0) { exportXML(); } }); gridDataButton.hint(maxWidth, profileNewButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).y) .applyTo(profileNewButton); gridDataButton.hint(maxWidth, profileRemoveButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).y) .applyTo(profileRemoveButton); gridDataButton.hint(maxWidth, profileEditButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).y) .applyTo(profileEditButton); mappingGroup = new Group(content, SWT.NONE); layoutExpandBoth.applyTo(mappingGroup); gridDataExpandBoth.applyTo(mappingGroup); mappingGroup.setText(Messages.getString("ButtonTabPage.keyPressMapping")); //$NON-NLS-1$ Composite compositeToLookBetter = new Composite(mappingGroup, SWT.NONE); layoutExpandHorizontal.applyTo(compositeToLookBetter); gridDataExpandHorizontal.applyTo(compositeToLookBetter); mappingTableViewer = new BupMapTableViewer(compositeToLookBetter, false); refreshCombo(); }
From source file:com.nokia.carbide.cpp.internal.pi.button.ui.ImportBupMapShowOverLapTask.java
License:Open Source License
public void createControl(Composite parent) { GridLayoutFactory layoutExpandBoth = GridLayoutFactory.fillDefaults(); GridDataFactory gridDataExpandBoth = GridDataFactory.fillDefaults().grab(true, true); container = new Composite(parent, SWT.NULL); layoutExpandBoth.applyTo(container); gridDataExpandBoth.applyTo(container); table = new Table(container, SWT.BORDER | SWT.V_SCROLL); layoutExpandBoth.applyTo(table);/* w w w . j a v a 2 s. c om*/ gridDataExpandBoth.applyTo(table); setControl(container); PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ComNokiaCarbidePiButtonHelpIDs.PI_KEY_MAP_IMPORT_WIZARD_OVERLAP); }
From source file:com.nokia.carbide.cpp.internal.pi.button.ui.SwitchBupMapDialog.java
License:Open Source License
public Control createDialogArea(Composite parent) { composite = new Composite(parent, SWT.NONE); PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ComNokiaCarbidePiButtonHelpIDs.PI_KEY_MAP_SWITCH_DIALOG); getShell().setText(Messages.getString("SwitchBupMapDialog.switchKeyPressProfile")); //$NON-NLS-1$ setTitleImage(ButtonPlugin.getImageDescriptor("icons/PI_Meter_20x20.png").createImage()); //$NON-NLS-1$ setTitle(Messages.getString("SwitchBupMapDialog.remapMessage")); //$NON-NLS-1$ GridLayoutFactory layoutExpandBoth = GridLayoutFactory.fillDefaults(); GridDataFactory gridDataExpandBoth = GridDataFactory.fillDefaults().grab(true, true); layoutExpandBoth.applyTo(composite); gridDataExpandBoth.applyTo(composite); profileTreeViewer = new BupProfileTreeViewer(composite); gridDataExpandBoth.applyTo(profileTreeViewer.getTree()); profileTreeViewer.addPostSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent arg0) { validatePage();/*from ww w . j a v a 2s. c om*/ } }); currentProfileComposite = new Composite(composite, SWT.NONE); layoutExpandBoth.copy().numColumns(2).applyTo(currentProfileComposite); gridDataExpandBoth.applyTo(currentProfileComposite); currentProfileLabel = new Label(currentProfileComposite, SWT.NONE); currentProfileLabel.setText(Messages.getString("SwitchBupMapDialog.currentProfile")); //$NON-NLS-1$ currenProfileText = new Text(currentProfileComposite, SWT.READ_ONLY); resetAllKeysButton = new Button(composite, SWT.CHECK); resetAllKeysButton.setText(Messages.getString("SwitchBupMapDialog.overwriteAllEventsWithDefault")); //$NON-NLS-1$ resetAllKeysButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) { } public void widgetSelected(SelectionEvent arg0) { resetAll = resetAllKeysButton.getSelection(); } }); buildBupMapProfileList(); resetAllKeysButton.setSelection(true); resetAllKeysButton.setEnabled(false); currenProfileText.setText(Messages.getString("SwitchBupMapDialog.none")); //$NON-NLS-1$ if (oldProfile != null) { resetAllKeysButton.setSelection(false); resetAllKeysButton.setEnabled(true); currenProfileText.setText(oldProfile.toString()); } return composite; }
From source file:eu.esdihumboldt.hale.ui.codelist.inspire.RegistrySource.java
License:Open Source License
/** * @see ImportSource#createControls(Composite) *//* w w w. j a va 2 s . co m*/ @Override public void createControls(Composite parent) { GridLayoutFactory parentLayout = GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(false); parentLayout.applyTo(parent); GridDataFactory labelData = GridDataFactory// .swtDefaults()// .align(SWT.BEGINNING, SWT.CENTER); GridDataFactory controlData = GridDataFactory// .swtDefaults()// .align(SWT.FILL, SWT.CENTER)// .grab(true, false); // preset label Label label = new Label(parent, SWT.NONE); label.setText("Select preset:"); labelData.applyTo(label); // preset selector selector = new CodeListSelector(parent); selector.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { if (description != null) { CodeListRef schema = selector.getSelectedObject(); if (schema != null && schema.getDescription() != null) { description.setText(schema.getDescription()); } else { description.setText(""); } } updateState(); } }); controlData.applyTo(selector.getControl()); // skipper Composite empty = new Composite(parent, SWT.NONE); GridDataFactory.swtDefaults().hint(1, 1).applyTo(empty); // description label description = new Label(parent, SWT.WRAP); GridDataFactory.fillDefaults().grab(true, true).applyTo(description); // prevent selector appearing very small parent.pack(); // initial configuration (fixed values) getConfiguration().setContentType( Platform.getContentTypeManager().getContentType(INSPIRECodeListConstants.CONTENT_TYPE_ID)); getConfiguration().setProviderFactory( IOProviderExtension.getInstance().getFactory(INSPIRECodeListConstants.PROVIDER_ID)); // initial state update updateState(); }
From source file:eu.esdihumboldt.hale.ui.schema.presets.PresetsSource.java
License:Open Source License
/** * @see ImportSource#createControls(Composite) */// w w w .ja v a 2 s.c o m @Override public void createControls(Composite parent) { GridLayoutFactory parentLayout = GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(false); parentLayout.applyTo(parent); GridDataFactory labelData = GridDataFactory// .swtDefaults()// .align(SWT.BEGINNING, SWT.CENTER); GridDataFactory controlData = GridDataFactory// .swtDefaults()// .align(SWT.FILL, SWT.CENTER)// .grab(true, false); // preset label Label label = new Label(parent, SWT.NONE); label.setText("Select preset:"); labelData.applyTo(label); // preset selector selector = new SchemaPresetSelector(parent); selector.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { if (description != null) { SchemaPreset schema = selector.getSelectedObject(); if (schema != null && schema.getDescription() != null) { description.setText(schema.getDescription()); } else { description.setText(""); } } updateState(true); } }); controlData.applyTo(selector.getControl()); // skipper Composite empty = new Composite(parent, SWT.NONE); GridDataFactory.swtDefaults().hint(1, 1).applyTo(empty); // description label description = new Label(parent, SWT.WRAP); GridDataFactory.fillDefaults().grab(true, true).applyTo(description); // preset label label = new Label(parent, SWT.NONE); label.setText("Import as"); labelData.applyTo(label); // create provider combo ComboViewer providers = createProviders(parent); controlData.applyTo(providers.getControl()); // prevent selector appearing very small parent.pack(); // initial state update updateState(true); }
From source file:org.eclipse.riena.example.client.views.ContextMenuSubModuleView.java
License:Open Source License
@Override protected void basicCreatePartControl(final Composite parent) { parent.setBackground(LnfManager.getLnf().getColor(LnfKeyConstants.SUB_MODULE_BACKGROUND)); parent.setLayout(new GridLayout(1, false)); final GridLayoutFactory groupGLF = GridLayoutFactory.fillDefaults().margins(20, 20).numColumns(2); final GridDataFactory groupGDF = GridDataFactory.fillDefaults().grab(true, false); final GridDataFactory labelGDF = GridDataFactory.swtDefaults().hint(100, SWT.DEFAULT); final Group groupSystem = UIControlsFactory.createGroup(parent, "Text with System-Context Menu:"); //$NON-NLS-1$ groupGLF.applyTo(groupSystem); groupGDF.applyTo(groupSystem);//from w ww .ja v a 2 s .co m final Label label1 = UIControlsFactory.createLabel(groupSystem, "Text:"); //$NON-NLS-1$ labelGDF.applyTo(label1); UIControlsFactory.createText(groupSystem, SWT.NONE, "textFieldSystem"); //$NON-NLS-1$ final Group groupText = UIControlsFactory.createGroup(parent, "Text with Context Menu:"); //$NON-NLS-1$ groupGLF.applyTo(groupText); groupGDF.applyTo(groupText); UIControlsFactory.createLabel(groupText, "Text:"); //$NON-NLS-1$ final Text textField = UIControlsFactory.createText(groupText, SWT.NONE, "textField"); //$NON-NLS-1$ textField.setMenu(createMenuWithFactory(textField)); final Label label2 = UIControlsFactory.createLabel(groupText, "Hide 'Clear':"); //$NON-NLS-1$ labelGDF.applyTo(label2); UIControlsFactory.createButtonCheck(groupText, "", "markerButton"); //$NON-NLS-1$ //$NON-NLS-2$ final Group groupTable = UIControlsFactory.createGroup(parent, "Table with Context Menu:"); //$NON-NLS-1$ groupGLF.numColumns(1).applyTo(groupTable); groupGDF.applyTo(groupTable); final Table table = UIControlsFactory.createTable(groupTable, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION); table.setMenu(createContextMenuForTable(table)); table.setLinesVisible(true); table.setHeaderVisible(true); addUIControl(table, "table"); //$NON-NLS-1$ final TableColumn colFirstName = new TableColumn(table, SWT.LEFT); colFirstName.setWidth(200); final TableColumn colLastName = new TableColumn(table, SWT.LEFT); colLastName.setWidth(200); final TableColumnLayout layout = new TableColumnLayout(); layout.setColumnData(colFirstName, new ColumnWeightData(30)); layout.setColumnData(colLastName, new ColumnWeightData(30)); }