Inital commit
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
/* Copyright (c) 2008 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package sample.appsforyourdomain.gmailsettings.gui;
|
||||
|
||||
import sample.appsforyourdomain.gmailsettings.GmailSettingsService;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JSplitPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
/**
|
||||
* This is the example GUI client for the Google Apps Gmail Settings API.
|
||||
*/
|
||||
public class GmailSettingsClient {
|
||||
public static final String APP_TITLE = "GUI Gmail Settings Client";
|
||||
public static final String ERROR_AUTHENTICATION_REQUIRED = "You must authenticate first.";
|
||||
|
||||
protected static final int DEFAULT_APP_HEIGHT = 350;
|
||||
protected static final int DEFAULT_APP_WIDTH = 600;
|
||||
protected static final int DEFAULT_PANE_DIVIDER_LOCATION = 150;
|
||||
|
||||
public static GmailSettingsService settings;
|
||||
public static UsersPanel users;
|
||||
|
||||
/**
|
||||
* Prevents the class from being instantiated.
|
||||
*/
|
||||
private GmailSettingsClient() {}
|
||||
|
||||
/**
|
||||
* Entry point for Graphical GMail Settings Client.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
UIManager.put("swing.boldMetal", Boolean.FALSE);
|
||||
|
||||
JFrame frame = new JFrame(APP_TITLE);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setSize(DEFAULT_APP_WIDTH, DEFAULT_APP_HEIGHT);
|
||||
|
||||
users = new UsersPanel();
|
||||
|
||||
TabbedPane settingTabs = new TabbedPane();
|
||||
JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, users, settingTabs);
|
||||
splitpane.setDividerLocation(DEFAULT_PANE_DIVIDER_LOCATION);
|
||||
|
||||
frame.add(splitpane);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/* Copyright (c) 2008 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package sample.appsforyourdomain.gmailsettings.gui;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/**
|
||||
* Stores some common information for the tabs.
|
||||
*/
|
||||
public class Tab extends JPanel {
|
||||
|
||||
protected String name;
|
||||
protected String tooltip;
|
||||
|
||||
/**
|
||||
* @param name The name to assign to the tab.
|
||||
* @param tooltip The tooltip to be used for the tab.
|
||||
*/
|
||||
public Tab(String name, String tooltip) {
|
||||
setName(name);
|
||||
setTooltip(tooltip);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Return the name of the tab
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the tab.
|
||||
*
|
||||
* @param name The name to assign to the tab.
|
||||
*/
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The current value for tooltip.
|
||||
*/
|
||||
public String getTooltip() {
|
||||
return this.tooltip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tooltop for the tab.
|
||||
*
|
||||
* @param tooltip The tooltip to be used for the tab.
|
||||
*/
|
||||
public void setTooltip(String tooltip) {
|
||||
this.tooltip = tooltip;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
/* Copyright (c) 2008 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package sample.appsforyourdomain.gmailsettings.gui;
|
||||
|
||||
import sample.appsforyourdomain.gmailsettings.Constants;
|
||||
import sample.appsforyourdomain.gmailsettings.GmailSettingsService;
|
||||
import com.google.gdata.util.ServiceException;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPasswordField;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
/**
|
||||
* Tab containing all the authentication information.
|
||||
*/
|
||||
public class TabAuthentication extends Tab {
|
||||
protected SpringLayout layout;
|
||||
protected JLabel domainLabel;
|
||||
protected JTextField domain;
|
||||
protected JLabel usernameLabel;
|
||||
protected JTextField username;
|
||||
protected JLabel passwordLabel;
|
||||
protected JPasswordField password;
|
||||
protected JButton submit;
|
||||
|
||||
/**
|
||||
* Setup all the components on the tab.
|
||||
*/
|
||||
public TabAuthentication() {
|
||||
super("Authentication", "Authenticate with a server");
|
||||
layout = new SpringLayout();
|
||||
setLayout(layout);
|
||||
|
||||
domainLabel = new JLabel("Domain: ");
|
||||
domain = new JTextField(12);
|
||||
domain.setText(Constants.DEFAULT_DOMAIN);
|
||||
|
||||
usernameLabel = new JLabel("Admin username: ");
|
||||
username = new JTextField(12);
|
||||
username.setText(Constants.DEFAULT_USERNAME);
|
||||
|
||||
passwordLabel = new JLabel("Admin password: ");
|
||||
password = new JPasswordField(12);
|
||||
password.setText(Constants.DEFAULT_PASSWORD);
|
||||
|
||||
submit = new JButton("Update");
|
||||
submit.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
try {
|
||||
GmailSettingsClient.settings = new GmailSettingsService(GmailSettingsClient.APP_TITLE,
|
||||
domain.getText(), username.getText(), new String (password.getPassword()));
|
||||
GmailSettingsClient.users.refresh(domain.getText(), username.getText(),
|
||||
new String (password.getPassword()));
|
||||
} catch (ServiceException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, domainLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, domainLabel, 5, SpringLayout.NORTH, this);
|
||||
layout.putConstraint(SpringLayout.WEST, domain, 5, SpringLayout.EAST, domainLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, domain, 5, SpringLayout.NORTH, this);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, usernameLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, usernameLabel, 5, SpringLayout.SOUTH, domain);
|
||||
layout.putConstraint(SpringLayout.WEST, username, 5, SpringLayout.EAST, usernameLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, username, 5, SpringLayout.SOUTH, domain);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, passwordLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, passwordLabel, 5, SpringLayout.SOUTH, username);
|
||||
layout.putConstraint(SpringLayout.WEST, password, 5, SpringLayout.EAST, passwordLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, password, 5, SpringLayout.SOUTH, username);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, submit, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, submit, 15, SpringLayout.SOUTH, password);
|
||||
|
||||
add(domainLabel);
|
||||
add(domain);
|
||||
add(usernameLabel);
|
||||
add(username);
|
||||
add(passwordLabel);
|
||||
add(password);
|
||||
add(submit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
/* Copyright (c) 2008 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package sample.appsforyourdomain.gmailsettings.gui;
|
||||
|
||||
import sample.appsforyourdomain.gmailsettings.Defaults;
|
||||
import com.google.gdata.util.ServiceException;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
/**
|
||||
* Tab containing all the filter information.
|
||||
*/
|
||||
public class TabFilter extends Tab {
|
||||
protected SpringLayout layout;
|
||||
protected JLabel fromLabel;
|
||||
protected JTextField from;
|
||||
protected JLabel toLabel;
|
||||
protected JTextField to;
|
||||
protected JLabel subjectLabel;
|
||||
protected JTextField subject;
|
||||
protected JLabel hasTheWordLabel;
|
||||
protected JTextField hasTheWord;
|
||||
protected JLabel doesNotHaveTheWordLabel;
|
||||
protected JTextField doesNotHaveTheWord;
|
||||
protected JCheckBox hasAttachment;
|
||||
protected JCheckBox shouldMarkAsRead;
|
||||
protected JCheckBox shouldArchive;
|
||||
protected JLabel labelLabel;
|
||||
protected JTextField label;
|
||||
protected JButton submit;
|
||||
|
||||
/**
|
||||
* Setup all the components on the tab.
|
||||
*/
|
||||
public TabFilter() {
|
||||
super("Filters", "");
|
||||
layout = new SpringLayout();
|
||||
setLayout(layout);
|
||||
|
||||
fromLabel = new JLabel("From: ");
|
||||
from = new JTextField(Defaults.FILTER_FROM, 25);
|
||||
|
||||
toLabel = new JLabel("To: ");
|
||||
to = new JTextField(Defaults.FILTER_TO, 25);
|
||||
|
||||
subjectLabel = new JLabel("Subject: ");
|
||||
subject = new JTextField(Defaults.FILTER_SUBJECT, 25);
|
||||
|
||||
hasTheWordLabel = new JLabel("Has the word: ");
|
||||
hasTheWord = new JTextField(Defaults.FILTER_HAS_THE_WORD, 25);
|
||||
|
||||
doesNotHaveTheWordLabel = new JLabel("Does not have the word: ");
|
||||
doesNotHaveTheWord = new JTextField(Defaults.FILTER_DOES_NOT_HAVE_THE_WORD, 25);
|
||||
|
||||
hasAttachment = new JCheckBox("Has attachment:", Defaults.FILTER_HAS_ATTACHMENT);
|
||||
|
||||
shouldMarkAsRead = new JCheckBox("Should mark as read:", Defaults.FILTER_SHOULD_MARK_AS_READ);
|
||||
|
||||
shouldArchive = new JCheckBox("Should archive:", Defaults.FILTER_SHOULD_ARCHIVE);
|
||||
|
||||
labelLabel = new JLabel("Label: ");
|
||||
label = new JTextField(Defaults.FILTER_LABEL, 25);
|
||||
|
||||
submit = new JButton("Submit");
|
||||
submit.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (GmailSettingsClient.settings == null) {
|
||||
JOptionPane.showMessageDialog(null, GmailSettingsClient.ERROR_AUTHENTICATION_REQUIRED,
|
||||
GmailSettingsClient.APP_TITLE, JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
GmailSettingsClient.settings.createFilter(GmailSettingsClient.users.
|
||||
getSelectedUsers(), from.getText(), to.getText(), subject.getText(),
|
||||
hasTheWord.getText(), doesNotHaveTheWord.getText(), hasAttachment.isSelected(),
|
||||
shouldMarkAsRead.isSelected(), shouldArchive.isSelected(), label.getText());
|
||||
} catch (IllegalArgumentException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (ServiceException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (MalformedURLException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (IOException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, fromLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, fromLabel, 5, SpringLayout.NORTH, this);
|
||||
layout.putConstraint(SpringLayout.WEST, from, 5, SpringLayout.EAST, fromLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, from, 5, SpringLayout.NORTH, this);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, toLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, toLabel, 5, SpringLayout.SOUTH, from);
|
||||
layout.putConstraint(SpringLayout.WEST, to, 5, SpringLayout.EAST, toLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, to, 5, SpringLayout.SOUTH, from);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, subjectLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, subjectLabel, 5, SpringLayout.SOUTH, to);
|
||||
layout.putConstraint(SpringLayout.WEST, subject, 5, SpringLayout.EAST, subjectLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, subject, 5, SpringLayout.SOUTH, to);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, hasTheWordLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, hasTheWordLabel, 5, SpringLayout.SOUTH, subject);
|
||||
layout.putConstraint(SpringLayout.WEST, hasTheWord, 5, SpringLayout.EAST, hasTheWordLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, hasTheWord, 5, SpringLayout.SOUTH, subject);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, doesNotHaveTheWordLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, doesNotHaveTheWordLabel, 5, SpringLayout.SOUTH,
|
||||
hasTheWord);
|
||||
layout.putConstraint(SpringLayout.WEST, doesNotHaveTheWord, 5, SpringLayout.EAST,
|
||||
doesNotHaveTheWordLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, doesNotHaveTheWord, 5, SpringLayout.SOUTH, hasTheWord);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, hasAttachment, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, hasAttachment, 5, SpringLayout.SOUTH,
|
||||
doesNotHaveTheWord);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, shouldMarkAsRead, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, shouldMarkAsRead, 5, SpringLayout.SOUTH,
|
||||
hasAttachment);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, shouldArchive, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, shouldArchive, 5, SpringLayout.SOUTH,
|
||||
shouldMarkAsRead);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, labelLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, labelLabel, 5, SpringLayout.SOUTH, shouldArchive);
|
||||
layout.putConstraint(SpringLayout.WEST, label, 5, SpringLayout.EAST, labelLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, label, 5, SpringLayout.SOUTH, shouldArchive);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, submit, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, submit, 15, SpringLayout.SOUTH, label);
|
||||
|
||||
add(fromLabel);
|
||||
add(from);
|
||||
add(toLabel);
|
||||
add(to);
|
||||
add(subjectLabel);
|
||||
add(subject);
|
||||
add(hasTheWordLabel);
|
||||
add(hasTheWord);
|
||||
add(doesNotHaveTheWordLabel);
|
||||
add(doesNotHaveTheWord);
|
||||
add(hasAttachment);
|
||||
add(shouldMarkAsRead);
|
||||
add(shouldArchive);
|
||||
add(labelLabel);
|
||||
add(label);
|
||||
add(submit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/* Copyright (c) 2008 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package sample.appsforyourdomain.gmailsettings.gui;
|
||||
|
||||
import sample.appsforyourdomain.gmailsettings.Constants;
|
||||
import sample.appsforyourdomain.gmailsettings.Defaults;
|
||||
import com.google.gdata.util.ServiceException;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
/**
|
||||
* Tab containing the forwarding information.
|
||||
*/
|
||||
public class TabForwarding extends Tab {
|
||||
protected SpringLayout layout;
|
||||
protected JCheckBox enable;
|
||||
protected JLabel forwardToLabel;
|
||||
protected JTextField forwardTo;
|
||||
protected JLabel actionLabel;
|
||||
protected JComboBox action;
|
||||
protected JButton submit;
|
||||
|
||||
/**
|
||||
* Setup all the components on the tab.
|
||||
*/
|
||||
public TabForwarding() {
|
||||
super("Forwarding", "");
|
||||
layout = new SpringLayout();
|
||||
setLayout(layout);
|
||||
|
||||
enable = new JCheckBox("Enable:", Defaults.FORWARDING_ENABLE);
|
||||
|
||||
forwardToLabel = new JLabel("Forward To: ");
|
||||
forwardTo = new JTextField(Defaults.FORWARDING_FORWARD_TO, 25);
|
||||
|
||||
actionLabel = new JLabel("Action: ");
|
||||
action = new JComboBox(Constants.FORWARDING_ACTION);
|
||||
action.setSelectedItem(Defaults.FORWARDING_ACTION);
|
||||
|
||||
submit = new JButton("Submit");
|
||||
submit.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (GmailSettingsClient.settings == null) {
|
||||
JOptionPane.showMessageDialog(null, GmailSettingsClient.ERROR_AUTHENTICATION_REQUIRED,
|
||||
GmailSettingsClient.APP_TITLE, JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
GmailSettingsClient.settings.changeForwarding(GmailSettingsClient.users.
|
||||
getSelectedUsers(), enable.isSelected(), forwardTo.getText(),
|
||||
action.getSelectedItem().toString());
|
||||
} catch (IllegalArgumentException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (ServiceException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (MalformedURLException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (IOException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, enable, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, enable, 5, SpringLayout.NORTH, this);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, forwardToLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, forwardToLabel, 5, SpringLayout.SOUTH, enable);
|
||||
layout.putConstraint(SpringLayout.WEST, forwardTo, 5, SpringLayout.EAST, forwardToLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, forwardTo, 5, SpringLayout.SOUTH, enable);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, actionLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, actionLabel, 5, SpringLayout.SOUTH, forwardTo);
|
||||
layout.putConstraint(SpringLayout.WEST, action, 5, SpringLayout.EAST, actionLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, action, 5, SpringLayout.SOUTH, forwardTo);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, submit, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, submit, 15, SpringLayout.SOUTH, action);
|
||||
|
||||
add(enable);
|
||||
add(forwardToLabel);
|
||||
add(forwardTo);
|
||||
add(actionLabel);
|
||||
add(action);
|
||||
add(submit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
/* Copyright (c) 2008 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package sample.appsforyourdomain.gmailsettings.gui;
|
||||
|
||||
import sample.appsforyourdomain.gmailsettings.Constants;
|
||||
import sample.appsforyourdomain.gmailsettings.Defaults;
|
||||
import com.google.gdata.util.ServiceException;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
/**
|
||||
* Tab containing all the general information.
|
||||
*/
|
||||
public class TabGeneral extends Tab {
|
||||
protected SpringLayout layout;
|
||||
protected JLabel pageSizeLabel;
|
||||
protected JComboBox pageSize;
|
||||
protected JCheckBox enableShortcuts;
|
||||
protected JCheckBox enableArrows;
|
||||
protected JCheckBox enableSnippets;
|
||||
protected JCheckBox enableUnicode;
|
||||
protected JButton submit;
|
||||
|
||||
|
||||
/**
|
||||
* Setup all the components on the tab.
|
||||
*/
|
||||
public TabGeneral() {
|
||||
super("General", "");
|
||||
layout = new SpringLayout();
|
||||
setLayout(layout);
|
||||
|
||||
pageSizeLabel = new JLabel("Page size: ");
|
||||
pageSize = new JComboBox(Constants.GENERAL_ALLOWED_PAGE_SIZES);
|
||||
|
||||
enableShortcuts = new JCheckBox("Enable shortcuts:", Defaults.GENERAL_ENABLE_SHORTCUTS);
|
||||
|
||||
enableArrows = new JCheckBox("Enable arrows:", Defaults.GENERAL_ENABLE_ARROWS);
|
||||
|
||||
enableSnippets = new JCheckBox("Enable snippets:", Defaults.GENERAL_ENABLE_SNIPPETS);
|
||||
|
||||
enableUnicode = new JCheckBox("Enable unicode:", Defaults.GENERAL_ENABLE_UNICODE);
|
||||
|
||||
submit = new JButton("Submit");
|
||||
submit.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (GmailSettingsClient.settings == null) {
|
||||
JOptionPane.showMessageDialog(null, GmailSettingsClient.ERROR_AUTHENTICATION_REQUIRED,
|
||||
GmailSettingsClient.APP_TITLE, JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
GmailSettingsClient.settings.changeGeneral(GmailSettingsClient.users.
|
||||
getSelectedUsers(), pageSize.getSelectedItem().toString(),
|
||||
enableShortcuts.isSelected(), enableArrows.isSelected(),
|
||||
enableSnippets.isSelected(),
|
||||
enableUnicode.isSelected());
|
||||
} catch (IllegalArgumentException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (ServiceException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (MalformedURLException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (IOException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, pageSizeLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, pageSizeLabel, 5, SpringLayout.NORTH, this);
|
||||
layout.putConstraint(SpringLayout.WEST, pageSize, 5, SpringLayout.EAST, pageSizeLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, pageSize, 5, SpringLayout.NORTH, this);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, enableShortcuts, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, enableShortcuts, 5, SpringLayout.SOUTH, pageSize);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, enableArrows, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, enableArrows, 5, SpringLayout.SOUTH, enableShortcuts);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, enableSnippets, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, enableSnippets, 5, SpringLayout.SOUTH, enableArrows);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, enableUnicode, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, enableUnicode, 5, SpringLayout.SOUTH, enableSnippets);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, submit, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, submit, 15, SpringLayout.SOUTH, enableUnicode);
|
||||
|
||||
add(pageSizeLabel);
|
||||
add(pageSize);
|
||||
add(enableShortcuts);
|
||||
add(enableArrows);
|
||||
add(enableSnippets);
|
||||
add(enableUnicode);
|
||||
add(submit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/* Copyright (c) 2008 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package sample.appsforyourdomain.gmailsettings.gui;
|
||||
|
||||
import sample.appsforyourdomain.gmailsettings.Defaults;
|
||||
import com.google.gdata.util.ServiceException;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
/**
|
||||
* Tab containing all the IMAP information.
|
||||
*/
|
||||
public class TabImap extends Tab {
|
||||
protected SpringLayout layout;
|
||||
protected JCheckBox imapEnabled;
|
||||
protected JButton submit;
|
||||
|
||||
/**
|
||||
* Setup all the components on the tab.
|
||||
*/
|
||||
public TabImap() {
|
||||
super("Imap", "");
|
||||
layout = new SpringLayout();
|
||||
setLayout(layout);
|
||||
|
||||
imapEnabled = new JCheckBox("Enable IMAP:", Defaults.IMAP_ENABLE);
|
||||
|
||||
submit = new JButton("Submit");
|
||||
submit.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (GmailSettingsClient.settings == null) {
|
||||
JOptionPane.showMessageDialog(null, GmailSettingsClient.ERROR_AUTHENTICATION_REQUIRED,
|
||||
GmailSettingsClient.APP_TITLE, JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
GmailSettingsClient.settings.changeImap(GmailSettingsClient.users.
|
||||
getSelectedUsers(), imapEnabled.isSelected());
|
||||
} catch (IllegalArgumentException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (ServiceException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (MalformedURLException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (IOException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, imapEnabled, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, imapEnabled, 5, SpringLayout.NORTH, this);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, submit, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, submit, 15, SpringLayout.SOUTH, imapEnabled);
|
||||
|
||||
add(imapEnabled);
|
||||
add(submit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/* Copyright (c) 2008 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package sample.appsforyourdomain.gmailsettings.gui;
|
||||
|
||||
import sample.appsforyourdomain.gmailsettings.Defaults;
|
||||
import com.google.gdata.util.ServiceException;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
/**
|
||||
* Tab containing all the label information.
|
||||
*/
|
||||
public class TabLabel extends Tab {
|
||||
protected SpringLayout layout;
|
||||
protected JLabel labelLabel;
|
||||
protected JTextField label;
|
||||
protected JButton submit;
|
||||
|
||||
/**
|
||||
* Setup all the components on the tab.
|
||||
*/
|
||||
public TabLabel() {
|
||||
super("Label", "");
|
||||
layout = new SpringLayout();
|
||||
setLayout(layout);
|
||||
|
||||
labelLabel = new JLabel("Label: ");
|
||||
label = new JTextField(Defaults.LABEL, 25);
|
||||
|
||||
submit = new JButton("Submit");
|
||||
submit.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (GmailSettingsClient.settings == null) {
|
||||
JOptionPane.showMessageDialog(null,
|
||||
GmailSettingsClient.ERROR_AUTHENTICATION_REQUIRED,
|
||||
GmailSettingsClient.APP_TITLE, JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
GmailSettingsClient.settings.createLabel(GmailSettingsClient.users.
|
||||
getSelectedUsers(), label.getText());
|
||||
} catch (IllegalArgumentException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (ServiceException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (MalformedURLException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (IOException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, labelLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, labelLabel, 5, SpringLayout.NORTH, this);
|
||||
layout.putConstraint(SpringLayout.WEST, label, 5, SpringLayout.EAST, labelLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, label, 5, SpringLayout.NORTH, this);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, submit, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, submit, 15, SpringLayout.SOUTH, label);
|
||||
|
||||
add(labelLabel);
|
||||
add(label);
|
||||
add(submit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/* Copyright (c) 2008 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package sample.appsforyourdomain.gmailsettings.gui;
|
||||
|
||||
import sample.appsforyourdomain.gmailsettings.Constants;
|
||||
import sample.appsforyourdomain.gmailsettings.Defaults;
|
||||
import com.google.gdata.util.ServiceException;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
/**
|
||||
* Tab containing all the language information.
|
||||
*/
|
||||
public class TabLanguage extends Tab {
|
||||
protected SpringLayout layout;
|
||||
protected JLabel languagesLabel;
|
||||
protected JComboBox languages;
|
||||
protected JButton submit;
|
||||
|
||||
/**
|
||||
* Setup all the components on the tab.
|
||||
*/
|
||||
public TabLanguage() {
|
||||
super("Language", "");
|
||||
layout = new SpringLayout();
|
||||
setLayout(layout);
|
||||
|
||||
languagesLabel = new JLabel("Languages: ");
|
||||
languages = new JComboBox(Constants.LANGUAGE_VALID_KEY);
|
||||
languages.setSelectedItem(Defaults.LANGUAGE);
|
||||
|
||||
submit = new JButton("Submit");
|
||||
submit.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (GmailSettingsClient.settings == null) {
|
||||
JOptionPane.showMessageDialog(null, GmailSettingsClient.ERROR_AUTHENTICATION_REQUIRED,
|
||||
GmailSettingsClient.APP_TITLE, JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
GmailSettingsClient.settings.changeLanguage(GmailSettingsClient.users.
|
||||
getSelectedUsers(), languages.getSelectedItem().toString());
|
||||
} catch (IllegalArgumentException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (ServiceException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (MalformedURLException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (IOException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, languagesLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, languagesLabel, 5, SpringLayout.NORTH, this);
|
||||
layout.putConstraint(SpringLayout.WEST, languages, 5, SpringLayout.EAST, languagesLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, languages, 5, SpringLayout.NORTH, this);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, submit, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, submit, 15, SpringLayout.SOUTH, languages);
|
||||
|
||||
add(languagesLabel);
|
||||
add(languages);
|
||||
add(submit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/* Copyright (c) 2008 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package sample.appsforyourdomain.gmailsettings.gui;
|
||||
|
||||
import sample.appsforyourdomain.gmailsettings.Constants;
|
||||
import sample.appsforyourdomain.gmailsettings.Defaults;
|
||||
import com.google.gdata.util.ServiceException;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
/**
|
||||
* Tab containing all the POP information.
|
||||
*/
|
||||
public class TabPop extends Tab {
|
||||
protected SpringLayout layout;
|
||||
protected JCheckBox enable;
|
||||
protected JLabel enableForLabel;
|
||||
protected JComboBox enableFor;
|
||||
protected JLabel actionLabel;
|
||||
protected JComboBox action;
|
||||
protected JButton submit;
|
||||
|
||||
/**
|
||||
* Setup all the components on the tab.
|
||||
*/
|
||||
public TabPop() {
|
||||
super("Pop","");
|
||||
layout = new SpringLayout();
|
||||
setLayout(layout);
|
||||
|
||||
enable = new JCheckBox("Enable:",Defaults.POP_ENABLE);
|
||||
|
||||
enableForLabel = new JLabel("Enable for: ");
|
||||
enableFor = new JComboBox(Constants.POP_ENABLE_FOR);
|
||||
enableFor.setSelectedItem(Defaults.POP_ENABLE_FOR);
|
||||
|
||||
actionLabel = new JLabel("Action: ");
|
||||
action = new JComboBox(Constants.POP_ACTION);
|
||||
action.setSelectedItem(Defaults.POP_ACTION);
|
||||
|
||||
submit = new JButton("Submit");
|
||||
submit.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (GmailSettingsClient.settings == null) {
|
||||
JOptionPane.showMessageDialog(null, GmailSettingsClient.ERROR_AUTHENTICATION_REQUIRED,
|
||||
GmailSettingsClient.APP_TITLE, JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
GmailSettingsClient.settings.changePop(GmailSettingsClient.users.
|
||||
getSelectedUsers(), enable.isSelected(), enableFor.getSelectedItem().toString(),
|
||||
action.getSelectedItem().toString());
|
||||
} catch (IllegalArgumentException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (ServiceException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (MalformedURLException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (IOException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, enable, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, enable, 5, SpringLayout.NORTH, this);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, enableForLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, enableForLabel, 5, SpringLayout.SOUTH, enable);
|
||||
layout.putConstraint(SpringLayout.WEST, enableFor, 5, SpringLayout.EAST, enableForLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, enableFor, 5, SpringLayout.SOUTH, enable);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, actionLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, actionLabel, 5, SpringLayout.SOUTH, enableFor);
|
||||
layout.putConstraint(SpringLayout.WEST, action, 5, SpringLayout.EAST, actionLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, action, 5, SpringLayout.SOUTH, enableFor);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, submit, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, submit, 15, SpringLayout.SOUTH, action);
|
||||
|
||||
add(enable);
|
||||
add(enableForLabel);
|
||||
add(enableFor);
|
||||
add(actionLabel);
|
||||
add(action);
|
||||
add(submit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/* Copyright (c) 2008 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package sample.appsforyourdomain.gmailsettings.gui;
|
||||
|
||||
import sample.appsforyourdomain.gmailsettings.Defaults;
|
||||
import com.google.gdata.util.ServiceException;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
/**
|
||||
* Tab containing all the send as information.
|
||||
*/
|
||||
public class TabSendAs extends Tab {
|
||||
protected SpringLayout layout;
|
||||
protected JLabel nameLabel;
|
||||
protected JTextField nameField;
|
||||
protected JLabel addressLabel;
|
||||
protected JTextField address;
|
||||
protected JLabel replyToLabel;
|
||||
protected JTextField replyTo;
|
||||
protected JCheckBox makeDefault;
|
||||
protected JButton submit;
|
||||
|
||||
/**
|
||||
* Setup all the components on the tab.
|
||||
*/
|
||||
public TabSendAs() {
|
||||
super("Send As", "");
|
||||
layout = new SpringLayout();
|
||||
setLayout(layout);
|
||||
|
||||
nameLabel = new JLabel("Name: ");
|
||||
nameField = new JTextField(Defaults.SEND_AS_NAME, 25);
|
||||
|
||||
addressLabel = new JLabel("Address: ");
|
||||
address = new JTextField(Defaults.SEND_AS_ADDRESS, 25);
|
||||
|
||||
replyToLabel = new JLabel("Send As: ");
|
||||
replyTo = new JTextField(Defaults.SEND_AS_REPLY_TO, 25);
|
||||
|
||||
makeDefault = new JCheckBox("Make Default:", Defaults.SEND_AS_MAKE_DEFAULT);
|
||||
|
||||
submit = new JButton("Set Send As");
|
||||
submit.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (GmailSettingsClient.settings == null) {
|
||||
JOptionPane.showMessageDialog(null, GmailSettingsClient.ERROR_AUTHENTICATION_REQUIRED,
|
||||
GmailSettingsClient.APP_TITLE, JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
GmailSettingsClient.settings.createSendAs(GmailSettingsClient.users.
|
||||
getSelectedUsers(), nameField.getText(), address.getText(), replyTo.getText(),
|
||||
makeDefault.isSelected());
|
||||
} catch (IllegalArgumentException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (ServiceException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (MalformedURLException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (IOException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, nameLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, nameLabel, 5, SpringLayout.NORTH, this);
|
||||
layout.putConstraint(SpringLayout.WEST, nameField, 5, SpringLayout.EAST, nameLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, nameField, 5, SpringLayout.NORTH, this);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, addressLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, addressLabel, 5, SpringLayout.SOUTH, nameField);
|
||||
layout.putConstraint(SpringLayout.WEST, address, 5, SpringLayout.EAST, addressLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, address, 5, SpringLayout.SOUTH, nameField);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, replyToLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, replyToLabel, 5, SpringLayout.SOUTH, address);
|
||||
layout.putConstraint(SpringLayout.WEST, replyTo, 5, SpringLayout.EAST, replyToLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, replyTo, 5, SpringLayout.SOUTH, address);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, makeDefault, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, makeDefault, 5, SpringLayout.SOUTH, replyTo);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, submit, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, submit, 15, SpringLayout.SOUTH, makeDefault);
|
||||
|
||||
add(nameLabel);
|
||||
add(nameField);
|
||||
add(addressLabel);
|
||||
add(address);
|
||||
add(replyToLabel);
|
||||
add(replyTo);
|
||||
add(makeDefault);
|
||||
add(submit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/* Copyright (c) 2008 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package sample.appsforyourdomain.gmailsettings.gui;
|
||||
|
||||
import sample.appsforyourdomain.gmailsettings.Defaults;
|
||||
import com.google.gdata.util.ServiceException;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
/**
|
||||
* Tab containing all the signature information.
|
||||
*/
|
||||
public class TabSignature extends Tab {
|
||||
protected SpringLayout layout;
|
||||
protected JLabel signatureLabel;
|
||||
protected JTextArea signature;
|
||||
protected JScrollPane signaturePane;
|
||||
protected JButton submit;
|
||||
|
||||
/**
|
||||
* Setup all the components on the tab.
|
||||
*/
|
||||
public TabSignature() {
|
||||
super("Signature", "Change a users's signature.");
|
||||
layout = new SpringLayout();
|
||||
setLayout(layout);
|
||||
|
||||
signatureLabel = new JLabel("Signature: ");
|
||||
signature = new JTextArea(Defaults.SIGNATURE, 4, 25);
|
||||
signaturePane = new JScrollPane(signature);
|
||||
|
||||
submit = new JButton("Set Signature");
|
||||
submit.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (GmailSettingsClient.settings == null) {
|
||||
JOptionPane.showMessageDialog(null, GmailSettingsClient.ERROR_AUTHENTICATION_REQUIRED,
|
||||
GmailSettingsClient.APP_TITLE, JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
GmailSettingsClient.settings.changeSignature(GmailSettingsClient.users.
|
||||
getSelectedUsers(), signature.getText());
|
||||
} catch (IllegalArgumentException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (ServiceException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (MalformedURLException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (IOException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, signatureLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, signatureLabel, 5, SpringLayout.NORTH, this);
|
||||
layout.putConstraint(SpringLayout.WEST, signaturePane, 5, SpringLayout.EAST, signatureLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, signaturePane, 5, SpringLayout.NORTH, this);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, submit, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, submit, 15, SpringLayout.SOUTH, signaturePane);
|
||||
|
||||
add(signatureLabel);
|
||||
add(signaturePane);
|
||||
add(submit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/* Copyright (c) 2008 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package sample.appsforyourdomain.gmailsettings.gui;
|
||||
|
||||
import sample.appsforyourdomain.gmailsettings.Defaults;
|
||||
import com.google.gdata.util.ServiceException;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
/**
|
||||
* Tab containing all the vacation information.
|
||||
*/
|
||||
public class TabVacation extends Tab {
|
||||
protected SpringLayout layout;
|
||||
protected JCheckBox enable;
|
||||
protected JLabel subjectLabel;
|
||||
protected JTextField subject;
|
||||
protected JLabel messageLabel;
|
||||
protected JTextField message;
|
||||
protected JLabel contactsOnlyLabel;
|
||||
protected JCheckBox contactsOnly;
|
||||
protected JButton submit;
|
||||
|
||||
/**
|
||||
* Setup all the components on the tab.
|
||||
*/
|
||||
public TabVacation() {
|
||||
super("Vacation Responder", "");
|
||||
layout = new SpringLayout();
|
||||
setLayout(layout);
|
||||
|
||||
enable = new JCheckBox("Enable:", Defaults.VACATION_ENABLE);
|
||||
|
||||
subjectLabel = new JLabel("Subject: ");
|
||||
subject = new JTextField(Defaults.VACATION_SUBJECT, 25);
|
||||
|
||||
messageLabel = new JLabel("Message: ");
|
||||
message = new JTextField(Defaults.VACATION_MESSAGE, 25);
|
||||
|
||||
contactsOnly = new JCheckBox("Contacts only:", Defaults.VACATION_CONTACTS_ONLY);
|
||||
|
||||
submit = new JButton("Submit");
|
||||
submit.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (GmailSettingsClient.settings == null) {
|
||||
JOptionPane.showMessageDialog(null, GmailSettingsClient.ERROR_AUTHENTICATION_REQUIRED,
|
||||
GmailSettingsClient.APP_TITLE, JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
GmailSettingsClient.settings.changeVacation(GmailSettingsClient.users.
|
||||
getSelectedUsers(), enable.isSelected(), subject.getText(), message.getText(),
|
||||
contactsOnly.isSelected());
|
||||
} catch (IllegalArgumentException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (ServiceException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (MalformedURLException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (IOException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, enable, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, enable, 5, SpringLayout.NORTH, this);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, subjectLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, subjectLabel, 5, SpringLayout.SOUTH, enable);
|
||||
layout.putConstraint(SpringLayout.WEST, subject, 5, SpringLayout.EAST, subjectLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, subject, 5, SpringLayout.SOUTH, enable);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, messageLabel, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, messageLabel, 5, SpringLayout.SOUTH, subject);
|
||||
layout.putConstraint(SpringLayout.WEST, message, 5, SpringLayout.EAST, messageLabel);
|
||||
layout.putConstraint(SpringLayout.NORTH, message, 5, SpringLayout.SOUTH, subject);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, contactsOnly, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, contactsOnly, 5, SpringLayout.SOUTH, message);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, submit, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, submit, 15, SpringLayout.SOUTH, contactsOnly);
|
||||
|
||||
add(enable);
|
||||
add(subjectLabel);
|
||||
add(subject);
|
||||
add(messageLabel);
|
||||
add(message);
|
||||
add(contactsOnly);
|
||||
add(submit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/* Copyright (c) 2008 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package sample.appsforyourdomain.gmailsettings.gui;
|
||||
|
||||
import sample.appsforyourdomain.gmailsettings.Defaults;
|
||||
import com.google.gdata.util.ServiceException;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
/**
|
||||
* Tab containing all the web clip information.
|
||||
*/
|
||||
public class TabWebClip extends Tab {
|
||||
protected SpringLayout layout;
|
||||
protected JCheckBox webClipEnabled;
|
||||
protected JButton submit;
|
||||
|
||||
public TabWebClip() {
|
||||
super("WebClip", "");
|
||||
layout = new SpringLayout();
|
||||
setLayout(layout);
|
||||
|
||||
webClipEnabled = new JCheckBox("Enable Web clip:", Defaults.WEBCLIP_ENABLE);
|
||||
submit = new JButton("Submit");
|
||||
submit.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (GmailSettingsClient.settings == null) {
|
||||
JOptionPane.showMessageDialog(null, GmailSettingsClient.ERROR_AUTHENTICATION_REQUIRED,
|
||||
GmailSettingsClient.APP_TITLE, JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
GmailSettingsClient.settings.changeWebClip(GmailSettingsClient.users.getSelectedUsers(),
|
||||
webClipEnabled.isSelected());
|
||||
} catch (IllegalArgumentException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (ServiceException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (MalformedURLException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (IOException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, webClipEnabled, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, webClipEnabled, 5, SpringLayout.NORTH, this);
|
||||
|
||||
layout.putConstraint(SpringLayout.WEST, submit, 5, SpringLayout.WEST, this);
|
||||
layout.putConstraint(SpringLayout.NORTH, submit, 15, SpringLayout.SOUTH, webClipEnabled);
|
||||
|
||||
add(webClipEnabled);
|
||||
add(submit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/* Copyright (c) 2008 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package sample.appsforyourdomain.gmailsettings.gui;
|
||||
|
||||
import javax.swing.JTabbedPane;
|
||||
|
||||
/**
|
||||
* Handles adding all the tabs needed.
|
||||
*/
|
||||
public class TabbedPane extends JTabbedPane {
|
||||
|
||||
protected Tab authenticationTab;
|
||||
protected Tab signatureTab;
|
||||
protected Tab labelTab;
|
||||
protected Tab filtersTab;
|
||||
protected Tab sendasTab;
|
||||
protected Tab popTab;
|
||||
protected Tab forwardingTab;
|
||||
protected Tab imapTab;
|
||||
protected Tab vacationTab;
|
||||
protected Tab languageTab;
|
||||
protected Tab generalTab;
|
||||
protected Tab webClipTab;
|
||||
|
||||
/**
|
||||
* Create an instance of all tabs required, and add them to the pane.
|
||||
*/
|
||||
public TabbedPane() {
|
||||
super(JTabbedPane.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);
|
||||
|
||||
authenticationTab = new TabAuthentication();
|
||||
signatureTab = new TabSignature();
|
||||
labelTab = new TabLabel();
|
||||
filtersTab = new TabFilter();
|
||||
sendasTab = new TabSendAs();
|
||||
popTab = new TabPop();
|
||||
forwardingTab = new TabForwarding();
|
||||
imapTab = new TabImap();
|
||||
vacationTab = new TabVacation();
|
||||
languageTab = new TabLanguage();
|
||||
generalTab = new TabGeneral();
|
||||
webClipTab = new TabWebClip();
|
||||
|
||||
addTab(authenticationTab);
|
||||
addTab(signatureTab);
|
||||
addTab(labelTab);
|
||||
addTab(filtersTab);
|
||||
addTab(sendasTab);
|
||||
addTab(popTab);
|
||||
addTab(forwardingTab);
|
||||
addTab(imapTab);
|
||||
addTab(vacationTab);
|
||||
addTab(languageTab);
|
||||
addTab(generalTab);
|
||||
addTab(webClipTab);
|
||||
|
||||
this.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for adding tabs to the pane.
|
||||
*
|
||||
* @param tab The tab to be added to the JTabbedPane
|
||||
*/
|
||||
protected void addTab(Tab tab) {
|
||||
super.addTab(tab.getName(), null, tab, tab.getTooltip());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
/* Copyright (c) 2008 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package sample.appsforyourdomain.gmailsettings.gui;
|
||||
|
||||
import com.google.gdata.client.appsforyourdomain.AppsForYourDomainQuery;
|
||||
import com.google.gdata.client.appsforyourdomain.UserService;
|
||||
import com.google.gdata.data.Link;
|
||||
import com.google.gdata.data.appsforyourdomain.provisioning.UserEntry;
|
||||
import com.google.gdata.data.appsforyourdomain.provisioning.UserFeed;
|
||||
import com.google.gdata.util.ServiceException;
|
||||
|
||||
import java.awt.GridLayout;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.DefaultListModel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
/**
|
||||
* Panel that uses the provisioning API to display all the users from a domain.
|
||||
*/
|
||||
public class UsersPanel extends JPanel {
|
||||
|
||||
protected JList users;
|
||||
protected DefaultListModel usersListModel;
|
||||
protected JScrollPane usersPane;
|
||||
|
||||
/**
|
||||
* Sets up the panel.
|
||||
*/
|
||||
public UsersPanel() {
|
||||
usersListModel = new DefaultListModel();
|
||||
users = new JList();
|
||||
users.setModel(usersListModel);
|
||||
usersPane = new JScrollPane(users);
|
||||
setLayout(new GridLayout(1, 1));
|
||||
add(usersPane);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns a list of all the users that were selected in the panel.
|
||||
*/
|
||||
public List<String> getSelectedUsers() {
|
||||
Object[] tmp = users.getSelectedValues();
|
||||
List<String> susers = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < tmp.length; i++) {
|
||||
susers.add(tmp[i].toString());
|
||||
}
|
||||
|
||||
return susers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the panel to display the users.
|
||||
*
|
||||
* @param domain The domain in which settings will be modified.
|
||||
* @param username The user name (not email) of a domain administrator.
|
||||
* @param password The user's password on the domain.
|
||||
*/
|
||||
public void refresh(String domain, String username, String password) {
|
||||
try {
|
||||
UserFeed usersFeed = getUsers(domain, username, password);
|
||||
usersListModel.clear();
|
||||
Iterator<UserEntry> userIterator = usersFeed.getEntries().iterator();
|
||||
while (userIterator.hasNext()) {
|
||||
usersListModel.addElement(userIterator.next().getLogin().getUserName());
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (IOException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (ServiceException e) {
|
||||
JOptionPane.showMessageDialog(null, e, GmailSettingsClient.APP_TITLE,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the first 100 users from the domain.
|
||||
*
|
||||
* @param domain The domain in which settings will be modified.
|
||||
* @param username The user name (not email) of a domain administrator.
|
||||
* @param password The user's password on the domain.
|
||||
* @return UserFeed containing all the user accounts in the domain.
|
||||
* @throws MalformedURLException if the batch feed URL cannot be constructed.
|
||||
* @throws IOException if an error occurs while communicating with the GData
|
||||
* service.
|
||||
* @throws ServiceException if the insert request failed due to system error.
|
||||
*/
|
||||
protected UserFeed getUsers(String domain, String username, String password)
|
||||
throws MalformedURLException, IOException, ServiceException {
|
||||
String domainUrlBase = null;
|
||||
UserFeed allUsers = null;
|
||||
|
||||
UserService userService = new UserService(GmailSettingsClient.APP_TITLE);
|
||||
userService.setUserCredentials(username + "@" + domain, password);
|
||||
|
||||
domainUrlBase = "https://www.google.com/a/feeds/" + domain + "/";
|
||||
URL retrieveUrl = new URL(domainUrlBase + "user/2.0/");
|
||||
AppsForYourDomainQuery query = new AppsForYourDomainQuery(retrieveUrl);
|
||||
query.setStartUsername(null);
|
||||
allUsers = new UserFeed();
|
||||
UserFeed currentPage;
|
||||
Link nextLink;
|
||||
do {
|
||||
currentPage = userService.query(query, UserFeed.class);
|
||||
allUsers.getEntries().addAll(currentPage.getEntries());
|
||||
nextLink = currentPage.getLink(Link.Rel.NEXT, Link.Type.ATOM);
|
||||
if (nextLink != null) {
|
||||
retrieveUrl = new URL(nextLink.getHref());
|
||||
}
|
||||
} while (nextLink != null);
|
||||
|
||||
return allUsers;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user