use of org.obeonetwork.tools.projectlibrary.ui.wizard.imp.ImportLibraryIntoProjectWizardModel.DependencyRow in project InformationSystem by ObeoNetwork.
the class ImportLibraryIntoProjectFileSelectionPage method computeDependenciesTable.
private void computeDependenciesTable() {
List<DependencyRow> rows = new ArrayList<>();
for (MManifest dependency : wizard.getModel().getDependencies()) {
DependencyRow row = new DependencyRow();
row.setId(dependency.getProjectId());
row.setVersion(dependency.getVersion());
String existingVersion = getExistingVersion(dependency.getProjectId());
if (existingVersion != null) {
row.setExistingVersion(existingVersion);
}
rows.add(row);
}
wizard.getModel().setExistingDependenciesRows(rows);
}
use of org.obeonetwork.tools.projectlibrary.ui.wizard.imp.ImportLibraryIntoProjectWizardModel.DependencyRow in project InformationSystem by ObeoNetwork.
the class ImportLibraryIntoProjectFileSelectionPage method createControl.
/**
* Create contents of the wizard.
* @param parent
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
setControl(container);
container.setLayout(new GridLayout(3, false));
Label lblModelingProject = new Label(container, SWT.NONE);
lblModelingProject.setText("Modeling project");
comboViewer = new ComboViewer(container, SWT.NONE);
comboViewer.setUseHashlookup(true);
Combo combo = comboViewer.getCombo();
combo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
computeDependenciesTable();
}
});
combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
Label lblNewLabel = new Label(container, SWT.NONE);
lblNewLabel.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
lblNewLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
lblNewLabel.setText("MAR File");
Label lblFileToImport = new Label(container, SWT.NONE);
lblFileToImport.setText("Import file");
txtMarFile = new Text(container, SWT.BORDER);
txtMarFile.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
Button btnBrowse = new Button(container, SWT.NONE);
btnBrowse.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
FileDialog dlg = new FileDialog(getShell());
dlg.setFileName(txtMarFile.getText());
dlg.setOverwrite(true);
dlg.setFilterExtensions(new String[] { "*.mar", "*.*" });
dlg.setFilterNames(new String[] { "MAR files (*.mar)", "All files (*.*)" });
String importFile = dlg.open();
if (importFile != null) {
try {
Manifest manifest = manifestServices.getManifestFromArchive(new File(importFile));
extractInfoFromManifest(manifest);
} catch (FileNotFoundException e1) {
// TODO Error thrown
e1.printStackTrace();
} catch (IOException e1) {
// TODO Error thrown
e1.printStackTrace();
}
txtMarFile.setText(importFile);
setPageComplete(isInfoComplete());
}
}
});
btnBrowse.setText("Browse...");
Label lblProjectId = new Label(container, SWT.NONE);
lblProjectId.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblProjectId.setText("Project ID");
txtProjectId = new Text(container, SWT.BORDER | SWT.READ_ONLY);
txtProjectId.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
Label lblVersion = new Label(container, SWT.NONE);
lblVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblVersion.setText("Version");
txtVersion = new Text(container, SWT.BORDER | SWT.READ_ONLY);
txtVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
Label lblCreationDate = new Label(container, SWT.NONE);
lblCreationDate.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblCreationDate.setText("Creation date");
txtCreationDate = new Text(container, SWT.BORDER | SWT.READ_ONLY);
txtCreationDate.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
Label lblComment = new Label(container, SWT.NONE);
lblComment.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
lblComment.setText("Comment");
txtComment = new Text(container, SWT.BORDER | SWT.READ_ONLY | SWT.MULTI);
txtComment.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
Label lblDependencies = new Label(container, SWT.NONE);
lblDependencies.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
lblDependencies.setText("Dependencies");
Composite composite = new Composite(container, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
TableColumnLayout tcl_composite = new TableColumnLayout();
composite.setLayout(tcl_composite);
TableViewer tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION);
table = tableViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableViewerColumn tableViewerColumnId = new TableViewerColumn(tableViewer, SWT.NONE);
TableColumn tblclmnProjectId = tableViewerColumnId.getColumn();
tcl_composite.setColumnData(tblclmnProjectId, new ColumnWeightData(1, ColumnWeightData.MINIMUM_WIDTH, true));
tblclmnProjectId.setText("Project ID");
tableViewerColumnId.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof DependencyRow) {
return ((DependencyRow) element).getId();
}
return super.getText(element);
}
});
TableViewerColumn tableViewerColumnVersion = new TableViewerColumn(tableViewer, SWT.NONE);
TableColumn tblclmnVersion = tableViewerColumnVersion.getColumn();
tcl_composite.setColumnData(tblclmnVersion, new ColumnWeightData(1, ColumnWeightData.MINIMUM_WIDTH, true));
tblclmnVersion.setText("Version");
tableViewerColumnVersion.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof DependencyRow) {
return ((DependencyRow) element).getVersion();
}
return super.getText(element);
}
});
TableViewerColumn tableViewerColumnExistingVersion = new TableViewerColumn(tableViewer, SWT.NONE);
TableColumn tblclmnExistingVersion = tableViewerColumnExistingVersion.getColumn();
tcl_composite.setColumnData(tblclmnExistingVersion, new ColumnWeightData(1, ColumnWeightData.MINIMUM_WIDTH, true));
tblclmnExistingVersion.setText("Existing version");
tableViewerColumnExistingVersion.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof DependencyRow) {
return ((DependencyRow) element).getExistingVersion();
}
return super.getText(element);
}
});
TableViewerColumn tableViewerColumnValid = new TableViewerColumn(tableViewer, SWT.NONE);
TableColumn tblclmnValid = tableViewerColumnValid.getColumn();
tcl_composite.setColumnData(tblclmnValid, new ColumnWeightData(1, ColumnWeightData.MINIMUM_WIDTH, true));
tblclmnValid.setText("Valid");
tableViewerColumnValid.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
// No text, we only want to display an image
return null;
}
@Override
public Image getImage(Object element) {
if (element instanceof DependencyRow) {
DependencyRow row = (DependencyRow) element;
if (ManifestUtils.isGreaterOrEqual(row.getVersion(), row.getExistingVersion())) {
return ResourceManager.getPluginImage("org.obeonetwork.tools.projectlibrary.ui", "icons/valid.gif");
} else {
return ResourceManager.getPluginImage("org.obeonetwork.tools.projectlibrary.ui", "icons/invalid.gif");
}
}
return super.getImage(element);
}
});
new Label(container, SWT.NONE);
new Label(container, SWT.NONE);
new Label(container, SWT.NONE);
tableViewer.setContentProvider(new ArrayContentProvider());
setPageComplete(isInfoComplete());
m_bindingContext = initDataBindings();
}
Aggregations