List of usage examples for org.eclipse.jface.dialogs Dialog open
public int open()
From source file:org.eclipse.jdt.internal.debug.ui.snippeteditor.SelectImportsAction.java
License:Open Source License
private void chooseImports() { String[] imports = getEditor().getImports(); Dialog dialog = new SelectImportsDialog(getEditor(), imports); dialog.open(); }
From source file:org.eclipse.jdt.ui.actions.GenerateMethodAbstractAction.java
License:Open Source License
/** * Runs the action.//from ww w. j a v a 2 s . co m * * @param shell the shell to use * @param type the type to generate stubs for * @throws CoreException if an error occurs */ void run(Shell shell, IType type) throws CoreException { initialize(type); boolean regenerate = false; if (isMethodAlreadyImplemented(fTypeBinding)) { regenerate = MessageDialog.openQuestion(getShell(), getErrorCaption(), Messages.format(ActionMessages.GenerateMethodAbstractAction_already_has_this_method_error, new String[] { BasicElementLabels.getJavaElementName(fTypeBinding.getQualifiedName()), getAlreadyImplementedErrorMethodName() })); if (!regenerate) { notifyResult(false); return; } } if (!generateCandidates()) { MessageDialog.openInformation(getShell(), getErrorCaption(), getNoMembersError()); notifyResult(false); return; } final SourceActionDialog dialog = createDialog(shell, type); final int dialogResult = dialog.open(); if (dialogResult == Window.OK) { final Object[] selected = dialog.getResult(); if (selected == null) { notifyResult(false); return; } final CodeGenerationSettings settings = createSettings(type, dialog); final IWorkspaceRunnable operation = createOperation(selected, settings, regenerate, type, dialog.getElementPosition()); ITypeBinding superclass = fTypeBinding.getSuperclass(); RefactoringStatus status = new RefactoringStatus(); status.merge(checkGeneralConditions(type, settings, selected)); if (!"java.lang.Object".equals(superclass.getQualifiedName())) { //$NON-NLS-1$ status.merge(checkSuperClass(superclass)); } for (int i = 0; i < selected.length; i++) { status.merge(checkMember(selected[i])); } if (status.hasEntries()) { Dialog d = RefactoringUI.createLightWeightStatusDialog(status, getShell(), getErrorCaption()); if (d.open() != Window.OK) { notifyResult(false); return; } } final IEditorPart editor = JavaUI.openInEditor(type.getCompilationUnit()); final IRewriteTarget target = editor != null ? (IRewriteTarget) editor.getAdapter(IRewriteTarget.class) : null; if (target != null) target.beginCompoundChange(); try { IRunnableContext context = JavaPlugin.getActiveWorkbenchWindow(); if (context == null) context = new BusyIndicatorRunnableContext(); ISchedulingRule schedulingRule = ResourcesPlugin.getWorkspace().getRoot(); PlatformUI.getWorkbench().getProgressService().runInUI(context, new WorkbenchRunnableAdapter(operation, schedulingRule), schedulingRule); } catch (InvocationTargetException exception) { ExceptionHandler.handle(exception, shell, getErrorCaption(), null); } catch (InterruptedException exception) { // Do nothing. Operation has been canceled by user. } finally { if (target != null) target.endCompoundChange(); } } notifyResult(dialogResult == Window.OK); }
From source file:org.eclipse.jface.snippets.dialogs.Snippet012DialogWithImageButtons.java
License:Open Source License
public Snippet012DialogWithImageButtons(final Shell shell) { Dialog dia = new Dialog(shell) { private ImageDescriptor getImageDescriptor(String path) { if (registry == null) { registry = new ImageRegistry(shell.getDisplay()); }/* w ww. j a va 2s . co m*/ ImageDescriptor desc = registry.getDescriptor(path); if (desc == null) { desc = ImageDescriptor.createFromFile(Snippet012DialogWithImageButtons.class, path); registry.put(path, desc); } return desc; } @Override protected Button createButton(Composite parent, int id, String label, boolean defaultButton) { Button b = super.createButton(parent, id, label, defaultButton); if (id == IDialogConstants.OK_ID) { b.setImage(getImageDescriptor("filesave.png").createImage()); //$NON-NLS-1$ // reset the button layout setButtonLayoutData(b); } else { b.setImage(getImageDescriptor("cancel.png").createImage()); //$NON-NLS-1$ // reset the button layout setButtonLayoutData(b); return b; } return b; } @Override protected Control createContents(Composite parent) { Label label = new Label(parent, SWT.CENTER); label.setText("Update Snippet012DialogWithImageButtons ..."); label.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); return super.createContents(parent); } }; dia.open(); }
From source file:org.eclipse.jface.snippets.dialogs.Snippet060DialogWithURLImageButtons.java
License:Open Source License
public Snippet060DialogWithURLImageButtons(final Shell shell) { Dialog dia = new Dialog(shell) { private ImageDescriptor getImageDescriptor(String path) { if (registry == null) { registry = new ImageRegistry(shell.getDisplay()); }//from ww w. j av a2 s .c o m ImageDescriptor desc = registry.getDescriptor(path); if (desc == null) { desc = ImageDescriptor .createFromURL(Snippet060DialogWithURLImageButtons.class.getResource(path)); registry.put(path, desc); } return desc; } @Override protected Button createButton(Composite parent, int id, String label, boolean defaultButton) { Button b = super.createButton(parent, id, label, defaultButton); if (id == IDialogConstants.OK_ID) { URL url; try { url = new URL("http://www.eclipse.org/home/images/enterprise.gif"); b.setImage(ImageDescriptor.createFromURL(url).createImage()); } catch (MalformedURLException e) { e.printStackTrace(); } // reset the button layout setButtonLayoutData(b); } else { b.setImage(getImageDescriptor("cancel.png").createImage()); //$NON-NLS-1$ // reset the button layout setButtonLayoutData(b); return b; } return b; } @Override protected Control createContents(Composite parent) { Label label = new Label(parent, SWT.CENTER); label.setText("Dialog with Url Image Buttons"); label.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); return super.createContents(parent); } }; dia.open(); }
From source file:org.eclipse.jface.snippets.resources.Snippet057FileImageDescriptors.java
License:Open Source License
public Snippet057FileImageDescriptors(final Shell shell) { Dialog dia = new Dialog(shell) { private ImageDescriptor getImageDescriptorFromClass(String path) { ImageDescriptor desc = getDescriptorBasedOn(shell, path); if (desc == null) { desc = ImageDescriptor.createFromFile(Snippet057FileImageDescriptors.class, path); registry.put(path, desc); }/* ww w . j a va 2 s. c o m*/ return desc; } private ImageDescriptor getImageDescriptorFromFile(String path) { ImageDescriptor desc = getDescriptorBasedOn(shell, path); if (desc == null) { URL classPath = Snippet057FileImageDescriptors.class.getResource(path); Class<?> bogus = null; desc = ImageDescriptor.createFromFile(bogus, classPath.getFile()); registry.put(path, desc); } return desc; } private ImageDescriptor getDescriptorBasedOn(final Shell shell, String path) { if (registry == null) { registry = new ImageRegistry(shell.getDisplay()); } return registry.getDescriptor(path); } @Override protected Button createButton(Composite parent, int id, String label, boolean defaultButton) { Button b = super.createButton(parent, id, label, defaultButton); if (id == IDialogConstants.OK_ID) { b.setImage(getImageDescriptorFromClass("filesave.png").createImage()); //$NON-NLS-1$ // reset the button layout setButtonLayoutData(b); } else { b.setImage(getImageDescriptorFromFile("cancel.png").createImage()); //$NON-NLS-1$ // reset the button layout setButtonLayoutData(b); return b; } return b; } @Override protected Control createContents(Composite parent) { Label label = new Label(parent, SWT.CENTER); label.setText("Snippet057FileImageDescriptors"); label.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); return super.createContents(parent); } }; dia.open(); }
From source file:org.eclipse.jst.server.tomcat.ui.tests.UITestHelper.java
License:Open Source License
/** * Automated test that checks all the labels and buttons of a dialog * to make sure there is enough room to display all the text. Any * text that wraps is only approximated and is currently not accurate. * /*from ww w . ja va2s . c om*/ * @param dialog the test dialog to be verified. */ public static void assertDialog(Dialog dialog) { Assert.assertNotNull(dialog); dialog.setBlockOnOpen(false); dialog.open(); Shell shell = dialog.getShell(); verifyCompositeText(shell); dialog.close(); }
From source file:org.eclipse.jubula.client.analyze.ui.components.AnalyzePreferenceDialog.java
License:Open Source License
/** * creates the AnalyzePreferenceDialog//w ww . j ava2s. c o m * @param parameterList * The List of AnalyzeParameters * @return dialog The AnalyzePreferenceDialog */ public Dialog createAnalyzePreferenceDialog(final List<AnalyzeParameter> parameterList) { if (parameterList.size() != 0) { // The AnalyzePreferenceDialog Dialog dialog = new Dialog(Display.getCurrent().getActiveShell()) { @Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); createDialogContent(composite, parameterList); return composite; } @Override protected Point getInitialSize() { int height; if (parameterList.size() <= 10) { height = (parameterList.size() * 32) + 132; } else { height = 452; } return new Point(600, height); } @Override protected void okPressed() { setCancelStatus(false); getDialog().close(); } @Override protected void cancelPressed() { setCancelStatus(true); getDialog().close(); } @Override protected void createButtonsForButtonBar(Composite parent) { ((GridLayout) parent.getLayout()).numColumns++; Button defaults = new Button(parent, SWT.PUSH); defaults.setData(parameterList); defaults.setText(Messages.DefaultsButton); defaults.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { restore(); } }); createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); } @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText(Messages.AnalyzePreferenceDialog); } }; setDialog(dialog); dialog.open(); return dialog; } setCancelStatus(false); return null; }
From source file:org.eclipse.jubula.client.teststyle.properties.TeststyleProjectPropertyPage.java
License:Open Source License
/** * Sets the events for the buttons.// www. j av a2 s .c o m */ public void setGrpEvents() { m_editAttrBtn.addSelectionListener(new SelectionAdapter() { @SuppressWarnings("synthetic-access") public void widgetSelected(SelectionEvent e) { ITreeSelection sel = (ITreeSelection) m_treeView.getSelection(); CheckNode node = (CheckNode) sel.getFirstElement(); BaseCheck check = node.getCheck(); Dialog dlg = new EditAttributeDialog(getShell(), check); int status = dlg.open(); if (status == Window.OK) { getApplyButton().setEnabled(true); } } }); m_editContBtn.addSelectionListener(new SelectionAdapter() { @SuppressWarnings("synthetic-access") public void widgetSelected(SelectionEvent e) { ITreeSelection sel = (ITreeSelection) m_treeView.getSelection(); CheckNode node = (CheckNode) sel.getFirstElement(); BaseCheck check = node.getCheck(); Dialog dlg = new EditContextDialog(getShell(), check); int status = dlg.open(); if (status == Window.OK) { getApplyButton().setEnabled(true); } } }); m_editSeverity.addSelectionListener(new SelectionAdapter() { @SuppressWarnings("synthetic-access") public void widgetSelected(SelectionEvent e) { Severity newSev = Severity.valueOf(m_editSeverity.getText()); ITreeSelection sel = (ITreeSelection) m_treeView.getSelection(); CheckNode node = (CheckNode) sel.getFirstElement(); node.setSeverity(newSev); getApplyButton().setEnabled(true); } }); }
From source file:org.eclipse.jubula.client.ui.rcp.properties.ProjectGeneralPropertyPage.java
License:Open Source License
/** * @param parent The parent <code>Composite</code> *//*from w ww . ja v a 2s . co m*/ private void createTrackChangesDeleteDataButton(Composite parent) { m_deleteChanges = new Button(parent, SWT.PUSH); m_deleteChanges.setText(Messages.PrefPageTrackChangesDeleteData); GridData gridData = new GridData(SWT.END, SWT.BEGINNING, false, false); gridData.horizontalSpan = 1; gridData.grabExcessHorizontalSpace = false; m_deleteChanges.setLayoutData(gridData); m_deleteChanges.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Dialog qDialog = new MessageDialog(getShell(), Messages.UtilsConfirmation, null, Messages.PrefPageTrackChangesDeleteDataQuestion, MessageDialog.QUESTION, new String[] { Messages.UtilsYes, Messages.UtilsNo }, 0); qDialog.setBlockOnOpen(true); qDialog.open(); if (qDialog.getReturnCode() == 0) { // delete all tracked changes try { PlatformUI.getWorkbench().getProgressService().run(true, false, new DeleteTrackedChangesOperation()); } catch (InvocationTargetException ite) { // nothing } catch (InterruptedException ie) { // nothing } } } }); }
From source file:org.eclipse.ltk.internal.ui.refactoring.ValidationCheckResultQuery.java
License:Open Source License
public boolean proceed(RefactoringStatus status) { final Dialog dialog = RefactoringUI.createRefactoringStatusDialog(status, fParent, fTitle, false); final int[] result = new int[1]; Runnable r = new Runnable() { public void run() { result[0] = dialog.open(); }//w w w .j a v a 2s. c om }; fParent.getDisplay().syncExec(r); return result[0] == IDialogConstants.OK_ID; }