use of org.eclipse.epp.mpc.core.model.INode 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();
}
}
use of org.eclipse.epp.mpc.core.model.INode in project epp.mpc by eclipse.
the class SelectionModelStateSerializer method serialize.
public String serialize() {
StringBuilder state = new StringBuilder(1024);
for (Map.Entry<CatalogItem, Operation> entry : selectionModel.getItemToSelectedOperation().entrySet()) {
if (entry.getValue() != Operation.NONE) {
if (state.length() > 0) {
state.append(' ');
}
INode data = (INode) entry.getKey().getData();
state.append(data.getId());
state.append('=');
state.append(entry.getValue().name());
}
}
return state.toString();
}
use of org.eclipse.epp.mpc.core.model.INode in project epp.mpc by eclipse.
the class DiscoveryItem method getFavoriteCount.
private Integer getFavoriteCount() {
if (connector.getData() instanceof INode) {
INode node = (INode) connector.getData();
IUserFavoritesService userFavoritesService = getUserFavoritesService();
if (userFavoritesService != null) {
return userFavoritesService.getFavoriteCount(node);
}
return node.getFavorited();
}
return null;
}
use of org.eclipse.epp.mpc.core.model.INode in project epp.mpc by eclipse.
the class DiscoveryItem method toggleFavorite.
private void toggleFavorite() {
final INode node = this.getCatalogItemNode();
final IUserFavoritesService userFavoritesService = getUserFavoritesService();
if (node != null && userFavoritesService != null) {
final boolean newFavorited = !isFavorited();
final Throwable[] error = new Throwable[] { null };
BusyIndicator.showWhile(getDisplay(), new Runnable() {
public void run() {
try {
ModalContext.run(new IRunnableWithProgress() {
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
userFavoritesService.getStorageService().runWithLogin(new Callable<Void>() {
public Void call() throws Exception {
userFavoritesService.setFavorite(node, newFavorited, monitor);
return null;
}
});
} catch (Exception e) {
error[0] = e;
}
}
}, true, new NullProgressMonitor(), getDisplay());
} catch (InvocationTargetException e) {
error[0] = e.getCause();
} catch (InterruptedException e) {
error[0] = e;
}
}
});
Throwable e = error[0];
if (e != null) {
if (e instanceof NotAuthorizedException) {
// authentication was cancelled
return;
} else if (e instanceof ConflictException) {
// silently ignored - service already tried to resolve this
return;
} else {
IStatus status = MarketplaceClientCore.computeStatus(e, NLS.bind(Messages.DiscoveryItem_FavoriteActionFailed, this.getNameLabelText()));
MarketplaceClientUi.handle(status, StatusManager.SHOW | StatusManager.BLOCK | StatusManager.LOG);
return;
}
}
setFavorited(newFavorited);
}
}
use of org.eclipse.epp.mpc.core.model.INode in project epp.mpc by eclipse.
the class DiscoveryItem method createInstallInfo.
@Override
protected void createInstallInfo(Composite parent) {
// prevent the button from changing the layout of the title
Composite composite = new Composite(parent, SWT.NULL);
GridDataFactory.fillDefaults().indent(DESCRIPTION_MARGIN_LEFT, BUTTONBAR_MARGIN_TOP).grab(true, false).align(SWT.BEGINNING, SWT.CENTER).applyTo(composite);
RowLayoutFactory.fillDefaults().type(SWT.HORIZONTAL).pack(true).applyTo(composite);
Integer installsTotal = null;
Integer installsRecent = null;
if (connector.getData() instanceof INode) {
INode node = (INode) connector.getData();
installsTotal = node.getInstallsTotal();
installsRecent = node.getInstallsRecent();
}
if (installsTotal != null || installsRecent != null) {
StyledText installInfo = new StyledText(composite, SWT.READ_ONLY | SWT.SINGLE);
setWidgetId(installInfo, WIDGET_ID_INSTALLS);
String totalText = installsTotal == null ? Messages.DiscoveryItem_Unknown_Installs : MessageFormat.format(Messages.DiscoveryItem_Compact_Number, installsTotal.intValue(), installsTotal * 0.001, installsTotal * 0.000001);
String recentText = installsRecent == null ? Messages.DiscoveryItem_Unknown_Installs : // $NON-NLS-1$
MessageFormat.format(// $NON-NLS-1$
"{0, number}", installsRecent.intValue());
String installInfoText = NLS.bind(Messages.DiscoveryItem_Installs, totalText, recentText);
int formatTotalsStart = installInfoText.indexOf(totalText);
if (formatTotalsStart == -1) {
installInfo.append(installInfoText);
} else {
if (formatTotalsStart > 0) {
installInfo.append(installInfoText.substring(0, formatTotalsStart));
}
StyledTextHelper.appendStyled(installInfo, totalText, new StyleRange(0, 0, null, null, SWT.BOLD));
installInfo.append(installInfoText.substring(formatTotalsStart + totalText.length()));
}
} else {
if (shareSolutionLink != null) {
shareSolutionLink.setShowText(true);
}
}
}
Aggregations