public Popup2(final IPopupProvider provider, final Widget... controls) { super(WorkbenchHelper.getShell(), PopupDialog.HOVER_SHELLSTYLE, false, false, false, false, false, null, null); this.provider = provider; final Shell parent = provider.getControllingShell(); parent.addListener(SWT.Move, hide); parent.addListener(SWT.Resize, hide); parent.addListener(SWT.Close, hide); parent.addListener(SWT.Deactivate, hide); parent.addListener(SWT.Hide, hide); parent.addListener(SWT.Dispose, event -> close()); for (final Widget c : controls) { if (c == null) { continue; } final TypedListener typedListener = new TypedListener(mtl); c.addListener(SWT.MouseEnter, typedListener); c.addListener(SWT.MouseExit, typedListener); c.addListener(SWT.MouseHover, typedListener); } }
public GenericInfoPopupDialog(Shell parentShell, String title, String message, final Runnable runnable) { super(parentShell, PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE | SWT.MODELESS, false, true, true, false, false, title, null); this.message = message; clickListener = new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { if (runnable != null) { runnable.run(); } close(); } }; }
public AbstractInPlaceDialog(Shell parent, int side, Control openControl) { super(parent, PopupDialog.INFOPOPUP_SHELLSTYLE, false, false, false, false, false, null, null); this.side = side; this.openControl = openControl; Rectangle bounds; if (openControl == null || openControl.isDisposed()) { bounds = new Rectangle(0, 0, 0, 0); } else { bounds = openControl.getBounds(); Point absPosition = openControl.toDisplay(openControl.getLocation()); bounds.x = absPosition.x - bounds.x; bounds.y = absPosition.y - bounds.y; } this.controlBounds = bounds; if (openControl != null) { openControl.addDisposeListener(disposeListener); } }
protected Control createDialogArea(Composite parent) { text = new Text(parent, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP | SWT.NO_FOCUS); // Use the compact margins employed by PopupDialog. GridData gd = new GridData(GridData.BEGINNING | GridData.FILL_BOTH); gd.horizontalIndent = PopupDialog.POPUP_HORIZONTALSPACING; gd.verticalIndent = PopupDialog.POPUP_VERTICALSPACING; text.setLayoutData(gd); text.setText(contents); // since SWT.NO_FOCUS is only a hint... text.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent event) { ContentProposalPopup.this.close(); } }); return text; }
public QuickLaunchDialog(Shell parent, History<String> history) { super(parent, PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE, GRAB_FOCUS, PERSIST_SIZE, PERSIST_BOUNDS, SHOW_DIALOG_MENU, SHOW_PERSIST_ACTIONS, TITLE, INFOTEXT); if (history==null){ history= new History<>(10); } this.history=history; }
@Override protected Control createDialogArea(Composite parent) { text = new Text(parent, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP | SWT.NO_FOCUS); // Use the compact margins employed by PopupDialog. GridData gd = new GridData(GridData.BEGINNING | GridData.FILL_BOTH); gd.horizontalIndent = PopupDialog.POPUP_HORIZONTALSPACING; gd.verticalIndent = PopupDialog.POPUP_VERTICALSPACING; text.setLayoutData(gd); text.setText(contents); // since SWT.NO_FOCUS is only a hint... text.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent event) { ContentProposalPopup.this.close(); } }); return text; }
public QuickOutline(Shell parent, JsonEditor editor, String fileContentType) { super(parent, PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE, true, true, true, true, true, null, null); this.fileContentType = fileContentType; IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class); this.bindingKey = bindingService.getBestActiveBindingFormattedFor(COMMAND_ID); this.triggerSequence = bindingService.getBestActiveBindingFor(COMMAND_ID); this.editor = editor; setInfoText(statusMessage()); create(); }
/** * The constructor * * @param shell * is the shell of the SuggestionBubble that is parent of this * dialog * @param parent * is the parent of this dialog. */ public PartialTranslationDialog(Shell shell, SuggestionBubble parent) { this.parent = parent; this.shell = shell; if (System.getProperty("os.name").toLowerCase().contains("windows")) { SHELL_STYLE = PopupDialog.INFOPOPUP_SHELLSTYLE; win = true; } else { SHELL_STYLE = PopupDialog.HOVER_SHELLSTYLE; win = false; } }
static Shell getPopup() { if (popup == null || popup.isDisposed() || popup.getShell() == null || popup.getShell().isDisposed()) { popup = new Shell(WorkbenchHelper.getShell(), PopupDialog.HOVER_SHELLSTYLE); popup.setLayout(new GridLayout(1, true)); } return popup; }
public TitaniumUpdatePopup(Shell parentShell, final Runnable updateAction) { super(parentShell, PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE | SWT.MODELESS, false, true, true, false, false, MessageFormat.format(EplMessages.TitaniumUpdatePopup_update_title, EclipseUtil.getStudioPrefix()), null); clickListener = new MouseAdapter() { public void mouseDown(MouseEvent e) { updateAction.run(); close(); } }; }
/** * Initialize default images in JFace's image registry. * */ private static void initializeDefaultImages() { Object bundle = null; // try { // bundle = JFaceActivator.getBundle(); // } catch (NoClassDefFoundError exception) { // // Test to see if OSGI is present // } declareImage(bundle, Wizard.DEFAULT_IMAGE, ICONS_PATH + "page.gif", //$NON-NLS-1$ Wizard.class, "images/page.gif"); //$NON-NLS-1$ // register default images for dialogs declareImage(bundle, Dialog.DLG_IMG_MESSAGE_INFO, ICONS_PATH + "message_info.gif", Dialog.class, "images/message_info.gif"); //$NON-NLS-1$ //$NON-NLS-2$ declareImage(bundle, Dialog.DLG_IMG_MESSAGE_WARNING, ICONS_PATH + "message_warning.gif", Dialog.class, //$NON-NLS-1$ "images/message_warning.gif"); //$NON-NLS-1$ declareImage(bundle, Dialog.DLG_IMG_MESSAGE_ERROR, ICONS_PATH + "message_error.gif", Dialog.class, "images/message_error.gif");//$NON-NLS-1$ //$NON-NLS-2$ declareImage(bundle, Dialog.DLG_IMG_HELP, ICONS_PATH + "help.gif", Dialog.class, "images/help.gif");//$NON-NLS-1$ //$NON-NLS-2$ declareImage( bundle, TitleAreaDialog.DLG_IMG_TITLE_BANNER, ICONS_PATH + "title_banner.png", TitleAreaDialog.class, "images/title_banner.gif");//$NON-NLS-1$ //$NON-NLS-2$ declareImage( bundle, PreferenceDialog.PREF_DLG_TITLE_IMG, ICONS_PATH + "pref_dialog_title.gif", PreferenceDialog.class, "images/pref_dialog_title.gif");//$NON-NLS-1$ //$NON-NLS-2$ declareImage(bundle, PopupDialog.POPUP_IMG_MENU, ICONS_PATH + "popup_menu.gif", PopupDialog.class, "images/popup_menu.gif");//$NON-NLS-1$ //$NON-NLS-2$ declareImage( bundle, PopupDialog.POPUP_IMG_MENU_DISABLED, ICONS_PATH + "popup_menu_disabled.gif", PopupDialog.class, "images/popup_menu_disabled.gif");//$NON-NLS-1$ //$NON-NLS-2$ }
@SuppressWarnings("deprecation") // backward compatibility public SelectionDialog(Shell parent, ISelectExecute mini, ITextEditor editor) { // Europa compatible constructor super((Shell) null, PopupDialog.HOVER_SHELLSTYLE, false, false, false, false, null, null); this.editor = editor; this.minibuffer = mini; }
public TeamExplorerSearchControlPopup(final TeamExplorerSearchControl searchControl) { // HOVER_SHELLSTYLE cannot get focus, which is nice in this case super(searchControl.getShell(), PopupDialog.HOVER_SHELLSTYLE, false, false, false, false, false, null, null); this.searchControl = searchControl; }
public static void sendDialogOpened(final PopupDialog dialog, final Map<String, String> properties) { Check.notNull(dialog, "dialog"); //$NON-NLS-1$ final String dialogName = getName(dialog); sendDialogOpened(dialogName, properties); }
InfoPopupDialog(Shell parent) { super(parent, PopupDialog.HOVER_SHELLSTYLE, false, false, false, false, false, null, null); }
@Override protected void adjustBounds() { Rectangle parentBounds = getParentShell().getBounds(); Rectangle proposedBounds; // Try placing the info popup to the right Rectangle rightProposedBounds = new Rectangle(parentBounds.x + parentBounds.width + PopupDialog.POPUP_HORIZONTALSPACING, parentBounds.y + PopupDialog.POPUP_VERTICALSPACING, parentBounds.width, parentBounds.height); rightProposedBounds = getConstrainedShellBounds(rightProposedBounds); // If it won't fit on the right, try the left if (rightProposedBounds.intersects(parentBounds)) { Rectangle leftProposedBounds = new Rectangle(parentBounds.x - parentBounds.width - POPUP_HORIZONTALSPACING - 1, parentBounds.y, parentBounds.width, parentBounds.height); leftProposedBounds = getConstrainedShellBounds(leftProposedBounds); // If it won't fit on the left, choose the proposed bounds // that fits the best if (leftProposedBounds.intersects(parentBounds)) { if (rightProposedBounds.x - parentBounds.x >= parentBounds.x - leftProposedBounds.x) { rightProposedBounds.x = parentBounds.x + parentBounds.width + PopupDialog.POPUP_HORIZONTALSPACING; proposedBounds = rightProposedBounds; } else { leftProposedBounds.width = parentBounds.x - POPUP_HORIZONTALSPACING - leftProposedBounds.x; proposedBounds = leftProposedBounds; } } else { // use the proposed bounds on the left proposedBounds = leftProposedBounds; } } else { // use the proposed bounds on the right proposedBounds = rightProposedBounds; } getShell().setBounds(proposedBounds); }
private void popUp(final String title, final String description){ new PopupDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE,true,false,false,false,false,title,null){ private static final int CURSOR_SIZE=15; private Label label = null; protected Point getInitialLocation(Point initialSize){ Display display=getShell().getDisplay(); Point location=display.getCursorLocation(); location.x+=CURSOR_SIZE; location.y+=CURSOR_SIZE; return location; } protected Control createDialogArea( Composite parent){ Font terminalFont = JFaceResources.getFont(JFaceResources.TEXT_FONT); label=new Label(parent,SWT.WRAP); label.setText(description); label.setFont(terminalFont); /* label.addFocusListener(new FocusAdapter(){ public void focusLost( FocusEvent event){ System.out.println("focus lost."); close(); } @Override public void focusGained(FocusEvent e) { super.focusGained(e); System.out.println("focus gained."); } } ); label.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { close(); } });*/ GridData gd=new GridData(GridData.BEGINNING | GridData.FILL_BOTH); gd.horizontalIndent=PopupDialog.POPUP_HORIZONTALSPACING; gd.verticalIndent=PopupDialog.POPUP_VERTICALSPACING; label.setLayoutData(gd); return label; } } .open(); }
/** * Constructor * * @param parent * is the parent {@link Text} object, to which SuggestionBubble * will be added. * @param targetLanguage * is the language, to which the * {@link SuggestionBubble.defaultText} will be translated */ public SuggestionBubble(Text parent, String targetLanguage) { shell = parent.getShell(); text = parent; this.targetLanguage = targetLanguage; suggestionFilter = new SuggestionFilter(); suggestions = new ArrayList<Suggestion>(); String srcLang = System .getProperty("tapiji.translator.default.language"); if (srcLang != null) { SRC_LANG = srcLang.substring(0, 2).toUpperCase(); } if (System.getProperty("os.name").toLowerCase().contains("windows")) { SHELL_STYLE = PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE; win = true; } else { SHELL_STYLE = PopupDialog.HOVER_SHELLSTYLE; win = false; } // MessagesEditorPlugin.getDefault().getBundle(). // getEntry("glossary.xml").getPath() // System.out.println("install path "+MessagesEditorPlugin.getDefault().getBundle().getEntry("/").getPath()+"glossary.xml"); SuggestionProviderUtils.addSuggestionProviderUpdateListener(this); /* * Read shortcut of content assist (code completion) directly from * org.eclipse.ui.IWorkbenchCommandConstants.EDIT_CONTENT_ASSIST and * save it to CONTENT_ASSIST final variable */ IBindingService bindingService = (IBindingService) PlatformUI .getWorkbench().getAdapter(IBindingService.class); CONTENT_ASSIST = bindingService .getBestActiveBindingFormattedFor(IWorkbenchCommandConstants.EDIT_CONTENT_ASSIST); init(); }
public QuickMenuDialog(Shell parent, String title) { super(parent, PopupDialog.INFOPOPUP_SHELLSTYLE, true, false, false, false, false, title, null); }
protected void adjustBounds() { Rectangle parentBounds = getParentShell().getBounds(); Rectangle proposedBounds; // Try placing the info popup to the right Rectangle rightProposedBounds = new Rectangle(parentBounds.x + parentBounds.width + PopupDialog.POPUP_HORIZONTALSPACING, parentBounds.y + PopupDialog.POPUP_VERTICALSPACING, parentBounds.width, parentBounds.height); rightProposedBounds = getConstrainedShellBounds(rightProposedBounds); // If it won't fit on the right, try the left if (rightProposedBounds.intersects(parentBounds)) { Rectangle leftProposedBounds = new Rectangle(parentBounds.x - parentBounds.width - POPUP_HORIZONTALSPACING - 1, parentBounds.y, parentBounds.width, parentBounds.height); leftProposedBounds = getConstrainedShellBounds(leftProposedBounds); // If it won't fit on the left, choose the proposed bounds // that fits the best if (leftProposedBounds.intersects(parentBounds)) { if (rightProposedBounds.x - parentBounds.x >= parentBounds.x - leftProposedBounds.x) { rightProposedBounds.x = parentBounds.x + parentBounds.width + PopupDialog.POPUP_HORIZONTALSPACING; proposedBounds = rightProposedBounds; } else { leftProposedBounds.width = parentBounds.x - POPUP_HORIZONTALSPACING - leftProposedBounds.x; proposedBounds = leftProposedBounds; } } else { // use the proposed bounds on the left proposedBounds = leftProposedBounds; } } else { // use the proposed bounds on the right proposedBounds = rightProposedBounds; } getShell().setBounds(proposedBounds); }
public StringPopup(Shell parent, String initText, Point defaultLocation) { super(parent, PopupDialog.INFOPOPUP_SHELLSTYLE, true, false, false, false, false, Activator.PLUG_NAME + " Window", null); this.initText = initText; this.defaultLocation = defaultLocation; }
/** * Creates a quick outline dialog containing a filterable tree * * @param adaptable * adaptable which can be used by child class implementations * @param parent * shell to use is null the outline will have no content! If the * gradle editor is null location setting etc. will not work. * @param title * title for dialog * @param minWidth * @param minHeight * @param infoText * additional information to show at the bottom of dialogs */ public AbstractFilterableTreeQuickDialog(IAdaptable adaptable, Shell parent, String title, int minWidth, int minHeight, String infoText) { super(parent, PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE, GRAB_FOCUS, PERSIST_SIZE, PERSIST_BOUNDS, DO_SHOW_DIALOG, SHOW_PERSIST_ACTIONS, title, infoText); this.minWidth = minWidth; this.minHeight = minHeight; contentProvider = createTreeContentProvider(adaptable); if (contentProvider == null) { contentProvider = new FallbackOutlineContentProvider(); } }
/** * Constructs a new instance of <code>KeyAssistDialog</code>. When the * dialog is first constructed, it contains no widgets. The dialog is first * created with no parent. If a parent is required, call * <code>setParentShell()</code>. Also, between uses, it might be * necessary to call <code>setParentShell()</code> as well. * * @param workbench * The workbench in which this dialog is created; must not be * <code>null</code>. * @param associatedKeyboard * The key binding listener for the workbench; must not be * <code>null</code>. * @param associatedState * The key binding state associated with the workbench; must not * be <code>null</code>. */ @SuppressWarnings("deprecation") public KeyAssistDialog(final PyEdit pyedit) { //Note: had to change to HOVER_SHELLSTYLE instead of INFOPOPUP_SHELLSTYLE because //otherwise the focus would end up in a null Control in linux (GTK), //which made the dialog show and hide quickly and go out of the ctrl+2 mode. //See: http://sourceforge.net/tracker/?func=detail&aid=2984743&group_id=85796&atid=577329 super((Shell) null, PopupDialog.HOVER_SHELLSTYLE, false, false, false, false, null, null); this.setInfoText(" Ctrl+2 actions "); }