Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 63bd7c42be311959f3d4060a431ff106ff9fda2d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*******************************************************************************
 * Copyright (c) 2009 ARM Limited and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     ARM Limited - Initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.sourcelookup;

import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
import org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Shell;

public class NewMappingSourceContainerBrowser extends AbstractSourceContainerBrowser {
    private static final String MAPPING = SourceLookupUIMessages.MappingSourceContainerBrowser_0;

    /* (non-Javadoc)
     * @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#addSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector)
     */
    @Override
    public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) {
        MappingSourceContainerDialog dialog = 
            	new MappingSourceContainerDialog(shell, new MappingSourceContainer(MAPPING));
        if (dialog.open() == Window.OK) {
            return new ISourceContainer[] { dialog.getContainer() };
        }
        return new ISourceContainer[0];
    }

    /* (non-Javadoc)
     * @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#canEditSourceContainers(org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[])
     */
    public boolean canEditSourceContainers(ISourceLookupDirector director, ISourceContainer[] containers) {
        return (containers.length == 1 && containers[0] instanceof MappingSourceContainer);
    }

    /* (non-Javadoc)
     * @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#editSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[])
     */
    public ISourceContainer[] editSourceContainers(Shell shell, ISourceLookupDirector director, ISourceContainer[] containers) {
        if (containers.length == 1 && containers[0] instanceof MappingSourceContainer) {
            MappingSourceContainerDialog dialog = 
                	new MappingSourceContainerDialog(shell, (MappingSourceContainer)containers[0]);
            if (dialog.open() == Window.OK) {
                return new ISourceContainer[] { dialog.getContainer() };
            }
        }
        return new ISourceContainer[0];
    }
}

Back to the top