use of org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.CatalogItemEntry in project epp.mpc by eclipse.
the class MarketplaceWizard method computeNewInstallCatalogItems.
private Set<CatalogItem> computeNewInstallCatalogItems() {
Set<CatalogItem> items = new HashSet<CatalogItem>();
Map<CatalogItem, Collection<String>> iusByCatalogItem = new HashMap<CatalogItem, Collection<String>>();
for (CatalogItemEntry entry : getSelectionModel().getCatalogItemEntries()) {
List<FeatureEntry> features = entry.getChildren();
Collection<String> featureIds = new ArrayList<String>(features.size());
for (FeatureEntry feature : features) {
if (feature.computeChangeOperation() == Operation.INSTALL) {
featureIds.add(feature.getFeatureDescriptor().getId());
}
}
if (!featureIds.isEmpty()) {
iusByCatalogItem.put(entry.getItem(), featureIds);
}
}
for (IInstallableUnit unit : operationIUs) {
for (Entry<CatalogItem, Collection<String>> entry : iusByCatalogItem.entrySet()) {
if (entry.getValue().contains(unit.getId())) {
items.add(entry.getKey());
}
}
}
return items;
}
use of org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.CatalogItemEntry in project epp.mpc by eclipse.
the class FeatureSelectionWizardPage method computeCheckedViewerState.
public void computeCheckedViewerState() {
// compute which ones should be checked. (update scenario where only part of a feature is installed)
List<Object> checkedElements = new ArrayList<Object>();
List<Object> grayCheckedElements = new ArrayList<Object>();
for (CatalogItemEntry entry : getWizard().getSelectionModel().getCatalogItemEntries()) {
int childCheckCount = 0;
boolean childGrayed = false;
for (FeatureEntry child : entry.getChildren()) {
if (child.isChecked()) {
checkedElements.add(child);
++childCheckCount;
}
}
if (childCheckCount > 0) {
for (FeatureEntry child : entry.getChildren()) {
if (!child.isChecked() && !child.getInstallableUnitItem().isOptional()) {
child.setChecked(true);
checkedElements.add(child);
++childCheckCount;
}
}
}
for (FeatureEntry child : entry.getChildren()) {
if (child.isGrayed()) {
checkedElements.add(child);
grayCheckedElements.add(child);
childGrayed = true;
}
}
if (childCheckCount == entry.getChildren().size()) {
checkedElements.add(entry);
} else if (childCheckCount > 0 || childGrayed) {
grayCheckedElements.add(entry);
checkedElements.add(entry);
}
}
viewer.setCheckedElements(checkedElements.toArray());
viewer.setGrayedElements(grayCheckedElements.toArray());
viewer.refresh(true);
}
use of org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.CatalogItemEntry in project epp.mpc by eclipse.
the class FeatureSelectionWizardPage method updateSelectionModel.
private void updateSelectionModel(Set<FeatureDescriptor> featureDescriptors) {
Map<String, FeatureDescriptor> descriptorById = new HashMap<String, FeatureDescriptor>();
for (FeatureDescriptor fd : featureDescriptors) {
descriptorById.put(fd.getId(), fd);
}
SelectionModel selectionModel = getWizard().getSelectionModel();
for (CatalogItemEntry entry : selectionModel.getCatalogItemEntries()) {
for (FeatureEntry child : entry.getChildren()) {
FeatureDescriptor descriptor = descriptorById.get(child.getFeatureDescriptor().getId());
if (descriptor != null) {
child.setFeatureDescriptor(descriptor);
}
}
}
}
use of org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.CatalogItemEntry in project epp.mpc by eclipse.
the class FeatureSelectionWizardPage method createControl.
public void createControl(Composite parent) {
container = new Composite(parent, SWT.NONE);
switchResultLayout = new StackLayout();
container.setLayout(switchResultLayout);
GridData data = new GridData(GridData.FILL_BOTH);
container.setLayoutData(data);
defaultComposite = new Composite(container, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(defaultComposite);
Composite treeContainer = new Composite(defaultComposite, SWT.NULL);
GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(treeContainer);
TreeColumnLayout columnLayout = new TreeColumnLayout();
treeContainer.setLayout(columnLayout);
viewer = new CheckboxTreeViewer(treeContainer, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
viewer.setUseHashlookup(true);
viewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
if (e1 == e2) {
return 0;
}
String s1;
String s2;
if (e1 instanceof CatalogItemEntry) {
s1 = ((CatalogItemEntry) e1).getItem().getName();
s2 = ((CatalogItemEntry) e2).getItem().getName();
} else {
FeatureEntry fe1 = (FeatureEntry) e1;
FeatureEntry fe2 = (FeatureEntry) e2;
if (fe1.getInstallableUnitItem().isOptional() != fe2.getInstallableUnitItem().isOptional()) {
// required items first
return fe1.getInstallableUnitItem().isOptional() ? 1 : -1;
}
s1 = fe1.getFeatureDescriptor().getName();
s2 = fe2.getFeatureDescriptor().getName();
}
int i = s1.compareToIgnoreCase(s2);
if (i == 0) {
i = s1.compareTo(s2);
if (i == 0) {
i = new Integer(System.identityHashCode(e1)).compareTo(System.identityHashCode(e2));
}
}
return i;
}
});
viewer.setContentProvider(new ContentProvider());
viewer.setInput(getWizard().getSelectionModel());
viewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
boolean checked = event.getChecked();
if (event.getElement() instanceof CatalogItemEntry) {
CatalogItemEntry entry = (CatalogItemEntry) event.getElement();
for (FeatureEntry child : entry.getChildren()) {
child.setChecked(checked);
}
} else if (event.getElement() instanceof FeatureEntry) {
FeatureEntry featureEntry = (FeatureEntry) event.getElement();
featureEntry.setChecked(checked);
}
refreshState();
}
});
column = new TreeViewerColumn(viewer, SWT.NONE);
column.setLabelProvider(new DelegatingStyledCellLabelProvider(new LabelProvider()));
columnLayout.setColumnData(column.getColumn(), new ColumnWeightData(100, 100, true));
detailsControl = new Group(defaultComposite, SWT.SHADOW_IN);
detailsControl.setText(Messages.FeatureSelectionWizardPage_details);
GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 300).exclude(true).applyTo(detailsControl);
GridLayoutFactory.fillDefaults().applyTo(detailsControl);
detailStatusText = new Text(detailsControl, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL);
GridDataFactory.fillDefaults().grab(true, true).applyTo(detailStatusText);
setControl(container);
Dialog.applyDialogFont(container);
MarketplaceClientUi.setDefaultHelp(getControl());
flipToDefaultComposite();
}
Aggregations