List of usage examples for org.eclipse.jface.dialogs IDialogConstants BUTTON_BAR_HEIGHT
int BUTTON_BAR_HEIGHT
To view the source code for org.eclipse.jface.dialogs IDialogConstants BUTTON_BAR_HEIGHT.
Click Source Link
From source file:ca.maestrosoft.eclipse.cdt.plugin.studio.option.ui.MaestroFileListControl.java
License:Open Source License
/** * Constructor/*from w ww. ja v a 2s.c o m*/ * * This FileListControl only prompts the user on Delete for BROWSE_FILE and BROWSE_DIR * @param parent * @param compTitle * @param type one of the IOption BROWSE types * @see #BROWSE_NONE * @see #BROWSE_FILE * @see #BROWSE_DIR */ public MaestroFileListControl(Composite parent, String compTitle, int type) { promptForDelete = type == BROWSE_FILE || type == BROWSE_DIR; // Default to no browsing browseType = type; //file panel Composite filePanel = new Composite(parent, SWT.NONE); GridLayout form1 = new GridLayout(); form1.numColumns = 1; form1.horizontalSpacing = 0; form1.verticalSpacing = 0; form1.marginHeight = 0; form1.marginWidth = 0; filePanel.setLayout(form1); filePanel.setLayoutData(new GridData(GridData.FILL_BOTH)); // title panel Composite titlePanel = new Composite(filePanel, SWT.BORDER); GridLayout titleform = new GridLayout(2, false); titleform.horizontalSpacing = 0; titleform.verticalSpacing = 0; titleform.marginHeight = 0; titleform.marginWidth = 0; titlePanel.setLayout(titleform); tgdata = new GridData(GridData.FILL_HORIZONTAL); tgdata.heightHint = IDialogConstants.BUTTON_BAR_HEIGHT; titlePanel.setLayoutData(tgdata); title = new Label(titlePanel, SWT.NONE | SWT.BOLD); this.compTitle = " " + compTitle; //$NON-NLS-1$ title.setText(this.compTitle); grid2 = new GridData(GridData.FILL_HORIZONTAL); title.setLayoutData(grid2); //button panel Composite buttonPanel = new Composite(titlePanel, SWT.NONE); GridLayout form2 = new GridLayout(); form2.numColumns = 7; form2.horizontalSpacing = 0; form2.verticalSpacing = 0; form2.marginWidth = 0; form2.marginHeight = 0; buttonPanel.setLayout(form2); // toolbar toolBar = new ToolBar(buttonPanel, SWT.HORIZONTAL | SWT.RIGHT | SWT.FLAT); // add toolbar item addItem = new ToolItem(toolBar, SWT.PUSH); addItem.setImage(IMG_ADD); addItem.setToolTipText(ADD_STR); addItem.addSelectionListener(getSelectionListener()); // delete toolbar item deleteItem = new ToolItem(toolBar, SWT.PUSH); deleteItem.setImage(IMG_DEL); deleteItem.setToolTipText(DEL_STR); deleteItem.addSelectionListener(getSelectionListener()); // edit toolbar item editItem = new ToolItem(toolBar, SWT.PUSH); editItem.setImage(IMG_EDIT); editItem.setToolTipText(EDIT_STR); editItem.addSelectionListener(getSelectionListener()); // moveup toolbar item moveUpItem = new ToolItem(toolBar, SWT.PUSH); moveUpItem.setImage(IMG_MOVEUP); moveUpItem.setToolTipText(MOVEUP_STR); moveUpItem.addSelectionListener(getSelectionListener()); // movedown toolbar item moveDownItem = new ToolItem(toolBar, SWT.PUSH); moveDownItem.setImage(IMG_MOVEDOWN); moveDownItem.setToolTipText(MOVEDOWN_STR); moveDownItem.addSelectionListener(getSelectionListener()); // relative path toolbar item relPathItem = new ToolItem(toolBar, SWT.PUSH); relPathItem.setImage(null); relPathItem.setEnabled(false); // absolute toolbar item absPathItem = new ToolItem(toolBar, SWT.PUSH); absPathItem.setImage(null); absPathItem.setEnabled(false); setType(browseType); grid3 = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING); buttonPanel.setLayoutData(grid3); // list control list = new ClipboardList(filePanel, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.MULTI); grid4 = new GridData(GridData.FILL_BOTH); // force the list to be no wider than the title bar Point preferredSize = titlePanel.computeSize(SWT.DEFAULT, SWT.DEFAULT); grid4.widthHint = preferredSize.x; grid4.heightHint = preferredSize.y * 3; grid4.horizontalSpan = 2; list.setLayoutData(grid4); list.addSelectionListener(getSelectionListener()); //Add a double-click event handler list.addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent e) { // Popup the editor on the selected item from the list editSelection(); } }); // Add a delete key listener list.addKeyListener(new KeyAdapter() { /* (non-Javadoc) * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent) */ @Override public void keyPressed(KeyEvent e) { switch (e.keyCode) { case SWT.BS: case SWT.DEL: if (e.stateMask == SWT.NONE) removePressed(); break; } } }); // Set-up Undo history undoContext = new ObjectUndoContext(this); operationHistory.setLimit(undoContext, 50); // Add command handlers for undo to the control try { IFocusService fs = (IFocusService) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getActivePart().getSite().getService(IFocusService.class); fs.addFocusTracker(list, "org.eclipse.cdt.ui.FileListControl"); //$NON-NLS-1$ } catch (Exception e) { // Any of the get* methods may return null. As this is in the UI constructor for this control // it shouldn't happen. Log and carry on. CUIPlugin.log(e); } selectionChanged(); }
From source file:com.architexa.diagrams.relo.jdt.actions.OpenReloSessionTreeDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite dlgComposite = (Composite) super.createDialogArea(parent); Composite composite = new Composite(dlgComposite, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2;// w w w. java 2s.co m composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); Label lbl = new Label(composite, SWT.NO_FOCUS); lbl.setText("Select path to open in Relo Session:"); ToolBar imgTB = new ToolBar(composite, SWT.FLAT | SWT.HORIZONTAL); ToolItem imgToolItem = new ToolItem(imgTB, SWT.PUSH); try { URL url = ReloPlugin.getDefault().getBundle().getEntry("icons/remove.gif"); imgToolItem.setImage(new Image(Display.getDefault(), url.openStream())); } catch (IOException e) { imgToolItem.setText("x"); } imgToolItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { removeSelected(); } }); imgTB.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); treeViewer = new TreeViewer(composite, SWT.BORDER); GridData treeGridData = new GridData(GridData.FILL_BOTH); treeGridData.minimumWidth = convertHorizontalDLUsToPixels(3 * IDialogConstants.BUTTON_WIDTH); treeGridData.minimumHeight = convertVerticalDLUsToPixels(4 * IDialogConstants.BUTTON_BAR_HEIGHT); treeGridData.horizontalSpan = 2; treeViewer.getControl().setLayoutData(treeGridData); treeViewer.setContentProvider(new TreeContentProvider()); treeViewer.setLabelProvider(lblProvider); treeViewer.setInput(rootTNode); treeViewer.getControl().setFocus(); //viewer.setSelection(new StructuredSelection(navPaths[0])); return dlgComposite; }
From source file:org.bonitasoft.studio.properties.sections.appearance.BonitaRulerGridPropertySection.java
License:Open Source License
/** * @param event -/*from w ww. ja v a 2s .c o m*/ * selection event * @param button - * event source * @param imageDescriptor - * the image to draw overlay on the button after the new * color is set * @return - new RGB color, or null if none selected */ private RGB changeColor(SelectionEvent event, Button button, ImageDescriptor imageDescriptor, int previousColor) { ColorPalettePopup popup = new ColorPalettePopup(button.getParent().getShell(), IDialogConstants.BUTTON_BAR_HEIGHT); popup.setPreviousColor(previousColor); Rectangle r = button.getBounds(); Point location = button.getParent().toDisplay(r.x, r.y); popup.open(new Point(location.x, location.y + r.height)); if (popup.useDefaultColor()) { Image overlyedImage = new ColorOverlayImageDescriptor(imageDescriptor.getImageData(), FigureUtilities.integerToRGB(new Integer(LIGHT_GRAY_RGB))).createImage(); disposeImage(button.getImage()); button.setImage(overlyedImage); return FigureUtilities.integerToRGB(new Integer(LIGHT_GRAY_RGB)); } if (popup.getSelectedColor() != null) { Image overlyedImage = new ColorOverlayImageDescriptor(imageDescriptor.getImageData(), popup.getSelectedColor()).createImage(); disposeImage(button.getImage()); button.setImage(overlyedImage); } return popup.getSelectedColor(); }
From source file:org.bonitasoft.studio.properties.sections.appearance.ForkedColorsAndFontsPropertySection.java
License:Open Source License
/** * @param event -/*from w w w .j av a2 s. c o m*/ * selection event * @param button - * event source * @param propertyId - * id of the property * @param commandName - * name of the command * @param imageDescriptor - * the image to draw overlay on the button after the new color is * set * @return - new RGB color, or null if none selected */ protected RGB changeColor(SelectionEvent event, Button button, final String propertyId, String commandName, ImageDescriptor imageDescriptor) { CustomColorPalettePopup popup = new CustomColorPalettePopup(button.getParent().getShell(), IDialogConstants.BUTTON_BAR_HEIGHT); popup.setPreviousColor(previousColor); Rectangle r = button.getBounds(); Point location = button.getParent().toDisplay(r.x, r.y); popup.open(new Point(location.x, location.y + r.height)); if (popup.getSelectedColor() == null && !popup.useDefaultColor()) { return null; } // selectedColor should be null if we are to use the default color final RGB selectedColor = popup.getSelectedColor(); final EStructuralFeature feature = (EStructuralFeature) PackageUtil.getElement(propertyId); // Update model in response to user List commands = new ArrayList(); Iterator it = getInputIterator(); RGB colorToReturn = selectedColor; RGB color = selectedColor; while (it.hasNext()) { final IGraphicalEditPart ep = (IGraphicalEditPart) it.next(); color = selectedColor; if (popup.useDefaultColor()) { Object preferredValue = ep.getPreferredValue(feature); if (preferredValue instanceof Integer) { color = FigureUtilities.integerToRGB((Integer) preferredValue); } } // If we are using default colors, we want to return the color of the first selected element to be consistent if (colorToReturn == null) { colorToReturn = color; } if (color != null) { final RGB finalColor = color; // need a final variable commands.add(createCommand(commandName, ((View) ep.getModel()).eResource(), new Runnable() { public void run() { ENamedElement element = PackageUtil.getElement(propertyId); if (element instanceof EStructuralFeature) ep.setStructuralFeatureValue(feature, FigureUtilities.RGBToInteger(finalColor)); } })); } } if (!commands.isEmpty()) { executeAsCompositeCommand(commandName, commands); Image overlyedImage = new ColorOverlayImageDescriptor(imageDescriptor.getImageData(), color) .createImage(); disposeImage(button.getImage()); button.setImage(overlyedImage); } return colorToReturn; }
From source file:org.eclipse.cdt.utils.ui.controls.FileListControl.java
License:Open Source License
/** * Constructor//w w w . j av a2s . com * * This FileListControl only prompts the user on Delete for BROWSE_FILE and BROWSE_DIR * @param parent * @param compTitle * @param type one of the IOption BROWSE types * @see #BROWSE_NONE * @see #BROWSE_FILE * @see #BROWSE_DIR */ public FileListControl(Composite parent, String compTitle, int type) { promptForDelete = type == BROWSE_FILE || type == BROWSE_DIR; // Default to no browsing browseType = type; //file panel Composite filePanel = new Composite(parent, SWT.NONE); GridLayout form1 = new GridLayout(); form1.numColumns = 1; form1.horizontalSpacing = 0; form1.verticalSpacing = 0; form1.marginHeight = 0; form1.marginWidth = 0; filePanel.setLayout(form1); filePanel.setLayoutData(new GridData(GridData.FILL_BOTH)); // title panel Composite titlePanel = new Composite(filePanel, SWT.BORDER); GridLayout titleform = new GridLayout(2, false); titleform.horizontalSpacing = 0; titleform.verticalSpacing = 0; titleform.marginHeight = 0; titleform.marginWidth = 0; titlePanel.setLayout(titleform); tgdata = new GridData(GridData.FILL_HORIZONTAL); tgdata.heightHint = IDialogConstants.BUTTON_BAR_HEIGHT; titlePanel.setLayoutData(tgdata); title = new Label(titlePanel, SWT.NONE | SWT.BOLD); this.compTitle = " " + compTitle; //$NON-NLS-1$ title.setText(this.compTitle); grid2 = new GridData(GridData.FILL_HORIZONTAL); title.setLayoutData(grid2); //button panel Composite buttonPanel = new Composite(titlePanel, SWT.NONE); GridLayout form2 = new GridLayout(); form2.numColumns = 5; form2.horizontalSpacing = 0; form2.verticalSpacing = 0; form2.marginWidth = 0; form2.marginHeight = 0; buttonPanel.setLayout(form2); // toolbar toolBar = new ToolBar(buttonPanel, SWT.HORIZONTAL | SWT.RIGHT | SWT.FLAT); // add toolbar item addItem = new ToolItem(toolBar, SWT.PUSH); addItem.setImage(IMG_ADD); addItem.setToolTipText(ADD_STR); addItem.addSelectionListener(getSelectionListener()); // delete toolbar item deleteItem = new ToolItem(toolBar, SWT.PUSH); deleteItem.setImage(IMG_DEL); deleteItem.setToolTipText(DEL_STR); deleteItem.addSelectionListener(getSelectionListener()); // edit toolbar item editItem = new ToolItem(toolBar, SWT.PUSH); editItem.setImage(IMG_EDIT); editItem.setToolTipText(EDIT_STR); editItem.addSelectionListener(getSelectionListener()); // moveup toolbar item moveUpItem = new ToolItem(toolBar, SWT.PUSH); moveUpItem.setImage(IMG_MOVEUP); moveUpItem.setToolTipText(MOVEUP_STR); moveUpItem.addSelectionListener(getSelectionListener()); // movedown toolbar item moveDownItem = new ToolItem(toolBar, SWT.PUSH); moveDownItem.setImage(IMG_MOVEDOWN); moveDownItem.setToolTipText(MOVEDOWN_STR); moveDownItem.addSelectionListener(getSelectionListener()); grid3 = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING); buttonPanel.setLayoutData(grid3); // list control list = new ClipboardList(filePanel, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.MULTI); grid4 = new GridData(GridData.FILL_BOTH); // force the list to be no wider than the title bar Point preferredSize = titlePanel.computeSize(SWT.DEFAULT, SWT.DEFAULT); grid4.widthHint = preferredSize.x; grid4.heightHint = preferredSize.y * 3; grid4.horizontalSpan = 2; list.setLayoutData(grid4); list.addSelectionListener(getSelectionListener()); //Add a double-click event handler list.addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent e) { // Popup the editor on the selected item from the list editSelection(); } }); // Add a delete key listener list.addKeyListener(new KeyAdapter() { /* (non-Javadoc) * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent) */ @Override public void keyPressed(KeyEvent e) { switch (e.keyCode) { case SWT.BS: case SWT.DEL: if (e.stateMask == SWT.NONE) removePressed(); break; } } }); // Set-up Undo history undoContext = new ObjectUndoContext(this); operationHistory.setLimit(undoContext, 50); // Add command handlers for undo to the control try { IFocusService fs = (IFocusService) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getActivePart().getSite().getService(IFocusService.class); fs.addFocusTracker(list, "org.eclipse.cdt.ui.FileListControl"); //$NON-NLS-1$ } catch (Exception e) { // Any of the get* methods may return null. As this is in the UI constructor for this control // it shouldn't happen. Log and carry on. CUIPlugin.log(e); } selectionChanged(); }
From source file:org.eclipse.gmf.runtime.diagram.ui.properties.sections.appearance.ColorsAndFontsPropertySection.java
License:Open Source License
/** * @param event -//from w ww . j a v a 2 s. c o m * selection event * @param button - * event source * @param propertyId - * id of the property * @param commandName - * name of the command * @param imageDescriptor - * the image to draw overlay on the button after the new color is * set * @return - new RGB color, or null if none selected */ protected RGB changeColor(SelectionEvent event, Button button, final String propertyId, String commandName, ImageDescriptor imageDescriptor) { ColorPalettePopup popup = new ColorPalettePopup(button.getParent().getShell(), IDialogConstants.BUTTON_BAR_HEIGHT); popup.setPreviousColor(previousColor); Rectangle r = button.getBounds(); Point location = button.getParent().toDisplay(r.x, r.y); popup.open(new Point(location.x, location.y + r.height)); if (popup.getSelectedColor() == null && !popup.useDefaultColor()) { return null; } // selectedColor should be null if we are to use the default color final RGB selectedColor = popup.getSelectedColor(); final EStructuralFeature feature = (EStructuralFeature) PackageUtil.getElement(propertyId); // Update model in response to user List commands = new ArrayList(); Iterator it = getInputIterator(); RGB colorToReturn = selectedColor; RGB color = selectedColor; while (it.hasNext()) { final IGraphicalEditPart ep = (IGraphicalEditPart) it.next(); color = selectedColor; if (popup.useDefaultColor()) { Object preferredValue = ep.getPreferredValue(feature); if (preferredValue instanceof Integer) { color = FigureUtilities.integerToRGB((Integer) preferredValue); } } // If we are using default colors, we want to return the color of the first selected element to be consistent if (colorToReturn == null) { colorToReturn = color; } if (color != null) { final RGB finalColor = color; // need a final variable commands.add(createCommand(commandName, ((View) ep.getModel()).eResource(), new Runnable() { public void run() { ENamedElement element = PackageUtil.getElement(propertyId); if (element instanceof EStructuralFeature) ep.setStructuralFeatureValue(feature, FigureUtilities.RGBToInteger(finalColor)); } })); } } if (!commands.isEmpty()) { executeAsCompositeCommand(commandName, commands); Image overlyedImage = new ColorOverlayImageDescriptor(imageDescriptor.getImageData(), color) .createImage(); disposeImage(button.getImage()); button.setImage(overlyedImage); } return colorToReturn; }
From source file:org.eclipse.gmf.tooling.simplemap.diagram.properties.figure.FigurePropertiesSection.java
License:Open Source License
/** * @param event -//from w w w. j a v a 2 s . com * selection event * @param button - * event source * @param propertyId - * id of the property * @param commandName - * name of the command * @param imageDescriptor - * the image to draw overlay on the button after the new color is * set * @return - new RGB color, or null if none selected */ protected RGB pickColor(Button button, int previousColor, RGB defaultColor) { ColorPalettePopup popup = new ColorPalettePopup(button.getParent().getShell(), IDialogConstants.BUTTON_BAR_HEIGHT); popup.setPreviousColor(previousColor); Rectangle r = button.getBounds(); Point location = button.getParent().toDisplay(r.x, r.y); popup.open(new Point(location.x - r.height / 6, location.y - 6 * r.height)); final RGB selectedColor = popup.getSelectedColor(); if (selectedColor == null && popup.useDefaultColor()) { return defaultColor; } return selectedColor; }
From source file:org.eclipse.gmf.tooling.simplemap.diagram.properties.figure.FigurePropertiesSection.java
License:Open Source License
/** * @param event -/*from w w w .j a v a 2 s . c o m*/ * selection event * @param button - * event source * @param propertyId - * id of the property * @param commandName - * name of the command * @param imageDescriptor - * the image to draw overlay on the button after the new color is * set * @return - new RGB color, or null if none selected */ protected RGB changeColor(SelectionEvent event, Button button, String commandName, ImageDescriptor imageDescriptor, final RGBColor inputColor, int previousColor) { ColorPalettePopup popup = new ColorPalettePopup(button.getParent().getShell(), IDialogConstants.BUTTON_BAR_HEIGHT); popup.setPreviousColor(previousColor); Rectangle r = button.getBounds(); Point location = button.getParent().toDisplay(r.x, r.y); popup.open(new Point(location.x, location.y + r.height)); if (popup.getSelectedColor() == null && !popup.useDefaultColor()) { return null; } // selectedColor should be null if we are to use the default color final RGB selectedColor = popup.getSelectedColor(); // Update model in response to user List<ICommand> commands = new ArrayList<ICommand>(); RGB colorToReturn = selectedColor; RGB color = selectedColor; color = selectedColor; // if (popup.useDefaultColor()) { // Object preferredValue = ep.getPreferredValue(feature); // if (preferredValue instanceof Integer) { // color = FigureUtilities // .integerToRGB((Integer) preferredValue); // } // } // If we are using default colors, we want to return the color of the first selected element to be consistent if (colorToReturn == null) { colorToReturn = color; } if (color != null) { final RGB finalColor = color; // need a final variable commands.add(createCommand(commandName, inputColor.eResource(), new Runnable() { public void run() { inputColor.setBlue(finalColor.blue); inputColor.setGreen(finalColor.green); inputColor.setRed(finalColor.red); } })); } if (!commands.isEmpty()) { executeAsCompositeCommand(commandName, commands); Image overlyedImage = new ColorOverlayImageDescriptor(imageDescriptor.getImageData(), color) .createImage(); disposeImage(button.getImage()); button.setImage(overlyedImage); } return colorToReturn; }
From source file:org.eclipse.papyrus.infra.gmfdiag.preferences.jface.preference.ColorFieldEditor.java
License:Open Source License
private void changeColors(Button button) { colorSelector = new ColorPalettePopup(colorButton.getParent().getShell(), IDialogConstants.BUTTON_BAR_HEIGHT); Rectangle r = button.getBounds(); Point location = button.getParent().toDisplay(r.x, r.y); colorSelector.open(location);/* www . ja v a 2 s .c o m*/ if (colorSelector.getSelectedColor() == null && !colorSelector.useDefaultColor()) { return; } updateButtonImage(colorSelector.getSelectedColor()); }
From source file:org.eclipse.papyrus.infra.gmfdiag.preferences.jface.preference.GradientFieldEditor.java
License:Open Source License
/** * Allow user to change the color of the given button. * //from www . ja v a 2 s . co m * @param button * the button * @return the selected color or null * @see org.eclipse.gmf.runtime.diagram.ui.properties.sections.appearance.ColorPalettePopup */ private RGB changeColor() { ColorPalettePopup popup = new ColorPalettePopup(colorButton.getParent().getShell(), IDialogConstants.BUTTON_BAR_HEIGHT); Rectangle r = colorButton.getBounds(); Point location = colorButton.getParent().toDisplay(r.x, r.y); popup.open(new Point(location.x, location.y + r.height)); if (popup.getSelectedColor() == null && !popup.useDefaultColor()) { return null; } RGB rgb = popup.getSelectedColor(); setButtonImage(rgb); return rgb; }