List of usage examples for org.eclipse.jface.dialogs IDialogConstants CANCEL_ID
int CANCEL_ID
To view the source code for org.eclipse.jface.dialogs IDialogConstants CANCEL_ID.
Click Source Link
From source file:com.android.ide.eclipse.adt.internal.refactorings.core.RenameResourceWizard.java
License:Open Source License
/** * Show a refactoring dialog for the given resource refactoring operation * * @param refactoring the rename refactoring * @param processor the field processor//from www . j ava 2s . c om * @param parent the parent shell * @param type the resource type * @param canClear whether the user is allowed to clear/reset the name to * nothing * @return true if the refactoring was performed, and false if it was * canceled * @throws CoreException if an unexpected error occurs */ private static boolean show(@NonNull RenameRefactoring refactoring, @NonNull RenameResourceProcessor processor, @NonNull Shell parent, @NonNull ResourceType type, boolean canClear) throws CoreException { RefactoringSaveHelper saveHelper = new RefactoringSaveHelper(RefactoringSaveHelper.SAVE_REFACTORING); if (!saveHelper.saveEditors(parent)) { return false; } try { RenameResourceWizard wizard = new RenameResourceWizard(refactoring, type, canClear); RefactoringWizardOpenOperation operation = new RefactoringWizardOpenOperation(wizard); String dialogTitle = wizard.getDefaultPageTitle(); int result = operation.run(parent, dialogTitle == null ? "" : dialogTitle); RefactoringStatus status = operation.getInitialConditionCheckingStatus(); if (status.hasFatalError()) { return false; } if (result == RefactoringWizardOpenOperation.INITIAL_CONDITION_CHECKING_FAILED || result == IDialogConstants.CANCEL_ID) { saveHelper.triggerIncrementalBuild(); return false; } // Save modified resources; need to trigger R file regeneration saveHelper.saveEditors(parent); return true; } catch (InterruptedException e) { return false; // Canceled } }
From source file:com.android.ide.eclipse.adt.internal.ui.WizardDialogEx.java
License:Open Source License
/** * Returns the cancel button.//ww w .j ava 2s . c o m * <p/> * Note: there is already a protected, deprecated method that does the same thing. * To avoid overriding a deprecated method, the name as be changed to ...Ex. */ public Button getCancelButtonEx() { return getButton(IDialogConstants.CANCEL_ID); }
From source file:com.android.ide.eclipse.adt.internal.wizards.newxmlfile.AddTranslationDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { mOkButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, // Don't make the OK button default as in most dialogs, since when you press // Return thinking you might edit a value it dismisses the dialog instead false);//from w w w . java 2 s . c o m createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); mOkButton.setEnabled(false); validatePage(); }
From source file:com.android.ide.eclipse.adt.internal.wizards.templates.NewTemplatePage.java
License:Open Source License
private String chooseActivity() { try {//from w ww . jav a 2 s. com // Compute a search scope: We need to merge all the subclasses // android.app.Fragment and android.support.v4.app.Fragment IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); IProject project = mValues.project; IJavaProject javaProject = BaseProjectHelper.getJavaProject(project); IType activityType = null; if (javaProject != null) { activityType = javaProject.findType(CLASS_ACTIVITY); } if (activityType == null) { IJavaProject[] projects = BaseProjectHelper.getAndroidProjects(null); for (IJavaProject p : projects) { activityType = p.findType(CLASS_ACTIVITY); if (activityType != null) { break; } } } if (activityType != null) { NullProgressMonitor monitor = new NullProgressMonitor(); ITypeHierarchy hierarchy = activityType.newTypeHierarchy(monitor); IType[] classes = hierarchy.getAllSubtypes(activityType); scope = SearchEngine.createJavaSearchScope(classes, IJavaSearchScope.SOURCES); } Shell parent = AdtPlugin.getShell(); final SelectionDialog dialog = JavaUI.createTypeDialog(parent, new ProgressMonitorDialog(parent), scope, IJavaElementSearchConstants.CONSIDER_CLASSES, false, // Use ? as a default filter to fill dialog with matches "?", //$NON-NLS-1$ new TypeSelectionExtension() { @Override public ITypeInfoFilterExtension getFilterExtension() { return new ITypeInfoFilterExtension() { @Override public boolean select(ITypeInfoRequestor typeInfoRequestor) { int modifiers = typeInfoRequestor.getModifiers(); if (!Flags.isPublic(modifiers) || Flags.isInterface(modifiers) || Flags.isEnum(modifiers)) { return false; } return true; } }; } }); dialog.setTitle("Choose Activity Class"); dialog.setMessage("Select an Activity class (? = any character, * = any string):"); if (dialog.open() == IDialogConstants.CANCEL_ID) { return null; } Object[] types = dialog.getResult(); if (types != null && types.length > 0) { return ((IType) types[0]).getFullyQualifiedName(); } } catch (JavaModelException e) { AdtPlugin.log(e, null); } catch (CoreException e) { AdtPlugin.log(e, null); } return null; }
From source file:com.android.ide.eclipse.auidt.internal.editors.layout.gre.ClientRulesEngine.java
License:Open Source License
@Override public String displayFragmentSourceInput() { try {/* w w w.ja v a2 s .co m*/ // Compute a search scope: We need to merge all the subclasses // android.app.Fragment and android.support.v4.app.Fragment IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); IProject project = mRulesEngine.getProject(); final IJavaProject javaProject = BaseProjectHelper.getJavaProject(project); if (javaProject != null) { IType oldFragmentType = javaProject.findType(CLASS_V4_FRAGMENT); // First check to make sure fragments are available, and if not, // warn the user. IAndroidTarget target = Sdk.getCurrent().getTarget(project); // No, this should be using the min SDK instead! if (target.getVersion().getApiLevel() < 11 && oldFragmentType == null) { // Compatibility library must be present MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), "Fragment Warning", null, "Fragments require API level 11 or higher, or a compatibility " + "library for older versions.\n\n" + " Do you want to install the compatibility library?", MessageDialog.QUESTION, new String[] { "Install", "Cancel" }, 1 /* default button: Cancel */); int answer = dialog.open(); if (answer == 0) { if (!AddSupportJarAction.install(project)) { return null; } } else { return null; } } // Look up sub-types of each (new fragment class and compatibility fragment // class, if any) and merge the two arrays - then create a scope from these // elements. IType[] fragmentTypes = new IType[0]; IType[] oldFragmentTypes = new IType[0]; if (oldFragmentType != null) { ITypeHierarchy hierarchy = oldFragmentType.newTypeHierarchy(new NullProgressMonitor()); oldFragmentTypes = hierarchy.getAllSubtypes(oldFragmentType); } IType fragmentType = javaProject.findType(CLASS_FRAGMENT); if (fragmentType != null) { ITypeHierarchy hierarchy = fragmentType.newTypeHierarchy(new NullProgressMonitor()); fragmentTypes = hierarchy.getAllSubtypes(fragmentType); } IType[] subTypes = new IType[fragmentTypes.length + oldFragmentTypes.length]; System.arraycopy(fragmentTypes, 0, subTypes, 0, fragmentTypes.length); System.arraycopy(oldFragmentTypes, 0, subTypes, fragmentTypes.length, oldFragmentTypes.length); scope = SearchEngine.createJavaSearchScope(subTypes, IJavaSearchScope.SOURCES); } Shell parent = AdtPlugin.getDisplay().getActiveShell(); final AtomicReference<String> returnValue = new AtomicReference<String>(); final AtomicReference<SelectionDialog> dialogHolder = new AtomicReference<SelectionDialog>(); final SelectionDialog dialog = JavaUI.createTypeDialog(parent, new ProgressMonitorDialog(parent), scope, IJavaElementSearchConstants.CONSIDER_CLASSES, false, // Use ? as a default filter to fill dialog with matches "?", //$NON-NLS-1$ new TypeSelectionExtension() { @Override public Control createContentArea(Composite parentComposite) { Composite composite = new Composite(parentComposite, SWT.NONE); composite.setLayout(new GridLayout(1, false)); Button button = new Button(composite, SWT.PUSH); button.setText("Create New..."); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String fqcn = createNewFragmentClass(javaProject); if (fqcn != null) { returnValue.set(fqcn); dialogHolder.get().close(); } } }); return composite; } @Override public ITypeInfoFilterExtension getFilterExtension() { return new ITypeInfoFilterExtension() { @Override public boolean select(ITypeInfoRequestor typeInfoRequestor) { int modifiers = typeInfoRequestor.getModifiers(); if (!Flags.isPublic(modifiers) || Flags.isInterface(modifiers) || Flags.isEnum(modifiers)) { return false; } return true; } }; } }); dialogHolder.set(dialog); dialog.setTitle("Choose Fragment Class"); dialog.setMessage("Select a Fragment class (? = any character, * = any string):"); if (dialog.open() == IDialogConstants.CANCEL_ID) { return null; } if (returnValue.get() != null) { return returnValue.get(); } Object[] types = dialog.getResult(); if (types != null && types.length > 0) { return ((IType) types[0]).getFullyQualifiedName(); } } catch (JavaModelException e) { AdtPlugin.log(e, null); } catch (CoreException e) { AdtPlugin.log(e, null); } return null; }
From source file:com.android.ide.eclipse.auidt.internal.launch.DeviceChooserDialog.java
License:Open Source License
/** * Create the button bar: We override the Dialog implementation of this method * so that we can create the checkbox at the same level as the 'Cancel' and 'OK' buttons. *//*from ww w. j av a 2 s . c o m*/ @Override protected Control createButtonBar(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(1, false); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); mUseDeviceForFutureLaunchesCheckbox = new Button(composite, SWT.CHECK); mUseDeviceForFutureLaunchesCheckbox.setSelection(sUseDeviceForFutureLaunchesValue); mResponse.setUseDeviceForFutureLaunches(sUseDeviceForFutureLaunchesValue); mUseDeviceForFutureLaunchesCheckbox.setText("Use same device for future launches"); mUseDeviceForFutureLaunchesCheckbox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { sUseDeviceForFutureLaunchesValue = mUseDeviceForFutureLaunchesCheckbox.getSelection(); mResponse.setUseDeviceForFutureLaunches(sUseDeviceForFutureLaunchesValue); } }); mUseDeviceForFutureLaunchesCheckbox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); createButton(composite, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(composite, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); return composite; }
From source file:com.android.ide.eclipse.auidt.internal.wizards.templates.NewTemplatePage.java
License:Open Source License
private String chooseActivity() { try {//from w w w .j av a2s .c o m // Compute a search scope: We need to merge all the subclasses // android.app.Fragment and android.support.v4.app.Fragment IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); IProject project = mValues.project; IJavaProject javaProject = BaseProjectHelper.getJavaProject(project); IType activityType = null; if (javaProject != null) { activityType = javaProject.findType(CLASS_ACTIVITY); } if (activityType == null) { IJavaProject[] projects = BaseProjectHelper.getAndroidProjects(null); for (IJavaProject p : projects) { activityType = p.findType(CLASS_ACTIVITY); if (activityType != null) { break; } } } if (activityType != null) { NullProgressMonitor monitor = new NullProgressMonitor(); ITypeHierarchy hierarchy = activityType.newTypeHierarchy(monitor); IType[] classes = hierarchy.getAllSubtypes(activityType); scope = SearchEngine.createJavaSearchScope(classes, IJavaSearchScope.SOURCES); } Shell parent = AdtPlugin.getDisplay().getActiveShell(); final SelectionDialog dialog = JavaUI.createTypeDialog(parent, new ProgressMonitorDialog(parent), scope, IJavaElementSearchConstants.CONSIDER_CLASSES, false, // Use ? as a default filter to fill dialog with matches "?", //$NON-NLS-1$ new TypeSelectionExtension() { @Override public ITypeInfoFilterExtension getFilterExtension() { return new ITypeInfoFilterExtension() { @Override public boolean select(ITypeInfoRequestor typeInfoRequestor) { int modifiers = typeInfoRequestor.getModifiers(); if (!Flags.isPublic(modifiers) || Flags.isInterface(modifiers) || Flags.isEnum(modifiers)) { return false; } return true; } }; } }); dialog.setTitle("Choose Activity Class"); dialog.setMessage("Select an Activity class (? = any character, * = any string):"); if (dialog.open() == IDialogConstants.CANCEL_ID) { return null; } Object[] types = dialog.getResult(); if (types != null && types.length > 0) { return ((IType) types[0]).getFullyQualifiedName(); } } catch (JavaModelException e) { AdtPlugin.log(e, null); } catch (CoreException e) { AdtPlugin.log(e, null); } return null; }
From source file:com.android.uiautomator.ControlDefineDialog.java
License:Apache License
/** * Create contents of the button bar./* ww w. j av a 2s. c o m*/ * * @param parent */ @Override protected void createButtonsForButtonBar(Composite parent) { mOkButton = createButton(parent, IDialogConstants.OK_ID, "", true); mOkButton.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { saveFile(); } }); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); }
From source file:com.android.uiautomator.OpenDialog.java
License:Apache License
/** * Create contents of the button bar.//from w w w . j a v a 2s . c o m * @param parent */ @Override protected void createButtonsForButtonBar(Composite parent) { mOkButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); updateButtonState(); }
From source file:com.appnativa.studio.composite.ColorFieldComposite.java
License:Open Source License
/** * Create the composite.//from ww w. ja va 2 s . co m * * @param parent * @param style */ public ColorFieldComposite(Composite parent, int style) { super(parent, style); GridLayout gridLayout = new GridLayout(3, false); gridLayout.verticalSpacing = 0; gridLayout.marginWidth = 0; gridLayout.marginHeight = 0; setLayout(gridLayout); addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { if (swtImage != null) { swtImage.dispose(); } swtImage = null; if (swtColor != null) { swtColor.dispose(); swtColor = null; } } }); colorLabel = new Label(this, SWT.NONE); colorLabel.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { updateDisplay(false); } }); GridData gd_colorLabel = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1); gd_colorLabel.widthHint = 24; gd_colorLabel.heightHint = 18; colorLabel.setLayoutData(gd_colorLabel); colorText = new Text(this, SWT.BORDER); colorText.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if ((e.keyCode == SWT.CR) || (e.keyCode == SWT.KEYPAD_CR)) { updateFromTextField(); } } }); colorText.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { updateFromTextField(); } }); colorText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); button = new Button(this, SWT.NONE); button.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (useEclipseColorDialog) { ColorDialog dialog = new ColorDialog(getShell()); if (color != null) { dialog.setRGB(new RGB(color.getRed(), color.getGreen(), color.getBlue())); } RGB rgb = dialog.open(); if (rgb != null) { color = new UIColor(rgb.red, rgb.green, rgb.blue); updateDisplay(true); } } else { ColorChooserDialog dialog = new ColorChooserDialog(getShell()); if (color != null) { dialog.setColor(color); } if (dialog.open() != IDialogConstants.CANCEL_ID) { color = dialog.getSelectedColor(); updateDisplay(true); } } } }); button.setText("..."); }