package Views;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.part.ViewPart;
import xMLBrowser.DBVerbindung;
public class View extends ViewPart {
private Text dbPfadText;
public static final String ID = "Views.view";
public void createPartControl(Composite parent) {
Composite top = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
top.setLayout(layout);
// top banner
Composite banner = new Composite(top, SWT.NONE);
banner.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_BEGINNING, true, false));
layout = new GridLayout();
layout.marginHeight = 5;
layout.marginWidth = 10;
layout.numColumns = 2;
banner.setLayout(layout);
Listener verbListener = new Listener ()
{
public void handleEvent(Event event) {
verbindeZuDB();
}
};
KeyListener verbKeyListener = new KeyListener ()
{
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.CR && dbPfadText.getText().length()>0)
verbindeZuDB();
}
public void keyReleased(KeyEvent e) {
}
};
GridData gdDBFenster = new GridData(SWT.FILL, SWT.FILL, true, true);
gdDBFenster.horizontalSpan = 3;
Label l = new Label(banner, SWT.SIMPLE);
l.setText("eXist Datenbank:");
dbPfadText = new Text(banner, SWT.SINGLE | SWT.BORDER);
dbPfadText.setText("xmldb:exist://localhost:8080/exist/xmlrpc/db/");
//dbPfadText.setText("xmldb:exist://win87.tfh-berlin.de/exist/xmlrpc/db/");
dbPfadText.setLayoutData(gdDBFenster);
dbPfadText.addKeyListener(verbKeyListener);
Button b = new Button(banner, SWT.FLAT);
b.setText("Verbinden");
b.addListener(SWT.Selection, verbListener);
}
private void verbindeZuDB()
{
getViewSite().getActionBars().getStatusLineManager().setMessage("Verbindung wird hergestellt ...");
DBVerbindung.getInstance().verbinde(dbPfadText.getText());
dbPfadText.setText("");
}
public void setFocus() {
}
}