use of org.eclipse.vorto.core.api.model.model.ModelId in project vorto by eclipse.
the class ModelUploadDialog method createReferencesTable.
private void createReferencesTable(Composite container, List<ModelId> references) {
Label lbtFirstName = new Label(container, SWT.NONE);
lbtFirstName.setText(REFERENCES_LABEL);
GridData data = new GridData();
data.grabExcessHorizontalSpace = true;
data.horizontalAlignment = GridData.FILL;
Table table = new Table(container, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
table.setLayoutData(data);
table.setHeaderVisible(true);
table.setLinesVisible(true);
for (String columnName : COLUMNS) {
TableColumn column = new TableColumn(table, SWT.NONE);
column.setText(columnName);
}
if (references != null) {
for (ModelId id : references) {
TableItem item = new TableItem(table, 0);
item.setImage(0, getImage(id));
item.setImage(1, ImageUtil.getImageForModelType(id.getModelType()));
item.setText(1, id.getName());
item.setText(2, id.getNamespace());
item.setText(3, id.getVersion());
}
}
for (int i = 0; i < COLUMNS.length; i++) {
table.getColumn(i).pack();
}
}
use of org.eclipse.vorto.core.api.model.model.ModelId in project vorto by eclipse.
the class AddSharedReferenceDropAction method downloadAndSaveModel.
// Download and save model from repository to local project.
// It also recursively do the same for the model references.
private Optional<IModelElement> downloadAndSaveModel(IModelProject project, ModelId modelId) {
try {
ModelResource model = modelRepo.getModel(modelId);
if (model != null) {
for (ModelId reference : model.getReferences()) {
downloadAndSaveModel(project, reference);
}
MessageDisplayFactory.getMessageDisplay().display("Downloading " + modelId.toString());
byte[] modelContent = modelRepo.downloadContent(model.getId());
return Optional.of(project.addModelElement(model.getId(), new ByteArrayInputStream(modelContent)));
} else {
MessageDisplayFactory.getMessageDisplay().displayError("Model " + modelId.toString() + " not found in repository.");
}
} catch (RepositoryException e) {
ExceptionHandlerFactory.getHandler().handle(e);
}
return Optional.empty();
}
use of org.eclipse.vorto.core.api.model.model.ModelId in project vorto by eclipse.
the class RepositoryResourceDropAction method downloadMappings.
private void downloadMappings(IModelProject modelProject, List<ModelId> referencedBy) {
for (ModelId modelId : referencedBy) {
ModelResource model = modelRepo.getModel(modelId);
if (model != null && model.getId().getModelType() == ModelType.Mapping) {
MessageDisplayFactory.getMessageDisplay().display("Downloading " + modelId.toString());
byte[] modelContent = modelRepo.downloadContent(model.getId());
saveToProject(modelProject, modelContent, model.getId());
}
}
}
use of org.eclipse.vorto.core.api.model.model.ModelId in project vorto by eclipse.
the class AbstractModelElement method getReferences.
public Set<IModelElement> getReferences() {
Set<IModelElement> references = new TreeSet<>();
for (ModelReference modelReference : getModel().getReferences()) {
for (ModelType possibleType : getPossibleReferenceTypes()) {
ModelId modelId = ModelIdFactory.newInstance(possibleType, modelReference);
IModelElement modelElementReference = this.modelProject.getModelElementById(modelId);
if (modelElementReference != null) {
references.add(modelElementReference);
break;
}
}
}
return references;
}
use of org.eclipse.vorto.core.api.model.model.ModelId in project vorto by eclipse.
the class DatatypeTreeViewer method initContextMenu.
protected void initContextMenu() {
final MenuManager menuMgr = new MenuManager("#PopupMenuDt");
Menu menu = menuMgr.createContextMenu(treeViewer.getControl());
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
if (!treeViewer.getStructuredSelection().isEmpty()) {
final IModelElement model = (IModelElement) treeViewer.getStructuredSelection().getFirstElement();
if (model.getId().getModelType() == ModelType.Datatype) {
menuMgr.add(ShareModelAction.newInstance(treeViewer, model));
menuMgr.add(DeleteModelAction.newInstance(localModelWorkspace, treeViewer, model));
menuMgr.add(new ProjectAction("New Mapping Model", ImageUtil.getImage("add_obj.gif"), treeViewer.getLocalModelWorkspace()) {
@Override
public void doAction() {
IModelElement firstElement = (IModelElement) treeViewer.getStructuredSelection().getFirstElement();
ModelId modelId = firstElement.getId();
WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), new MappingModelWizard(treeViewer.getLocalModelWorkspace().getProjectBrowser().getSelectedProject(), modelId));
dialog.create();
dialog.open();
}
});
}
}
manager.add(new ProjectAction("New Entity", ImageUtil.getImage("add_obj.gif"), treeViewer.getLocalModelWorkspace()) {
@Override
public void doAction() {
WizardDialog wizardDialog = new WizardDialog(treeViewer.getControl().getShell(), new EntityWizard(treeViewer.getLocalModelWorkspace().getProjectBrowser().getSelectedProject()));
if (wizardDialog.open() == Window.OK) {
populate(treeViewer.getLocalModelWorkspace().getProjectBrowser().getSelectedProject().getModelElementsByType(ModelType.Datatype));
}
}
});
manager.add(new ProjectAction("New Enum", ImageUtil.getImage("add_obj.gif"), treeViewer.getLocalModelWorkspace()) {
@Override
public void doAction() {
WizardDialog wizardDialog = new WizardDialog(treeViewer.getControl().getShell(), new EnumWizard(treeViewer.getLocalModelWorkspace().getProjectBrowser().getSelectedProject()));
if (wizardDialog.open() == Window.OK) {
populate(treeViewer.getLocalModelWorkspace().getProjectBrowser().getSelectedProject().getModelElementsByType(ModelType.Datatype));
}
}
});
}
});
menuMgr.setRemoveAllWhenShown(true);
this.treeViewer.getControl().setMenu(menu);
}
Aggregations