Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Custom popupDialog: is this the right way to do id?
Custom popupDialog: is this the right way to do id? [message #754711] Thu, 03 November 2011 23:40
Eclipse UserFriend
I need to show a dialog with a "content assist look and feel", but my
eclipse rcp rich client application doesn't have any editor.. The dialog
is shown on a mousehover event... it's like a tooltip, but it contains a
custom composite with a tree or a table, and it must have the focus and
resizing management like a content assist popupDialog.
I did a new class like the one below, but the question is: maybe I am
using the wrong tool, or using it the wrong way... are there any ways to
use popupDialogs better than I did?
I didn't find any documentation on this topic... When this task will be
completed, I'll surely write a little tutorial!

Thank you in advance!

This is the class:

package it.rcpvision.project.popupdialogs;

import it.rcpvision.project.Model;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.jface.dialogs.PopupDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.wb.swt.SWTResourceManager;

public class CustomPopupDialog extends PopupDialog {

public static final int POPUP_MAXIMUM_WIDTH = 400;
public static final int POPUP_MINIMUM_HEIGHT = 300;
private Model model;

private Point location;
private Composite dialogArea;

public CustomPopupDialog(Shell parent, Model model, Point location) {
super(parent, INFOPOPUP_SHELLSTYLE, true, false, false, false, false,
model.getTitle(), null);
this.model = model;
this.location = location;

protected Control createDialogArea(Composite parent) {
dialogArea = (Composite) super.createDialogArea(parent);

CustomizedComposite customComposite = new
CustomizedComposite(dialogArea, SWT.NONE);
return dialogArea;

protected void adjustBounds() {
Shell shell = this.getShell();

Rectangle displayBounds =
int popupWidth = POPUP_MAXIMUM_WIDTH;
int dialogAreaHeight = dialogArea.getClientArea().height;
int popupHeight = dialogAreaHeight < POPUP_MINIMUM_HEIGHT ?
POPUP_MINIMUM_HEIGHT : dialogAreaHeight;

if (popupWidth + location.x > displayBounds.width){
location.x = location.x - popupWidth;

if (popupHeight + location.y > displayBounds.height) {
location.y = location.y - popupHeight;

Rectangle popupDialogBounds = new Rectangle(location.x, location.y,
popupWidth, popupHeight);




Lorenzo Murrocu
Eclispe Developer
Previous Topic:SourceViewer undo support
Next Topic:StyledCellLabelProvider and SWT.FULL_SELECTION
Goto Forum:

Current Time: Mon May 21 11:21:01 GMT 2018

Powered by FUDForum. Page generated in 0.01597 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top