/*
* File : GOIMAboutDialog.java
* Created : 03.12.2005
* By : kahless
*
* Gamer's Own Instant Messenger
* Copyright (C) 2005 Herbert Poul (kahless@sphene.net)
* http://goim.sphene.net
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package net.sphene.goim.rcp.ui.dialogs;
import java.net.MalformedURLException;
import java.net.URL;
import net.sphene.goim.rcp.GOIMPlugin;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.events.HyperlinkEvent;
import org.eclipse.ui.forms.events.IHyperlinkListener;
import org.eclipse.ui.forms.widgets.FormText;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
public class GOIMCreditDialog extends Dialog {
public static final String CREDIT_PROPERTY = "net.sphene.goim.credits";
public GOIMCreditDialog(Shell parentShell) {
super(parentShell);
setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE | getDefaultOrientation());
}
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText("Gamers Own Instant Messenger - Credits");
}
@Override
protected Control createDialogArea(Composite parent) {
parent = new Composite(parent,SWT.NONE);
GridLayout parentLayout = new GridLayout(1,true);
parentLayout.marginWidth = parentLayout.marginHeight = 0;
parent.setLayout(parentLayout);
GridData parentGridData = new GridData(SWT.FILL,SWT.FILL,true,true);
parentGridData.heightHint = 500;
parentGridData.widthHint = 500;
parent.setLayoutData(parentGridData);
//super.createDialogArea(parent);
FormToolkit tk = GOIMPlugin.getFormToolkit(parent.getDisplay());
ScrolledForm form = tk.createScrolledForm(parent);
form.setText("Gamers Own Instant Messenger - Credits");
form.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
String aboutText = Platform.getProduct().getProperty(CREDIT_PROPERTY);
// StringBuffer buf = new StringBuffer();
// buf.append("<form>")
// .append("<p>")
// .append("<span color=\"header\" font=\"header\">Gamers Own Instant Messenger</span><br/>")
// .append("<img href=\"aboutImage\" align=\"bottom\" /></p><p>")
// .append(aboutText.replace("\n","<br/>"))
// .append("</p><p>")
// .append("<span color=\"header\" font=\"header\">Credits</span><br/><br/>")
// .append("</p>")
// .append("<li><b>Herbert Poul</b></li>")
// .append("<li bindent=\"20\">Coming soon</li>")
// .append("</form>");
TableWrapLayout formBodyLayout = new TableWrapLayout();
formBodyLayout.leftMargin = 10;
form.getBody().setLayout(formBodyLayout);
form.getBody().setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
FormText text = tk.createFormText(form.getBody(),true);
// text.setText(buf.toString(),true,true);
text.setText(aboutText,true,true);
// text.setImage("aboutImage",img);
// text.setColor("header",tk.getColors().getColor(FormColors.TITLE));
// text.setFont( "header",JFaceResources.getHeaderFont());
TableWrapData tableWrapData = new TableWrapData(TableWrapData.FILL);
text.setLayoutData(tableWrapData);
text.addHyperlinkListener(new IHyperlinkListener(){
public void linkEntered(HyperlinkEvent e) {
}
public void linkExited(HyperlinkEvent e) {
}
public void linkActivated(HyperlinkEvent e) {
try {
PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL((String)e.data));
} catch (PartInitException e1) {
e1.printStackTrace();
} catch (MalformedURLException e1) {
e1.printStackTrace();
}
}});
return form.getContent();
}
@Override
protected void buttonPressed(int buttonId) {
super.buttonPressed(buttonId);
}
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
true);
}
}