Example usage for org.eclipse.jface.dialogs IDialogConstants CANCEL_ID

List of usage examples for org.eclipse.jface.dialogs IDialogConstants CANCEL_ID

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants CANCEL_ID.

Prototype

int CANCEL_ID

To view the source code for org.eclipse.jface.dialogs IDialogConstants CANCEL_ID.

Click Source Link

Document

Button id for a "Cancel" button (value 1).

Usage

From source file:com.amalto.workbench.dialogs.SimpleXpathInputDialog.java

License:Open Source License

@Override
protected void cancelPressed() {
    setReturnCode(CANCEL);//from w  ww  .  j  a  v a 2  s  . c o m
    getButton(IDialogConstants.CANCEL_ID).setData("dialog", SimpleXpathInputDialog.this);//$NON-NLS-1$
    // no close let Action Handler handle it
}

From source file:com.amalto.workbench.dialogs.ViewInputDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    // create OK and Cancel buttons by default
    okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
    // do this here because setting the text will set enablement on the ok
    // button/*  ww w.  j  a  va 2s . c  om*/
    okButton.setEnabled(false);
}

From source file:com.amalto.workbench.editors.dialog.CustomInputDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    // create OK and Cancel buttons by default
    okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
    // do this here because setting the text will set enablement on the ok
    // button/*  w w  w  . j a v  a2  s  .  c om*/
    text.setFocus();
    if (value != null) {
        text.setText(value);
        text.selectAll();
    }
}

From source file:com.amalto.workbench.export.ImportItemsWizard.java

License:Open Source License

private int isOveride(String name, String obTypeName) {

    final MessageDialog dialog = new MessageDialog(getShell(), Messages.ImportItemsWizard_12, null,
            Messages.ImportItemsWizard_13 + obTypeName + Messages.ImportItemsWizard_14 + name
                    + Messages.ImportItemsWizard_15,
            MessageDialog.QUESTION,/*from   w w  w  .  jav  a  2s.c om*/
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
            0);
    dialog.open();
    int result = dialog.getReturnCode();
    if (result == 0) {
        return IDialogConstants.YES_ID;
    }
    if (result == 1) {
        return IDialogConstants.YES_TO_ALL_ID;
    }
    if (result == 2) {
        return IDialogConstants.NO_ID;
    }
    return IDialogConstants.CANCEL_ID;

}

From source file:com.amazonaws.eclipse.lambda.invoke.ui.InvokeFunctionInputDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, INVOKE_BUTTON_ID, "Invoke", true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}

From source file:com.amitinside.e4.rcp.todo.dialogs.PasswordDialog.java

License:Apache License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.OK_ID, "Login", true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}

From source file:com.android.ide.eclipse.adt.internal.editors.layout.gre.ClientRulesEngine.java

License:Open Source License

@Override
public String displayFragmentSourceInput() {
    try {//from  w w w  .  j  a v  a  2 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.getShell();
        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) || Flags.isAbstract(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.adt.internal.editors.layout.gre.ClientRulesEngine.java

License:Open Source License

@Override
public String displayCustomViewClassInput() {
    try {// w ww .  j  a va2  s.  c  om
        IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
        IProject project = mRulesEngine.getProject();
        final IJavaProject javaProject = BaseProjectHelper.getJavaProject(project);
        if (javaProject != 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[] viewTypes = new IType[0];
            IType fragmentType = javaProject.findType(CLASS_VIEW);
            if (fragmentType != null) {
                ITypeHierarchy hierarchy = fragmentType.newTypeHierarchy(new NullProgressMonitor());
                viewTypes = hierarchy.getAllSubtypes(fragmentType);
            }
            scope = SearchEngine.createJavaSearchScope(viewTypes, IJavaSearchScope.SOURCES);
        }

        Shell parent = AdtPlugin.getShell();
        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 = createNewCustomViewClass(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) || Flags.isAbstract(modifiers)) {
                                    return false;
                                }
                                return true;
                            }
                        };
                    }
                });
        dialogHolder.set(dialog);

        dialog.setTitle("Choose Custom View Class");
        dialog.setMessage("Select a Custom View 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.adt.internal.editors.layout.properties.XmlPropertyEditor.java

License:Open Source License

@Override
protected boolean setEditorText(Property property, String text) throws Exception {
    Object oldValue = property.getValue();
    String old = oldValue != null ? oldValue.toString() : null;

    // If users enters a new id without specifying the @id/@+id prefix, insert it
    boolean isId = isIdProperty(property);
    if (isId && !text.startsWith(PREFIX_RESOURCE_REF)) {
        text = NEW_ID_PREFIX + text;//w w  w . j ava 2s. co  m
    }

    // Handle id refactoring: if you change an id, may want to update references too.
    // Ask user.
    if (isId && property instanceof XmlProperty && old != null && !old.isEmpty() && text != null
            && !text.isEmpty() && !text.equals(old)) {
        XmlProperty xmlProperty = (XmlProperty) property;
        IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore();
        String refactorPref = store.getString(AdtPrefs.PREFS_REFACTOR_IDS);
        boolean performRefactor = false;
        Shell shell = AdtPlugin.getShell();
        if (refactorPref == null || refactorPref.isEmpty()
                || refactorPref.equals(MessageDialogWithToggle.PROMPT)) {
            MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion(shell,
                    "Update References?",
                    "Update all references as well? "
                            + "This will update all XML references and Java R field references.",
                    "Do not show again", false, store, AdtPrefs.PREFS_REFACTOR_IDS);
            switch (dialog.getReturnCode()) {
            case IDialogConstants.CANCEL_ID:
                return false;
            case IDialogConstants.YES_ID:
                performRefactor = true;
                break;
            case IDialogConstants.NO_ID:
                performRefactor = false;
                break;
            }
        } else {
            performRefactor = refactorPref.equals(MessageDialogWithToggle.ALWAYS);
        }
        if (performRefactor) {
            CommonXmlEditor xmlEditor = xmlProperty.getXmlEditor();
            if (xmlEditor != null) {
                IProject project = xmlEditor.getProject();
                if (project != null && shell != null) {
                    RenameResourceWizard.renameResource(shell, project, ResourceType.ID, stripIdPrefix(old),
                            stripIdPrefix(text), false);
                }
            }
        }
    }

    property.setValue(text);

    return true;
}

From source file:com.android.ide.eclipse.adt.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 w ww .j  a  v 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(mUseDeviceForFutureLaunches);
    mResponse.setUseDeviceForFutureLaunches(mUseDeviceForFutureLaunches);
    mUseDeviceForFutureLaunchesCheckbox.setText("Use same device for future launches");
    mUseDeviceForFutureLaunchesCheckbox.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            mUseDeviceForFutureLaunches = mUseDeviceForFutureLaunchesCheckbox.getSelection();
            mResponse.setUseDeviceForFutureLaunches(mUseDeviceForFutureLaunches);
        }
    });
    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;
}