List of usage examples for org.eclipse.jface.layout GridLayoutFactory numColumns
public GridLayoutFactory numColumns(int numColumns)
From source file:com.twinsoft.convertigo.eclipse.editors.connector.htmlconnector.XpathEvaluatorComposite.java
License:Open Source License
protected void initialize() { GridLayoutFactory gdf = GridLayoutFactory.swtDefaults(); gdf.margins(1, 1).spacing(1, 1).equalWidth(false); setLayout(gdf.numColumns(2).create()); //TODO:setBackground(new Color(Display.getDefault(),255,0,121)); Composite buttons = new Composite(this, SWT.NONE); buttons.setLayoutData(new GridData(GridData.FILL_VERTICAL | GridData.HORIZONTAL_ALIGN_END)); String[] buttonsDefNames = new String[] { "name", "tooltip", "disable_msg", "image_url", "other" }; String[][][] buttonsDefinition = getButtonsDefinition(); int numButtonsDefinition = buttonsDefinition.length; String[][][] buttonsDef = new String[numButtonsDefinition + 1][][]; for (int i = 0; i < numButtonsDefinition; i++) buttonsDef[i] = buttonsDefinition[i]; buttonsDef[numButtonsDefinition] = new String[][] { //name , tooltip , disable_msg , image_url , other { "calcxpath", "Evaluate Xpath", "modify the Xpath", "/com/twinsoft/convertigo/eclipse/editors/images/calc_xpath.png", null }, { "backward", "Backward Xpath history", null, "/com/twinsoft/convertigo/eclipse/editors/images/backward_history.png", null }, { "forward", "Forward Xpath history", null, "/com/twinsoft/convertigo/eclipse/editors/images/forward_history.png", null }, { "anchor", "Set anchor", "evaluate the Xpath", "/com/twinsoft/convertigo/eclipse/editors/images/anchor.png", null } }; SelectionListener listener = new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { }//from w w w. jav a 2 s . c o m public void widgetSelected(SelectionEvent e) { boolean enable = ((Boolean) e.widget.getData("enable")).booleanValue(); if (enable) { String name = (String) e.widget.getData("name"); if (name.equals("calcxpath")) { performCalcXpath(); } else if (name.equals("backward")) { moveHistory(true); } else if (name.equals("forward")) { moveHistory(false); } else if (name.equals("anchor")) { setAnchor(isAnchorDisabled); } else { buttonSelected(name); } } } }; buttons.setLayout(gdf.numColumns(buttonsDef.length).create()); buttonsMap = new HashMap<String, Button>(); for (int i = 0; i < buttonsDef.length; i++) { String[][] columnDef = buttonsDef[i]; Composite column = new Composite(buttons, SWT.NONE); column.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); column.setLayout(new FillLayout(SWT.VERTICAL)); for (int j = 0; j < columnDef.length; j++) { String[] buttonDef = columnDef[j]; Button button = new Button(column, SWT.FLAT); buttonsMap.put(buttonDef[0], button); for (int k = 0; k < buttonsDefNames.length; k++) { button.setData(buttonsDefNames[k], buttonDef[k]); } button.addSelectionListener(listener); enableButton(button, false); } } Composite evaluator = new Composite(this, SWT.NONE); evaluator.setLayoutData(new GridData(GridData.FILL_BOTH)); evaluator.setLayout(gdf.numColumns(1).create()); Composite evaluator_up = new Composite(evaluator, SWT.NONE); evaluator_up.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); evaluator_up.setLayout(gdf.numColumns(2).create()); lab = new Label(evaluator_up, SWT.NONE); lab.setText("xPath"); lab.setToolTipText( "ctrl+up : backward history\nctrl+down : forward history\nYou can drag the xPath edit zone to the project tree on :\n - \"Inherited screen classes\" folder to create ScreenClasses\n - \"Criterias\" folder to create Criterias\n - \"Extraction Rules\" folder to create ExtractionRules"); xpath = new StyledText(evaluator_up, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); xpath.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); xpath.setWordWrap(true); xpath.addVerifyKeyListener(new VerifyKeyListener() { public void verifyKey(VerifyEvent event) { if (event.stateMask == SWT.CTRL) { if (event.keyCode == SWT.ARROW_DOWN) { moveHistory(false); return; } else if (event.keyCode == SWT.ARROW_UP) { moveHistory(true); return; } } if (event.character == '\r') { event.doit = false; performCalcXpath(); } else if (currentAnchor != null) { int anchorStart = xpath.getText().indexOf(currentAnchor); if (anchorStart >= 0) { int caret = xpath.getCaretOffset(); if (caret > anchorStart && caret < anchorStart + currentAnchor.length()) { event.doit = Arrays.binarySearch(allowKeyInAnchor, event.keyCode) >= 0; } } } } }); xpath.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { lastEval = null; refreshButtonsEnable(); } }); SashForm evaluator_down = new SashForm(evaluator, SWT.HORIZONTAL); evaluator_down.setLayoutData(new GridData(GridData.FILL_BOTH)); nodesResult = new TwsDomTree(evaluator_down, SWT.MULTI); new TreeColumn(nodesResult.getTree(), SWT.LEFT).setText("Document"); new TreeColumn(nodesResult.getTree(), SWT.RIGHT).setText("Value"); nodesResult.setHeaderVisible(true); nodesResult.getColumn(0).setWidth(400); nodeData = new Text(evaluator_down, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER); nodeData.setEditable(false); evaluator_down.setWeights(new int[] { 70, 30 }); }
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 ww w. j a v a2 s . co m * @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.cdt.internal.ui.workingsets.WorkingSetConfigurationBlock.java
License:Open Source License
/** * Creates the "project configurations" pane in the lower part of the sash form. * /*from w ww .ja va 2 s . c o m*/ * @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 project configurations pane */ protected Composite createProjectConfigsArea(Composite parent, GridLayoutFactory layoutFactory) { Composite result = new Composite(parent, SWT.NONE); layoutFactory.numColumns(1).applyTo(result); GridDataFactory layoutDataFactory = GridDataFactory.fillDefaults(); Label label = new Label(result, SWT.NONE); label.setText(WorkingSetMessages.WSConfigDialog_projTree_label); layoutDataFactory.applyTo(label); ProjectConfigsController projectsController = new ProjectConfigsController(); CheckboxTreeViewer tree = new CheckboxTreeViewer(result); layoutDataFactory.span(1, 1).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tree.getControl()); controller.setProjectConfigsController(projectsController); projectsController.setWorkingSetConfigurationsController(controller); projectsController.setTreeViewer(tree); tree.setComparator(new ViewerComparator()); tree.getTree().getAccessible().addAccessibleListener(new AccessibleAdapter() { @Override public void getName(AccessibleEvent e) { e.result = WorkingSetMessages.WSConfigDialog_projTree_accessible_name; } }); return result; }
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);/* w w w. j a v a 2s. c o m*/ groupGDF.applyTo(groupSystem); 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)); }
From source file:org.jboss.tools.openshift.internal.ui.server.ServerSettingsWizardPage.java
License:Open Source License
private void createAdvancedGroup(Composite parent, DataBindingContext dbc) { DialogAdvancedPart advancedPart = new DialogAdvancedPart() { @Override//from w ww . j a v a2s .co m protected void createAdvancedContent(Composite advancedComposite) { createSourcePathControls(advancedComposite, model, dbc); createDeploymentControls(advancedComposite, model, dbc); createRouteControls(advancedComposite, model, dbc); } @Override protected GridLayoutFactory adjustAdvancedCompositeLayout(GridLayoutFactory gridLayoutFactory) { return gridLayoutFactory.numColumns(numColumns).margins(0, 0); } }; advancedPart.createAdvancedGroup(parent, numColumns); }
From source file:org.jboss.tools.openshift.internal.ui.wizard.connection.AdvancedConnectionEditor.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from w ww.j a v a 2s. c om public Composite createControls(Composite parent, Object context, DataBindingContext dbc) { this.pageModel = (ConnectionWizardPageModel) context; this.selectedConnection = BeanProperties.value(ConnectionWizardPageModel.PROPERTY_SELECTED_CONNECTION) .observe(pageModel); model = new AdvancedConnectionEditorModel(); Composite composite = setControl(new Composite(parent, SWT.None)); GridLayoutFactory.fillDefaults().applyTo(composite); DialogAdvancedPart part = new DialogAdvancedPart() { @Override protected void createAdvancedContent(Composite advancedComposite) { Label lblRegistry = new Label(advancedComposite, SWT.NONE); lblRegistry.setText("Image Registry URL:"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(150, SWT.DEFAULT) .applyTo(lblRegistry); Text txtRegistry = new Text(advancedComposite, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(txtRegistry); registryURLObservable = WidgetProperties.text(SWT.Modify).observeDelayed(DELAY, txtRegistry); ValueBindingBuilder.bind(registryURLObservable) .validatingAfterConvert(new URLValidator(VALIDATOR_URL_TYPE, true)) .converting(new TrimTrailingSlashConverter()) .to(BeanProperties.value(AdvancedConnectionEditorModel.PROP_REGISTRY_URL).observe(model)) .in(dbc); Label lblNamespace = new Label(advancedComposite, SWT.NONE); lblNamespace.setText("Cluster namespace:"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(150, SWT.DEFAULT) .applyTo(lblNamespace); Text txtClusterNamespace = new Text(advancedComposite, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false) .applyTo(txtClusterNamespace); clusterNamespaceObservable = WidgetProperties.text(SWT.Modify).observeDelayed(DELAY, txtClusterNamespace); ValueBindingBuilder.bind(clusterNamespaceObservable).converting(new TrimmingStringConverter()).to( BeanProperties.value(AdvancedConnectionEditorModel.PROP_CLUSTER_NAMESPACE).observe(model)) .in(dbc); } @Override protected GridLayoutFactory adjustAdvancedCompositeLayout(GridLayoutFactory gridLayoutFactory) { return gridLayoutFactory.numColumns(2); } }; part.createAdvancedGroup(composite, 1); this.connectionAdvancedPropertiesProvider = new ConnectionAdvancedPropertiesProvider(); return composite; }
From source file:org.marketcetera.photon.notification.DesktopNotificationPopup.java
/** * Creates the heading area of the popup. * /*from w w w . j ava 2 s . c om*/ * @param parent * the parent */ private void createHeading(Composite parent) { Composite composite = new Composite(parent, SWT.NO_FOCUS); composite.setBackground(parent.getBackground()); GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); // layout depends on whether there is an image Image image = getImage(mNotification); GridLayoutFactory layout = GridLayoutFactory.swtDefaults().spacing(15, 5); if (image != null) { layout.numColumns(3).applyTo(composite); Label imageLabel = new Label(composite, SWT.NO_FOCUS); imageLabel.setBackground(parent.getBackground()); GridDataFactory.defaultsFor(imageLabel).span(1, 3).applyTo(imageLabel); imageLabel.setImage(image); } else { layout.numColumns(2).applyTo(composite); } createLabel(composite, Messages.POPUP_SUBJECT_LABEL.getText(), getLabelFont(), SWT.RIGHT); // Special label that truncates text with "..." as necessary final Label subject = new Label(composite, SWT.NO_FOCUS); subject.setBackground(parent.getBackground()); subject.setFont(parent.getFont()); GridDataFactory.fillDefaults().grab(true, false).applyTo(subject); subject.addPaintListener(new PaintListener() { @Override public void paintControl(PaintEvent e) { subject.setText(fitLineToWidth(e.gc, mNotification.getSubject(), e.width)); // The text only needs to be calculated once. subject.removePaintListener(this); } }); createLabel(composite, Messages.POPUP_PRIORITY_LABEL.getText(), getLabelFont(), SWT.RIGHT); createLabel(composite, getSeverityLabel(mNotification.getSeverity()), parent.getFont(), SWT.NONE); createLabel(composite, Messages.POPUP_TIMESTAMP_LABEL.getText(), getLabelFont(), SWT.RIGHT); createLabel(composite, mNotification.getDate().toString(), parent.getFont(), SWT.NONE); }