Back to index

wims  3.65+svn20090927
Classes | Public Member Functions | Package Attributes | Private Member Functions
WIMSchem.ds.DialogEditColumns Class Reference
Inheritance diagram for WIMSchem.ds.DialogEditColumns:
Inheritance graph
[legend]
Collaboration diagram for WIMSchem.ds.DialogEditColumns:
Collaboration graph
[legend]

List of all members.

Classes

class  SchemaDataModel

Public Member Functions

 DialogEditColumns (Frame Parent, DataSheet DS)
boolean Execute ()
int[] ResultOldPos ()
int[] ResultNewPos ()
String[] ResultName ()
int[] ResultType ()
String[] ResultDescr ()
void actionPerformed (ActionEvent e)

Package Attributes

JButton bappend
JButton bdelete
JButton bmoveup
JButton bmovedn
JButton baccept
JButton breject
JTable table
SchemaDataModel model
DataSheet ds
ArrayList< Integer > idx = new ArrayList<Integer>()
ArrayList< String > name = new ArrayList<String>()
ArrayList< Integer > type = new ArrayList<Integer>()
ArrayList< String > descr = new ArrayList<String>()
int[] resultOldPos = null
int[] resultNewPos = null
int[] resultType = null
String[] resultName = null
String[] resultDescr = null

Private Member Functions

void SetColumnModel ()
void ActionAppend ()
void ActionDelete ()
void ActionMove (int Dir)
void ActionAccept ()
void ActionReject ()

Detailed Description

Definition at line 27 of file DialogEditColumns.java.


Constructor & Destructor Documentation

WIMSchem.ds.DialogEditColumns.DialogEditColumns ( Frame  Parent,
DataSheet  DS 
) [inline]

Definition at line 42 of file DialogEditColumns.java.

    {
       super(Parent,"Edit Column Layout",true);
       ds=DS;
       
       setLayout(new BorderLayout());
       
       for (int n=0;n<ds.NumCols();n++)
       {
           idx.add(new Integer(n+1));
           name.add(ds.ColName(n));
           type.add(new Integer(ds.ColType(n)));
           descr.add(ds.ColDescr(n));
       }
       model=new SchemaDataModel(idx,name,type,descr);
       table=new JTable(model);
           
       SetColumnModel();
       
       JPanel buttons=new JPanel();
       buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
       bappend=new JButton("Append"); bappend.addActionListener(this); bappend.setMnemonic(KeyEvent.VK_P);
       bdelete=new JButton("Delete"); bdelete.addActionListener(this); bdelete.setMnemonic(KeyEvent.VK_D);
       bmoveup=new JButton("Move Up"); bmoveup.addActionListener(this); bmoveup.setMnemonic(KeyEvent.VK_U);
       bmovedn=new JButton("Move Down"); bmovedn.addActionListener(this); bmovedn.setMnemonic(KeyEvent.VK_N);
       baccept=new JButton("Accept"); baccept.addActionListener(this); baccept.setMnemonic(KeyEvent.VK_A);
       breject=new JButton("Reject"); breject.addActionListener(this); breject.setMnemonic(KeyEvent.VK_R);

       buttons.add(bappend);
       buttons.add(bdelete);
       buttons.add(bmoveup);
       buttons.add(bmovedn);
       buttons.add(baccept);
       buttons.add(breject);

       add(new JScrollPane(table),BorderLayout.CENTER);
       add(buttons,BorderLayout.SOUTH);
       
       pack();
    }

Here is the call graph for this function:


Member Function Documentation

void WIMSchem.ds.DialogEditColumns.ActionAccept ( ) [inline, private]

Definition at line 135 of file DialogEditColumns.java.

    {
       for (int n=0;n<idx.size();n++) if (name.get(n).length()==0)
       {
           JOptionPane.showMessageDialog(null,"All columns must be named.","Invalid",JOptionPane.ERROR_MESSAGE);
           return;
       }

       // count retained+new+deleted
       int nsz=ds.NumCols();
       boolean[] retained=new boolean[ds.NumCols()];
       for (int n=0;n<idx.size();n++) 
       {
           int i=idx.get(n).intValue();
           if (i==0) nsz++; else retained[i-1]=true;
       }
       
       // build up the indices: add the retained and new columns first, then the deleted columns
       int[] oldIdx=new int[nsz],newIdx=new int[nsz],newType=new int[nsz];
       String[] newName=new String[nsz],newDescr=new String[nsz];
       
       int pos=0;
       for (int n=0;n<idx.size();n++,pos++)
       {
           oldIdx[n]=idx.get(n).intValue()-1;
           newIdx[n]=pos;
           newName[n]=name.get(n);
           newType[n]=type.get(n).intValue();
           newDescr[n]=descr.get(n);
       }
       for (int n=0;n<retained.length;n++) if (!retained[n]) 
       {
           oldIdx[pos]=n;
           newIdx[pos]=-1;
           // (other fields left blank)
           pos++;
       }
       
       // make a string version of the to-do list
       String explan="";
       for (int n=0;n<oldIdx.length;n++)
       {
           if (oldIdx[n]<0 && newIdx[n]>=0)
           {
              explan+="New column: ["+newName[n]+"], type: "+DataSheet.TypeName(newType[n])+"\n";
           }
           else if (oldIdx[n]>=0 && newIdx[n]<0)
           {
              explan+="Delete column: ["+ds.ColName(oldIdx[n])+"]\n";
           }
           else if (oldIdx[n]>=0 && newIdx[n]>=0)
           {
              if (newName[n].compareTo(ds.ColName(oldIdx[n]))!=0)
                  explan+="Rename ["+ds.ColName(oldIdx[n])+"] to ["+newName[n]+"]\n";
              if (newDescr[n].compareTo(ds.ColDescr(oldIdx[n]))!=0)
                  explan+="Change description for ["+newName[n]+"]\n";
              if (ds.ColType(oldIdx[n])!=newType[n])
                  explan+="Change type of ["+newName[n]+"] to: "+DataSheet.TypeName(newType[n])+"\n";
              if (newIdx[n]!=oldIdx[n])
                  explan+="Reorder ["+newName[n]+"] from #"+(oldIdx[n]+1)+" to #"+(newIdx[n]+1)+"\n";
           }
       }
       if (explan.length()==0) {setVisible(false); return;} // nothing to do, equivalent to reject
       
       String opt[]={"Yes","No"};
       if (JOptionPane.showOptionDialog(null,explan,"Apply Changes?",
                  JOptionPane.YES_NO_OPTION,JOptionPane.YES_NO_OPTION,null,opt,opt[0])!=JOptionPane.YES_OPTION) return;

       resultOldPos=oldIdx;
       resultNewPos=newIdx;
       resultName=newName;
       resultType=newType;
       resultDescr=newDescr;
       setVisible(false);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void WIMSchem.ds.DialogEditColumns.ActionAppend ( ) [inline, private]

Definition at line 98 of file DialogEditColumns.java.

    {
       idx.add(0);
       name.add("");
       type.add(DataSheet.COLTYPE_STRING);
       descr.add("");
       model.fireTableStructureChanged();
       SetColumnModel();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void WIMSchem.ds.DialogEditColumns.ActionDelete ( ) [inline, private]

Definition at line 108 of file DialogEditColumns.java.

    {
       int i=table.getSelectedRow();
       if (i<0) return;
       idx.remove(i);
       name.remove(i);
       type.remove(i);
       descr.remove(i);
       model.fireTableStructureChanged();
       SetColumnModel();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void WIMSchem.ds.DialogEditColumns.ActionMove ( int  Dir) [inline, private]

Definition at line 120 of file DialogEditColumns.java.

    {
       int i=table.getSelectedRow();
       if (i<0 || i+Dir<0 || i+Dir>=idx.size()) return;

       idx.add(i+Dir,idx.remove(i));
       name.add(i+Dir,name.remove(i));
       type.add(i+Dir,type.remove(i));
       descr.add(i+Dir,descr.remove(i));

       model.fireTableStructureChanged();
       SetColumnModel();
       table.changeSelection(i+Dir,table.getSelectedColumn(),false,false);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void WIMSchem.ds.DialogEditColumns.actionPerformed ( ActionEvent  e) [inline]

Definition at line 229 of file DialogEditColumns.java.

    {
       if (e.getSource()==bappend) ActionAppend();
       else if (e.getSource()==bdelete) ActionDelete();
       else if (e.getSource()==bmoveup) ActionMove(-1);
       else if (e.getSource()==bmovedn) ActionMove(1);
       else if (e.getSource()==baccept) ActionAccept();
       else if (e.getSource()==breject) ActionReject();
    }

Here is the call graph for this function:

void WIMSchem.ds.DialogEditColumns.ActionReject ( ) [inline, private]

Definition at line 211 of file DialogEditColumns.java.

    {
       setVisible(false);
    }

Here is the caller graph for this function:

Definition at line 217 of file DialogEditColumns.java.

    {
       setVisible(true);
       return resultOldPos!=null;
    }

Here is the caller graph for this function:

Definition at line 227 of file DialogEditColumns.java.

{return resultDescr;}

Here is the caller graph for this function:

Definition at line 225 of file DialogEditColumns.java.

{return resultName;}

Here is the caller graph for this function:

Definition at line 224 of file DialogEditColumns.java.

{return resultNewPos;}

Here is the caller graph for this function:

Definition at line 223 of file DialogEditColumns.java.

{return resultOldPos;}

Here is the caller graph for this function:

Definition at line 226 of file DialogEditColumns.java.

{return resultType;}

Here is the caller graph for this function:

Definition at line 83 of file DialogEditColumns.java.

    {
       JComboBox colTypes=new JComboBox();
       colTypes.addItem(DataSheet.TypeName(DataSheet.COLTYPE_MOLECULE));
       colTypes.addItem(DataSheet.TypeName(DataSheet.COLTYPE_STRING));
       colTypes.addItem(DataSheet.TypeName(DataSheet.COLTYPE_REAL));
       colTypes.addItem(DataSheet.TypeName(DataSheet.COLTYPE_INTEGER));
       colTypes.addItem(DataSheet.TypeName(DataSheet.COLTYPE_BOOLEAN));
       table.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(colTypes));
       table.setPreferredScrollableViewportSize(new Dimension(350,200));
       table.getColumnModel().getColumn(0).setMaxWidth(40);
       table.getColumnModel().getColumn(1).setMaxWidth(150);
       table.getColumnModel().getColumn(2).setMaxWidth(100);
    }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 29 of file DialogEditColumns.java.

Definition at line 29 of file DialogEditColumns.java.

Definition at line 29 of file DialogEditColumns.java.

Definition at line 29 of file DialogEditColumns.java.

Definition at line 29 of file DialogEditColumns.java.

Definition at line 29 of file DialogEditColumns.java.

ArrayList<String> WIMSchem.ds.DialogEditColumns.descr = new ArrayList<String>() [package]

Definition at line 37 of file DialogEditColumns.java.

Definition at line 32 of file DialogEditColumns.java.

ArrayList<Integer> WIMSchem.ds.DialogEditColumns.idx = new ArrayList<Integer>() [package]

Definition at line 34 of file DialogEditColumns.java.

Definition at line 31 of file DialogEditColumns.java.

ArrayList<String> WIMSchem.ds.DialogEditColumns.name = new ArrayList<String>() [package]

Definition at line 35 of file DialogEditColumns.java.

String [] WIMSchem.ds.DialogEditColumns.resultDescr = null [package]

Definition at line 40 of file DialogEditColumns.java.

String [] WIMSchem.ds.DialogEditColumns.resultName = null [package]

Definition at line 40 of file DialogEditColumns.java.

Definition at line 39 of file DialogEditColumns.java.

Definition at line 39 of file DialogEditColumns.java.

Definition at line 39 of file DialogEditColumns.java.

Definition at line 30 of file DialogEditColumns.java.

ArrayList<Integer> WIMSchem.ds.DialogEditColumns.type = new ArrayList<Integer>() [package]

Definition at line 36 of file DialogEditColumns.java.


The documentation for this class was generated from the following file: