use of org.eclipse.vorto.core.ui.model.IModelProject in project vorto by eclipse.
the class AbstractProjectSelectionViewPart method createPartControl.
/**
* Create contents of the view part.
*
* @param parent
*/
@Override
public void createPartControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
FormLayout layout = new FormLayout();
layout.marginHeight = 5;
layout.marginWidth = 5;
container.setLayout(layout);
projectSelectionViewer = createProjectSelectionViewer(container, getViewerText());
projectSelectionViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof IModelProject) {
IModelProject project = (IModelProject) element;
return project.getProject().getName();
}
return super.getText(element);
}
});
projectSelectionViewer.setContentProvider(ArrayContentProvider.getInstance());
Collection<IModelProject> modelProjects = getModelProjects();
projectSelectionViewer.setInput(modelProjects);
projectSelectionViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
if (event.getSelection() instanceof IStructuredSelection) {
IStructuredSelection iSelection = (IStructuredSelection) event.getSelection();
IModelProject project = (IModelProject) iSelection.getFirstElement();
selectedProject = project;
populate(selectedProject);
}
}
});
hookListeners();
Composite modelPanel = createViewerComposite(container, projectSelectionViewer.getCombo());
datatypeTreeViewer = getDataTypeTreeViewer(modelPanel);
functionBlockTreeViewer = getFunctionblockTreeViewer(modelPanel);
infoModelTreeViewer = getInfomodelTreeViewer(modelPanel);
multipleSelectionProvider = new MultipleSelectionProvider();
getSite().setSelectionProvider(multipleSelectionProvider);
if (!modelProjects.isEmpty()) {
setSelectedProject(modelProjects.iterator().next());
}
}
use of org.eclipse.vorto.core.ui.model.IModelProject in project vorto by eclipse.
the class AbstractProjectSelectionViewPart method createProjectSelectionViewer.
private ComboViewer createProjectSelectionViewer(final Composite container, String labelStr) {
Button newProjectButton = new Button(container, SWT.NONE);
newProjectButton.setImage(ImageUtil.getImage("add_obj.gif"));
newProjectButton.setToolTipText(getAddToolTipText());
newProjectButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
switch(e.type) {
case SWT.Selection:
WizardDialog wizardDialog = new WizardDialog(container.getShell(), getProjectWizard());
if (wizardDialog.open() == Window.OK) {
projectSelectionViewer.setInput(getModelProjects());
AbstractProjectWizardPage page = (AbstractProjectWizardPage) wizardDialog.getCurrentPage();
IModelProject project = getModelProjectFromName(page.getProjName());
selectedProject = project;
projectSelectionViewer.setSelection(new StructuredSelection(project), true);
}
break;
default:
}
}
});
FormData buttonFormdata = new FormData();
buttonFormdata.top = new FormAttachment(0, 0);
buttonFormdata.right = new FormAttachment(100, 0);
newProjectButton.setLayoutData(buttonFormdata);
Button deleteButton = new Button(container, SWT.NONE);
deleteButton.setImage(ImageUtil.getImage("delete.gif"));
deleteButton.setToolTipText(getDeleteToolTipText());
deleteButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
switch(e.type) {
case SWT.Selection:
if (selectedProject != null) {
if (!Display.getDefault().isDisposed()) {
Display.getDefault().syncExec(newDeleteProjectRunnable(selectedProject));
}
}
break;
default:
}
}
});
FormData deleteButtonFormdata = new FormData();
deleteButtonFormdata.top = new FormAttachment(0, 0);
deleteButtonFormdata.right = new FormAttachment(newProjectButton, -10);
deleteButton.setLayoutData(deleteButtonFormdata);
ComboViewer comboViewer = new ComboViewer(container, SWT.READ_ONLY);
Combo combo = comboViewer.getCombo();
FormData viewerFormData = new FormData();
viewerFormData.top = new FormAttachment(newProjectButton, 10);
viewerFormData.left = new FormAttachment(0, 0);
viewerFormData.right = new FormAttachment(100, 0);
combo.setLayoutData(viewerFormData);
Label label = new Label(container, SWT.NONE);
label.setText(labelStr);
FormData labelFormData = new FormData();
labelFormData.bottom = new FormAttachment(comboViewer.getCombo(), -10);
labelFormData.left = new FormAttachment(0, 0);
label.setLayoutData(labelFormData);
return comboViewer;
}
Aggregations