Converted build to NetBeans-provided Ant, so adding
[funambol-groupdav-connector.git] / src / java / net / bionicmessage / funambol / admin / taskSourceAdminPanel.java
blobddd058f0f71943f387dd692660641869f70293ff
1 /*
2 * taskSourceAdminPanel.java
4 * Created on December 13, 2006, 9:26 PM
5 */
7 package net.bionicmessage.funambol.admin;
9 import com.funambol.admin.ui.SourceManagementPanel;
10 import com.funambol.framework.engine.source.ContentType;
11 import com.funambol.framework.engine.source.SyncSourceInfo;
12 import java.awt.event.ActionEvent;
13 import java.util.Properties;
14 import net.bionicmessage.funambol.BVersion;
15 import net.bionicmessage.funambol.source.taskGroupDAVConnector;
17 /**
19 * @author matt
21 public class taskSourceAdminPanel extends SourceManagementPanel {
22 taskGroupDAVConnector source = null;
23 Properties connectorProps = null;
24 /** Creates new form taskSourceAdminPanel */
25 public taskSourceAdminPanel() {
26 initComponents();
29 /** This method is called from within the constructor to
30 * initialize the form.
31 * WARNING: Do NOT modify this code. The content of this method is
32 * always regenerated by the Form Editor.
34 // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
35 private void initComponents() {
37 jLabel1 = new javax.swing.JLabel();
38 sourceLabel = new javax.swing.JLabel();
39 sourceField = new javax.swing.JTextField();
40 jLabel2 = new javax.swing.JLabel();
41 serverLabel = new javax.swing.JLabel();
42 serverField = new javax.swing.JTextField();
43 dirLabel = new javax.swing.JLabel();
44 dirField = new javax.swing.JTextField();
45 jLabel3 = new javax.swing.JLabel();
46 storeLabel = new javax.swing.JLabel();
47 storeField = new javax.swing.JTextField();
48 jLabel4 = new javax.swing.JLabel();
49 jLabel5 = new javax.swing.JLabel();
50 verHead = new javax.swing.JLabel();
51 versionLabel = new javax.swing.JLabel();
52 saveButton = new javax.swing.JButton();
53 typeField = new javax.swing.JTextField();
55 setLayout(null);
57 jLabel1.setFont(new java.awt.Font("Dialog", 0, 24));
58 jLabel1.setText("Task Source Admin Panel");
59 add(jLabel1);
60 jLabel1.setBounds(0, 0, 293, 29);
62 sourceLabel.setText("SyncML Source");
63 add(sourceLabel);
64 sourceLabel.setBounds(10, 50, 91, 15);
66 sourceField.setText("jTextField1");
67 add(sourceField);
68 sourceField.setBounds(190, 50, 250, 19);
70 jLabel2.setText("Data format");
71 add(jLabel2);
72 jLabel2.setBounds(10, 80, 75, 15);
74 serverLabel.setText("GroupDAV Server");
75 add(serverLabel);
76 serverLabel.setBounds(10, 110, 107, 15);
78 serverField.setText("http://server:port/");
79 add(serverField);
80 serverField.setBounds(190, 110, 250, 19);
82 dirLabel.setText("GroupDAV Source");
83 add(dirLabel);
84 dirLabel.setBounds(10, 140, 110, 15);
86 dirField.setText("/groupdav/Tasks/");
87 add(dirField);
88 dirField.setBounds(190, 140, 250, 19);
90 jLabel3.setFont(new java.awt.Font("Dialog", 0, 12));
91 jLabel3.setText("Use %USER% for multi user OGo etc.");
92 add(jLabel3);
93 jLabel3.setBounds(190, 170, 240, 15);
95 storeLabel.setText("Store location");
96 add(storeLabel);
97 storeLabel.setBounds(10, 190, 100, 15);
99 storeField.setText("/opt/Funambol/stores");
100 add(storeField);
101 storeField.setBounds(190, 190, 250, 19);
103 jLabel4.setFont(new java.awt.Font("Dialog", 0, 12));
104 jLabel4.setText("On Windows, double backslash paths");
105 add(jLabel4);
106 jLabel4.setBounds(190, 220, 250, 15);
108 jLabel5.setFont(new java.awt.Font("Dialog", 0, 12));
109 jLabel5.setText("i.e C:\\\\funambol\\\\stores");
110 add(jLabel5);
111 jLabel5.setBounds(190, 240, 240, 15);
113 verHead.setText("Version");
114 add(verHead);
115 verHead.setBounds(10, 270, 60, 15);
117 versionLabel.setText("jLabel6");
118 add(versionLabel);
119 versionLabel.setBounds(70, 270, 240, 15);
121 saveButton.setText("Save settings");
122 saveButton.addActionListener(new java.awt.event.ActionListener() {
123 public void actionPerformed(java.awt.event.ActionEvent evt) {
124 saveButtonActionPerformed(evt);
127 add(saveButton);
128 saveButton.setBounds(320, 270, 120, 25);
130 typeField.setText("text/x-vcalendar");
131 add(typeField);
132 typeField.setBounds(190, 80, 250, 19);
133 }// </editor-fold>//GEN-END:initComponents
135 private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
136 source.setSourceURI(sourceField.getText());
137 source.setName(sourceField.getText());
138 source.setType(typeField.getText());
139 connectorProps.setProperty("connector.server",serverField.getText());
140 connectorProps.setProperty("connector.store",storeField.getText());
141 connectorProps.setProperty("connector.folder",dirField.getText());
142 source.setProperties(connectorProps);
143 ContentType[] ctypes = {new ContentType(typeField.getText(),"1.0")};
144 SyncSourceInfo sinfo = new SyncSourceInfo(ctypes,0);
145 source.setInfo(sinfo);
146 if (getState() == STATE_INSERT) {
147 this.actionPerformed(new ActionEvent(this, ACTION_EVENT_INSERT, evt.getActionCommand()));
148 } else {
149 this.actionPerformed(new ActionEvent(this, ACTION_EVENT_UPDATE, evt.getActionCommand()));
151 }//GEN-LAST:event_saveButtonActionPerformed
153 public void updateForm() {
154 if (source == null) {
155 source = (taskGroupDAVConnector)this.getSyncSource();
157 sourceField.setText(source.getSourceURI());
158 connectorProps = source.getProperties();
159 if (connectorProps != null) {
160 serverField.setText(connectorProps.getProperty("connector.server"));
161 storeField.setText(connectorProps.getProperty("connector.store"));
162 dirField.setText(connectorProps.getProperty("connector.folder"));
163 String mode = connectorProps.getProperty("connector.mode");
164 } else {
165 connectorProps = new Properties();
167 versionLabel.setText(BVersion.version);
171 // Variables declaration - do not modify//GEN-BEGIN:variables
172 private javax.swing.JTextField dirField;
173 private javax.swing.JLabel dirLabel;
174 private javax.swing.JLabel jLabel1;
175 private javax.swing.JLabel jLabel2;
176 private javax.swing.JLabel jLabel3;
177 private javax.swing.JLabel jLabel4;
178 private javax.swing.JLabel jLabel5;
179 private javax.swing.JButton saveButton;
180 private javax.swing.JTextField serverField;
181 private javax.swing.JLabel serverLabel;
182 private javax.swing.JTextField sourceField;
183 private javax.swing.JLabel sourceLabel;
184 private javax.swing.JTextField storeField;
185 private javax.swing.JLabel storeLabel;
186 private javax.swing.JTextField typeField;
187 private javax.swing.JLabel verHead;
188 private javax.swing.JLabel versionLabel;
189 // End of variables declaration//GEN-END:variables