use of org.eclipse.titan.designer.samples.SampleProject in project titan.EclipsePlug-ins by eclipse.
the class NewTITANProjectWizard method createNewProject.
/**
* Creating a new project.
*
* @return the new project created.
*/
private IProject createNewProject() {
final IProject tempProjectHandle = mainPage.getProjectHandle();
URI location = null;
if (!mainPage.useDefaults()) {
location = mainPage.getLocationURI();
}
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
final String tempExecutableName = tempProjectHandle.getName();
final IProject newProjectHandle = ResourcesPlugin.getWorkspace().getRoot().getProject(tempExecutableName);
final IProjectDescription description = workspace.newProjectDescription(tempExecutableName);
description.setLocationURI(location);
TITANNature.addTITANNatureToProject(description);
final WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
@Override
protected void execute(final IProgressMonitor monitor) throws CoreException {
createProject(description, newProjectHandle, monitor);
String sourceFolder = optionsPage.getSourceFolder();
if (!"".equals(sourceFolder)) {
IFolder folder = newProjectHandle.getFolder(sourceFolder);
if (!folder.exists()) {
try {
folder.create(true, true, null);
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
final SampleProject sample = contentPage.getSampleProject();
if (sample != null) {
sample.setupProject(newProjectHandle.getProject(), folder);
ProjectFileHandler pfHandler = new ProjectFileHandler(newProjectHandle.getProject());
pfHandler.saveProjectSettings();
}
if (optionsPage.isExcludeFromBuildSelected()) {
folder.setPersistentProperty(new QualifiedName(FolderBuildPropertyData.QUALIFIER, FolderBuildPropertyData.EXCLUDE_FROM_BUILD_PROPERTY), TRUE);
}
}
newProjectHandle.setPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, ProjectBuildPropertyData.GENERATE_MAKEFILE_PROPERTY), TRUE);
newProjectHandle.setPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, TTCN3PreprocessorOptionsData.TTCN3_PREPROCESSOR_PROPERTY), "cpp");
newProjectHandle.setPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, CCompilerOptionsData.CXX_COMPILER_PROPERTY), "g++");
}
};
try {
getContainer().run(true, true, op);
} catch (InterruptedException e) {
return null;
} catch (final InvocationTargetException e) {
final Throwable t = e.getTargetException();
if (t != null) {
ErrorReporter.parallelErrorDisplayInMessageDialog(CREATION_FAILED, t.getMessage());
}
return null;
}
newProject = newProjectHandle;
return newProject;
}
use of org.eclipse.titan.designer.samples.SampleProject in project titan.EclipsePlug-ins by eclipse.
the class NewTITANProjectContentPage method createSampleProjectsGroup.
/**
* Creates the sample project selection part of the window
*
* @param parent
* the parent composite
*/
private void createSampleProjectsGroup(final Composite parent) {
final Group projectAndDescription = new Group(parent, SWT.NONE);
final GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
projectAndDescription.setLayout(gridLayout);
projectAndDescription.setLayoutData(new GridData(GridData.FILL_BOTH));
projectAndDescription.setText("Sample projects");
final List samplesList = new List(projectAndDescription, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
samplesList.setLayoutData(new GridData(GridData.FILL_BOTH));
int indexOfEmptyProject = 0;
int i = 0;
for (Map.Entry<String, SampleProject> entry : SampleProjects.getProjects().entrySet()) {
samplesList.add(entry.getValue().getName());
if ("Empty Project".equals(entry.getValue().getName())) {
indexOfEmptyProject = i;
}
++i;
}
samplesList.select(indexOfEmptyProject);
sampleProject = SampleProjects.getProjects().get(samplesList.getSelection()[0]);
final Label description = new Label(projectAndDescription, SWT.BORDER);
description.setLayoutData(new GridData(GridData.FILL_BOTH));
description.setText(sampleProject.getDescription());
samplesList.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (samplesList.getSelectionCount() != 1) {
return;
}
sampleProject = SampleProjects.getProjects().get(samplesList.getSelection()[0]);
description.setText(sampleProject.getDescription());
}
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
// Do nothing
}
});
}
Aggregations