Example usage for org.eclipse.jface.viewers StructuredSelection getFirstElement

List of usage examples for org.eclipse.jface.viewers StructuredSelection getFirstElement

Introduction

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

Prototype

@Override
    public Object getFirstElement() 

Source Link

Usage

From source file:net.sf.wickedshell.ui.batch.BatchManager.java

License:Open Source License

/**
 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
 *//*  w w  w  .  j  a v  a2  s .  co  m*/
public void selectionChanged(SelectionChangedEvent event) {
    StructuredSelection selection = (StructuredSelection) event.getSelection();
    if (!selection.isEmpty()) {
        IBatchFileDescriptor descriptor = (IBatchFileDescriptor) selection.getFirstElement();
        File selectedFile = new File(descriptor.getFilename());
        try {
            char[] fileContentBuffer = new char[256];
            StringBuffer fileContent = new StringBuffer();
            FileReader fileReader = new FileReader(selectedFile);
            while (fileReader.read(fileContentBuffer) != -1) {
                fileContent.append(fileContentBuffer);
            }
            fileReader.close();
            textBatchFile.setText(fileContent.toString());
        } catch (IOException exception) {
            textBatchFile.setText("Error while reading selected file (" + exception.getMessage() + ")!");
        }
    } else {
        textBatchFile.setText("");
    }
}

From source file:net.sourceforge.eclipseccase.ui.preferences.DiffMergePreferencePage.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    useExternal = new BooleanFieldEditor(COMPARE_EXTERNAL,
            PreferenceMessages.getString("Preferences.General.CompareWithExternalTool"), //$NON-NLS-1$
            composite);/*from   w w w.ja  v a2  s  .  co  m*/

    // Handle change diff ext&int
    useExternal.setPropertyChangeListener(new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if ((Boolean) event.getNewValue() == true && selectedDiffTool.equals(TOOL_IBM)) {
                execPath.setEnabled(false);
            } else if ((Boolean) event.getNewValue() == false) {
                execPath.setEnabled(false);
            } else {
                execPath.setEnabled(true);
            }
        }
    });
    addFieldEditor(useExternal);

    // Diff Group
    Group groupDiff = new Group(composite, SWT.NULL);
    GridLayout layoutDiff = new GridLayout();
    layoutDiff.numColumns = 1;
    groupDiff.setLayout(layoutDiff);
    GridData dataDiff = new GridData();
    dataDiff.horizontalAlignment = GridData.FILL;
    groupDiff.setLayoutData(dataDiff);
    groupDiff.setText("External Diff tool settings:");
    comboViewer = new ComboViewer(groupDiff);
    Combo combo = comboViewer.getCombo();
    combo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    comboViewer.setContentProvider(new IStructuredContentProvider() {
        String[] vals;

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            vals = (String[]) newInput;
        }

        public Object[] getElements(Object inputElement) {
            return vals;
        }
    });
    // This is called when I select the page.
    comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent evt) {
            ISelection selection = evt.getSelection();
            if (selection instanceof StructuredSelection) {
                StructuredSelection sel = (StructuredSelection) selection;
                if (!selection.isEmpty()) {
                    selectedDiffTool = sel.getFirstElement().toString();
                    if (selectedDiffTool.equals(TOOL_IBM)) {
                        // Sine we already have cleartool path no need to
                        // input.
                        execPath.setEnabled(false);
                    } else if (useExternal.getBooleanValue() == false) {
                        // When we use no
                        execPath.setEnabled(false);
                    } else {
                        execPath.setEnabled(true);
                    }

                }

                // set matching execPath
                if (selectedDiffTool != null & execPath != null) {
                    toolPathMap = PreferenceHelper.strToMap(getPreferenceStore()
                            .getString(IClearCasePreferenceConstants.EXTERNAL_DIFF_TOOL_EXEC_PATH));
                    execPath.setText(PreferenceHelper.getExecPath(selectedDiffTool, toolPathMap));
                }
            }
        }
    });
    createLabel(groupDiff, PreferenceMessages.getString("DiffMergePreferencePage.External.Diff.Tool.ExecPath"), //$NON-NLS-1$
            SPAN);
    execPath = new Text(groupDiff, SWT.BORDER);
    execPath.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    useExternalMerge = new BooleanFieldEditor(MERGE_EXTERNAL,
            PreferenceMessages.getString("Preferences.General.MergeWithExternalTool"), //$NON-NLS-1$
            composite);
    // Handle change diff ext&int
    useExternalMerge.setPropertyChangeListener(new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if ((Boolean) event.getNewValue() == true && selectedMergeTool.equals(TOOL_IBM)) {
                mergeExecPath.setEnabled(false);
            } else if ((Boolean) event.getNewValue() == false) {
                mergeExecPath.setEnabled(false);
            } else {
                mergeExecPath.setEnabled(true);
            }
        }
    });
    addFieldEditor(useExternalMerge);

    // Merge Group
    Group mergeGroup = new Group(composite, SWT.NULL);
    GridLayout diffLayout = new GridLayout();
    diffLayout.numColumns = 1;
    mergeGroup.setLayout(diffLayout);
    GridData mergeData = new GridData();
    dataDiff.horizontalAlignment = GridData.FILL;
    mergeGroup.setLayoutData(mergeData);
    mergeGroup.setText("External Merge Tool Settings:");
    mergeComboViewer = new ComboViewer(mergeGroup);
    Combo mergeCombo = mergeComboViewer.getCombo();
    mergeCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    mergeComboViewer.setContentProvider(new IStructuredContentProvider() {
        String[] vals;

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            vals = (String[]) newInput;
        }

        public Object[] getElements(Object inputElement) {
            return vals;
        }
    });

    mergeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent evt) {

            ISelection selection = evt.getSelection();
            if (selection instanceof StructuredSelection) {
                StructuredSelection sel = (StructuredSelection) selection;
                if (useExternalMerge.getBooleanValue() == false)
                    return;// this overrides
                if (!selection.isEmpty()) {

                    selectedMergeTool = sel.getFirstElement().toString();

                    if (selectedMergeTool.equals(TOOL_IBM)) {
                        // Sine we already have cleartool path no need to
                        // input.
                        mergeExecPath.setEnabled(false);
                    } else if (useExternalMerge.getBooleanValue() == false) {
                        // When we use no
                        mergeExecPath.setEnabled(false);
                    } else {
                        mergeExecPath.setEnabled(true);
                    }
                }

                // set matching execPath
                if (selectedMergeTool != null & mergeExecPath != null) {
                    mergeToolPathMap = PreferenceHelper.strToMap(getPreferenceStore()
                            .getString(IClearCasePreferenceConstants.EXTERNAL_MERGE_TOOL_EXEC_PATH));
                    mergeExecPath.setText(PreferenceHelper.getExecPath(selectedMergeTool, mergeToolPathMap));
                }

            }
        }
    });

    createLabel(mergeGroup,
            PreferenceMessages.getString("DiffMergePreferencePage.External.Merge.Tool.ExecPath"), SPAN); //$NON-NLS-1$
    mergeExecPath = new Text(mergeGroup, SWT.BORDER);
    mergeExecPath.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    initializeValues();
    return parent;
}

From source file:net.sourceforge.javahexeditor.plugin.editors.HexEditor.java

License:Open Source License

@Override
public void setSelection(ISelection selection) {
    if (selection.isEmpty()) {
        return;/*from   w ww  . j  a va 2  s .co m*/
    }
    StructuredSelection aSelection = (StructuredSelection) selection;
    long[] startEnd = (long[]) aSelection.getFirstElement();
    long start = startEnd[0];
    long end = start;
    if (startEnd.length > 1) {
        end = startEnd[1];
    }
    if (aSelection.size() > 1) {
        startEnd = (long[]) aSelection.toArray()[1];
        end = startEnd[0];
        if (startEnd.length > 1) {
            end = startEnd[1];
        }
    }
    getManager().setSelection(new RangeSelection(start, end));
}

From source file:net.sourceforge.sqlexplorer.preferences.DriverPreferencePage.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {

    noDefaultAndApplyButton();//from w  w  w.  j ava 2  s . c o  m
    _driverModel = SQLExplorerPlugin.getDefault().getDriverModel();

    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent,
            SQLExplorerPlugin.PLUGIN_ID + ".DriverContainerGroup");

    _prefs = SQLExplorerPlugin.getDefault().getPreferenceStore();

    GridLayout parentLayout = new GridLayout(1, false);
    parentLayout.marginTop = parentLayout.marginBottom = 0;
    parentLayout.marginHeight = 0;
    parentLayout.verticalSpacing = 10;
    parent.setLayout(parentLayout);

    GridLayout layout;

    Composite myComposite = new Composite(parent, SWT.NONE);

    // Define layout.
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = layout.marginHeight = 0;
    layout.horizontalSpacing = 20;
    layout.verticalSpacing = 10;
    myComposite.setLayout(layout);

    myComposite.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, true));

    GridData gid = new GridData(GridData.FILL_BOTH);
    gid.grabExcessHorizontalSpace = gid.grabExcessVerticalSpace = true;
    gid.horizontalAlignment = gid.verticalAlignment = GridData.FILL;
    gid.verticalSpan = 6;
    _tableViewer = new TableViewer(myComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    _tableViewer.getControl().setLayoutData(gid);
    _tableViewer.setContentProvider(new DriverContentProvider());
    final DriverLabelProvider dlp = new DriverLabelProvider();
    _tableViewer.setLabelProvider(dlp);
    _tableViewer.getTable().addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            dlp.dispose();
            if (_boldfont != null) {
                _boldfont.dispose();
            }

        }
    });
    _tableViewer.getTable().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            changeDriver();
        }
    });

    _tableViewer.setInput(_driverModel);
    selectFirst();
    final Table table = _tableViewer.getTable();

    myComposite.layout();
    parent.layout();

    // Add Buttons
    gid = new GridData(GridData.FILL);
    gid.widthHint = 75;
    Button add = new Button(myComposite, SWT.PUSH);
    add.setText(Messages.getString("Preferences.Drivers.Button.Add"));
    add.setLayoutData(gid);
    add.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CreateDriverDlg dlg = new CreateDriverDlg(getShell(), CreateDriverDlg.Type.CREATE, null);
            dlg.open();

            _tableViewer.refresh();
            selectFirst();
        }
    });

    gid = new GridData(GridData.FILL);
    gid.widthHint = 75;
    Button edit = new Button(myComposite, SWT.PUSH);
    edit.setText(Messages.getString("Preferences.Drivers.Button.Edit"));
    edit.setLayoutData(gid);
    edit.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            changeDriver();
            _tableViewer.refresh();
        }
    });

    gid = new GridData(GridData.FILL);
    gid.widthHint = 75;
    Button copy = new Button(myComposite, SWT.PUSH);
    copy.setText(Messages.getString("Preferences.Drivers.Button.Copy"));
    copy.setLayoutData(gid);
    copy.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            StructuredSelection sel = (StructuredSelection) _tableViewer.getSelection();
            ManagedDriver dv = (ManagedDriver) sel.getFirstElement();
            if (dv != null) {
                CreateDriverDlg dlg = new CreateDriverDlg(getShell(), CreateDriverDlg.Type.COPY, dv);
                dlg.open();
                _tableViewer.refresh();
            }
        }
    });

    gid = new GridData(GridData.FILL);
    gid.widthHint = 75;
    Button remove = new Button(myComposite, SWT.PUSH);
    remove.setText(Messages.getString("Preferences.Drivers.Button.Remove"));
    remove.setLayoutData(gid);
    remove.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            StructuredSelection sel = (StructuredSelection) _tableViewer.getSelection();
            ManagedDriver managedDriver = (ManagedDriver) sel.getFirstElement();
            if (managedDriver != null) {
                // when the driver is used by other Aliases, give a warning to user
                if (managedDriver.isUsedByAliases()) {
                    MessageDialog.openWarning(getShell(),
                            Messages.getString("Preferences.Drivers.ConfirmDelete.Title"),
                            Messages.getString("Preferences.Drivers.ConfirmDelete.Warning"));
                } else {
                    boolean okToDelete = MessageDialog.openConfirm(getShell(),
                            Messages.getString("Preferences.Drivers.ConfirmDelete.Title"),
                            Messages.getString("Preferences.Drivers.ConfirmDelete.Prefix")
                                    + _tableViewer.getTable().getSelection()[0].getText()
                                    + Messages.getString("Preferences.Drivers.ConfirmDelete.Postfix"));
                    if (okToDelete) {
                        _driverModel.removeDriver(managedDriver);
                        _tableViewer.refresh();
                        selectFirst();
                    }
                }
            }
        }
    });

    gid = new GridData(GridData.FILL);
    gid.widthHint = 73;
    Button bdefault = new Button(myComposite, SWT.PUSH);
    bdefault.setText(Messages.getString("Preferences.Drivers.Button.Default"));
    bdefault.setLayoutData(gid);
    // Remove bold font on all elements, and make selected element bold
    bdefault.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            for (int i = 0; i < _tableViewer.getTable().getItemCount(); i++) {

                _tableViewer.getTable().getItem(i).setFont(0, table.getFont());
            }
            _boldfont = new Font(_tableViewer.getTable().getDisplay(), table.getFont().toString(),
                    table.getFont().getFontData()[0].getHeight(), SWT.BOLD);
            _tableViewer.getTable().getSelection()[0].setFont(0, _boldfont);
            _prefs.setValue(IConstants.DEFAULT_DRIVER, _tableViewer.getTable().getSelection()[0].getText());
        }
    });

    // add button to restore default drivers
    Button bRestore = new Button(parent, SWT.PUSH);
    bRestore.setText(Messages.getString("Preferences.Drivers.Button.RestoreDefault"));
    bRestore.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            try {
                _driverModel.restoreDrivers();
                _tableViewer.refresh();
                selectFirst();
            } catch (ExplorerException ex) {
                SQLExplorerPlugin.error("Cannot restore default driver configuration", ex);
            }
        }
    });

    bRestore.setLayoutData(new GridData(SWT.RIGHT, SWT.BOTTOM, false, false));

    selectDefault(table);

    return parent;
}

From source file:net.ssehub.easy.producer.examples.internal.ExamplesWizardPage.java

License:Apache License

@Override
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout(2, true));
    container.setLayoutData(new GridData(SWT.FILL));

    // Example selection
    examplesList = CheckboxTableViewer.newCheckList(container,
            SWT.BORDER | SWT.MULTI | SWT.FILL | SWT.V_SCROLL | SWT.H_SCROLL);
    examplesList.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    examplesList.setContentProvider(new IStructuredContentProvider() {

        @Override//from ww w  .  j  ava 2 s . c  o  m
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            // Not needed
        }

        @Override
        public void dispose() {
            // Not needed
        }

        @Override
        public Object[] getElements(Object inputElement) {
            return (Object[]) inputElement;
        }
    });
    examplesList.setLabelProvider(new LabelProvider());
    examplesList.setInput(AvailableExamples.INSTANCE.getExamples());

    // Description
    descriptionArea = new Browser(container, SWT.BORDER | SWT.FILL);
    descriptionArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    examplesList.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            try {
                if (!event.getSelection().isEmpty()) {
                    StructuredSelection selection = (StructuredSelection) event.getSelection();
                    ExamplesWizardPage.this.selectionChanged(selection.getFirstElement());
                } else {
                    descriptionArea.setText("");
                }
            } catch (ClassCastException cce) {
                LOGGER.exception(cce);
            }
        }
    });

    examplesList.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            selectionChanged(event.getElement());
        }
    });

    setControl(container);
}

From source file:net.tourbook.common.util.DialogModifyColumns.java

License:Open Source License

private ColumnProfile getSelectedProfile() {

    final StructuredSelection selection = (StructuredSelection) _profileViewer.getSelection();

    final ColumnProfile selectedProfile = (ColumnProfile) selection.getFirstElement();

    return selectedProfile;
}

From source file:net.tourbook.importdata.DialogEasyImportConfig.java

License:Open Source License

private void onIC_DblClick() {

    /*/*from ww  w. j a v  a  2  s.  co m*/
     * Set active config and close the dialog.
     */

    final StructuredSelection selection = (StructuredSelection) _icViewer.getSelection();
    final ImportConfig selectedIC = (ImportConfig) selection.getFirstElement();

    _dialogEasyConfig.setActiveImportConfig(selectedIC);

    okPressed();
}

From source file:net.tourbook.importdata.DialogEasyImportConfig.java

License:Open Source License

private void onIC_Remove() {

    final StructuredSelection selection = (StructuredSelection) _icViewer.getSelection();
    final ImportConfig selectedConfig = (ImportConfig) selection.getFirstElement();

    int selectedIndex = -1;
    final ArrayList<ImportConfig> configItems = _dialogEasyConfig.importConfigs;

    // get index of the selected config
    for (int configIndex = 0; configIndex < configItems.size(); configIndex++) {

        final ImportConfig config = configItems.get(configIndex);

        if (config.equals(selectedConfig)) {
            selectedIndex = configIndex;
            break;
        }/*w ww.j av a2s  . c om*/
    }

    if (selectedIndex == -1) {

        // item not found which should not happen
        return;
    }

    // update model
    configItems.remove(selectedIndex);

    // update UI
    _icViewer.refresh();

    // select config at the same position
    if (configItems.size() > 0) {

        if (selectedIndex >= configItems.size()) {
            selectedIndex--;
        }

        final ImportConfig nextConfig = configItems.get(selectedIndex);

        _icViewer.setSelection(new StructuredSelection(nextConfig), true);
    }

    _icViewer.getTable().setFocus();

    enable_IC_Controls();
}

From source file:net.tourbook.importdata.DialogEasyImportConfig.java

License:Open Source License

private void onIL_Remove() {

    final StructuredSelection selection = (StructuredSelection) _ilViewer.getSelection();
    final ImportLauncher selectedConfig = (ImportLauncher) selection.getFirstElement();

    int selectedIndex = -1;
    final ArrayList<ImportLauncher> configItems = _dialogEasyConfig.importLaunchers;

    // get index of the selected config
    for (int configIndex = 0; configIndex < configItems.size(); configIndex++) {

        final ImportLauncher config = configItems.get(configIndex);

        if (config.equals(selectedConfig)) {
            selectedIndex = configIndex;
            break;
        }// w  w w.j a v a  2s.  c o m
    }

    if (selectedIndex == -1) {

        // item not found which should not happen
        return;
    }

    // update model
    configItems.remove(selectedIndex);

    // update UI
    _ilViewer.refresh();

    // select config at the same position

    if (configItems.size() > 0) {

        if (selectedIndex >= configItems.size()) {
            selectedIndex--;
        }

        final ImportLauncher nextConfig = configItems.get(selectedIndex);

        _ilViewer.setSelection(new StructuredSelection(nextConfig), true);
    }

    _ilViewer.getTable().setFocus();
}

From source file:net.tourbook.map2.view.Map2View.java

License:Open Source License

private void onSelectionChanged(final ISelection selection) {

    //      System.out.println((UI.timeStampNano() + " [" + getClass().getSimpleName() + "] ")
    //            + ("\tonSelectionChanged: " + selection));
    //      // TODO remove SYSTEM.OUT.PRINTLN

    if (_isPartVisible == false) {

        if (selection instanceof SelectionTourData || selection instanceof SelectionTourId
                || selection instanceof SelectionTourIds) {

            // keep only selected tours
            _selectionWhenHidden = selection;
        }//ww w.  j  a va  2s. c  o m
        return;
    }

    if (selection instanceof SelectionTourData) {

        final SelectionTourData selectionTourData = (SelectionTourData) selection;
        final TourData tourData = selectionTourData.getTourData();

        paintTours_20_One(tourData, false);
        paintPhotoSelection(selection);

        enableActions();

    } else if (selection instanceof SelectionTourId) {

        final SelectionTourId tourIdSelection = (SelectionTourId) selection;
        final TourData tourData = TourManager.getInstance().getTourData(tourIdSelection.getTourId());

        paintTours_20_One(tourData, false);
        paintPhotoSelection(selection);

        enableActions();

    } else if (selection instanceof SelectionTourIds) {

        // paint all selected tours

        final ArrayList<Long> tourIds = ((SelectionTourIds) selection).getTourIds();
        if (tourIds.size() == 0) {

            // history tour (without tours) is displayed

            final ArrayList<Photo> allPhotos = paintPhotoSelection(selection);

            if (allPhotos.size() > 0) {

                //               centerPhotos(allPhotos, false);
                showDefaultMap(true);

                enableActions();
            }

        } else if (tourIds.size() == 1) {

            // only 1 tour is displayed, synch with this tour !!!

            final TourData tourData = TourManager.getInstance().getTourData(tourIds.get(0));

            paintTours_20_One(tourData, false);
            paintPhotoSelection(selection);

            enableActions();

        } else {

            // paint multiple tours

            paintTours(tourIds);
            paintPhotoSelection(selection);

            enableActions(true);
        }

    } else if (selection instanceof SelectionChartInfo) {

        final SelectionChartInfo chartInfo = (SelectionChartInfo) selection;

        TourData tourData = null;

        final Chart chart = chartInfo.getChart();
        if (chart instanceof TourChart) {
            final TourChart tourChart = (TourChart) chart;
            tourData = tourChart.getTourData();
        }

        if (tourData != null && tourData.isMultipleTours()) {

            // multiple tours are selected

        } else {

            // use old behaviour

            final ChartDataModel chartDataModel = chartInfo.chartDataModel;
            if (chartDataModel != null) {

                final Object tourId = chartDataModel.getCustomData(Chart.CUSTOM_DATA_TOUR_ID);
                if (tourId instanceof Long) {

                    tourData = TourManager.getInstance().getTourData((Long) tourId);
                    if (tourData == null) {

                        // tour is not in the database, try to get it from the raw data manager

                        final HashMap<Long, TourData> rawData = RawDataManager.getInstance().getImportedTours();
                        tourData = rawData.get(tourId);
                    }
                }
            }
        }

        if (tourData != null) {

            positionMapTo_TourSliders(tourData, chartInfo.leftSliderValuesIndex,
                    chartInfo.rightSliderValuesIndex, chartInfo.selectedSliderValuesIndex, null);

            enableActions();
        }

    } else if (selection instanceof SelectionChartXSliderPosition) {

        final SelectionChartXSliderPosition xSliderPos = (SelectionChartXSliderPosition) selection;
        final Chart chart = xSliderPos.getChart();
        if (chart == null) {
            return;
        }

        final Object customData = xSliderPos.getCustomData();
        if (customData instanceof SelectedTourSegmenterSegments) {

            /*
             * This event is fired in the tour chart when a toursegmenter segment is selected
             */

            selectTourSegments((SelectedTourSegmenterSegments) customData);

        } else {

            final ChartDataModel chartDataModel = chart.getChartDataModel();
            final Object tourId = chartDataModel.getCustomData(Chart.CUSTOM_DATA_TOUR_ID);

            if (tourId instanceof Long) {

                final TourData tourData = TourManager.getInstance().getTourData((Long) tourId);
                if (tourData != null) {

                    final int leftSliderValueIndex = xSliderPos.getLeftSliderValueIndex();
                    int rightSliderValueIndex = xSliderPos.getRightSliderValueIndex();

                    rightSliderValueIndex = rightSliderValueIndex == SelectionChartXSliderPosition.IGNORE_SLIDER_POSITION
                            ? leftSliderValueIndex
                            : rightSliderValueIndex;

                    positionMapTo_TourSliders(//
                            tourData, leftSliderValueIndex, rightSliderValueIndex, leftSliderValueIndex, null);

                    enableActions();
                }
            }
        }

    } else if (selection instanceof SelectionTourMarker) {

        final SelectionTourMarker markerSelection = (SelectionTourMarker) selection;

        onSelectionChanged_TourMarker(markerSelection, true);

    } else if (selection instanceof SelectionMapPosition) {

        final SelectionMapPosition mapPositionSelection = (SelectionMapPosition) selection;

        final int valueIndex1 = mapPositionSelection.getSlider1ValueIndex();
        int valueIndex2 = mapPositionSelection.getSlider2ValueIndex();

        valueIndex2 = valueIndex2 == SelectionChartXSliderPosition.IGNORE_SLIDER_POSITION ? valueIndex1
                : valueIndex2;

        positionMapTo_TourSliders(//
                mapPositionSelection.getTourData(), valueIndex1, valueIndex2, valueIndex1, null);

        enableActions();

    } else if (selection instanceof PointOfInterest) {

        _isTourOrWayPoint = false;

        clearView();

        final PointOfInterest poi = (PointOfInterest) selection;

        _poiPosition = poi.getPosition();
        _poiName = poi.getName();

        final String boundingBox = poi.getBoundingBox();
        if (boundingBox == null) {
            _poiZoomLevel = _map.getZoom();
        } else {
            _poiZoomLevel = _map.getZoom(boundingBox);
        }

        if (_poiZoomLevel == -1) {
            _poiZoomLevel = _map.getZoom();
        }

        _map.setPoi(_poiPosition, _poiZoomLevel, _poiName);

        _actionShowPOI.setChecked(true);

        enableActions();

    } else if (selection instanceof StructuredSelection) {

        final StructuredSelection structuredSelection = (StructuredSelection) selection;
        final Object firstElement = structuredSelection.getFirstElement();

        if (firstElement instanceof TVICatalogComparedTour) {

            final TVICatalogComparedTour comparedTour = (TVICatalogComparedTour) firstElement;
            final long tourId = comparedTour.getTourId();

            final TourData tourData = TourManager.getInstance().getTourData(tourId);
            paintTours_20_One(tourData, false);

        } else if (firstElement instanceof TVICompareResultComparedTour) {

            final TVICompareResultComparedTour compareResultItem = (TVICompareResultComparedTour) firstElement;
            final TourData tourData = TourManager.getInstance()
                    .getTourData(compareResultItem.getComparedTourData().getTourId());
            paintTours_20_One(tourData, false);

        } else if (firstElement instanceof TourWayPoint) {

            final TourWayPoint wp = (TourWayPoint) firstElement;

            final TourData tourData = wp.getTourData();

            paintTours_20_One(tourData, false);

            _map.setPOI(_wayPointToolTipProvider, wp);

            enableActions();
        }

        enableActions();

    } else if (selection instanceof PhotoSelection) {

        paintPhotos(((PhotoSelection) selection).galleryPhotos);

        enableActions();

    } else if (selection instanceof SelectionTourCatalogView) {

        // show reference tour

        final SelectionTourCatalogView tourCatalogSelection = (SelectionTourCatalogView) selection;

        final TVICatalogRefTourItem refItem = tourCatalogSelection.getRefItem();
        if (refItem != null) {

            final TourData tourData = TourManager.getInstance().getTourData(refItem.getTourId());

            paintTours_20_One(tourData, false);

            enableActions();
        }

    } else if (selection instanceof SelectionDeletedTours) {

        clearView();
    }
}