1
package org.herac.tuxguitar.gui.tools.browser.ftp;
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;
19
public class TGBrowserFactoryImpl implements TGBrowserFactory{
21
public TGBrowserFactoryImpl() {
25
public String getType(){
29
public String getName(){
33
public TGBrowser newTGBrowser(TGBrowserData data) {
34
if(data instanceof TGBrowserDataImpl){
35
return new TGBrowserImpl((TGBrowserDataImpl)data);
40
public TGBrowserData parseData(String string) {
41
return TGBrowserDataImpl.fromString(string);
44
public TGBrowserData dataDialog(Shell parent) {
45
return new TGBrowserDataDialog().show(parent);
49
class TGBrowserDataDialog{
51
protected TGBrowserDataImpl data;
53
public TGBrowserDataImpl show(Shell parent){
54
final Shell dialog = DialogUtils.newDialog(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
56
dialog.setLayout(new GridLayout());
57
dialog.setText(TuxGuitar.getProperty("FTP Location"));
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));
64
GridData textData = new GridData(SWT.FILL,SWT.FILL,true,true);
65
textData.minimumWidth = 300;
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);
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);
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);
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);
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));
96
GridData data = new GridData(SWT.FILL,SWT.FILL,true,true);
97
data.minimumWidth = 80;
98
data.minimumHeight = 25;
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);
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) {
125
dialog.setDefaultButton( buttonOk );
127
DialogUtils.openDialog(dialog,DialogUtils.OPEN_STYLE_CENTER | DialogUtils.OPEN_STYLE_PACK | DialogUtils.OPEN_STYLE_WAIT);
b'\\ No newline at end of file'