Search in sources :

Example 1 with ProjectPaths

use of org.bndtools.api.ProjectPaths in project bndtools by bndtools.

the class NewBndProjectWizardPageOne method getSourceClasspathEntries.

@Override
public IClasspathEntry[] getSourceClasspathEntries() {
    IPath projectPath = new Path(getProjectName()).makeAbsolute();
    ProjectPaths projectPaths = ProjectPaths.DEFAULT;
    List<IClasspathEntry> newEntries = new ArrayList<IClasspathEntry>(2);
    newEntries.add(JavaCore.newSourceEntry(projectPath.append(projectPaths.getSrc()), null, projectPath.append(projectPaths.getBin())));
    boolean enableTestSrcDir;
    try {
        if (template == null)
            enableTestSrcDir = true;
        else {
            ObjectClassDefinition templateMeta = template.getMetadata();
            enableTestSrcDir = findAttribute(templateMeta, ProjectTemplateParam.TEST_SRC_DIR.getString()) != null;
        }
    } catch (Exception e) {
        Plugin.getDefault().getLog().log(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error accessing template parameters", e));
        enableTestSrcDir = true;
    }
    if (enableTestSrcDir)
        newEntries.add(JavaCore.newSourceEntry(projectPath.append(projectPaths.getTestSrc()), null, projectPath.append(projectPaths.getTestBin())));
    return newEntries.toArray(new IClasspathEntry[0]);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IPath(org.eclipse.core.runtime.IPath) ProjectPaths(org.bndtools.api.ProjectPaths) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) ArrayList(java.util.ArrayList) ObjectClassDefinition(org.osgi.service.metatype.ObjectClassDefinition)

Example 2 with ProjectPaths

use of org.bndtools.api.ProjectPaths in project bndtools by bndtools.

the class ProjectLayoutGroup method createControl.

public Control createControl(Composite parent) {
    Group group = new Group(parent, SWT.NONE);
    group.setText(groupTitle);
    group.setLayout(new GridLayout(Math.max(4, ProjectLayout.values().length), true));
    SelectionListener radioListener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            for (Button button : layoutChoices) {
                if (button.getSelection()) {
                    assert (button.getData() instanceof ProjectLayout);
                    chosenProjectLayout = (ProjectLayout) button.getData();
                    return;
                }
            }
        }
    };
    for (ProjectLayout projectLayout : ProjectLayout.values()) {
        ProjectPaths projectPaths = ProjectPaths.DEFAULT;
        final Button radioButton = new Button(group, SWT.RADIO);
        radioButton.setText(projectPaths.getTitle());
        radioButton.setData(projectLayout);
        radioButton.setSelection(this.chosenProjectLayout == projectLayout);
        radioButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
        radioButton.setToolTipText(projectPaths.getToolTip());
        radioButton.addSelectionListener(radioListener);
        layoutChoices.add(radioButton);
    }
    return group;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ProjectLayout(org.bndtools.api.ProjectLayout) ProjectPaths(org.bndtools.api.ProjectPaths) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

ProjectPaths (org.bndtools.api.ProjectPaths)2 ArrayList (java.util.ArrayList)1 ProjectLayout (org.bndtools.api.ProjectLayout)1 IPath (org.eclipse.core.runtime.IPath)1 IStatus (org.eclipse.core.runtime.IStatus)1 Path (org.eclipse.core.runtime.Path)1 Status (org.eclipse.core.runtime.Status)1 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Group (org.eclipse.swt.widgets.Group)1 ObjectClassDefinition (org.osgi.service.metatype.ObjectClassDefinition)1