aboutsummaryrefslogtreecommitdiff
path: root/eclipse/plugins/com.android.ide.eclipse.ndk/src/com/android/ide/eclipse/ndk/internal/wizards/AddNativeWizardPage.java
blob: 65af270b0c4be1016c57ce5159bd1ef79687ac1f (plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
 * Copyright (C) 2011 The Android Open Source Project
 *
 * Licensed under the Eclipse Public License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.eclipse.org/org/documents/epl-v10.php
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.ide.eclipse.ndk.internal.wizards;

import com.android.ide.eclipse.ndk.internal.Messages;
import com.android.ide.eclipse.ndk.internal.NdkManager;

import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

import java.util.Map;

public class AddNativeWizardPage extends WizardPage {

    private final String defaultLibraryName;

    private Text libraryNameText;

    public AddNativeWizardPage(Map<String, String> templateArgs) {
        super("addNativeWizardPage"); //$NON-NLS-1$
        setDescription(Messages.AddNativeWizardPage_Description);
        setTitle(Messages.AddNativeWizardPage_Title);

        defaultLibraryName = templateArgs.get(NdkManager.LIBRARY_NAME);
        if (!NdkManager.isNdkLocationValid()) {
            setErrorMessage(Messages.AddNativeWizardPage_Location_not_valid);
        }
    }

    @Override
    public boolean isPageComplete() {
        return NdkManager.isNdkLocationValid();
    }

    @Override
    public void createControl(Composite parent) {
        Composite container = new Composite(parent, SWT.NULL);
        setControl(container);
        container.setLayout(new GridLayout(2, false));

        Label lblLibraryName = new Label(container, SWT.NONE);
        lblLibraryName.setText(Messages.AddNativeWizardPage_LibraryName);

        Composite composite = new Composite(container, SWT.NONE);
        composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        composite.setLayout(new GridLayout(3, false));

        Label lblLib = new Label(composite, SWT.NONE);
        lblLib.setText("lib"); //$NON-NLS-1$

        libraryNameText = new Text(composite, SWT.BORDER);
        libraryNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        libraryNameText.setText(defaultLibraryName);

        Label lblso = new Label(composite, SWT.NONE);
        lblso.setText(".so"); //$NON-NLS-1$
    }

    public void updateArgs(Map<String, String> templateArgs) {
        templateArgs.put(NdkManager.LIBRARY_NAME, libraryNameText.getText());
    }

}