~ubuntu-branches/ubuntu/oneiric/tuxguitar/oneiric

« back to all changes in this revision

Viewing changes to TuxGuitar-browser-ftp/src/org/herac/tuxguitar/gui/tools/browser/ftp/TGBrowserFactoryImpl.java

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2008-06-19 00:30:30 UTC
  • mto: (5.1.2 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20080619003030-h719szrhsngou7c6
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.herac.tuxguitar.gui.tools.browser.ftp;
 
2
 
 
3
import org.eclipse.swt.SWT;
 
4
import org.eclipse.swt.events.SelectionAdapter;
 
5
import org.eclipse.swt.events.SelectionEvent;
 
6
import org.eclipse.swt.layout.GridData;
 
7
import org.eclipse.swt.layout.GridLayout;
 
8
import org.eclipse.swt.widgets.Button;
 
9
import org.eclipse.swt.widgets.Composite;
 
10
import org.eclipse.swt.widgets.Label;
 
11
import org.eclipse.swt.widgets.Shell;
 
12
import org.eclipse.swt.widgets.Text;
 
13
import org.herac.tuxguitar.gui.TuxGuitar;
 
14
import org.herac.tuxguitar.gui.tools.browser.base.TGBrowser;
 
15
import org.herac.tuxguitar.gui.tools.browser.base.TGBrowserData;
 
16
import org.herac.tuxguitar.gui.tools.browser.base.TGBrowserFactory;
 
17
import org.herac.tuxguitar.gui.util.DialogUtils;
 
18
 
 
19
public class TGBrowserFactoryImpl implements TGBrowserFactory{
 
20
        
 
21
        public TGBrowserFactoryImpl() {
 
22
                super();
 
23
        }
 
24
        
 
25
        public String getType(){
 
26
                return "ftp";
 
27
        }
 
28
        
 
29
        public String getName(){
 
30
                return "FTP";
 
31
        }
 
32
        
 
33
        public TGBrowser newTGBrowser(TGBrowserData data) {
 
34
                if(data instanceof TGBrowserDataImpl){
 
35
                        return new TGBrowserImpl((TGBrowserDataImpl)data);
 
36
                }
 
37
                return null;
 
38
        }
 
39
        
 
40
        public TGBrowserData parseData(String string) {
 
41
                return TGBrowserDataImpl.fromString(string);
 
42
        }
 
43
        
 
44
        public TGBrowserData dataDialog(Shell parent) {
 
45
                return new TGBrowserDataDialog().show(parent);
 
46
        }
 
47
        
 
48
}
 
49
class TGBrowserDataDialog{
 
50
        
 
51
        protected TGBrowserDataImpl data;
 
52
        
 
53
        public TGBrowserDataImpl show(Shell parent){
 
54
                final Shell dialog = DialogUtils.newDialog(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
 
55
                
 
56
                dialog.setLayout(new GridLayout());
 
57
                dialog.setText(TuxGuitar.getProperty("FTP Location"));
 
58
                
 
59
                //-------------LIBRARY DATA-----------------------------------------------
 
60
                Composite composite = new Composite(dialog, SWT.NONE);
 
61
                composite.setLayout(new GridLayout(2,false));
 
62
                composite.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
 
63
                
 
64
                GridData textData = new GridData(SWT.FILL,SWT.FILL,true,true);
 
65
                textData.minimumWidth = 300;
 
66
                
 
67
                //host
 
68
                Label hostLabel = new Label(composite, SWT.NULL);
 
69
                hostLabel.setText(TuxGuitar.getProperty("Host"));
 
70
                final Text hostText = new Text(composite,SWT.BORDER);
 
71
                hostText.setLayoutData(textData);
 
72
                
 
73
                //path
 
74
                Label pathLabel = new Label(composite, SWT.NULL);
 
75
                pathLabel.setText(TuxGuitar.getProperty("Path"));
 
76
                final Text pathText = new Text(composite,SWT.BORDER);
 
77
                pathText.setLayoutData(textData);
 
78
                
 
79
                //user
 
80
                Label userLabel = new Label(composite, SWT.NULL);
 
81
                userLabel.setText(TuxGuitar.getProperty("Login name"));
 
82
                final Text userText = new Text(composite,SWT.BORDER);
 
83
                userText.setLayoutData(textData);
 
84
                
 
85
                //password
 
86
                Label passwordLabel = new Label(composite, SWT.NULL);
 
87
                passwordLabel.setText(TuxGuitar.getProperty("Password"));
 
88
                final Text passwordText = new Text(composite,SWT.BORDER | SWT.PASSWORD);
 
89
                passwordText.setLayoutData(textData);
 
90
                
 
91
                //------------------BUTTONS--------------------------
 
92
                Composite buttons = new Composite(dialog, SWT.NONE);
 
93
                buttons.setLayout(new GridLayout(2,false));
 
94
                buttons.setLayoutData(new GridData(SWT.END,SWT.FILL,true,true));
 
95
                
 
96
                GridData data = new GridData(SWT.FILL,SWT.FILL,true,true);
 
97
                data.minimumWidth = 80;
 
98
                data.minimumHeight = 25;
 
99
                
 
100
                final Button buttonOk = new Button(buttons, SWT.PUSH);
 
101
                buttonOk.setText(TuxGuitar.getProperty("ok"));
 
102
                buttonOk.setLayoutData(data);
 
103
                buttonOk.addSelectionListener(new SelectionAdapter() {
 
104
                        public void widgetSelected(SelectionEvent arg0) {
 
105
                                String host = hostText.getText();
 
106
                                String path = pathText.getText();
 
107
                                String user = userText.getText();
 
108
                                String password = passwordText.getText();
 
109
                                if(host != null && host.length() > 0){
 
110
                                        TGBrowserDataDialog.this.data = new TGBrowserDataImpl(host,path,user,password);
 
111
                                }
 
112
                                dialog.dispose();
 
113
                        }
 
114
                });
 
115
                
 
116
                Button buttonCancel = new Button(buttons, SWT.PUSH);
 
117
                buttonCancel.setLayoutData(data);
 
118
                buttonCancel.setText(TuxGuitar.getProperty("cancel"));
 
119
                buttonCancel.addSelectionListener(new SelectionAdapter() {
 
120
                        public void widgetSelected(SelectionEvent arg0) {
 
121
                                dialog.dispose();
 
122
                        }
 
123
                });
 
124
                
 
125
                dialog.setDefaultButton( buttonOk );
 
126
                
 
127
                DialogUtils.openDialog(dialog,DialogUtils.OPEN_STYLE_CENTER | DialogUtils.OPEN_STYLE_PACK | DialogUtils.OPEN_STYLE_WAIT);
 
128
                
 
129
                return this.data;
 
130
        }
 
131
}
 
 
b'\\ No newline at end of file'