| /* |
| * Copyright (c) 2015 Eike Stepper (Berlin, Germany) and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Eike Stepper - initial API and implementation |
| */ |
| package org.eclipse.userstorage.ui; |
| |
| import org.eclipse.userstorage.IStorageService; |
| import org.eclipse.userstorage.ui.internal.Activator; |
| |
| import org.eclipse.jface.dialogs.TitleAreaDialog; |
| import org.eclipse.jface.resource.ImageDescriptor; |
| import org.eclipse.swt.SWT; |
| import org.eclipse.swt.events.DisposeEvent; |
| import org.eclipse.swt.events.DisposeListener; |
| import org.eclipse.swt.graphics.Image; |
| import org.eclipse.swt.widgets.Composite; |
| import org.eclipse.swt.widgets.Control; |
| import org.eclipse.swt.widgets.Shell; |
| |
| /** |
| * @author Eike Stepper |
| */ |
| public abstract class AbstractDialog extends TitleAreaDialog |
| { |
| public AbstractDialog(Shell parentShell) |
| { |
| super(parentShell); |
| setShellStyle(SWT.SHELL_TRIM | SWT.BORDER | SWT.APPLICATION_MODAL); |
| } |
| |
| @Override |
| protected Control createDialogArea(Composite parent) |
| { |
| Shell shell = getShell(); |
| |
| ImageDescriptor descriptor = Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/LoginBanner.png"); |
| final Image titleImage = descriptor.createImage(shell.getDisplay()); |
| |
| shell.addDisposeListener(new DisposeListener() |
| { |
| @Override |
| public void widgetDisposed(DisposeEvent e) |
| { |
| titleImage.dispose(); |
| } |
| }); |
| |
| setTitleImage(titleImage); |
| return super.createDialogArea(parent); |
| } |
| |
| public static String createShellText(IStorageService service) |
| { |
| String shellText = "User Storage Service"; |
| |
| String authority = service.getServiceURI().getAuthority(); |
| if (authority != null && authority.endsWith(".eclipse.org")) |
| { |
| shellText = "Eclipse " + shellText; |
| } |
| |
| return shellText; |
| } |
| } |