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

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

Introduction

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

Prototype

public LabelProvider() 

Source Link

Document

Creates a new label provider.

Usage

From source file:de.bht.fpa.mail.s000000.common.filter.operator.BooleanFilterOperatorComposite.java

License:Open Source License

public BooleanFilterOperatorComposite(Composite parent) {
    super(parent, SWT.NONE);
    setLayout(new GridLayout(2, false));

    Combo comboOperation = new Combo(this, SWT.READ_ONLY);
    comboOperation.setItems(new String[] { FilterOperator.IS.value() });
    comboOperation.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
    comboOperation.select(0);/* w  ww.  ja va 2  s.c  o  m*/

    comboViewer = new ComboViewer(this, SWT.READ_ONLY);
    Combo comboValue = comboViewer.getCombo();
    comboValue.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
    comboViewer.setContentProvider(ArrayContentProvider.getInstance());
    comboViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            return String.valueOf(element);
        }
    });
    comboViewer.setInput(new Boolean[] { Boolean.TRUE, Boolean.FALSE });

    // default
    comboViewer.setSelection(new StructuredSelection(Boolean.TRUE));

    operator = FilterOperator.IS;
}

From source file:de.bht.fpa.mail.s000000.common.filter.operator.DefaultFilterOperatorComposite.java

License:Open Source License

public DefaultFilterOperatorComposite(Composite parent) {
    super(parent, SWT.NONE);
    setLayout(new GridLayout(2, false));

    ComboViewer comboViewer = new ComboViewer(this, SWT.READ_ONLY);
    Combo combo = comboViewer.getCombo();
    combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    comboViewer.setContentProvider(ArrayContentProvider.getInstance());
    comboViewer.setLabelProvider(new LabelProvider() {
        @Override//from  w ww . j ava  2  s . co m
        public String getText(Object element) {
            if (!(element instanceof FilterOperator)) {
                throw new IllegalArgumentException();
            }
            return ((FilterOperator) element).value();
        }
    });
    comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            operator = SelectionHelper.handleStructuredSelectionEvent(event, FilterOperator.class);
        }
    });
    comboViewer.setInput(FilterOperator.values());

    // default
    comboViewer.setSelection(new StructuredSelection(FilterOperator.CONTAINS));

    text = new Text(this, SWT.BORDER);
    text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1));
}

From source file:de.bht.fpa.mail.s000000.common.filter.operator.ImportanceFilterOperatorComposite.java

License:Open Source License

public ImportanceFilterOperatorComposite(Composite parent) {
    super(parent, SWT.NONE);
    setLayout(new GridLayout(2, false));

    Combo comboOperation = new Combo(this, SWT.READ_ONLY);
    comboOperation.setItems(new String[] { FilterOperator.IS.value() });
    comboOperation.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
    comboOperation.select(0);//w  w w . j  a v  a 2 s . c  o m

    comboViewer = new ComboViewer(this, SWT.READ_ONLY);
    Combo comboValue = comboViewer.getCombo();
    comboValue.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
    comboViewer.setContentProvider(ArrayContentProvider.getInstance());
    comboViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            return ((Importance) element).value();
        }
    });
    comboViewer.setInput(new Importance[] { Importance.HIGH, Importance.NORMAL, Importance.LOW });

    operator = FilterOperator.IS;
}

From source file:de.bht.fpa.mail.s000000.common.filter.type.FilterTypeComponent.java

License:Open Source License

/**
 * Create the composite./* w  w  w. j a  v  a2 s  .c  o m*/
 * 
 * @param parent
 * @param style
 */
public FilterTypeComponent(final Composite parent) {
    super(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = 0;
    setLayout(layout);

    filterTypeComboViewer = new ComboViewer(this, SWT.READ_ONLY);
    final Combo combo = filterTypeComboViewer.getCombo();
    combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));

    filterTypeComboViewer.setContentProvider(ArrayContentProvider.getInstance());
    filterTypeComboViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            if (!(element instanceof FilterType)) {
                throw new IllegalArgumentException();
            }
            return ((FilterType) element).value();
        }
    });

    filterTypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            if (stackLayout.topControl != null) {
                stackLayout.topControl.dispose();
            }
            FilterType selectedFilterType = getSelectedFilterType();
            switch (selectedFilterType) {
            case SENDER:
            case RECIPIENTS:
            case SUBJECT:
            case TEXT:
                filterOperatorComposite = new DefaultFilterOperatorComposite(filterPanel);
                break;
            case READ:
                filterOperatorComposite = new BooleanFilterOperatorComposite(filterPanel);
                break;
            case IMPORTANCE:
                filterOperatorComposite = new ImportanceFilterOperatorComposite(filterPanel);
                break;
            default:
                throw new IllegalArgumentException("Unknown filter type: " + selectedFilterType);
            }
            stackLayout.topControl = filterOperatorComposite;
            filterPanel.layout();
        }
    });

    filterTypeComboViewer.setInput(FilterType.values());

    filterPanel = new Composite(this, SWT.NONE);
    filterPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    stackLayout = new StackLayout();
    filterPanel.setLayout(stackLayout);

    filterTypeComboViewer.setSelection(new StructuredSelection(FilterType.SENDER));
}

From source file:de.bmotionstudio.core.editor.property.FontPropertyDescriptor.java

License:Eclipse Public License

/**
 * Creates an property descriptor with the given id and display name.
 * // ww w.j a  v a 2  s  .  com
 * @param id
 *            the id of the property
 * @param displayName
 *            the name to display for the property
 */
public FontPropertyDescriptor(Object id, String displayName) {
    super(id, displayName);
    setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            return super.getText(element);
        }
    });
}

From source file:de.fhg.igd.eclipse.ui.util.extension.exclusive.ExclusiveExtensionCombo.java

License:Apache License

/**
 * Constructor//w ww  .  jav  a2 s . c o m
 * 
 * @param extension the extension
 * @param parent the parent composite for the combo
 */
public ExclusiveExtensionCombo(ExclusiveExtension<T, F> extension, Composite parent) {
    super();

    this.extension = extension;

    this.viewer = new ComboViewer(parent);

    viewer.setContentProvider(ArrayContentProvider.getInstance());
    viewer.setLabelProvider(new LabelProvider() {

        @SuppressWarnings("unchecked")
        @Override
        public Image getImage(Object element) {
            return ExclusiveExtensionCombo.this.getImage((F) element);
        }

        @SuppressWarnings("unchecked")
        @Override
        public String getText(Object element) {
            return ExclusiveExtensionCombo.this.getText((F) element);
        }

    });

    viewer.setInput(extension.getFactories());
    viewer.setSelection(new StructuredSelection(extension.getCurrentDefinition()));
}

From source file:de.fraunhofer.esk.ernest.core.analysis.framework.SelectedAnalysesHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // at first we need to see which analyses can be shown in the dialog, so which file extension has the selection. See which files where selected when the Handler was started
    ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
    if (selection != null) {
        // list for all analyses that are to be shown in the list
        ArrayList<AnalysisType> validAnalyses = new ArrayList<AnalysisType>();
        // go through all analyses and see which one matches the extension of the selection (one or more files)
        for (AnalysisType a : AnalysisType.getAnalyses()) {
            if (ERNESTHandlerUtil.selectionToFile(selection, true, a.getExtension().split(",")) != null) {
                validAnalyses.add(a);/*from   w  w w .ja v a  2 s  .  co  m*/
            }
        }

        if (validAnalyses.size() > 0) {

            // load preferred analyses into the menu (activate checkbox)
            IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
            // list of the checked analyses
            ArrayList<AnalysisType> preferredAnalyses = new ArrayList<AnalysisType>();
            for (AnalysisType a : validAnalyses) {
                // getBoolean also returns false if the key is not stored, thats exactly what we want
                if (prefStore.getBoolean(a.getClassname())) {
                    preferredAnalyses.add(a);
                }
            }

            // Start ListDialog with checkboxes
            // Create the dialog window
            ListSelectionDialog listviewer = new ListSelectionDialog(HandlerUtil.getActiveShell(event),
                    validAnalyses, new ArrayContentProvider(),
                    // only show the name of the analyses
                    new LabelProvider() {
                        @Override
                        public String getText(Object element) {
                            AnalysisType a = (AnalysisType) element;
                            return a.getName();
                        }
                    }, "Select Analyses:");

            // preferred ones are checked at the beginning
            listviewer.setInitialElementSelections(preferredAnalyses);

            if (listviewer.open() == Window.OK) {
                // get what the user has chosen
                Object[] results = listviewer.getResult();
                ArrayList<AnalysisType> selectedAnalyses = new ArrayList<AnalysisType>();
                if (results != null && results.length > 0) {
                    for (Object obj : results) {
                        AnalysisType a = (AnalysisType) obj;
                        selectedAnalyses.add(a);
                    }

                    // Store the preferred analyses
                    // so uncheck old ones, check the new ones
                    for (AnalysisType a : preferredAnalyses) {
                        prefStore.setValue(a.getClassname(), false);
                    }
                    for (AnalysisType a : selectedAnalyses) {
                        prefStore.setValue(a.getClassname(), true);
                    }

                    // start all selected analyses
                    AnalysisType[] tmpAnalysisTypeArray = selectedAnalyses
                            .toArray(new AnalysisType[selectedAnalyses.size()]);

                    HashSet<String> extensions = new HashSet<String>();
                    for (AnalysisType a : selectedAnalyses) {
                        extensions.addAll(Arrays.asList(a.getExtension().split(",")));
                    }
                    String[] extensionsArray = extensions.toArray(new String[extensions.size()]);

                    Collection<IFile> analysisFiles = ERNESTHandlerUtil.selectionToFiles(selection, -1, true,
                            extensionsArray);
                    String[] fileArray = new String[analysisFiles.size()];
                    int i = 0;
                    // Now start a Job for every selected file
                    for (IFile analysisFile : analysisFiles) {
                        // Get the Filename of the Resource (including Path)
                        String file = analysisFile.getFullPath().toString();

                        fileArray[i++] = file;
                    }

                    // create a job and schedule
                    Job job = new AnalysisJob(tmpAnalysisTypeArray, fileArray);
                    job.setUser(true);
                    job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
                    job.schedule();
                } else {
                    MessageDialog.openError(HandlerUtil.getActiveShell(event), "ERNEST Analysis",
                            "No analysis selected.");
                }
            } else {
                // user pressed cancel, do nothing.
            }
        }
    }
    return null;
}

From source file:de.fzi.skillpro.order.dialogs.CreateNewOrderDialog.java

License:Open Source License

private void createContainerItems(Composite container, GridDataFactory gdGrab) {
    final Label orderLabel = new Label(container, SWT.NONE);
    orderLabel.setText("ID");
    final Text orderText = new Text(container, SWT.BORDER);
    orderText.setLayoutData(gdGrab.create());

    final Label nameLabel = new Label(container, SWT.NONE);
    nameLabel.setText("Name");
    final Text nameText = new Text(container, SWT.BORDER);
    nameText.setLayoutData(gdGrab.create());

    final Label productLabel = new Label(container, SWT.NONE);
    productLabel.setText("Product");
    final ComboViewer productCV = new ComboViewer(container);
    productCV.getControl().setLayoutData(gdGrab.create());
    productCV.setContentProvider(new ArrayContentProvider());
    productCV.setLabelProvider(new LabelProvider() {
        @Override//from  w w  w.  j  av  a2  s.  com
        public String getText(Object element) {
            return ((Product) element).getName();
        }
    });
    productCV.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            product = (Product) ((IStructuredSelection) productCV.getSelection()).getFirstElement();
            validate();
        }
    });
    productCV.setInput(SkillproService.getSkillproProvider().getProductRepo().getEntities());

    final Label quantityLabel = new Label(container, SWT.NONE);
    quantityLabel.setText("Quantity");
    final Text quantityText = new Text(container, SWT.BORDER);
    quantityText.setText(DEFAULT_QUANTITY + "");
    quantityText.setLayoutData(gdGrab.create());

    final Label startDateLabel = new Label(container, SWT.NONE);
    startDateLabel.setText("Start Date");
    final DateTime startDateTime = new DateTime(container, SWT.DATE | SWT.MEDIUM);
    startDateTime.setLayoutData(gdGrab.create());

    final Label endDateLabel = new Label(container, SWT.NONE);
    endDateLabel.setText("End Date");
    final DateTime endDateTime = new DateTime(container, SWT.DATE | SWT.MEDIUM);
    endDateTime.setLayoutData(gdGrab.create());
    // Listeners
    SelectionListener dateListener = new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            DateTime source = (DateTime) e.getSource();
            if (source == startDateTime) {
                startDate.set(Calendar.DAY_OF_MONTH, startDateTime.getDay());
                startDate.set(Calendar.MONTH, startDateTime.getMonth() + 1);
                startDate.set(Calendar.YEAR, startDateTime.getYear());
            } else if (source == endDateTime) {
                deadline.set(Calendar.DAY_OF_MONTH, endDateTime.getDay());
                deadline.set(Calendar.MONTH, endDateTime.getMonth() + 1);
                deadline.set(Calendar.YEAR, endDateTime.getYear());
            }
            validate();
        }
    };

    ModifyListener modifyListener = new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            Text source = (Text) e.getSource();
            if (source == quantityText) {
                try {
                    quantity = Integer.parseInt(quantityText.getText());
                } catch (NumberFormatException ex) {
                    quantityText.setText("");
                }
            } else if (source == orderText) {
                id = orderText.getText();
            }
            validate();
        }
    };
    // ADD LISTENERS
    orderText.addModifyListener(modifyListener);
    quantityText.addModifyListener(modifyListener);
    nameText.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            name = nameText.getText();
            validate();
        }
    });
    startDateTime.addSelectionListener(dateListener);
    endDateTime.addSelectionListener(dateListener);
}

From source file:de.instanttouch.ui.scaffolding.swt.presenter.SnakeListPresenter.java

License:Open Source License

@Override
public void init(Object layoutData, boolean bValidate) {

    this.bValidate = bValidate;

    composite.setLayoutData(layoutData);
    composite.setLayout(new GridLayout(6, false));

    Label label = new Label(composite, SWT.NONE);
    label.setText(list.getName());/*w w w .j a  v a 2 s  .  c o  m*/
    String desc = type.getConstraints().getDescription();
    if (desc != null) {
        label.setToolTipText(desc);
    }

    GridData labelLayoutData = new GridData();
    // labelLayoutData.widthHint = 100;
    label.setLayoutData(labelLayoutData);

    if (type.getConstraints().isEnabled()) {
        Button configure = new Button(composite, SWT.PUSH);

        String path = "icons/add.png";
        Image image = Activator.getImage(path);
        configure.setImage(image);
        configure.setText("add");
        configure.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {

                add();
            }

        });

        Button delete = new Button(composite, SWT.PUSH);

        path = "icons/delete.png";
        image = Activator.getImage(path);
        delete.setImage(image);
        delete.setText("del");
        delete.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent event) {

                ISelection selection = tableViewer != null ? tableViewer.getSelection()
                        : elements.getSelection();
                if (selection instanceof IStructuredSelection) {
                    IStructuredSelection structuredSelection = (IStructuredSelection) selection;
                    Object selected = structuredSelection.getFirstElement();
                    if (selected instanceof SnakeType) {
                        T type = (T) selected;
                        list.remove(type);
                        refresh();
                    }

                }
            }

        });

        String count = "(" + list.size() + " elements)";
        label = new Label(composite, SWT.NONE);
        label.setText(count);
        desc = type.getConstraints().getDescription();
        if (desc != null) {
            label.setToolTipText(desc);
        }

    }

    boolean tableCanBeUsed = false;
    try {
        SnakeType innerType = list.newElement();
        if (innerType != null && innerType.handleAsBasic()) {
            tableCanBeUsed = true;
        } else if (innerType instanceof SnakeEntity) {
            tableCanBeUsed = SnakeTableViewer.onlyBasicTypes((SnakeEntity) innerType);
        }
    } catch (Exception e) {
        SnakeLog.log(e);
    }

    GridData listLayoutData = new GridData(GridData.FILL_BOTH);

    listLayoutData.widthHint = 200;
    listLayoutData.heightHint = 100;
    listLayoutData.horizontalSpan = 6;

    if (tableCanBeUsed) {
        try {
            boolean matchName = true;
            SnakeViewerFilter filter = new SnakeViewerFilter(new SnakeString("filter pattern"), matchName);
            SnakeComposite filterComposite;
            try {
                filterComposite = filter.createComposite(composite);
                GridData gridData = new GridData();
                // gridData.widthHint = 250;

                filterComposite.setLayoutData(gridData);
            } catch (SnakeModelException e) {
                SnakeExceptionHandler.handle(e);
            }

            SnakeScrolledComposite scrolledComposite = new SnakeScrolledComposite(composite, SWT.NONE);
            scrolledComposite.setLayout(new GridLayout(6, false));
            scrolledComposite.setLayoutData(listLayoutData);

            tableViewer = new SnakeTableViewer(scrolledComposite,
                    SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION, list);

            tableViewer.getTable().setLayoutData(listLayoutData);
            tableViewer.addFilter(filter);

            tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

                @Override
                public void selectionChanged(SelectionChangedEvent event) {
                    selectOption(event);
                }
            });

            scrolledComposite.setContent(tableViewer.getTable());
        } catch (SnakeModelException e) {
            SnakeLog.warning("failed creating SnakeTableViewer for list:" + list.getClass().getCanonicalName());
        }
    }
    if (!tableCanBeUsed || tableViewer == null) {

        elements = new ListViewer(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);

        elements.getControl().setLayoutData(listLayoutData);

        elements.setLabelProvider(new LabelProvider() {

            @Override
            public Image getImage(Object element) {

                // TODO Auto-generated method stub
                return super.getImage(element);
            }

            @Override
            public String getText(Object element) {

                if (element instanceof SnakeType) {
                    SnakeType type = (SnakeType) element;
                    return /*
                           * TODO really needed ? type.getName() +
                           * ", value= " +
                           */type.toString();
                }
                return super.getText(element);
            }
        });
        elements.setContentProvider(new IStructuredContentProvider() {

            @Override
            public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {

                // TODO Auto-generated method stub

            }

            @Override
            public void dispose() {

                // TODO Auto-generated method stub

            }

            @Override
            public Object[] getElements(Object inputElement) {

                return list.all().toArray();
            }
        });
        elements.setInput(list);

        elements.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                selectOption(event);
            }

        });

        elements.addDoubleClickListener(new IDoubleClickListener() {

            @Override
            public void doubleClick(DoubleClickEvent event) {

                if (list instanceof SnakeOption) {

                    SnakeDialog snakeDialog = getDialog();
                    if (snakeDialog != null) {
                        snakeDialog.close();
                    }

                } else {

                    ISelection selection = event.getSelection();
                    if (selection instanceof IStructuredSelection) {
                        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
                        Object selected = structuredSelection.getFirstElement();

                        if (selected instanceof SnakeType) {
                            SnakeType type = (SnakeType) selected;
                            open(type);
                        }

                    }
                }
            }
        });
    }
}

From source file:de.instanttouch.ui.scaffolding.swt.presenter.SnakeMapPresenter.java

License:Open Source License

@Override
public void init(Object layoutData, boolean bValidate) {

    this.bValidate = bValidate;

    composite.setLayoutData(layoutData);
    composite.setLayout(new GridLayout(6, false));

    Label label = new Label(composite, SWT.NONE);
    label.setText(map.getName());/*www  . j  ava  2s.  c o  m*/

    String desc = type.getConstraints().getDescription();
    if (desc != null) {
        label.setToolTipText(desc);
    }

    GridData labelLayoutData = new GridData();
    // labelLayoutData.widthHint = 100;
    label.setLayoutData(labelLayoutData);

    if (type.getConstraints().isEnabled()) {

        Button configure = new Button(composite, SWT.PUSH);

        String path = "icons/add.png";
        Image image = Activator.getImage(path);
        configure.setImage(image);
        configure.setText("add");
        configure.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {

                add();
            }

        });

        Button delete = new Button(composite, SWT.PUSH);

        path = "icons/delete.png";
        image = Activator.getImage(path);
        delete.setImage(image);
        delete.setText("del");
        delete.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent event) {

                if (tableViewer != null) {
                    ISelection selection = tableViewer.getSelection();
                    if (selection instanceof IStructuredSelection) {
                        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
                        Object selected = structuredSelection.getFirstElement();
                        if (selected instanceof SnakeMapEntry) {
                            SnakeMapEntry<K, V> helper = (SnakeMapEntry<K, V>) selected;
                            K type = helper.getKey();
                            if (type != null) {
                                map.remove(type);
                                refresh();
                            }
                        }

                    }

                }

                else {
                    ISelection selection = elements.getSelection();
                    if (selection instanceof IStructuredSelection) {
                        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
                        Object selected = structuredSelection.getFirstElement();
                        if (selected instanceof SnakeMapEntry) {
                            SnakeMapEntry<K, V> helper = (SnakeMapEntry<K, V>) selected;
                            K type = helper.getKey();
                            if (type != null) {
                                map.remove(type);
                                refresh();
                            }
                        }

                    }
                }
            }

        });

        String count = "(" + map.values().size() + " elements)";
        label = new Label(composite, SWT.NONE);
        label.setText(count);
        desc = type.getConstraints().getDescription();
        if (desc != null) {
            label.setToolTipText(desc);
        }

    }

    boolean tableCanBeUsed = false;
    try {
        SnakeType keyType = map.newKey();
        SnakeType valueType = map.newValue();
        if (keyType.handleAsBasic() && valueType.handleAsBasic()) {
            tableCanBeUsed = true;
        }
    } catch (Exception e) {
        SnakeLog.log(e);
    }

    GridData listLayoutData = new GridData(GridData.FILL_BOTH);

    // listLayoutData.widthHint = 300;
    // listLayoutData.heightHint = 100;
    listLayoutData.horizontalSpan = 6;

    if (tableCanBeUsed) {
        try {
            tableViewer = new MapTableViewer(composite,
                    SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION, map);

            tableViewer.getTable().setLayoutData(listLayoutData);

            tableViewer.setDoubleClickAction(new SnakeAction("show map entry") {

                @Override
                public void run() {

                    try {
                        if (input == null) {
                            throw new SnakeNotInitializedException("input is not initialized");
                        }

                        if (input instanceof SnakeMapEntry) {
                            SnakeMapEntry helper = (SnakeMapEntry) input;
                            if (Dialog.OK == mapOpen(helper)) {
                                refresh();
                            }
                        }

                        else {
                            throw new SnakeWrongTypeException("unexpected type: " + input);
                        }
                    } catch (Exception e) {
                        SnakeExceptionHandler.handle(e);
                    }
                }
            });
        } catch (SnakeModelException e) {
            SnakeLog.warning("failed creating SnakeTableViewer for map:" + map.getClass().getCanonicalName());
        }
    }
    if (!tableCanBeUsed || tableViewer == null) {

        elements = new ListViewer(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);

        // listLayoutData.widthHint = 200;
        // listLayoutData.heightHint = 100;
        listLayoutData.horizontalSpan = 6;
        elements.getControl().setLayoutData(listLayoutData);

        elements.setLabelProvider(new LabelProvider() {

            @Override
            public Image getImage(Object element) {

                // TODO Auto-generated method stub
                return super.getImage(element);
            }

            @Override
            public String getText(Object element) {

                if (element instanceof SnakeMapEntry) {
                    String label = "";
                    SnakeMapEntry helper = (SnakeMapEntry) element;

                    SnakeType key = helper.getKey();
                    if (key != null) {
                        label += "key: ";
                        label += key.toString();
                    }

                    label += ", value= ";
                    SnakeType value = helper.getValue();
                    if (value != null) {
                        label += value.toString();
                    }

                    return label;
                }
                return super.getText(element);
            }
        });
        elements.setContentProvider(new IStructuredContentProvider() {

            @Override
            public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {

                // TODO Auto-generated method stub

            }

            @Override
            public void dispose() {

                // TODO Auto-generated method stub

            }

            @Override
            public Object[] getElements(Object inputElement) {

                List<SnakeMapEntry<K, V>> helpers = new Vector<SnakeMapEntry<K, V>>();

                for (K key : map.keySet()) {
                    V value = map.get(key);
                    SnakeMapEntry<K, V> helper = new SnakeMapEntry<K, V>(key, value, map);
                    helpers.add(helper);
                }

                return helpers.toArray();
            }
        });
        elements.setInput(map);

        elements.addDoubleClickListener(new IDoubleClickListener() {

            @Override
            public void doubleClick(DoubleClickEvent event) {

                ISelection selection = event.getSelection();
                if (selection instanceof IStructuredSelection) {
                    IStructuredSelection structuredSelection = (IStructuredSelection) selection;
                    Object selected = structuredSelection.getFirstElement();
                    if (selected instanceof SnakeMapEntry) {
                        SnakeMapEntry helper = (SnakeMapEntry) selected;
                        if (Dialog.OK == mapOpen(helper)) {
                            refresh();
                        }
                    }
                }
            }
        });

    }
}