1 /*******************************************************************************
2 * Copyright (c) 2004 J�r�me N�gre.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.jnegre.org/cpl1_0.html
9 * J�r�me N�gre - initial API and implementation
10 *******************************************************************************/
13 * Created on 19 d�c. 2004
15 package net.sourceforge.phpeclipse.news.dialogs;
17 import java.util.ArrayList;
19 import net.sourceforge.phpeclipse.news.Channel;
20 import net.sourceforge.phpeclipse.news.Plugin;
21 import net.sourceforge.phpeclipse.news.pref.ChannelStore;
23 import org.eclipse.jface.dialogs.Dialog;
24 import org.eclipse.swt.SWT;
25 import org.eclipse.swt.layout.GridData;
26 import org.eclipse.swt.layout.GridLayout;
27 import org.eclipse.swt.widgets.Composite;
28 import org.eclipse.swt.widgets.Control;
29 import org.eclipse.swt.widgets.Label;
30 import org.eclipse.swt.widgets.Shell;
31 import org.eclipse.swt.widgets.Text;
34 * @author J�r�me N�gre
36 public class NewChannelDialog extends Dialog {
38 private Text titleText;
44 public NewChannelDialog(Shell parentShell) {
46 setShellStyle(SWT.DIALOG_TRIM|SWT.RESIZE);
49 protected Control createDialogArea(Composite parent) {
50 Composite composite = (Composite)super.createDialogArea(parent);
51 GridLayout layout = new GridLayout(2,false);
52 composite.setLayout(layout);
53 //composite.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_CYAN));
55 Label label = new Label(composite, SWT.NONE);
56 label.setText("Title: ");
57 titleText = new Text(composite, SWT.BORDER);
58 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
59 titleText.setLayoutData(gd);
61 label = new Label(composite, SWT.NONE);
62 label.setText("Url: ");
63 urlText = new Text(composite, SWT.BORDER);
64 gd = new GridData(GridData.FILL_HORIZONTAL);
65 urlText.setLayoutData(gd);
70 protected void configureShell(Shell newShell) {
71 super.configureShell(newShell);
72 newShell.setText("Add New Channel");
76 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
78 protected void okPressed() {
79 Channel channel = new Channel(titleText.getText(), urlText.getText());
80 ArrayList channels = Plugin.getDefault().getChannelList();
81 ChannelStore.saveReadStatus(channels);
82 channels.add(channel);
83 ChannelStore.setChannels(channels);
84 Plugin.getDefault().updateChannelList();
85 Plugin.getDefault().update();