List of usage examples for org.eclipse.jface.layout GridLayoutFactory copy
public GridLayoutFactory copy()
From source file:com.nokia.carbide.cpp.internal.pi.button.ui.BupProfileEditDialog.java
License:Open Source License
public Control createDialogArea(Composite parent) { getShell().setText(/*from w w w . j av a 2 s . co m*/ 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.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 ww w. j av a 2 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.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();/* ww w. ja v a2 s . com*/ } }); 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; }