summaryrefslogtreecommitdiff
path: root/src/YalpInputs/YalpPGSqlInput/YalpPGSQLIndexer/Browser.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/YalpInputs/YalpPGSqlInput/YalpPGSQLIndexer/Browser.java')
-rw-r--r--src/YalpInputs/YalpPGSqlInput/YalpPGSQLIndexer/Browser.java160
1 files changed, 160 insertions, 0 deletions
diff --git a/src/YalpInputs/YalpPGSqlInput/YalpPGSQLIndexer/Browser.java b/src/YalpInputs/YalpPGSqlInput/YalpPGSQLIndexer/Browser.java
new file mode 100644
index 0000000..2b2e65a
--- /dev/null
+++ b/src/YalpInputs/YalpPGSqlInput/YalpPGSQLIndexer/Browser.java
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2006 Manuel Traut and Volker Dahnke
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors: Manuel Traut and Volker Dahnke
+ */
+
+package YalpClients.SwtClient.GUI;
+
+import YalpClients.*;
+import YalpClients.SwtClient.*;
+
+import YalpInterfaces.*;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+import java.util.LinkedList;
+
+/*
+ * Class Browser
+ *
+ * <em></em>
+ *
+ * @author Volker Dahnke / Manuel Traut
+ *
+ * @version 1 02-04-2006<br>
+ */
+public class Browser extends Composite{
+ private Composite parentComposite;
+ private Display display1;
+ private Shell shell;
+ private Model model;
+ private LinkedList<String> alreadyBrowsed;
+ private Tree tree;
+ private Button add;
+ private Button cancel;
+
+ Browser( Composite parent,
+ final Model model,
+ Display display,
+ Composite parentComposite,
+ int style )
+ {
+ super(parent, style);
+ this.parentComposite=parentComposite;
+ this.alreadyBrowsed = new LinkedList<String>();
+ this.model = model;
+ this.display1 = display;
+ this.shell = new Shell(this.display1,SWT.NONE);
+ this.setSize(300,400);
+ GridLayout gridLayout = new GridLayout();
+ this.shell.setLayout(gridLayout);
+ gridLayout.numColumns = 2;
+
+ GridData treeGrid = new GridData();
+ treeGrid.horizontalSpan = 2;
+ treeGrid.widthHint = 300;
+ treeGrid.heightHint = 400;
+ treeGrid.grabExcessHorizontalSpace = true;
+ treeGrid.grabExcessVerticalSpace = true;
+ treeGrid.horizontalAlignment = SWT.FILL;
+ treeGrid.verticalAlignment = SWT.FILL;
+
+ this.tree = new Tree(this.shell, SWT.SINGLE);
+ this.tree.setLayoutData(treeGrid);
+
+ TreeItem tmp;
+ /*
+ for(YalpFile aFile : model.getDir("/")){
+ tmp = new TreeItem(this.tree, SWT.NULL);
+ tmp.setText(aFile.name);
+ if(aFile.isDir) tmp.setImage(new Image(display1, "folder.gif"));
+ else tmp.setImage(new Image(display1, "yalpV2_klein.gif"));
+ }
+ */
+ this.tree.addSelectionListener (
+ new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ String path = getPath();
+ if(!alreadyBrowsed.contains(path)){
+ alreadyBrowsed.add(path);
+ TreeItem tmp;
+ /*
+ for(YalpFile aFile : model.getDir(path)){
+ tmp = new TreeItem(tree.getSelection()[0],SWT.NULL);
+ tmp.setText(aFile.name);
+ if(aFile.isDir) tmp.setImage(new Image(display1, "folder.gif"));
+ else tmp.setImage(new Image(display1, "yalpV2_klein.gif"));
+ tmp.getParentItem().setExpanded(true);
+ }
+ */
+ }
+ }
+ }
+ );
+
+ GridData buttonGrid1 = new GridData();
+ buttonGrid1.horizontalSpan = 1;
+
+ this.add = new Button(this.shell, SWT.PUSH);
+ this.add.setText("Indicate");
+ this.add.setLayoutData(buttonGrid1);
+ this.add.addSelectionListener(new SelectionAdapter(){
+ public void widgetSelected(SelectionEvent e){
+ // model.addDir(getPath());
+ parentEnable(true);
+ shell.setVisible(false);
+ }
+ });
+
+ GridData buttonGrid2 = new GridData();
+ buttonGrid2.horizontalSpan = 1;
+ buttonGrid2.horizontalAlignment = SWT.END;
+
+ this.cancel = new Button(this.shell, SWT.PUSH);
+ this.cancel.setText("Cancel");
+ this.cancel.setLayoutData(buttonGrid2);
+ this.cancel.addSelectionListener(new SelectionAdapter(){
+ public void widgetSelected(SelectionEvent e){
+ parentEnable(true);
+ shell.setVisible(false);
+ }
+ });
+ }
+
+ public void show(){
+ parentEnable(false);
+ Point size=this.getSize();
+ Rectangle parentRec=((Shell)this.parentComposite).getBounds();
+ Rectangle thisRec=this.shell.computeTrim(parentRec.x+(parentRec.width/2)-(size.x/2),parentRec.y+(parentRec.height/2)-(size.y/2),size.x,size.y);
+ shell.setBounds(thisRec);
+ shell.open();
+ while(!shell.isDisposed()){
+ if(!this.display1.readAndDispatch()) this.display1.sleep();
+ }
+ this.display1.dispose();
+ }
+
+ private String getPath(){
+ TreeItem actualItem = tree.getSelection()[0];
+ String path = "/"+tree.getSelection()[0].getText();
+ while(actualItem.getParentItem() != null){
+ actualItem = actualItem.getParentItem();
+ path = "/" + actualItem.getText() + path;
+ }
+ return path;
+ }
+ private void parentEnable(boolean bool){
+ parentComposite.setEnabled(bool);
+ }
+}