Modified: incubator/oodt/trunk/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/panels/Row.java URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/panels/Row.java?rev=963384&r1=963383&r2=963384&view=diff ============================================================================== --- incubator/oodt/trunk/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/panels/Row.java (original) +++ incubator/oodt/trunk/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/panels/Row.java Mon Jul 12 17:40:21 2010 @@ -1,4 +1,4 @@ -/* +/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -15,7 +15,6 @@ * limitations under the License. */ - package org.apache.oodt.cas.filemgr.browser.view.panels; import java.awt.Color; @@ -23,61 +22,62 @@ import java.awt.Color; import javax.swing.BoxLayout; import javax.swing.JPanel; -public class Row extends JPanel{ - - private Cell cells[]; - - public Row(int numCells){ - //create cells - cells = new Cell[numCells]; - for(int i=0;i<numCells;i++){ - cells[i] = new Cell(); - cells[i].setText(""); - } - - //set background, etc. - this.setBackground(Color.WHITE); - this.setLayout(new BoxLayout(this,BoxLayout.LINE_AXIS)); - - for(int i=0;i<numCells;i++){ - this.add(cells[i]); - } - } - - public void hideCol(int colNum){ - Cell c = (Cell)this.getComponent(colNum); - c.setVisible(false); - } - - public void unhideCol(int colNum){ - Cell c = (Cell)this.getComponent(colNum); - c.setVisible(true); - } - - public void setText(int colNum, String text){ - Cell c = (Cell)this.getComponent(colNum); - c.setText(text); - c.repaint(); - } - - public String getText(int colNum){ - Cell c = (Cell)this.getComponent(colNum); - return c.getText(); - } - - public int getWidth(int colNum){ - Cell c = (Cell)this.getComponent(colNum); - return c.getWidth(); - } - - public void changeWidth(int colNum, int newWidth){ - Cell c = (Cell)this.getComponent(colNum); - int change = c.getWidth() - newWidth; - c.setWidth(newWidth); - for(int i=colNum+1;i<this.getComponentCount();i++){ - this.getComponent(i).setLocation(this.getComponent(i).getX()-change, this.getComponent(i).getY()); - } - this.repaint(); - } +public class Row extends JPanel { + + private Cell cells[]; + + public Row(int numCells) { + // create cells + cells = new Cell[numCells]; + for (int i = 0; i < numCells; i++) { + cells[i] = new Cell(); + cells[i].setText(""); + } + + // set background, etc. + this.setBackground(Color.WHITE); + this.setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); + + for (int i = 0; i < numCells; i++) { + this.add(cells[i]); + } + } + + public void hideCol(int colNum) { + Cell c = (Cell) this.getComponent(colNum); + c.setVisible(false); + } + + public void unhideCol(int colNum) { + Cell c = (Cell) this.getComponent(colNum); + c.setVisible(true); + } + + public void setText(int colNum, String text) { + Cell c = (Cell) this.getComponent(colNum); + c.setText(text); + c.repaint(); + } + + public String getText(int colNum) { + Cell c = (Cell) this.getComponent(colNum); + return c.getText(); + } + + public int getWidth(int colNum) { + Cell c = (Cell) this.getComponent(colNum); + return c.getWidth(); + } + + public void changeWidth(int colNum, int newWidth) { + Cell c = (Cell) this.getComponent(colNum); + int change = c.getWidth() - newWidth; + c.setWidth(newWidth); + for (int i = colNum + 1; i < this.getComponentCount(); i++) { + this.getComponent(i).setLocation(this.getComponent(i).getX() - change, + this.getComponent(i).getY()); + } + this.repaint(); + } }
Modified: incubator/oodt/trunk/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/panels/TablePane.java URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/panels/TablePane.java?rev=963384&r1=963383&r2=963384&view=diff ============================================================================== --- incubator/oodt/trunk/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/panels/TablePane.java (original) +++ incubator/oodt/trunk/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/panels/TablePane.java Mon Jul 12 17:40:21 2010 @@ -1,4 +1,4 @@ -/* +/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. Modified: incubator/oodt/trunk/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/prompts/ConnectPrompt.java URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/prompts/ConnectPrompt.java?rev=963384&r1=963383&r2=963384&view=diff ============================================================================== --- incubator/oodt/trunk/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/prompts/ConnectPrompt.java (original) +++ incubator/oodt/trunk/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/prompts/ConnectPrompt.java Mon Jul 12 17:40:21 2010 @@ -1,4 +1,4 @@ -/* +/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -15,7 +15,6 @@ * limitations under the License. */ - package org.apache.oodt.cas.filemgr.browser.view.prompts; import java.awt.Color; @@ -35,83 +34,82 @@ import javax.swing.border.CompoundBorder import javax.swing.border.EmptyBorder; import javax.swing.border.LineBorder; -public class ConnectPrompt extends JFrame implements ActionListener{ - - private CASField topPanel; - private ConnectButton bottomPanel; - - public ConnectPrompt(ActionListener listener){ - this.setName("New Connection"); - this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); - Dimension d = new Dimension(400,100); - this.setMinimumSize(d); - this.setMaximumSize(d); - this.setPreferredSize(d); - - this.getContentPane().setLayout(new BoxLayout(this.getContentPane(),BoxLayout.Y_AXIS)); - this.getContentPane().setBackground(Color.WHITE); - - - topPanel = new CASField(this); - bottomPanel = new ConnectButton(listener); - this.add(topPanel); - this.add(bottomPanel); - } - - public String getCASUrl(){ - return topPanel.casRef.getText(); - } - - - private class CASField extends JPanel{ - - protected JTextField casRef; - - protected CASField(ActionListener listener){ - this.setBackground(Color.WHITE); - this.setLayout(new BoxLayout(this,BoxLayout.X_AXIS)); - Dimension d = new Dimension(400,30); - this.setMaximumSize(d); - this.setMinimumSize(d); - this.setPreferredSize(d); - - EmptyBorder line1 = new EmptyBorder(5,10,5,5); - this.setBorder(line1); - - this.add(new JLabel("CAS File Manager URL: ")); - casRef = new JTextField(); - casRef.addActionListener(listener); - this.add(casRef); - } - } - - private class ConnectButton extends JPanel{ - - protected JButton connect; - protected JButton cancel; - - protected ConnectButton(ActionListener listener){ - this.setBackground(Color.WHITE); - this.setLayout(new BoxLayout(this,BoxLayout.X_AXIS)); - - EmptyBorder line1 = new EmptyBorder(5,20,5,5); - this.setBorder(line1); - - this.add(new JLabel(" ")); - connect = new JButton("Connect"); - connect.setBackground(Color.WHITE); - connect.addActionListener(listener); - cancel = new JButton("Cancel"); - cancel.setBackground(Color.WHITE); - cancel.addActionListener(listener); - cancel.setName("ConnectCancel"); - this.add(cancel); - this.add(connect); - } - } - - public void actionPerformed(ActionEvent arg0) { - bottomPanel.connect.doClick(); - } - +public class ConnectPrompt extends JFrame implements ActionListener { + + private CASField topPanel; + private ConnectButton bottomPanel; + + public ConnectPrompt(ActionListener listener) { + this.setName("New Connection"); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + Dimension d = new Dimension(400, 100); + this.setMinimumSize(d); + this.setMaximumSize(d); + this.setPreferredSize(d); + + this.getContentPane().setLayout( + new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS)); + this.getContentPane().setBackground(Color.WHITE); + + topPanel = new CASField(this); + bottomPanel = new ConnectButton(listener); + this.add(topPanel); + this.add(bottomPanel); + } + + public String getCASUrl() { + return topPanel.casRef.getText(); + } + + private class CASField extends JPanel { + + protected JTextField casRef; + + protected CASField(ActionListener listener) { + this.setBackground(Color.WHITE); + this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); + Dimension d = new Dimension(400, 30); + this.setMaximumSize(d); + this.setMinimumSize(d); + this.setPreferredSize(d); + + EmptyBorder line1 = new EmptyBorder(5, 10, 5, 5); + this.setBorder(line1); + + this.add(new JLabel("CAS File Manager URL: ")); + casRef = new JTextField(); + casRef.addActionListener(listener); + this.add(casRef); + } + } + + private class ConnectButton extends JPanel { + + protected JButton connect; + protected JButton cancel; + + protected ConnectButton(ActionListener listener) { + this.setBackground(Color.WHITE); + this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); + + EmptyBorder line1 = new EmptyBorder(5, 20, 5, 5); + this.setBorder(line1); + + this.add(new JLabel(" ")); + connect = new JButton("Connect"); + connect.setBackground(Color.WHITE); + connect.addActionListener(listener); + cancel = new JButton("Cancel"); + cancel.setBackground(Color.WHITE); + cancel.addActionListener(listener); + cancel.setName("ConnectCancel"); + this.add(cancel); + this.add(connect); + } + } + + public void actionPerformed(ActionEvent arg0) { + bottomPanel.connect.doClick(); + } + } Modified: incubator/oodt/trunk/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/prompts/QueryBuilderPrompt.java URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/prompts/QueryBuilderPrompt.java?rev=963384&r1=963383&r2=963384&view=diff ============================================================================== --- incubator/oodt/trunk/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/prompts/QueryBuilderPrompt.java (original) +++ incubator/oodt/trunk/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/prompts/QueryBuilderPrompt.java Mon Jul 12 17:40:21 2010 @@ -1,4 +1,4 @@ -/* +/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -15,7 +15,6 @@ * limitations under the License. */ - package org.apache.oodt.cas.filemgr.browser.view.prompts; import org.apache.oodt.cas.filemgr.structs.RangeQueryCriteria; @@ -47,409 +46,408 @@ import javax.swing.border.LineBorder; import org.apache.oodt.cas.filemgr.browser.controller.WindowListener; import org.apache.oodt.cas.filemgr.browser.model.CasDB; -public class QueryBuilderPrompt extends JFrame{ - - protected CasDB database; - protected WindowListener listener; - - protected TypePanel tPanel; - protected QuerySelectionPanel qPanel; - protected JScrollPane scrollPane; - protected BuiltQueryPane builtPanel; - protected SearchPanel sPanel; - - public QueryBuilderPrompt(CasDB db, WindowListener l){ - - database = db; - listener = l; - - this.setName("Query Builder"); - this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); - Dimension d = new Dimension(500,400); - this.setMinimumSize(d); - this.setMaximumSize(d); - this.setPreferredSize(d); - - this.getContentPane().setLayout(new BoxLayout(this.getContentPane(),BoxLayout.Y_AXIS)); - this.getContentPane().setBackground(Color.WHITE); - - tPanel = new TypePanel(this); - qPanel = new QuerySelectionPanel(this); - sPanel = new SearchPanel(this); - builtPanel = new BuiltQueryPane(this); - - scrollPane=new JScrollPane(qPanel); - Dimension scrollDim = new Dimension(500,220); - scrollPane.setMaximumSize(scrollDim); - scrollPane.setMinimumSize(scrollDim); - scrollPane.setPreferredSize(scrollDim); - - this.getContentPane().add(tPanel); - this.getContentPane().add(scrollPane); - this.getContentPane().add(builtPanel); - this.getContentPane().add(sPanel); - } - - - public org.apache.oodt.cas.filemgr.structs.Query getQuery(){ - return qPanel.getCasQuery(); - } - - public String getQueryString(){ - return qPanel.getQuery(); - } - - public String getProductType(){ - return tPanel.getType(); - } - - private class QueryPanel extends JPanel{ - - private JComboBox elements; - private JComboBox ops; - private JPanel placeholder; - private boolean showOp; - - public QueryPanel(QueryBuilderPrompt prompt){ - Dimension d = new Dimension(460,35); - this.setMaximumSize(d); - this.setMinimumSize(d); - this.setPreferredSize(d); - this.setBackground(Color.WHITE); - this.setLayout(new BoxLayout(this,BoxLayout.X_AXIS)); - - showOp = false; - ops = new JComboBox(new String[]{"AND","OR","NOT"}); - Dimension opsDim = new Dimension(75,25); - ops.setMaximumSize(opsDim); - ops.setMinimumSize(opsDim); - ops.setPreferredSize(opsDim); - ops.setBackground(Color.WHITE); - ops.setVisible(false); - - placeholder = new JPanel(); - placeholder.setBackground(Color.WHITE); - placeholder.setMaximumSize(opsDim); - placeholder.setMinimumSize(opsDim); - placeholder.setPreferredSize(opsDim); - - elements = new JComboBox(prompt.database.getAvailableElements(prompt.tPanel.getType())); - elements.setBackground(Color.WHITE); - Dimension dElem = new Dimension(150,25); - elements.setMaximumSize(dElem); - elements.setMinimumSize(dElem); - elements.setPreferredSize(dElem); - - this.add(ops); - this.add(placeholder); - this.add(elements); - } - - public void addOp(){ - showOp = true; - ops.setVisible(true); - placeholder.setVisible(false); - } - - public String getElement(){ - return elements.getSelectedItem().toString(); - } - - public String getOp(){ - String op = ""; - if(showOp){ - op = ops.getSelectedItem().toString(); - } - return op; - } - } - - - private class TermQueryPanel extends QueryPanel{ - - private JTextField text; - - - public TermQueryPanel(QueryBuilderPrompt prompt){ - super(prompt); - - text = new JTextField(); - Dimension dText = new Dimension(150,25); - text.setPreferredSize(dText); - text.setMaximumSize(dText); - text.setMinimumSize(dText); - text.setBackground(Color.WHITE); - text.addFocusListener(prompt.builtPanel); - text.addActionListener(prompt.builtPanel); - - this.add(new JLabel(" Matches ")); - this.add(text); - } - - public String getText(){ - return text.getText(); - } - - } - - private class RangeQueryPanel extends QueryPanel{ - - private JTextField start; - private JTextField stop; - - public RangeQueryPanel(QueryBuilderPrompt prompt){ - super(prompt); - - start = new JTextField(); - stop = new JTextField(); - - Dimension dText = new Dimension(60,25); - start.setMaximumSize(dText); - start.setMinimumSize(dText); - start.setPreferredSize(dText); - start.addFocusListener(prompt.builtPanel); - start.addActionListener(prompt.builtPanel); - - stop.setMaximumSize(dText); - stop.setMinimumSize(dText); - stop.setPreferredSize(dText); - stop.addFocusListener(prompt.builtPanel); - stop.addActionListener(prompt.builtPanel); - - this.add(new JLabel(" Between ")); - this.add(start); - this.add(new JLabel(" And ")); - this.add(stop); - } - - public String getStart(){ - return start.getText(); - } - - public String getStop(){ - return stop.getText(); - } - - } - - - - private class QuerySelectionPanel extends JPanel implements ActionListener{ - - private JButton addTerm; - private JButton addRange; - private QueryBuilderPrompt prompt; - - public QuerySelectionPanel(QueryBuilderPrompt prompt){ - this.prompt = prompt; - this.setBackground(Color.WHITE); - - - EmptyBorder line1 = new EmptyBorder(2,2,2,2); - LineBorder line2 = new LineBorder(Color.BLACK,1); - CompoundBorder cp = new CompoundBorder(line1,line2); - this.setBorder(cp); - this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); - - JPanel buttonPanel = new JPanel(); - Dimension buttonDim = new Dimension(460,30); - buttonPanel.setMaximumSize(buttonDim); - buttonPanel.setMinimumSize(buttonDim); - buttonPanel.setPreferredSize(buttonDim); - buttonPanel.setBackground(Color.WHITE); - buttonPanel.setLayout(new BoxLayout(buttonPanel,BoxLayout.X_AXIS)); - - addTerm = new JButton("Add Term Criteria"); - addTerm.setBackground(Color.WHITE); - addTerm.addActionListener(this); - - addRange = new JButton("Add Range Criteria"); - addRange.setBackground(Color.WHITE); - addRange.addActionListener(this); - - buttonPanel.add(addTerm); - buttonPanel.add(addRange); - this.add(buttonPanel); - } - - public void actionPerformed(ActionEvent arg0) { - if(arg0.getActionCommand().equals("Add Term Criteria")){ - TermQueryPanel tq = new TermQueryPanel(prompt); - if(this.getComponentCount()>1) tq.addOp(); - int insertOrder = this.getComponentCount()-1; - if(insertOrder<0) insertOrder = 0; - this.add(tq,insertOrder); - this.validate(); - prompt.scrollPane.validate(); - } else if(arg0.getActionCommand().equals("Add Range Criteria")){ - RangeQueryPanel rq = new RangeQueryPanel(prompt); - if(this.getComponentCount()>1) rq.addOp(); - int insertOrder = this.getComponentCount()-1; - if(insertOrder<0) insertOrder = 0; - this.add(rq,insertOrder); - this.validate(); - prompt.scrollPane.validate(); - } - } - - public String getQuery(){ - String q = new String(); - for(int i=0;i<this.getComponentCount();i++){ - Component c = this.getComponent(i); - if(c instanceof TermQueryPanel){ - q += ((TermQueryPanel)c).getOp()+ " "; - q += ((TermQueryPanel)c).getElement() + ":"; - q += ((TermQueryPanel)c).getText()+" "; - } else if(c instanceof RangeQueryPanel){ - q += ((RangeQueryPanel)c).getOp()+ " "; - q += ((RangeQueryPanel)c).getElement() + ":["; - q += ((RangeQueryPanel)c).getStart() + " TO "; - q += ((RangeQueryPanel)c).getStop() + "] "; - } - } - - return q; - } - - public org.apache.oodt.cas.filemgr.structs.Query getCasQuery(){ - org.apache.oodt.cas.filemgr.structs.Query q = - new org.apache.oodt.cas.filemgr.structs.Query(); - for(int i=0;i<this.getComponentCount();i++){ - Component c = this.getComponent(i); - String element; - if(c instanceof TermQueryPanel){ - element = database.getElementID(((TermQueryPanel)c).getElement()); - String criteria = ((TermQueryPanel)c).getText(); - if(!element.equals("")&&!criteria.equals("")){ - TermQueryCriteria tc = new TermQueryCriteria(); - tc.setElementName(element); - tc.setValue(criteria); - q.addCriterion(tc); - } - } else if(c instanceof RangeQueryPanel){ - element = database.getElementID(((RangeQueryPanel)c).getElement()); - String startCriteria = ((RangeQueryPanel)c).getStart(); - String stopCriteria = ((RangeQueryPanel)c).getStop(); - if(!element.equals("")&&!startCriteria.equals("")&&!stopCriteria.equals("")){ - RangeQueryCriteria rt = new RangeQueryCriteria(); - rt.setElementName(element); - rt.setStartValue(startCriteria); - rt.setEndValue(stopCriteria); - q.addCriterion(rt); - } - } - } - - return q; - } - - } - - private class SearchPanel extends JPanel{ - private JButton search; - - public SearchPanel(QueryBuilderPrompt prompt){ - Dimension d = new Dimension(500,40); - this.setMaximumSize(d); - this.setMinimumSize(d); - this.setPreferredSize(d); - EmptyBorder line1 = new EmptyBorder(2,2,2,2); - LineBorder line2 = new LineBorder(Color.BLACK,1); - CompoundBorder cp = new CompoundBorder(line1,line2); - this.setBorder(cp); - this.setLayout(new BorderLayout()); - this.setBackground(Color.WHITE); - - search = new JButton("Search"); - search.setName("AdvancedQuery"); - search.addActionListener(prompt.listener); - search.setBackground(Color.WHITE); - - JPanel buttonPanel = new JPanel(); - buttonPanel.setBackground(Color.WHITE); - buttonPanel.setLayout(new BoxLayout(buttonPanel,BoxLayout.X_AXIS)); - buttonPanel.add(search); - this.add(buttonPanel, BorderLayout.EAST); - } - - - } - - private class TypePanel extends JPanel{ - - private JComboBox types; - - public TypePanel(QueryBuilderPrompt prompt){ - - Dimension d = new Dimension(500,40); - this.setMaximumSize(d); - this.setMinimumSize(d); - this.setPreferredSize(d); - EmptyBorder line1 = new EmptyBorder(2,2,2,2); - LineBorder line2 = new LineBorder(Color.BLACK,1); - CompoundBorder cp = new CompoundBorder(line1,line2); - this.setBorder(cp); - - - - types = new JComboBox(database.getAvailableTypes()); - types.setBackground(Color.WHITE); - Dimension tDim = new Dimension(200,30); - types.setMaximumSize(tDim); - types.setMinimumSize(tDim); - types.setPreferredSize(tDim); - - this.setBackground(Color.WHITE); - this.setLayout(new BoxLayout(this,BoxLayout.X_AXIS)); - - JLabel label = new JLabel(" Product Type: "); - - this.add(label); - this.add(types); - } - - public String getType(){ - return types.getSelectedItem().toString(); - } - } - - private class BuiltQueryPane extends JPanel implements FocusListener, ActionListener{ - - private QueryBuilderPrompt p; - private JTextArea field; - - public BuiltQueryPane(QueryBuilderPrompt prompt){ - - Dimension d = new Dimension(500,75); - this.setMaximumSize(d); - this.setMinimumSize(d); - this.setPreferredSize(d); - - EmptyBorder line1 = new EmptyBorder(2,2,2,2); - LineBorder line2 = new LineBorder(Color.BLACK,1); - CompoundBorder cp = new CompoundBorder(line1,line2); - this.setBorder(cp); - this.setLayout(new BorderLayout()); - - field = new JTextArea(); - Font font = new Font("san-serif", Font.PLAIN, 10); - field.setFont(font); - field.setBackground(Color.WHITE); - field.setLineWrap(true); - field.setWrapStyleWord(true); - - this.add(field, BorderLayout.CENTER); - } - - public void focusGained(FocusEvent arg0) {} - - public void focusLost(FocusEvent arg0) { - field.setText(qPanel.getQuery()); - } - - public void actionPerformed(ActionEvent arg0) { - field.setText(qPanel.getQuery()); - } - } - +public class QueryBuilderPrompt extends JFrame { + + protected CasDB database; + protected WindowListener listener; + + protected TypePanel tPanel; + protected QuerySelectionPanel qPanel; + protected JScrollPane scrollPane; + protected BuiltQueryPane builtPanel; + protected SearchPanel sPanel; + + public QueryBuilderPrompt(CasDB db, WindowListener l) { + + database = db; + listener = l; + + this.setName("Query Builder"); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + Dimension d = new Dimension(500, 400); + this.setMinimumSize(d); + this.setMaximumSize(d); + this.setPreferredSize(d); + + this.getContentPane().setLayout( + new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS)); + this.getContentPane().setBackground(Color.WHITE); + + tPanel = new TypePanel(this); + qPanel = new QuerySelectionPanel(this); + sPanel = new SearchPanel(this); + builtPanel = new BuiltQueryPane(this); + + scrollPane = new JScrollPane(qPanel); + Dimension scrollDim = new Dimension(500, 220); + scrollPane.setMaximumSize(scrollDim); + scrollPane.setMinimumSize(scrollDim); + scrollPane.setPreferredSize(scrollDim); + + this.getContentPane().add(tPanel); + this.getContentPane().add(scrollPane); + this.getContentPane().add(builtPanel); + this.getContentPane().add(sPanel); + } + + public org.apache.oodt.cas.filemgr.structs.Query getQuery() { + return qPanel.getCasQuery(); + } + + public String getQueryString() { + return qPanel.getQuery(); + } + + public String getProductType() { + return tPanel.getType(); + } + + private class QueryPanel extends JPanel { + + private JComboBox elements; + private JComboBox ops; + private JPanel placeholder; + private boolean showOp; + + public QueryPanel(QueryBuilderPrompt prompt) { + Dimension d = new Dimension(460, 35); + this.setMaximumSize(d); + this.setMinimumSize(d); + this.setPreferredSize(d); + this.setBackground(Color.WHITE); + this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); + + showOp = false; + ops = new JComboBox(new String[] { "AND", "OR", "NOT" }); + Dimension opsDim = new Dimension(75, 25); + ops.setMaximumSize(opsDim); + ops.setMinimumSize(opsDim); + ops.setPreferredSize(opsDim); + ops.setBackground(Color.WHITE); + ops.setVisible(false); + + placeholder = new JPanel(); + placeholder.setBackground(Color.WHITE); + placeholder.setMaximumSize(opsDim); + placeholder.setMinimumSize(opsDim); + placeholder.setPreferredSize(opsDim); + + elements = new JComboBox(prompt.database + .getAvailableElements(prompt.tPanel.getType())); + elements.setBackground(Color.WHITE); + Dimension dElem = new Dimension(150, 25); + elements.setMaximumSize(dElem); + elements.setMinimumSize(dElem); + elements.setPreferredSize(dElem); + + this.add(ops); + this.add(placeholder); + this.add(elements); + } + + public void addOp() { + showOp = true; + ops.setVisible(true); + placeholder.setVisible(false); + } + + public String getElement() { + return elements.getSelectedItem().toString(); + } + + public String getOp() { + String op = ""; + if (showOp) { + op = ops.getSelectedItem().toString(); + } + return op; + } + } + + private class TermQueryPanel extends QueryPanel { + + private JTextField text; + + public TermQueryPanel(QueryBuilderPrompt prompt) { + super(prompt); + + text = new JTextField(); + Dimension dText = new Dimension(150, 25); + text.setPreferredSize(dText); + text.setMaximumSize(dText); + text.setMinimumSize(dText); + text.setBackground(Color.WHITE); + text.addFocusListener(prompt.builtPanel); + text.addActionListener(prompt.builtPanel); + + this.add(new JLabel(" Matches ")); + this.add(text); + } + + public String getText() { + return text.getText(); + } + + } + + private class RangeQueryPanel extends QueryPanel { + + private JTextField start; + private JTextField stop; + + public RangeQueryPanel(QueryBuilderPrompt prompt) { + super(prompt); + + start = new JTextField(); + stop = new JTextField(); + + Dimension dText = new Dimension(60, 25); + start.setMaximumSize(dText); + start.setMinimumSize(dText); + start.setPreferredSize(dText); + start.addFocusListener(prompt.builtPanel); + start.addActionListener(prompt.builtPanel); + + stop.setMaximumSize(dText); + stop.setMinimumSize(dText); + stop.setPreferredSize(dText); + stop.addFocusListener(prompt.builtPanel); + stop.addActionListener(prompt.builtPanel); + + this.add(new JLabel(" Between ")); + this.add(start); + this.add(new JLabel(" And ")); + this.add(stop); + } + + public String getStart() { + return start.getText(); + } + + public String getStop() { + return stop.getText(); + } + + } + + private class QuerySelectionPanel extends JPanel implements ActionListener { + + private JButton addTerm; + private JButton addRange; + private QueryBuilderPrompt prompt; + + public QuerySelectionPanel(QueryBuilderPrompt prompt) { + this.prompt = prompt; + this.setBackground(Color.WHITE); + + EmptyBorder line1 = new EmptyBorder(2, 2, 2, 2); + LineBorder line2 = new LineBorder(Color.BLACK, 1); + CompoundBorder cp = new CompoundBorder(line1, line2); + this.setBorder(cp); + this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + + JPanel buttonPanel = new JPanel(); + Dimension buttonDim = new Dimension(460, 30); + buttonPanel.setMaximumSize(buttonDim); + buttonPanel.setMinimumSize(buttonDim); + buttonPanel.setPreferredSize(buttonDim); + buttonPanel.setBackground(Color.WHITE); + buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); + + addTerm = new JButton("Add Term Criteria"); + addTerm.setBackground(Color.WHITE); + addTerm.addActionListener(this); + + addRange = new JButton("Add Range Criteria"); + addRange.setBackground(Color.WHITE); + addRange.addActionListener(this); + + buttonPanel.add(addTerm); + buttonPanel.add(addRange); + this.add(buttonPanel); + } + + public void actionPerformed(ActionEvent arg0) { + if (arg0.getActionCommand().equals("Add Term Criteria")) { + TermQueryPanel tq = new TermQueryPanel(prompt); + if (this.getComponentCount() > 1) + tq.addOp(); + int insertOrder = this.getComponentCount() - 1; + if (insertOrder < 0) + insertOrder = 0; + this.add(tq, insertOrder); + this.validate(); + prompt.scrollPane.validate(); + } else if (arg0.getActionCommand().equals("Add Range Criteria")) { + RangeQueryPanel rq = new RangeQueryPanel(prompt); + if (this.getComponentCount() > 1) + rq.addOp(); + int insertOrder = this.getComponentCount() - 1; + if (insertOrder < 0) + insertOrder = 0; + this.add(rq, insertOrder); + this.validate(); + prompt.scrollPane.validate(); + } + } + + public String getQuery() { + String q = new String(); + for (int i = 0; i < this.getComponentCount(); i++) { + Component c = this.getComponent(i); + if (c instanceof TermQueryPanel) { + q += ((TermQueryPanel) c).getOp() + " "; + q += ((TermQueryPanel) c).getElement() + ":"; + q += ((TermQueryPanel) c).getText() + " "; + } else if (c instanceof RangeQueryPanel) { + q += ((RangeQueryPanel) c).getOp() + " "; + q += ((RangeQueryPanel) c).getElement() + ":["; + q += ((RangeQueryPanel) c).getStart() + " TO "; + q += ((RangeQueryPanel) c).getStop() + "] "; + } + } + + return q; + } + + public org.apache.oodt.cas.filemgr.structs.Query getCasQuery() { + org.apache.oodt.cas.filemgr.structs.Query q = new org.apache.oodt.cas.filemgr.structs.Query(); + for (int i = 0; i < this.getComponentCount(); i++) { + Component c = this.getComponent(i); + String element; + if (c instanceof TermQueryPanel) { + element = database.getElementID(((TermQueryPanel) c).getElement()); + String criteria = ((TermQueryPanel) c).getText(); + if (!element.equals("") && !criteria.equals("")) { + TermQueryCriteria tc = new TermQueryCriteria(); + tc.setElementName(element); + tc.setValue(criteria); + q.addCriterion(tc); + } + } else if (c instanceof RangeQueryPanel) { + element = database.getElementID(((RangeQueryPanel) c).getElement()); + String startCriteria = ((RangeQueryPanel) c).getStart(); + String stopCriteria = ((RangeQueryPanel) c).getStop(); + if (!element.equals("") && !startCriteria.equals("") + && !stopCriteria.equals("")) { + RangeQueryCriteria rt = new RangeQueryCriteria(); + rt.setElementName(element); + rt.setStartValue(startCriteria); + rt.setEndValue(stopCriteria); + q.addCriterion(rt); + } + } + } + + return q; + } + + } + + private class SearchPanel extends JPanel { + private JButton search; + + public SearchPanel(QueryBuilderPrompt prompt) { + Dimension d = new Dimension(500, 40); + this.setMaximumSize(d); + this.setMinimumSize(d); + this.setPreferredSize(d); + EmptyBorder line1 = new EmptyBorder(2, 2, 2, 2); + LineBorder line2 = new LineBorder(Color.BLACK, 1); + CompoundBorder cp = new CompoundBorder(line1, line2); + this.setBorder(cp); + this.setLayout(new BorderLayout()); + this.setBackground(Color.WHITE); + + search = new JButton("Search"); + search.setName("AdvancedQuery"); + search.addActionListener(prompt.listener); + search.setBackground(Color.WHITE); + + JPanel buttonPanel = new JPanel(); + buttonPanel.setBackground(Color.WHITE); + buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); + buttonPanel.add(search); + this.add(buttonPanel, BorderLayout.EAST); + } + + } + + private class TypePanel extends JPanel { + + private JComboBox types; + + public TypePanel(QueryBuilderPrompt prompt) { + + Dimension d = new Dimension(500, 40); + this.setMaximumSize(d); + this.setMinimumSize(d); + this.setPreferredSize(d); + EmptyBorder line1 = new EmptyBorder(2, 2, 2, 2); + LineBorder line2 = new LineBorder(Color.BLACK, 1); + CompoundBorder cp = new CompoundBorder(line1, line2); + this.setBorder(cp); + + types = new JComboBox(database.getAvailableTypes()); + types.setBackground(Color.WHITE); + Dimension tDim = new Dimension(200, 30); + types.setMaximumSize(tDim); + types.setMinimumSize(tDim); + types.setPreferredSize(tDim); + + this.setBackground(Color.WHITE); + this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); + + JLabel label = new JLabel(" Product Type: "); + + this.add(label); + this.add(types); + } + + public String getType() { + return types.getSelectedItem().toString(); + } + } + + private class BuiltQueryPane extends JPanel implements FocusListener, + ActionListener { + + private QueryBuilderPrompt p; + private JTextArea field; + + public BuiltQueryPane(QueryBuilderPrompt prompt) { + + Dimension d = new Dimension(500, 75); + this.setMaximumSize(d); + this.setMinimumSize(d); + this.setPreferredSize(d); + + EmptyBorder line1 = new EmptyBorder(2, 2, 2, 2); + LineBorder line2 = new LineBorder(Color.BLACK, 1); + CompoundBorder cp = new CompoundBorder(line1, line2); + this.setBorder(cp); + this.setLayout(new BorderLayout()); + + field = new JTextArea(); + Font font = new Font("san-serif", Font.PLAIN, 10); + field.setFont(font); + field.setBackground(Color.WHITE); + field.setLineWrap(true); + field.setWrapStyleWord(true); + + this.add(field, BorderLayout.CENTER); + } + + public void focusGained(FocusEvent arg0) { + } + + public void focusLost(FocusEvent arg0) { + field.setText(qPanel.getQuery()); + } + + public void actionPerformed(ActionEvent arg0) { + field.setText(qPanel.getQuery()); + } + } + } Modified: incubator/oodt/trunk/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/prompts/SortPrompt.java URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/prompts/SortPrompt.java?rev=963384&r1=963383&r2=963384&view=diff ============================================================================== --- incubator/oodt/trunk/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/prompts/SortPrompt.java (original) +++ incubator/oodt/trunk/app/fmbrowser/src/main/java/org/apache/oodt/cas/filemgr/browser/view/prompts/SortPrompt.java Mon Jul 12 17:40:21 2010 @@ -1,4 +1,4 @@ -/* +/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -15,7 +15,6 @@ * limitations under the License. */ - package org.apache.oodt.cas.filemgr.browser.view.prompts; import java.awt.Color; @@ -34,121 +33,121 @@ import javax.swing.border.EmptyBorder; import org.apache.oodt.cas.filemgr.browser.view.MainWindow; -public class SortPrompt extends JFrame{ - - private ColumnPanel cPanel; - private ConnectButton cButtons; - - public SortPrompt(MainWindow window, ActionListener listener){ - this.setName("Sort"); - this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); - Dimension d = new Dimension(350,150); - this.setMinimumSize(d); - this.setMaximumSize(d); - this.setPreferredSize(d); - - this.getContentPane().setLayout(new BoxLayout(this.getContentPane(),BoxLayout.Y_AXIS)); - this.getContentPane().setBackground(Color.WHITE); - - cPanel = new ColumnPanel(window); - cButtons = new ConnectButton(listener); - this.add(cPanel); - this.add(cButtons); - } - - public int getSortIndex(){ - return cPanel.getSortIndex(); - } - - public String getSortType(){ - return cPanel.getSortType(); - } - - protected class ColumnPanel extends JPanel{ - - protected JComboBox ColChoices; - protected JComboBox SortChoices; - protected JButton cancel; - protected JButton ok; - - public ColumnPanel(MainWindow window){ - ColChoices = new JComboBox(window.getColHeaders()); - ColChoices.setSelectedIndex(0); - ColChoices.setBackground(Color.WHITE); - String[] sortPatterns = {"Accending","Descending"}; - SortChoices = new JComboBox(sortPatterns); - SortChoices.setSelectedIndex(0); - SortChoices.setBackground(Color.WHITE); - - Dimension choicesDim = new Dimension(200,20); - ColChoices.setMinimumSize(choicesDim); - ColChoices.setMaximumSize(choicesDim); - ColChoices.setPreferredSize(choicesDim); - SortChoices.setMinimumSize(choicesDim); - SortChoices.setMaximumSize(choicesDim); - SortChoices.setPreferredSize(choicesDim); - - this.setBackground(Color.WHITE); - this.setLayout(new GridBagLayout()); - GridBagConstraints c = new GridBagConstraints(); - - - EmptyBorder line1 = new EmptyBorder(5,10,5,5); - this.setBorder(line1); - - c.gridx = 0; - c.gridy = 0; - c.ipadx = 10; - c.ipady = 10; - this.add(new JLabel("Sort By: "), c); - - c.gridx = 1; - c.gridy = 0; - this.add(ColChoices, c); - - c.gridx = 0; - c.gridy = 1; - this.add(new JLabel("In Order: "), c); - - c.gridx = 1; - c.gridy = 1; - this.add(SortChoices, c); - - } - - public int getSortIndex(){ - return ColChoices.getSelectedIndex(); - } - - public String getSortType(){ - return SortChoices.getSelectedItem().toString(); - } - - } - - private class ConnectButton extends JPanel{ - - protected JButton connect; - protected JButton cancel; - - protected ConnectButton(ActionListener listener){ - this.setBackground(Color.WHITE); - this.setLayout(new BoxLayout(this,BoxLayout.X_AXIS)); - - EmptyBorder line1 = new EmptyBorder(5,20,5,5); - this.setBorder(line1); - - this.add(new JLabel(" ")); - connect = new JButton("OK"); - connect.setBackground(Color.WHITE); - connect.addActionListener(listener); - cancel = new JButton("Cancel"); - cancel.setBackground(Color.WHITE); - cancel.addActionListener(listener); - cancel.setName("SortCancel"); - this.add(cancel); - this.add(connect); - } - } - +public class SortPrompt extends JFrame { + + private ColumnPanel cPanel; + private ConnectButton cButtons; + + public SortPrompt(MainWindow window, ActionListener listener) { + this.setName("Sort"); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + Dimension d = new Dimension(350, 150); + this.setMinimumSize(d); + this.setMaximumSize(d); + this.setPreferredSize(d); + + this.getContentPane().setLayout( + new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS)); + this.getContentPane().setBackground(Color.WHITE); + + cPanel = new ColumnPanel(window); + cButtons = new ConnectButton(listener); + this.add(cPanel); + this.add(cButtons); + } + + public int getSortIndex() { + return cPanel.getSortIndex(); + } + + public String getSortType() { + return cPanel.getSortType(); + } + + protected class ColumnPanel extends JPanel { + + protected JComboBox ColChoices; + protected JComboBox SortChoices; + protected JButton cancel; + protected JButton ok; + + public ColumnPanel(MainWindow window) { + ColChoices = new JComboBox(window.getColHeaders()); + ColChoices.setSelectedIndex(0); + ColChoices.setBackground(Color.WHITE); + String[] sortPatterns = { "Accending", "Descending" }; + SortChoices = new JComboBox(sortPatterns); + SortChoices.setSelectedIndex(0); + SortChoices.setBackground(Color.WHITE); + + Dimension choicesDim = new Dimension(200, 20); + ColChoices.setMinimumSize(choicesDim); + ColChoices.setMaximumSize(choicesDim); + ColChoices.setPreferredSize(choicesDim); + SortChoices.setMinimumSize(choicesDim); + SortChoices.setMaximumSize(choicesDim); + SortChoices.setPreferredSize(choicesDim); + + this.setBackground(Color.WHITE); + this.setLayout(new GridBagLayout()); + GridBagConstraints c = new GridBagConstraints(); + + EmptyBorder line1 = new EmptyBorder(5, 10, 5, 5); + this.setBorder(line1); + + c.gridx = 0; + c.gridy = 0; + c.ipadx = 10; + c.ipady = 10; + this.add(new JLabel("Sort By: "), c); + + c.gridx = 1; + c.gridy = 0; + this.add(ColChoices, c); + + c.gridx = 0; + c.gridy = 1; + this.add(new JLabel("In Order: "), c); + + c.gridx = 1; + c.gridy = 1; + this.add(SortChoices, c); + + } + + public int getSortIndex() { + return ColChoices.getSelectedIndex(); + } + + public String getSortType() { + return SortChoices.getSelectedItem().toString(); + } + + } + + private class ConnectButton extends JPanel { + + protected JButton connect; + protected JButton cancel; + + protected ConnectButton(ActionListener listener) { + this.setBackground(Color.WHITE); + this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); + + EmptyBorder line1 = new EmptyBorder(5, 20, 5, 5); + this.setBorder(line1); + + this.add(new JLabel(" ")); + connect = new JButton("OK"); + connect.setBackground(Color.WHITE); + connect.addActionListener(listener); + cancel = new JButton("Cancel"); + cancel.setBackground(Color.WHITE); + cancel.addActionListener(listener); + cancel.setName("SortCancel"); + this.add(cancel); + this.add(connect); + } + } + }
