use of org.eclipse.epp.mpc.ui.Operation in project epp.mpc by eclipse.
the class MarketplacePage method canSkipFeatureSelection.
protected boolean canSkipFeatureSelection() {
SelectionModel selectionModel = getWizard().getSelectionModel();
Map<CatalogItem, Operation> selectedOperations = selectionModel.getItemToSelectedOperation();
Set<Entry<CatalogItem, Operation>> entrySet = selectedOperations.entrySet();
Operation mode = null;
for (Entry<CatalogItem, Operation> entry : entrySet) {
if (!(entry.getKey() instanceof MarketplaceNodeCatalogItem)) {
return false;
}
MarketplaceNodeCatalogItem item = (MarketplaceNodeCatalogItem) entry.getKey();
Operation value = entry.getValue();
switch(value) {
case NONE:
continue;
case INSTALL:
case UPDATE:
if (mode == null) {
mode = Operation.INSTALL;
} else if (mode == Operation.UNINSTALL) {
return false;
}
if (hasOptionalFeatures(item)) {
return false;
}
break;
case UNINSTALL:
if (mode == null) {
mode = Operation.UNINSTALL;
} else if (mode == Operation.INSTALL) {
return false;
}
if (hasOptionalFeatures(item)) {
return false;
}
break;
case CHANGE:
return false;
}
}
if (mode == null) {
return false;
}
return true;
}
use of org.eclipse.epp.mpc.ui.Operation in project epp.mpc by eclipse.
the class MarketplaceWizard method updateSelection.
protected void updateSelection() {
List<Entry<CatalogItem, Operation>> itemToSelectedOperation = new ArrayList<Entry<CatalogItem, Operation>>(getSelectionModel().getItemToSelectedOperation().entrySet());
final List<CatalogItem> noninstallableItems = new ArrayList<CatalogItem>();
for (Entry<CatalogItem, Operation> entry : itemToSelectedOperation) {
if (entry.getValue() != Operation.NONE) {
boolean unavailableInstall = (Boolean.FALSE.equals(entry.getKey().getAvailable()) || entry.getKey().getSiteUrl() == null) && (entry.getValue() == Operation.INSTALL || entry.getValue() == Operation.UPDATE);
if (unavailableInstall) {
getSelectionModel().select(entry.getKey(), Operation.NONE);
noninstallableItems.add(entry.getKey());
} else {
entry.getKey().setSelected(true);
}
}
}
MarketplacePage marketplacePage = getCatalogPage();
MarketplaceViewer viewer = marketplacePage == null ? null : marketplacePage.getViewer();
if (marketplacePage != null && viewer != null && !viewer.getControl().isDisposed()) {
viewer.setSelection(new StructuredSelection(viewer.getCheckedItems()));
marketplacePage.setPageComplete(viewer.isComplete());
}
if (!noninstallableItems.isEmpty()) {
notifyNonInstallableItems(noninstallableItems);
}
}
use of org.eclipse.epp.mpc.ui.Operation in project epp.mpc by eclipse.
the class MarketplaceWizard method importFavorites.
protected void importFavorites(MarketplaceDiscoveryStrategy marketplaceStrategy, String url) {
FavoritesCatalog favoritesCatalog = new FavoritesCatalog();
ImportFavoritesWizard importFavoritesWizard = new ImportFavoritesWizard(favoritesCatalog, getConfiguration(), this);
importFavoritesWizard.setInitialFavoritesUrl(url);
final ImportFavoritesPage importFavoritesPage = importFavoritesWizard.getImportFavoritesPage();
favoritesCatalog.getDiscoveryStrategies().add(new FavoritesDiscoveryStrategy(marketplaceStrategy) {
private String discoveryError = null;
@Override
protected void preDiscovery() {
discoveryError = null;
}
@Override
protected void handleDiscoveryError(CoreException ex) throws CoreException {
discoveryError = ImportFavoritesPage.handleDiscoveryError(getFavoritesReference(), ex);
}
@Override
protected void postDiscovery() {
final String errorMessage = this.discoveryError;
this.discoveryError = null;
importFavoritesPage.setDiscoveryError(errorMessage);
}
});
ImportFavoritesWizardDialog importWizard = new ImportFavoritesWizardDialog(getShell(), importFavoritesWizard);
Map<String, Operation> oldOperations = getSelectionModel().getItemIdToSelectedOperation();
int result = importWizard.open();
if (result == Window.OK) {
MarketplacePage catalogPage = getCatalogPage();
catalogPage.setActiveTab(ContentType.FAVORITES);
catalogPage.reloadCatalog();
Map<String, Operation> newOperations = getSelectionModel().getItemIdToSelectedOperation();
if (!newOperations.equals(oldOperations)) {
updateSelection();
}
}
}
use of org.eclipse.epp.mpc.ui.Operation 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.mpc.ui.Operation 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);
}
}
}
}
}
Aggregations