List of usage examples for org.eclipse.jface.dialogs IDialogConstants VERTICAL_MARGIN
int VERTICAL_MARGIN
To view the source code for org.eclipse.jface.dialogs IDialogConstants VERTICAL_MARGIN.
Click Source Link
From source file:org.eclipse.ui.texteditor.MessageRegion.java
License:Open Source License
/** * Create the contents for the receiver. * * @param parent the Composite that the children will be created in *///from www . ja va 2 s . c o m public void createContents(Composite parent) { messageComposite = new Composite(parent, SWT.NONE); GridLayout messageLayout = new GridLayout(); messageLayout.numColumns = 2; messageLayout.marginWidth = 0; messageLayout.marginHeight = 0; messageLayout.makeColumnsEqualWidth = false; messageComposite.setLayout(messageLayout); messageImageLabel = new Label(messageComposite, SWT.NONE); GridData imageData = new GridData(GridData.VERTICAL_ALIGN_CENTER); Image sizingImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR); Rectangle imageBounds; if (sizingImage == null) imageBounds = new Rectangle(0, 0, IDialogConstants.VERTICAL_MARGIN * 2, IDialogConstants.VERTICAL_MARGIN * 2); else imageBounds = sizingImage.getBounds(); imageData.heightHint = imageBounds.height + IDialogConstants.VERTICAL_SPACING; imageData.widthHint = imageBounds.width + IDialogConstants.HORIZONTAL_SPACING; messageImageLabel.setLayoutData(imageData); messageText = new Text(messageComposite, SWT.NONE); messageText.setEditable(false); messageText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); GridData textData = new GridData( GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER); messageText.setLayoutData(textData); hideRegion(); }
From source file:org.eclipse.ui.views.markers.internal.DialogProblemFilter.java
License:Open Source License
Composite createSelectedFilterArea(Composite composite) { Composite wrapper = new Composite(composite, SWT.NONE); FormLayout wrapperLayout = new FormLayout(); wrapperLayout.marginHeight = 0;/*from ww w . java 2s.c om*/ wrapperLayout.marginWidth = 0; wrapper.setLayout(wrapperLayout); systemSettingsLabel = createSystemSettingsLabel(wrapper); systemSettingsLabel.setVisible(false); FormData systemData = new FormData(); systemData.top = new FormAttachment(0, IDialogConstants.VERTICAL_MARGIN); systemData.left = new FormAttachment(0, IDialogConstants.HORIZONTAL_MARGIN); systemData.right = new FormAttachment(100, -1 * IDialogConstants.HORIZONTAL_MARGIN); systemData.bottom = new FormAttachment(100, -1 * IDialogConstants.VERTICAL_MARGIN); systemSettingsLabel.setLayoutData(systemData); userFilterComposite = super.createSelectedFilterArea(wrapper); FormData userData = new FormData(); userData.top = new FormAttachment(0); userData.left = new FormAttachment(0); userData.right = new FormAttachment(100); userData.bottom = new FormAttachment(100); userFilterComposite.setLayoutData(userData); return wrapper; }
From source file:org.eclipse.ui.views.markers.internal.MarkerResolutionDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { initializeDialogUnits(parent);// ww w . j a v a2s . c om setTitleImage(JFaceResources.getResources().createImageWithDefault( IDEInternalWorkbenchImages.getImageDescriptor(IDEInternalWorkbenchImages.IMG_DLGBAN_QUICKFIX_DLG))); Composite mainArea = (Composite) super.createDialogArea(parent); // Create a new composite as there is the title bar seperator // to deal with Composite control = new Composite(mainArea, SWT.NONE); control.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); FormLayout layout = new FormLayout(); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.spacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); control.setLayout(layout); Label resolutionsLabel = new Label(control, SWT.NONE); resolutionsLabel.setText(MarkerMessages.MarkerResolutionDialog_Resolutions_List_Title); resolutionsLabel.setLayoutData(new FormData()); resolutionsList = new ListViewer(control, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL); resolutionsList.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { return resolutions; } /* * (non-Javadoc) * * @see org.eclipse.jface.viewers.IContentProvider#dispose() */ public void dispose() { } /* * (non-Javadoc) * * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, * java.lang.Object, java.lang.Object) */ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }); resolutionsList.setLabelProvider(new LabelProvider() { public String getText(Object element) { return ((IMarkerResolution) element).getLabel(); } }); resolutionsList.addSelectionChangedListener(new ISelectionChangedListener() { /* * (non-Javadoc) * * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) */ public void selectionChanged(SelectionChangedEvent event) { WorkbenchMarkerResolution resolution = getSelectedWorkbenchResolution(); if (resolution == null || markerMap.containsKey(resolution)) addMatching.setEnabled(false); else addMatching.setEnabled(true); markersTable.refresh(); } }); resolutionsList.setInput(this); resolutionsList.setComparator(resolutionsComparator); FormData listData = new FormData(); listData.top = new FormAttachment(resolutionsLabel, 0); listData.left = new FormAttachment(0); listData.right = new FormAttachment(100, 0); listData.height = convertHeightInCharsToPixels(10); resolutionsList.getControl().setLayoutData(listData); Label title = new Label(control, SWT.NONE); title.setText(MarkerMessages.MarkerResolutionDialog_Problems_List_Title); FormData labelData = new FormData(); labelData.top = new FormAttachment(resolutionsList.getControl(), 0); labelData.left = new FormAttachment(0); title.setLayoutData(labelData); Composite buttons = createTableButtons(control); FormData buttonData = new FormData(); buttonData.top = new FormAttachment(title, 0); buttonData.right = new FormAttachment(100); buttonData.height = convertHeightInCharsToPixels(10); buttons.setLayoutData(buttonData); createMarkerTable(control); FormData tableData = new FormData(); tableData.top = new FormAttachment(buttons, 0, SWT.TOP); tableData.left = new FormAttachment(0); tableData.right = new FormAttachment(buttons, 0); tableData.height = convertHeightInCharsToPixels(10); markersTable.getControl().setLayoutData(tableData); progressPart = new ProgressMonitorPart(control, new GridLayout()); FormData progressData = new FormData(); progressData.top = new FormAttachment(markersTable.getControl(), 0); progressData.left = new FormAttachment(0); progressData.right = new FormAttachment(100, 0); progressPart.setLayoutData(progressData); Dialog.applyDialogFont(control); String message = NLS.bind(MarkerMessages.MarkerResolutionDialog_Description, Util.getProperty(IMarker.MESSAGE, originalMarker)); if (message.length() > 50) { // Add a carriage return in the middle if we can int insertionIndex = chooseWhitespace(message); if (insertionIndex > 0) { StringBuffer buffer = new StringBuffer(); buffer.append(message.substring(0, insertionIndex)); buffer.append("\n"); //$NON-NLS-1$ buffer.append(message.substring(insertionIndex, message.length())); message = buffer.toString(); } } setMessage(message); return mainArea; }
From source file:org.eclipse.umlgen.dsl.eth.presentation.components.ComponentsEditorDialog.java
License:Open Source License
/** * {@inheritDoc}/*from www.jav a 2s.c o m*/ * * @see org.eclipse.emf.edit.ui.celleditor.FeatureEditorDialog#createDialogArea(org.eclipse.swt.widgets.Composite) */ @Override protected Control createDialogArea(Composite parent) { Composite contents = new Composite(parent, SWT.NONE); { GridLayout layout = new GridLayout(); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); contents.setLayout(layout); contents.setLayoutData(new GridData(GridData.FILL_BOTH)); applyDialogFont(contents); } GridLayout contentsGridLayout = (GridLayout) contents.getLayout(); contentsGridLayout.numColumns = 3; GridData contentsGridData = (GridData) contents.getLayoutData(); contentsGridData.horizontalAlignment = SWT.FILL; contentsGridData.verticalAlignment = SWT.FILL; Text patternText = null; if (choiceOfValues != null) { Group filterGroupComposite = new Group(contents, SWT.NONE); filterGroupComposite.setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Choices_pattern_group")); filterGroupComposite.setLayout(new GridLayout(2, false)); filterGroupComposite.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 3, 1)); Label label = new Label(filterGroupComposite, SWT.NONE); label.setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Choices_pattern_label")); patternText = new Text(filterGroupComposite, SWT.BORDER); patternText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); } Composite choiceComposite = new Composite(contents, SWT.NONE); { GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); data.horizontalAlignment = SWT.END; choiceComposite.setLayoutData(data); GridLayout layout = new GridLayout(); data.horizontalAlignment = SWT.FILL; layout.marginHeight = 0; layout.marginWidth = 0; layout.numColumns = 1; choiceComposite.setLayout(layout); } Label choiceLabel = new Label(choiceComposite, SWT.NONE); choiceLabel.setText(choiceOfValues == null ? EMFEditUIPlugin.INSTANCE.getString("_UI_Value_label") : EMFEditUIPlugin.INSTANCE.getString("_UI_Choices_label")); GridData choiceLabelGridData = new GridData(); choiceLabelGridData.verticalAlignment = SWT.FILL; choiceLabelGridData.horizontalAlignment = SWT.FILL; choiceLabel.setLayoutData(choiceLabelGridData); final Tree choiceTable = choiceOfValues == null ? null : new Tree(choiceComposite, SWT.MULTI | SWT.BORDER); if (choiceTable != null) { GridData choiceTableGridData = new GridData(); choiceTableGridData.widthHint = Display.getCurrent().getBounds().width / 5; choiceTableGridData.heightHint = Display.getCurrent().getBounds().height / 3; choiceTableGridData.verticalAlignment = SWT.FILL; choiceTableGridData.horizontalAlignment = SWT.FILL; choiceTableGridData.grabExcessHorizontalSpace = true; choiceTableGridData.grabExcessVerticalSpace = true; choiceTable.setLayoutData(choiceTableGridData); } final TreeViewer choiceTreeViewer = choiceOfValues == null ? null : new TreeViewer(choiceTable); if (choiceOfValues != null) { choiceTreeViewer.setContentProvider(new ComponentsChoiceAdapterFactoryContentProvider( new TreeItemProviderAdapterFactory(), values.getChildren(), object)); choiceTreeViewer.setLabelProvider(labelProvider); final PatternFilter filter = new PatternFilter() { @Override protected boolean isParentMatch(Viewer viewer, Object element) { return viewer instanceof AbstractTreeViewer && super.isParentMatch(viewer, element); } }; choiceTreeViewer.addFilter(filter); choiceTreeViewer.setComparator(new ViewerComparator()); assert patternText != null; patternText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { filter.setPattern(((Text) e.widget).getText()); choiceTreeViewer.refresh(); } }); choiceTreeViewer.setInput(new ItemProvider(choiceOfValues)); } // We use multi even for a single line because we want to respond to the // enter key. // int style = multiLine ? SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER : SWT.MULTI | SWT.BORDER; final Text choiceText = choiceOfValues == null ? new Text(choiceComposite, style) : null; if (choiceText != null) { GridData choiceTextGridData = new GridData(); choiceTextGridData.widthHint = Display.getCurrent().getBounds().width / 5; choiceTextGridData.verticalAlignment = SWT.BEGINNING; choiceTextGridData.horizontalAlignment = SWT.FILL; choiceTextGridData.grabExcessHorizontalSpace = true; if (multiLine) { choiceTextGridData.verticalAlignment = SWT.FILL; choiceTextGridData.grabExcessVerticalSpace = true; } choiceText.setLayoutData(choiceTextGridData); } Composite controlButtons = new Composite(contents, SWT.NONE); GridData controlButtonsGridData = new GridData(); controlButtonsGridData.verticalAlignment = SWT.FILL; controlButtonsGridData.horizontalAlignment = SWT.FILL; controlButtons.setLayoutData(controlButtonsGridData); GridLayout controlsButtonGridLayout = new GridLayout(); controlButtons.setLayout(controlsButtonGridLayout); new Label(controlButtons, SWT.NONE); final Button addButton = new Button(controlButtons, SWT.PUSH); addButton.setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Add_label")); GridData addButtonGridData = new GridData(); addButtonGridData.verticalAlignment = SWT.FILL; addButtonGridData.horizontalAlignment = SWT.FILL; addButton.setLayoutData(addButtonGridData); final Button removeButton = new Button(controlButtons, SWT.PUSH); removeButton.setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Remove_label")); GridData removeButtonGridData = new GridData(); removeButtonGridData.verticalAlignment = SWT.FILL; removeButtonGridData.horizontalAlignment = SWT.FILL; removeButton.setLayoutData(removeButtonGridData); Label spaceLabel = new Label(controlButtons, SWT.NONE); GridData spaceLabelGridData = new GridData(); spaceLabelGridData.verticalSpan = 2; spaceLabel.setLayoutData(spaceLabelGridData); Composite featureComposite = new Composite(contents, SWT.NONE); { GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); data.horizontalAlignment = SWT.END; featureComposite.setLayoutData(data); GridLayout layout = new GridLayout(); data.horizontalAlignment = SWT.FILL; layout.marginHeight = 0; layout.marginWidth = 0; layout.numColumns = 1; featureComposite.setLayout(layout); } Label featureLabel = new Label(featureComposite, SWT.NONE); featureLabel.setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Feature_label")); GridData featureLabelGridData = new GridData(); featureLabelGridData.horizontalSpan = 2; featureLabelGridData.horizontalAlignment = SWT.FILL; featureLabelGridData.verticalAlignment = SWT.FILL; featureLabel.setLayoutData(featureLabelGridData); final Tree featureTable = new Tree(featureComposite, SWT.MULTI | SWT.BORDER); GridData featureTableGridData = new GridData(); featureTableGridData.widthHint = Display.getCurrent().getBounds().width / 5; featureTableGridData.heightHint = Display.getCurrent().getBounds().height / 3; featureTableGridData.verticalAlignment = SWT.FILL; featureTableGridData.horizontalAlignment = SWT.FILL; featureTableGridData.grabExcessHorizontalSpace = true; featureTableGridData.grabExcessVerticalSpace = true; featureTable.setLayoutData(featureTableGridData); final TreeViewer featureTableViewer = new TreeViewer(featureTable); featureTableViewer.setContentProvider(contentProvider); featureTableViewer.setLabelProvider(labelProvider); featureTableViewer.setComparator(new ViewerComparator()); featureTableViewer.setInput(values); if (!values.getChildren().isEmpty()) { featureTableViewer.setSelection(new StructuredSelection(values.getChildren().get(0))); } if (choiceTreeViewer != null) { choiceTreeViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { if (addButton.isEnabled()) { addButton.notifyListeners(SWT.Selection, null); } } }); featureTableViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { if (removeButton.isEnabled()) { removeButton.notifyListeners(SWT.Selection, null); } } }); } if (choiceText != null) { choiceText.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent event) { if (!multiLine && (event.character == '\r' || event.character == '\n')) { try { Object value = EcoreUtil.createFromString((EDataType) eClassifier, choiceText.getText()); values.getChildren().add(value); choiceText.setText(""); featureTableViewer.setSelection(new StructuredSelection(value)); event.doit = false; } catch (RuntimeException exception) { // Ignore } } else if (event.character == '\33') { choiceText.setText(""); event.doit = false; } } }); } addButton.addSelectionListener(new SelectionAdapter() { // event is null when choiceTableViewer is double clicked @Override public void widgetSelected(SelectionEvent event) { if (choiceTreeViewer != null) { IStructuredSelection selection = (IStructuredSelection) choiceTreeViewer.getSelection(); for (Iterator<?> i = selection.iterator(); i.hasNext();) { Object value = i.next(); if (isCandidateValue(value)) { values.getChildren().add(value); } } featureTableViewer.setSelection(selection); choiceTreeViewer.refresh(); } else if (choiceText != null) { try { Object value = EcoreUtil.createFromString((EDataType) eClassifier, choiceText.getText()); if (isCandidateValue(value)) { values.getChildren().add(value); choiceText.setText(""); } featureTableViewer.setSelection(new StructuredSelection(value)); } catch (RuntimeException exception) { // Ignore } } choiceTreeViewer.refresh(); } }); removeButton.addSelectionListener(new SelectionAdapter() { // event is null when featureTableViewer is double clicked @Override public void widgetSelected(SelectionEvent event) { IStructuredSelection selection = (IStructuredSelection) featureTableViewer.getSelection(); Object firstValue = null; for (Iterator<?> i = selection.iterator(); i.hasNext();) { Object value = i.next(); if (firstValue == null) { firstValue = value; } values.getChildren().remove(value); } if (!values.getChildren().isEmpty()) { featureTableViewer.setSelection(new StructuredSelection(values.getChildren().get(0))); } if (choiceTreeViewer != null) { choiceTreeViewer.setSelection(selection); } else if (choiceText != null) { if (firstValue != null) { String value = EcoreUtil.convertToString((EDataType) eClassifier, firstValue); choiceText.setText(value); } } choiceTreeViewer.refresh(); } }); return contents; }
From source file:org.eclipse.umlgen.dsl.eth.presentation.connectors.ConnectorsEditorDialog.java
License:Open Source License
/** * {@inheritDoc}//from w w w . j a v a 2s . c o m * * @see org.eclipse.emf.edit.ui.celleditor.FeatureEditorDialog#createDialogArea(org.eclipse.swt.widgets.Composite) */ @Override protected Control createDialogArea(Composite parent) { Composite contents = new Composite(parent, SWT.NONE); { GridLayout layout = new GridLayout(); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); contents.setLayout(layout); contents.setLayoutData(new GridData(GridData.FILL_BOTH)); applyDialogFont(contents); } GridLayout contentsGridLayout = (GridLayout) contents.getLayout(); contentsGridLayout.numColumns = 3; GridData contentsGridData = (GridData) contents.getLayoutData(); contentsGridData.horizontalAlignment = SWT.FILL; contentsGridData.verticalAlignment = SWT.FILL; Text patternText = null; if (choiceOfValues != null) { Group filterGroupComposite = new Group(contents, SWT.NONE); filterGroupComposite.setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Choices_pattern_group")); filterGroupComposite.setLayout(new GridLayout(2, false)); filterGroupComposite.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 3, 1)); Label label = new Label(filterGroupComposite, SWT.NONE); label.setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Choices_pattern_label")); patternText = new Text(filterGroupComposite, SWT.BORDER); patternText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); } Composite choiceComposite = new Composite(contents, SWT.NONE); { GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); data.horizontalAlignment = SWT.END; choiceComposite.setLayoutData(data); GridLayout layout = new GridLayout(); data.horizontalAlignment = SWT.FILL; layout.marginHeight = 0; layout.marginWidth = 0; layout.numColumns = 1; choiceComposite.setLayout(layout); } Label choiceLabel = new Label(choiceComposite, SWT.NONE); choiceLabel.setText(choiceOfValues == null ? EMFEditUIPlugin.INSTANCE.getString("_UI_Value_label") : EMFEditUIPlugin.INSTANCE.getString("_UI_Choices_label")); GridData choiceLabelGridData = new GridData(); choiceLabelGridData.verticalAlignment = SWT.FILL; choiceLabelGridData.horizontalAlignment = SWT.FILL; choiceLabel.setLayoutData(choiceLabelGridData); final Tree choiceTable = choiceOfValues == null ? null : new Tree(choiceComposite, SWT.MULTI | SWT.BORDER); if (choiceTable != null) { GridData choiceTableGridData = new GridData(); choiceTableGridData.widthHint = Display.getCurrent().getBounds().width / 5; choiceTableGridData.heightHint = Display.getCurrent().getBounds().height / 3; choiceTableGridData.verticalAlignment = SWT.FILL; choiceTableGridData.horizontalAlignment = SWT.FILL; choiceTableGridData.grabExcessHorizontalSpace = true; choiceTableGridData.grabExcessVerticalSpace = true; choiceTable.setLayoutData(choiceTableGridData); } final TreeViewer choiceTreeViewer = choiceOfValues == null ? null : new TreeViewer(choiceTable); if (choiceOfValues != null) { choiceTreeViewer.setContentProvider(new ConnectorsChoiceAdapterFactoryContentProvider( new TreeItemProviderAdapterFactory(), values.getChildren())); choiceTreeViewer.setLabelProvider( new ConnectorsChoiceLabelProvider(propertyDescriptor.getLabelProvider(object))); final PatternFilter filter = new PatternFilter() { @Override protected boolean isParentMatch(Viewer viewer, Object element) { return viewer instanceof AbstractTreeViewer && super.isParentMatch(viewer, element); } }; choiceTreeViewer.addFilter(filter); choiceTreeViewer.setComparator(new ViewerComparator()); assert patternText != null; patternText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { filter.setPattern(((Text) e.widget).getText()); choiceTreeViewer.refresh(); } }); choiceTreeViewer.setInput(new ItemProvider(choiceOfValues)); } // We use multi even for a single line because we want to respond to the // enter key. // int style = multiLine ? SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER : SWT.MULTI | SWT.BORDER; final Text choiceText = choiceOfValues == null ? new Text(choiceComposite, style) : null; if (choiceText != null) { GridData choiceTextGridData = new GridData(); choiceTextGridData.widthHint = Display.getCurrent().getBounds().width / 5; choiceTextGridData.verticalAlignment = SWT.BEGINNING; choiceTextGridData.horizontalAlignment = SWT.FILL; choiceTextGridData.grabExcessHorizontalSpace = true; if (multiLine) { choiceTextGridData.verticalAlignment = SWT.FILL; choiceTextGridData.grabExcessVerticalSpace = true; } choiceText.setLayoutData(choiceTextGridData); } Composite controlButtons = new Composite(contents, SWT.NONE); GridData controlButtonsGridData = new GridData(); controlButtonsGridData.verticalAlignment = SWT.FILL; controlButtonsGridData.horizontalAlignment = SWT.FILL; controlButtons.setLayoutData(controlButtonsGridData); GridLayout controlsButtonGridLayout = new GridLayout(); controlButtons.setLayout(controlsButtonGridLayout); new Label(controlButtons, SWT.NONE); final Button addButton = new Button(controlButtons, SWT.PUSH); addButton.setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Add_label")); GridData addButtonGridData = new GridData(); addButtonGridData.verticalAlignment = SWT.FILL; addButtonGridData.horizontalAlignment = SWT.FILL; addButton.setLayoutData(addButtonGridData); final Button removeButton = new Button(controlButtons, SWT.PUSH); removeButton.setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Remove_label")); GridData removeButtonGridData = new GridData(); removeButtonGridData.verticalAlignment = SWT.FILL; removeButtonGridData.horizontalAlignment = SWT.FILL; removeButton.setLayoutData(removeButtonGridData); Label spaceLabel = new Label(controlButtons, SWT.NONE); GridData spaceLabelGridData = new GridData(); spaceLabelGridData.verticalSpan = 2; spaceLabel.setLayoutData(spaceLabelGridData); Composite featureComposite = new Composite(contents, SWT.NONE); { GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); data.horizontalAlignment = SWT.END; featureComposite.setLayoutData(data); GridLayout layout = new GridLayout(); data.horizontalAlignment = SWT.FILL; layout.marginHeight = 0; layout.marginWidth = 0; layout.numColumns = 1; featureComposite.setLayout(layout); } Label featureLabel = new Label(featureComposite, SWT.NONE); featureLabel.setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Feature_label")); GridData featureLabelGridData = new GridData(); featureLabelGridData.horizontalSpan = 2; featureLabelGridData.horizontalAlignment = SWT.FILL; featureLabelGridData.verticalAlignment = SWT.FILL; featureLabel.setLayoutData(featureLabelGridData); final Tree featureTable = new Tree(featureComposite, SWT.MULTI | SWT.BORDER); GridData featureTableGridData = new GridData(); featureTableGridData.widthHint = Display.getCurrent().getBounds().width / 5; featureTableGridData.heightHint = Display.getCurrent().getBounds().height / 3; featureTableGridData.verticalAlignment = SWT.FILL; featureTableGridData.horizontalAlignment = SWT.FILL; featureTableGridData.grabExcessHorizontalSpace = true; featureTableGridData.grabExcessVerticalSpace = true; featureTable.setLayoutData(featureTableGridData); final TreeViewer featureTableViewer = new TreeViewer(featureTable); featureTableViewer.setContentProvider(contentProvider); featureTableViewer.setLabelProvider(labelProvider); featureTableViewer.setComparator(new ViewerComparator()); featureTableViewer.setInput(values); if (!values.getChildren().isEmpty()) { featureTableViewer.setSelection(new StructuredSelection(values.getChildren().get(0))); } if (choiceTreeViewer != null) { choiceTreeViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { if (addButton.isEnabled()) { addButton.notifyListeners(SWT.Selection, null); } } }); featureTableViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { if (removeButton.isEnabled()) { removeButton.notifyListeners(SWT.Selection, null); } } }); } if (choiceText != null) { choiceText.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent event) { if (!multiLine && (event.character == '\r' || event.character == '\n')) { try { Object value = EcoreUtil.createFromString((EDataType) eClassifier, choiceText.getText()); values.getChildren().add(value); choiceText.setText(""); featureTableViewer.setSelection(new StructuredSelection(value)); event.doit = false; } catch (RuntimeException exception) { // Ignore } } else if (event.character == '\33') { choiceText.setText(""); event.doit = false; } } }); } addButton.addSelectionListener(new SelectionAdapter() { // event is null when choiceTableViewer is double clicked @Override public void widgetSelected(SelectionEvent event) { if (choiceTreeViewer != null) { IStructuredSelection selection = (IStructuredSelection) choiceTreeViewer.getSelection(); for (Iterator<?> i = selection.iterator(); i.hasNext();) { Object value = i.next(); if (isCandidateValue(value)) { values.getChildren().add(value); } } featureTableViewer.setSelection(selection); } else if (choiceText != null) { try { Object value = EcoreUtil.createFromString((EDataType) eClassifier, choiceText.getText()); if (isCandidateValue(value)) { values.getChildren().add(value); choiceText.setText(""); } featureTableViewer.setSelection(new StructuredSelection(value)); } catch (RuntimeException exception) { // Ignore } } choiceTreeViewer.refresh(); } }); removeButton.addSelectionListener(new SelectionAdapter() { // event is null when featureTableViewer is double clicked @Override public void widgetSelected(SelectionEvent event) { IStructuredSelection selection = (IStructuredSelection) featureTableViewer.getSelection(); Object firstValue = null; for (Iterator<?> i = selection.iterator(); i.hasNext();) { Object value = i.next(); if (firstValue == null) { firstValue = value; } values.getChildren().remove(value); } if (!values.getChildren().isEmpty()) { featureTableViewer.setSelection(new StructuredSelection(values.getChildren().get(0))); } if (choiceTreeViewer != null) { choiceTreeViewer.setSelection(selection); } else if (choiceText != null) { if (firstValue != null) { String value = EcoreUtil.convertToString((EDataType) eClassifier, firstValue); choiceText.setText(value); } } choiceTreeViewer.refresh(); } }); return contents; }
From source file:org.eclipse.vjet.eclipse.internal.ui.preferences.formatting.CreateProfileDialog.java
License:Open Source License
public Control createDialogArea(Composite parent) { final int numColumns = 2; GridData gd;//from ww w .ja v a 2s . co m final GridLayout layout = new GridLayout(numColumns, false); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); final Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(layout); // Create "Profile name:" label gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = numColumns; gd.widthHint = convertWidthInCharsToPixels(60); final Label nameLabel = new Label(composite, SWT.WRAP); nameLabel.setText(FormatterMessages.CreateProfileDialog_profile_name_label_text); nameLabel.setLayoutData(gd); // Create text field to enter name gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = numColumns; fNameText = new Text(composite, SWT.SINGLE | SWT.BORDER); fNameText.setLayoutData(gd); fNameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { doValidation(); } }); // Create "Initialize settings ..." label gd = new GridData(); gd.horizontalSpan = numColumns; Label profileLabel = new Label(composite, SWT.WRAP); profileLabel.setText(FormatterMessages.CreateProfileDialog_base_profile_label_text); profileLabel.setLayoutData(gd); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = numColumns; fProfileCombo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY); fProfileCombo.setLayoutData(gd); // "Open the edit dialog now" checkbox gd = new GridData(); gd.horizontalSpan = numColumns; fEditCheckbox = new Button(composite, SWT.CHECK); fEditCheckbox.setText(FormatterMessages.CreateProfileDialog_open_edit_dialog_checkbox_text); fEditCheckbox.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { fOpenEditDialog = ((Button) e.widget).getSelection(); } public void widgetDefaultSelected(SelectionEvent e) { } }); final IDialogSettings dialogSettings = VjetUIPlugin.getDefault().getDialogSettings();//.get(PREF_OPEN_EDIT_DIALOG); if (dialogSettings.get(PREF_OPEN_EDIT_DIALOG) != null) { fOpenEditDialog = dialogSettings.getBoolean(PREF_OPEN_EDIT_DIALOG); } else { fOpenEditDialog = true; } fEditCheckbox.setSelection(fOpenEditDialog); fProfileCombo.setItems(fSortedNames); fProfileCombo.setText(fProfileManager.getDefaultProfile().getName()); updateStatus(fEmpty); applyDialogFont(composite); fNameText.setFocus(); return composite; }
From source file:org.eclipse.wst.common.frameworks.internal.ui.ErrorDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { // create a composite with standard margins and spacing Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); composite.setLayout(layout);/*ww w . ja v a2 s . c o m*/ composite.setLayoutData(new GridData(GridData.FILL_BOTH)); composite.setFont(parent.getFont()); ((GridLayout) composite.getLayout()).numColumns = 2; // create image Image image = composite.getDisplay().getSystemImage(SWT.ICON_ERROR); if (image != null) { Label label = new Label(composite, 0); image.setBackground(label.getBackground()); label.setImage(image); label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_BEGINNING)); } // create message if (message2 != null) { Label label = new Label(composite, SWT.WRAP); label.setText(message2); GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); label.setLayoutData(data); label.setFont(parent.getFont()); } return composite; }
From source file:org.eclipse.wst.jsdt.internal.ui.actions.GenerateConstructorUsingFieldsSelectionDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { initializeDialogUnits(parent);/* w w w . j ava 2s . co m*/ Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); GridData gd = null; layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); composite.setLayout(layout); Composite classConstructorComposite = addSuperClassConstructorChoices(composite); gd = new GridData(GridData.FILL_BOTH); classConstructorComposite.setLayoutData(gd); Composite inner = new Composite(composite, SWT.NONE); GridLayout innerLayout = new GridLayout(); innerLayout.numColumns = 2; innerLayout.marginHeight = 0; innerLayout.marginWidth = 0; inner.setLayout(innerLayout); Label messageLabel = createMessageArea(inner); if (messageLabel != null) { gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan = 2; messageLabel.setLayoutData(gd); } CheckboxTreeViewer treeViewer = createTreeViewer(inner); gd = new GridData(GridData.FILL_BOTH); gd.widthHint = convertWidthInCharsToPixels(fWidth); gd.heightHint = convertHeightInCharsToPixels(fHeight); treeViewer.getControl().setLayoutData(gd); treeViewer.addSelectionChangedListener(fTreeViewerAdapter); Composite buttonComposite = createSelectionButtons(inner); gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); buttonComposite.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); inner.setLayoutData(gd); Composite entryComposite = createInsertPositionCombo(composite); entryComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite commentComposite = createCommentSelection(composite); commentComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite overrideSuperComposite = createOmitSuper(composite); overrideSuperComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Control linkControl = createLinkControl(composite); if (linkControl != null) linkControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); gd = new GridData(GridData.FILL_BOTH); composite.setLayoutData(gd); applyDialogFont(composite); return composite; }
From source file:org.eclipse.wst.jsdt.internal.ui.dialogs.SourceActionDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { initializeDialogUnits(parent);/*ww w . j a v a 2 s. c om*/ Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); GridData gd = null; layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); composite.setLayout(layout); Label messageLabel = createMessageArea(composite); if (messageLabel != null) { gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan = 2; messageLabel.setLayoutData(gd); } Composite inner = new Composite(composite, SWT.NONE); GridLayout innerLayout = new GridLayout(); innerLayout.numColumns = 2; innerLayout.marginHeight = 0; innerLayout.marginWidth = 0; inner.setLayout(innerLayout); inner.setFont(parent.getFont()); CheckboxTreeViewer treeViewer = createTreeViewer(inner); gd = new GridData(GridData.FILL_BOTH); gd.widthHint = convertWidthInCharsToPixels(fWidth); gd.heightHint = convertHeightInCharsToPixels(fHeight); treeViewer.getControl().setLayoutData(gd); Composite buttonComposite = createSelectionButtons(inner); gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); buttonComposite.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); inner.setLayoutData(gd); fInsertPositionComposite = createInsertPositionCombo(composite); fInsertPositionComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite commentComposite = createCommentSelection(composite); commentComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Control linkControl = createLinkControl(composite); if (linkControl != null) linkControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); gd = new GridData(GridData.FILL_BOTH); composite.setLayoutData(gd); applyDialogFont(composite); return composite; }
From source file:org.eclipse.wst.jsdt.internal.ui.preferences.AppearancePreferencePage.java
License:Open Source License
protected Control createContents(Composite parent) { initializeDialogUnits(parent);// ww w . ja v a 2 s.com int nColumns = 1; Composite result = new Composite(parent, SWT.NONE); result.setFont(parent.getFont()); GridLayout layout = new GridLayout(); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = 0; layout.numColumns = nColumns; result.setLayout(layout); fShowMethodReturnType.doFillIntoGrid(result, nColumns); // fShowMethodTypeParameters.doFillIntoGrid(result, nColumns); fShowCategory.doFillIntoGrid(result, nColumns); fShowMembersInPackageView.doFillIntoGrid(result, nColumns); fShowColoredLabels.doFillIntoGrid(result, nColumns); fFoldPackagesInPackageExplorer.doFillIntoGrid(result, nColumns); // new Separator().doFillIntoGrid(result, nColumns); // fCompressPackageNames.doFillIntoGrid(result, nColumns); // fPackageNamePattern.doFillIntoGrid(result, 2); // LayoutUtil.setHorizontalGrabbing(fPackageNamePattern.getTextControl(null)); // LayoutUtil.setWidthHint(fPackageNamePattern.getLabelControl(null), convertWidthInCharsToPixels(65)); // new Separator().doFillIntoGrid(result, nColumns); // fStackBrowsingViewsVertically.doFillIntoGrid(result, nColumns); // String noteTitle= PreferencesMessages.AppearancePreferencePage_note; // String noteMessage= PreferencesMessages.AppearancePreferencePage_preferenceOnlyEffectiveForNewPerspectives; // Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), result, noteTitle, noteMessage); // GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); // gd.horizontalSpan= 2; // noteControl.setLayoutData(gd); initFields(); Dialog.applyDialogFont(result); return result; }