use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem in project epp.mpc by eclipse.
the class ImportFavoritesWizard method openFavoritesInMarketplace.
private void openFavoritesInMarketplace(List<MarketplaceNodeCatalogItem> selection) {
final IMarketplaceClientService clientService = MarketplaceClient.getMarketplaceClientService();
final IMarketplaceClientConfiguration config = clientService.newConfiguration();
MarketplaceCatalogConfiguration catalogConfiguration = getConfiguration();
config.setCatalogDescriptors(catalogConfiguration.getCatalogDescriptors());
config.setCatalogDescriptor(catalogConfiguration.getCatalogDescriptor());
Map<String, Operation> initialOperations = new HashMap<String, Operation>();
for (MarketplaceNodeCatalogItem item : selection) {
initialOperations.put(item.getData().getId(), Operation.INSTALL);
}
config.setInitialOperations(initialOperations);
Display.getCurrent().asyncExec(new Runnable() {
public void run() {
clientService.openFavorites(config);
}
});
}
use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem in project epp.mpc by eclipse.
the class InstallAllActionLink method installAll.
protected void installAll() {
MarketplaceViewer viewer = marketplacePage.getViewer();
List<CatalogItem> items = viewer.getCatalog().getItems();
// We need to first select the items in the selection model and then
// set the selection to the viewer. Otherwise the MarketplacePage listener
// will advance the wizard on the first selected item.
SelectionModel selectionModel = viewer.getSelectionModel();
for (CatalogItem catalogItem : items) {
if (catalogItem instanceof MarketplaceNodeCatalogItem) {
MarketplaceNodeCatalogItem nodeItem = (MarketplaceNodeCatalogItem) catalogItem;
if (selectionModel.getSelectedOperation(nodeItem) == Operation.NONE) {
selectionModel.select(nodeItem, Operation.INSTALL);
}
}
}
// viewer.getCheckedItems() is based on the SelectionModel state, so it already has the
// updated selection. Just let the viewer synchronize its remaining selection state with it.
viewer.setSelection(new StructuredSelection(viewer.getCheckedItems()));
if (!viewer.getSelection().isEmpty()) {
marketplacePage.showNextPage();
}
}
use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem in project epp.mpc by eclipse.
the class ItemButtonController method updateButtonState.
private void updateButtonState() {
primaryState = ButtonState.DISABLED;
selectableStates = Collections.emptyList();
MarketplaceNodeCatalogItem catalogItem = (MarketplaceNodeCatalogItem) item.getData();
if (catalogItem.getInstallableUnits().isEmpty()) {
return;
}
List<Operation> availableOperations = catalogItem.getAvailableOperations();
if (availableOperations.isEmpty()) {
return;
}
Operation selectedOperation = item.getSelectedOperation();
Operation primaryOperation = selectedOperation;
switch(selectedOperation) {
case UPDATE:
primaryState = ButtonState.UPDATE_PENDING;
break;
case UNINSTALL:
primaryState = ButtonState.UNINSTALL_PENDING;
break;
case CHANGE:
primaryState = ButtonState.CHANGE_PENDING;
break;
case INSTALL:
primaryState = ButtonState.INSTALL_PENDING;
break;
case NONE:
primaryOperation = availableOperations.get(0);
primaryState = ButtonState.forOperation(primaryOperation);
break;
}
if (availableOperations.size() > 1) {
selectableStates = new ArrayList<ButtonState>(availableOperations.size() - 1);
for (Operation operation : availableOperations) {
if (operation != primaryOperation) {
ButtonState selectableState = ButtonState.forOperation(operation);
if (selectableState != ButtonState.DISABLED) {
selectableStates.add(selectableState);
}
}
}
}
}
use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem in project epp.mpc by eclipse.
the class SelectionModel method select.
/**
* Select the given item with the given operation.
*
* @param item
* the item to select
* @param operation
* the operation to perform. Providing {@link Operation#NONE} removes the selection
*/
public boolean select(CatalogItem item, Operation operation) {
boolean changed = false;
Operation sanitizedOperation = operation;
if (operation != null && Operation.NONE != operation && item instanceof MarketplaceNodeCatalogItem) {
MarketplaceNodeCatalogItem nodeItem = (MarketplaceNodeCatalogItem) item;
List<Operation> availableOperations = nodeItem.getAvailableOperations();
if (!availableOperations.contains(operation)) {
sanitizedOperation = null;
switch(operation) {
case INSTALL:
if (availableOperations.contains(Operation.UPDATE)) {
sanitizedOperation = Operation.UPDATE;
}
break;
case UPDATE:
if (availableOperations.contains(Operation.INSTALL)) {
sanitizedOperation = Operation.UPDATE;
}
break;
}
}
}
if (sanitizedOperation == null || Operation.NONE == sanitizedOperation) {
if (itemToOperation.remove(item) != Operation.NONE) {
changed = true;
}
if (entries != null) {
Iterator<CatalogItemEntry> it = entries.iterator();
while (it.hasNext()) {
CatalogItemEntry entry = it.next();
if (entry.getItem().equals(item)) {
it.remove();
}
}
}
} else {
Operation previous = itemToOperation.put(item, sanitizedOperation);
if (previous != sanitizedOperation) {
changed = true;
if (entries != null) {
Iterator<CatalogItemEntry> it = entries.iterator();
while (it.hasNext()) {
CatalogItemEntry entry = it.next();
if (entry.getItem().equals(item)) {
it.remove();
}
}
CatalogItemEntry itemEntry = createItemEntry(item, sanitizedOperation);
entries.add(itemEntry);
}
}
}
if (changed) {
selectionChanged();
}
return changed;
}
use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem in project epp.mpc by eclipse.
the class MarketplaceInfoSerializationTest method saveAndLoad.
@Test
public void saveAndLoad() throws Exception {
MarketplaceNodeCatalogItem item = MarketplaceInfoTest.createTestItem();
catalogRegistry.map(item.getMarketplaceUrl(), item.getData());
new MarketplaceInfo(catalogRegistry).save(getUserHomeRegistryFile());
File registryFile = getUserHomeRegistryFile();
assertTrue(MessageFormat.format("Registry file ''{0}'' does not exist", registryFile.getAbsolutePath()), registryFile.exists());
assertTrue(MessageFormat.format("Registry file ''{0}'' is empty", registryFile.getAbsolutePath()), registryFile.length() > 0);
MarketplaceInfo loaded = loadMarketplaceInfo();
assertNotNull(loaded);
assertFalse(loaded.getIuToNodeKey().isEmpty());
assertFalse(loaded.getNodeKeyToIU().isEmpty());
assertEquals(catalogRegistry.getIuToNodeKey(), loaded.getIuToNodeKey());
assertEquals(catalogRegistry.getNodeKeyToIU(), loaded.getNodeKeyToIU());
}
Aggregations