Example usage for org.eclipse.jface.viewers LabelProvider dispose

List of usage examples for org.eclipse.jface.viewers LabelProvider dispose

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers LabelProvider dispose.

Prototype

@Override
public void dispose() 

Source Link

Document

The BaseLabelProvider implementation of this IBaseLabelProvider method clears its internal listener list.

Usage

From source file:com.arc.embeddedcdt.launch.LaunchShortcut.java

License:Open Source License

/**
 * Method chooseDebugConfig.//from   w  ww.  j  a v  a2  s  .  c  om
 * @param debugConfigs
 * @param mode
 * @return ICDebugConfiguration
 */
private ICDebugConfiguration chooseDebugConfig(ICDebugConfiguration[] debugConfigs, String mode) {
    LabelProvider provider = new LabelProvider() {
        /**
         * The <code>LabelProvider</code> implementation of this 
         * <code>ILabelProvider</code> method returns the element's <code>toString</code>
         * string. Subclasses may override.
         */
        public String getText(Object element) {
            if (element == null) {
                return ""; //$NON-NLS-1$
            } else if (element instanceof ICDebugConfiguration) {
                return ((ICDebugConfiguration) element).getName();
            }
            return element.toString();
        }
    };
    ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), provider);
    dialog.setElements(debugConfigs);
    dialog.setTitle(getDebugConfigDialogTitleString(debugConfigs, mode));
    dialog.setMessage(getDebugConfigDialogMessageString(debugConfigs, mode));
    dialog.setMultipleSelection(false);
    int result = dialog.open();
    provider.dispose();
    if (result == Window.OK) {
        return (ICDebugConfiguration) dialog.getFirstResult();
    }
    return null;
}

From source file:org.emftools.emf2gv.processor.ui.EMF2GvLaunchConfigFiltersTab.java

License:Open Source License

/**
 * Handles a click on the 'new' button./*from  www. jav  a 2  s . co m*/
 */
private void handleNewButton() {
    SafeRunner.run(new SafeRunnable() {
        public void run() throws Exception {
            if (mainTab.isInGraphicalDescriptionGenerationMode()) {
                MessageDialog.openInformation(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                        "Warning",
                        "OCL Filtering is available only when a graphical description is selected. Please select a graphical description in the main tab.");
            } else {
                // EClass hierarchy retrieval
                List<EClass> eClasses = getAuthorizedEClasses();
                final LabelProvider labelProvider = new LabelProvider() {
                    @Override
                    public String getText(Object element) {
                        return adapterFactoryLabelProvider.getText(element);
                    }

                    @Override
                    public Image getImage(Object element) {
                        return adapterFactoryLabelProvider.getImage(element);
                    }
                };
                ElementListSelectionDialog dialog = new ElementListSelectionDialog(
                        PlatformUI.getWorkbench().getDisplay().getActiveShell(), labelProvider);
                dialog.setElements(eClasses.toArray());
                dialog.setInitialSelections(new Object[] {});
                dialog.setTitle("EClass selection");
                dialog.setMessage("Select an EClass");
                dialog.setMultipleSelection(false);
                int result = dialog.open();
                labelProvider.dispose();
                if (result == Window.OK) {
                    OCLConstraint oCLConstraint = new OCLConstraint();
                    oCLConstraint.context = (EClass) dialog.getFirstResult();
                    OCLInputDialog inputDialog = new OCLInputDialog(
                            PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                            "New boolean OCL value editor", getOcl(), oCLConstraint.context, "true",
                            EcorePackage.eINSTANCE.getEBoolean(), true);
                    if (inputDialog.open() == Window.OK) {
                        oCLConstraint.value = inputDialog.getValue();
                        oCLConstraints.add(oCLConstraint);
                        eClassesTableViewer.refresh();
                        eClassesTableViewer.setSelection(new StructuredSelection(oCLConstraint));
                        eClassesTableViewer.setChecked(oCLConstraint, true);
                        updateLaunchConfigurationDialog();
                    }
                }
            }
        }
    });
}