Search in sources :

Example 1 with ProjectFolderSelectionDialog

use of org.python.pydev.ui.dialogs.ProjectFolderSelectionDialog in project Pydev by fabioz.

the class PyProjectProperties method createTabProjectSourceFolders.

private void createTabProjectSourceFolders(String sourcePath) {
    TabItem tabItem = new TabItem(tabFolder, SWT.None);
    tabItem.setText("Source Folders");
    tabItem.setImage(ImageCache.asImage(SharedUiPlugin.getImageCache().get(UIConstants.SOURCE_FOLDER_ICON)));
    Composite topComp = new Composite(tabFolder, SWT.None);
    topComp.setLayout(new GridLayout(1, false));
    GridData gd;
    GridData data;
    Label l2 = new Label(topComp, SWT.None);
    l2.setText("Project Source Folders (and zips/jars/eggs).\n\n" + "When using variables, the final paths resolved must be workspace-relative.");
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = false;
    l2.setLayoutData(gd);
    treeSourceFolders = new TreeWithAddRemove(topComp, 0, PythonNature.getStrAsStrItems(sourcePath)) {

        @Override
        protected String getButtonLabel(int i) {
            switch(i) {
                case 0:
                    return "Add source folder";
                case 1:
                    return "Add zip/jar/egg";
                case 2:
                    return "Add based on variable";
                default:
                    throw new AssertionError("Unexpected: " + i);
            }
        }

        @Override
        protected void handleAddButtonSelected(int nButton) {
            if (nButton == 0) {
                addItemWithDialog(new ProjectFolderSelectionDialog(getShell(), project, true, "Choose source folders to add to PYTHONPATH"), project);
            } else if (nButton == 1) {
                addItemWithDialog(new ResourceSelectionDialog(getShell(), project, "Choose zip/jar/egg to add to PYTHONPATH"), project);
            } else if (nButton == 2) {
                addItemWithDialog(new InputDialog(getShell(), "Add path to resolve with variable", "Add path to resolve with variable in the format: ${VARIABLE}", "", null));
            } else {
                throw new AssertionError("Unexpected");
            }
        }

        @Override
        protected String getImageConstant() {
            return UIConstants.SOURCE_FOLDER_ICON;
        }
    };
    data = new GridData(GridData.FILL_BOTH);
    data.grabExcessHorizontalSpace = true;
    data.grabExcessVerticalSpace = true;
    treeSourceFolders.setLayoutData(data);
    tabItem.setControl(topComp);
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) TabItem(org.eclipse.swt.widgets.TabItem) GridLayout(org.eclipse.swt.layout.GridLayout) ResourceSelectionDialog(org.eclipse.ui.dialogs.ResourceSelectionDialog) TreeWithAddRemove(org.python.pydev.ui.editors.TreeWithAddRemove) ProjectFolderSelectionDialog(org.python.pydev.ui.dialogs.ProjectFolderSelectionDialog) GridData(org.eclipse.swt.layout.GridData)

Aggregations

InputDialog (org.eclipse.jface.dialogs.InputDialog)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 TabItem (org.eclipse.swt.widgets.TabItem)1 ResourceSelectionDialog (org.eclipse.ui.dialogs.ResourceSelectionDialog)1 ProjectFolderSelectionDialog (org.python.pydev.ui.dialogs.ProjectFolderSelectionDialog)1 TreeWithAddRemove (org.python.pydev.ui.editors.TreeWithAddRemove)1