Search in sources :

Example 11 with MarketplaceNodeCatalogItem

use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem in project epp.mpc by eclipse.

the class MarketplaceInfoSerializationTest method load.

@Test
public void load() throws Exception {
    File registryFile = getUserHomeRegistryFile();
    copyRegistryFile(registryFile, 100);
    MarketplaceInfo loaded = loadMarketplaceInfo();
    assertFalse(loaded.getIuToNodeKey().isEmpty());
    assertFalse(loaded.getNodeKeyToIU().isEmpty());
    MarketplaceNodeCatalogItem item = MarketplaceInfoTest.createTestItem();
    catalogRegistry.map(item.getMarketplaceUrl(), item.getData());
    assertEquals(catalogRegistry.getIuToNodeKey(), loaded.getIuToNodeKey());
    assertEquals(catalogRegistry.getNodeKeyToIU(), loaded.getNodeKeyToIU());
}
Also used : MarketplaceInfo(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceInfo) File(java.io.File) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem) Test(org.junit.Test)

Example 12 with MarketplaceNodeCatalogItem

use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem in project epp.mpc by eclipse.

the class ProvisioningJobListener method done.

@Override
public void done(IJobChangeEvent event) {
    if (event.getResult().isOK()) {
        Job job = new Job(Messages.ProvisioningJobListener_notificationTaskName) {

            {
                setPriority(Job.LONG);
                setSystem(true);
                setUser(true);
            }

            @Override
            protected IStatus run(final IProgressMonitor monitor) {
                ConcurrentTaskManager taskManager = new ConcurrentTaskManager(installItems.size(), Messages.ProvisioningJobListener_notificationTaskName);
                for (CatalogItem item : installItems) {
                    if (item instanceof MarketplaceNodeCatalogItem) {
                        final MarketplaceNodeCatalogItem nodeItem = (MarketplaceNodeCatalogItem) item;
                        taskManager.submit(new Runnable() {

                            public void run() {
                                INode node = nodeItem.getData();
                                URL marketplaceUrl = nodeItem.getMarketplaceUrl();
                                IMarketplaceService marketplaceService = ServiceHelper.getMarketplaceServiceLocator().getMarketplaceService(marketplaceUrl.toString());
                                marketplaceService.reportInstallSuccess(node, new NullProgressMonitor() {

                                    @Override
                                    public boolean isCanceled() {
                                        return monitor.isCanceled();
                                    }
                                });
                            }
                        });
                    }
                }
                try {
                    taskManager.waitUntilFinished(monitor);
                } catch (CoreException e) {
                    return e.getStatus();
                }
                return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
            }
        };
        job.schedule();
    }
}
Also used : CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) INode(org.eclipse.epp.mpc.core.model.INode) CoreException(org.eclipse.core.runtime.CoreException) ConcurrentTaskManager(org.eclipse.epp.internal.mpc.ui.util.ConcurrentTaskManager) Job(org.eclipse.core.runtime.jobs.Job) IMarketplaceService(org.eclipse.epp.mpc.core.service.IMarketplaceService) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem) URL(java.net.URL)

Example 13 with MarketplaceNodeCatalogItem

use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem in project epp.mpc by eclipse.

the class SelectionModel method computeChildren.

private void computeChildren(CatalogItemEntry itemEntry) {
    List<FeatureEntry> children = new ArrayList<FeatureEntry>();
    List<MarketplaceNodeInstallableUnitItem> iuItems = ((MarketplaceNodeCatalogItem) itemEntry.getItem()).getInstallableUnitItems();
    if (iuItems != null) {
        for (MarketplaceNodeInstallableUnitItem iuItem : iuItems) {
            FeatureEntry featureEntry = new FeatureEntry(itemEntry, iuItem);
            featureEntry.setInstalled(computeInstalled(featureEntry));
            featureEntry.setChecked(computeInitiallyChecked(featureEntry));
            children.add(featureEntry);
        }
    }
    itemEntry.children = children;
}
Also used : ArrayList(java.util.ArrayList) MarketplaceNodeInstallableUnitItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeInstallableUnitItem) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem)

Example 14 with MarketplaceNodeCatalogItem

use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem in project epp.mpc by eclipse.

the class SelectionModelStateSerializer method deserialize.

/**
 * @param state
 *            the state to restore
 * @param operationByNodeExtras
 *            additional operations to include
 * @param monitor
 */
public void deserialize(String state, Map<String, Operation> operationByNodeExtras, IProgressMonitor monitor) {
    Map<String, Operation> operationByNodeId = new HashMap<String, Operation>();
    if (state != null && state.length() > 0) {
        // $NON-NLS-1$
        Pattern pattern = Pattern.compile("([^\\s=]+)=(\\S+)");
        Matcher matcher = pattern.matcher(state);
        while (matcher.find()) {
            String nodeId = matcher.group(1);
            String operationName = matcher.group(2);
            Operation operation = Operation.valueOf(operationName);
            operationByNodeId.put(nodeId, operation);
        }
    }
    if (operationByNodeExtras != null) {
        operationByNodeId.putAll(operationByNodeExtras);
    }
    if (!operationByNodeId.isEmpty()) {
        catalog.performQuery(monitor, operationByNodeId.keySet());
        for (CatalogItem item : catalog.getItems()) {
            if (item instanceof MarketplaceNodeCatalogItem) {
                MarketplaceNodeCatalogItem nodeItem = (MarketplaceNodeCatalogItem) item;
                Operation operation = operationByNodeId.get(nodeItem.getData().getId());
                if (operation != null && operation != Operation.NONE) {
                    if (nodeItem.isInstalled() && operation == Operation.INSTALL) {
                        operation = Operation.UPDATE;
                    }
                    selectionModel.select(nodeItem, operation);
                }
            }
        }
    }
}
Also used : CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem) Pattern(java.util.regex.Pattern) HashMap(java.util.HashMap) Matcher(java.util.regex.Matcher) Operation(org.eclipse.epp.mpc.ui.Operation) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem)

Example 15 with MarketplaceNodeCatalogItem

use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem in project epp.mpc by eclipse.

the class DiscoveryItem method setFavorited.

private void setFavorited(boolean newFavorited) {
    boolean oldFavorited = isFavorited();
    if (oldFavorited != newFavorited) {
        // FIXME we should type the connector to MarketplaceNodeCatalogItem
        MarketplaceNodeCatalogItem nodeConnector = (MarketplaceNodeCatalogItem) connector;
        nodeConnector.setUserFavorite(newFavorited);
        if (!newFavorited && getViewer().getContentType() == ContentType.FAVORITES) {
            getViewer().getCatalog().removeItem(connector);
            getViewer().refresh();
        } else {
            refreshFavoriteButton();
        }
    }
}
Also used : MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem)

Aggregations

MarketplaceNodeCatalogItem (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem)18 Operation (org.eclipse.epp.mpc.ui.Operation)5 CatalogItem (org.eclipse.equinox.internal.p2.discovery.model.CatalogItem)5 ArrayList (java.util.ArrayList)4 INode (org.eclipse.epp.mpc.core.model.INode)4 URL (java.net.URL)3 HashMap (java.util.HashMap)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 Test (org.junit.Test)3 File (java.io.File)2 MarketplaceInfo (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceInfo)2 MarketplaceNodeInstallableUnitItem (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeInstallableUnitItem)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 List (java.util.List)1 Entry (java.util.Map.Entry)1 Callable (java.util.concurrent.Callable)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 CoreException (org.eclipse.core.runtime.CoreException)1