use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class MarketplacePage method updateBranding.
private void updateBranding() {
disableTabSelection = true;
updateTitle();
CatalogDescriptor descriptor = configuration.getCatalogDescriptor();
ICatalogBranding oldBranding = currentBranding;
ICatalogBranding branding = descriptor == null ? null : descriptor.getCatalogBranding();
if (branding == null) {
branding = getDefaultBranding();
}
currentBranding = branding;
TabItem selectedTabItem = getSelectedTabItem();
int tabIndex = 0;
boolean hasTab = branding.hasSearchTab();
searchTabItem = updateTab(searchTabItem, ContentType.SEARCH, WIDGET_ID_TAB_SEARCH, branding.getSearchTabName(), hasTab, oldBranding.hasSearchTab(), tabIndex);
if (hasTab) {
tabIndex++;
}
hasTab = hasFeaturedMarketTab(branding);
featuredMarketTabItem = updateTab(featuredMarketTabItem, ContentType.SEARCH, WIDGET_ID_TAB_FEATURED_MARKET, branding.getFeaturedMarketTabName(), hasTab, hasFeaturedMarketTab(oldBranding), tabIndex);
if (hasTab) {
tabIndex++;
}
hasTab = branding.hasRecentTab();
recentTabItem = updateTab(recentTabItem, ContentType.SEARCH, WIDGET_ID_TAB_RECENT, branding.getRecentTabName(), hasTab, oldBranding.hasRecentTab(), tabIndex);
if (hasTab) {
tabIndex++;
}
hasTab = branding.hasPopularTab();
popularTabItem = updateTab(popularTabItem, ContentType.SEARCH, WIDGET_ID_TAB_POPULAR, branding.getPopularTabName(), hasTab, oldBranding.hasPopularTab(), tabIndex);
if (hasTab) {
tabIndex++;
}
hasTab = branding.hasRelatedTab();
relatedTabItem = updateTab(relatedTabItem, ContentType.SEARCH, WIDGET_ID_TAB_RELATED, branding.getRelatedTabName(), hasTab, oldBranding.hasRelatedTab(), tabIndex);
if (hasTab) {
tabIndex++;
}
hasTab = hasFavoritedTab(branding);
favoritedTabItem = updateTab(favoritedTabItem, ContentType.SEARCH, WIDGET_ID_TAB_FAVORITES, getFavoritedTabName(branding), hasTab, hasFavoritedTab(oldBranding), tabIndex);
if (hasTab) {
tabIndex++;
}
updateNewsTab();
if (selectedTabItem == null || selectedTabItem.isDisposed()) {
tabFolder.setSelection(0);
}
final ImageDescriptor defaultWizardIconDescriptor = DiscoveryImages.BANNER_DISOVERY;
if (branding.getWizardIcon() == null) {
setImageDescriptor(defaultWizardIconDescriptor);
} else {
final Display display = Display.getCurrent();
MarketplaceClientUiPlugin.getInstance().getResourceProvider().provideResource(new ResourceReceiver<ImageDescriptor>() {
public ImageDescriptor processResource(URL resource) {
return ImageDescriptor.createFromURL(resource);
}
public void setResource(final ImageDescriptor resource) {
display.asyncExec(new Runnable() {
public void run() {
try {
setImageDescriptor(resource);
} catch (SWTException ex) {
// broken image
setImageDescriptor(defaultWizardIconDescriptor);
}
}
});
}
}, branding.getWizardIcon(), defaultWizardIconDescriptor);
}
disableTabSelection = false;
}
use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class MarketplacePage method hasFavoritedTab.
private boolean hasFavoritedTab(ICatalogBranding branding) {
if (branding.hasFavoritesTab()) {
return true;
}
CatalogDescriptor catalogDescriptor = this.configuration.getCatalogDescriptor();
if (catalogDescriptor == null) {
return false;
}
URL url = catalogDescriptor.getUrl();
IUserFavoritesService favoritesService = url == null ? null : ServiceHelper.getMarketplaceServiceLocator().getFavoritesService(url.toString());
return favoritesService != null;
}
use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class MarketplaceWizardDialog method configureShell.
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
// make jface dialog accessible for swtbot
newShell.setData(this);
new MarketplaceDropAdapter() {
@Override
protected void proceedInstallation(String url) {
SolutionInstallationInfo info = MarketplaceUrlHandler.createSolutionInstallInfo(url);
CatalogDescriptor catalogDescriptor = info.getCatalogDescriptor();
String installItem = info.getInstallId();
// we ignore previous wizard state here, since the wizard is still open...
if (installItem != null && installItem.length() > 0) {
info.setState(null);
getWizard().handleInstallRequest(info, url);
}
}
@Override
protected void proceedFavorites(String url) {
getWizard().importFavorites(url);
}
}.installDropTarget(newShell);
final IWorkbenchListener workbenchListener = new IWorkbenchListener() {
public boolean preShutdown(IWorkbench workbench, boolean forced) {
MarketplaceWizardDialog wizardDialog = MarketplaceWizardDialog.this;
Shell wizardShell = wizardDialog.getShell();
if (wizardShell != null && !wizardShell.isDisposed()) {
if (!forced) {
MarketplaceWizard wizard = wizardDialog.getWizard();
boolean hasPendingActions = false;
IWizardPage currentPage = wizardDialog.getCurrentPage();
if (currentPage != null && wizard != null) {
if (currentPage == wizard.getCatalogPage()) {
hasPendingActions = !wizard.getSelectionModel().getSelectedCatalogItems().isEmpty();
} else {
hasPendingActions = true;
}
}
if (hasPendingActions) {
Shell parentShell = activate(wizardDialog.getShell());
MessageDialog messageDialog = new MessageDialog(parentShell, Messages.MarketplaceWizardDialog_PromptPendingActionsTitle, null, Messages.MarketplaceWizardDialog_PromptPendingActionsMessage, MessageDialog.QUESTION_WITH_CANCEL, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, SWT.NONE);
int result = messageDialog.open();
switch(result) {
case // yes
0:
finishWizard();
return false;
case // no
1:
break;
// cancel
case 3:
// [x]
case SWT.DEFAULT:
default:
return false;
}
}
}
if (forced) {
wizardShell.close();
} else {
boolean closed = wizardDialog.close();
return closed;
}
}
return true;
}
private void finishWizard() {
MarketplaceWizardDialog wizardDialog = MarketplaceWizardDialog.this;
MarketplaceWizard wizard = wizardDialog.getWizard();
IWizardPage currentPage = wizardDialog.getCurrentPage();
if (currentPage == wizard.getCatalogPage()) {
((MarketplacePage) currentPage).showNextPage();
}
}
private Shell activate(Shell shell) {
Shell activeShell = shell.getDisplay().getActiveShell();
if (activeShell != shell) {
Shell[] childShells = shell.getShells();
if (childShells.length == 0 || !Arrays.asList(childShells).contains(activeShell)) {
shell.forceActive();
shell.forceFocus();
}
}
if (activeShell == null) {
activeShell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
if (activeShell == null) {
activeShell = shell;
}
}
return activeShell;
}
public void postShutdown(IWorkbench workbench) {
}
};
PlatformUI.getWorkbench().addWorkbenchListener(workbenchListener);
newShell.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
PlatformUI.getWorkbench().removeWorkbenchListener(workbenchListener);
}
});
if (newShell.getParent() == null) {
// bug 500379 - root shells don't handle escape traversal by default
newShell.addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent e) {
if (e.keyCode == SWT.ESC) {
Shell shell = (Shell) e.widget;
if (shell != null && !shell.isDisposed() && shell.isVisible() && shell.isEnabled()) {
shell.close();
}
}
}
});
}
}
use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class CatalogSwitcher method setSelection.
public void setSelection(ISelection newSelection) {
if (newSelection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) newSelection;
CatalogDescriptor oldDescriptor = this.selection;
CatalogDescriptor newDescriptor = (CatalogDescriptor) structuredSelection.getFirstElement();
this.selection = newDescriptor;
refreshSelection();
if (newDescriptor != oldDescriptor) {
fireSelectionChanged();
}
}
}
use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class CatalogSwitcher method createContents.
private void createContents(final Composite parent) {
createHeader(parent);
final ScrolledComposite scrollArea = new ScrolledComposite(parent, SWT.V_SCROLL);
scrollArea.setLayout(new FillLayout());
marketplaceArea = new Composite(scrollArea, SWT.NONE);
RowLayout layout = new RowLayout(SWT.HORIZONTAL);
layout.marginLeft = layout.marginRight = layout.marginTop = layout.marginBottom = layout.marginHeight = layout.marginWidth = 0;
marketplaceArea.setLayout(layout);
Color listBackground = getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
setBackground(listBackground);
marketplaceArea.setBackground(listBackground);
scrollArea.setBackground(listBackground);
List<CatalogDescriptor> catalogDescriptors = configuration.getCatalogDescriptors();
for (CatalogDescriptor catalogDescriptor : catalogDescriptors) {
createMarketplace(marketplaceArea, catalogDescriptor);
}
scrollArea.setContent(marketplaceArea);
scrollArea.setExpandVertical(true);
scrollArea.setExpandHorizontal(true);
scrollArea.setMinHeight(MIN_SCROLL_HEIGHT);
scrollArea.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
Rectangle r = parent.getClientArea();
int scrollBarWidth = scrollArea.getVerticalBar().getSize().x;
scrollArea.setMinSize(marketplaceArea.computeSize(r.width - scrollBarWidth, SWT.DEFAULT));
}
});
}
Aggregations