package data.stdforms;
import sale.*;
import data.*;
import data.swing.*;
import data.stdforms.twotableformsheet.*;
import users.*;
import util.swing.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
public class TwoTableFormSheet extends FormSheet {
private MoveStrategy m_ms;
private UIGate m_uigGate;
private transient util.swing.AbstractTableModel m_atmLeftModel;
private transient util.swing.AbstractTableModel m_atmRightModel;
private final int[] m_anLeftSelection = new int[] { -1 };
private final int[] m_anRightSelection = new int[] { -1 };
protected TwoTableFormSheet (String sCaption,
FormSheetContentCreator fscc,
UIGate uigGate,
MoveStrategy ms) {
super (sCaption,
(JComponent) null,
true);
m_ms = ms;
setGate (uigGate);
addContentCreator (fscc);
}
public Object getLeftSelectedRecord() {
return m_atmLeftModel.getRecord (m_anLeftSelection[0]);
}
public Object getRightSelectedRecord() {
return m_atmRightModel.getRecord (m_anRightSelection[0]);
}
public MoveStrategy getStrategy() {
return m_ms;
}
public void setStrategy (MoveStrategy ms) {
m_ms = ms;
}
public UIGate getGate() {
return m_uigGate;
}
public void setGate (UIGate uigGate) {
if (m_uigGate != null) {
m_uigGate.setFormSheet (null);
}
m_uigGate = uigGate;
if (m_uigGate != null) {
m_uigGate.setFormSheet (this);
}
}
public static TwoTableFormSheet create (String sCaption,
final CountingStock csSource,
final CountingStock csDest,
final DataBasket db,
UIGate uigGate,
final Comparator cmpSource,
final Comparator cmpDest,
final boolean fShowZerosSource,
final boolean fShowZerosDest,
final TableEntryDescriptor tedSource,
final TableEntryDescriptor tedDest,
CSCSStrategy cscssMoveStrategy) {
if (csSource.getCatalog (db) != csDest.getCatalog (db)) {
throw new CatalogConflictException();
}
FormSheetContentCreator fscc = new FormSheetContentCreator() {
protected void createFormSheetContent (FormSheet fs) {
final TwoTableFormSheet ttfs = (TwoTableFormSheet) fs;
final int[] anCounter = { 1 };
JCountingStockTable jcstSource = new JCountingStockTable (csSource,
db,
cmpSource,
fShowZerosSource,
((tedSource != null)?
(tedSource):
((csSource instanceof MoneyBag)?
(new DefaultMoneyBagItemTED ((Currency) csSource.getCatalog (db))):
(new DefaultCountingStockItemTED()))));
jcstSource.setSelectionObserver (ttfs.m_anLeftSelection);
final util.swing.AbstractTableModel atmSource = (util.swing.AbstractTableModel) jcstSource.getModel();
ttfs.m_atmLeftModel = atmSource;
JCountingStockTable jcstDest = new JCountingStockTable (csDest,
db,
cmpDest,
fShowZerosDest,
((tedDest != null)?
(tedDest):
((csDest instanceof MoneyBag)?
(new DefaultMoneyBagItemTED ((Currency) csDest.getCatalog (db))):
(new DefaultCountingStockItemTED()))));
jcstDest.setSelectionObserver (ttfs.m_anRightSelection);
final util.swing.AbstractTableModel atmDest = (util.swing.AbstractTableModel) jcstDest.getModel();
ttfs.m_atmRightModel = atmDest;
JTextField jtf = new JIntInput (anCounter, 1, 1, Integer.MAX_VALUE);
JButton jbRight = new JButton (getResourceText (BUTTON_RIGHT));
JButton jbLeft = new JButton (getResourceText (BUTTON_LEFT));
JPanel jpForm = new JPanel();
jpForm.setLayout (new BoxLayout (jpForm, BoxLayout.X_AXIS));
jpForm.add (new JScrollPane (jcstSource));
jpForm.add (createCentralBox (jbRight, jbLeft, jtf, ttfs.getStrategy()));
jpForm.add (new JScrollPane (jcstDest));
if (ttfs.getStrategy().canMoveToDest()) {
jbRight.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
CountingStockTableModel.Record r = (CountingStockTableModel.Record) atmSource.getRecord (ttfs.m_anLeftSelection[0]);
if (r != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((CSCSStrategy) ttfs.getStrategy()).getMoveToDestProcess (p, sp, csSource, csDest, db, r.getDescriptor(), anCounter[0], ttfs));
}
}
}
});
}
if (ttfs.getStrategy().canMoveToSource()) {
jbLeft.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
CountingStockTableModel.Record r = (CountingStockTableModel.Record) atmDest.getRecord (ttfs.m_anRightSelection[0]);
if (r != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((CSCSStrategy) ttfs.getStrategy()).getMoveToSourceProcess (p, sp, csSource, csDest, db, r.getDescriptor(), anCounter[0], ttfs));
}
}
}
});
}
fs.setComponent (jpForm);
}
};
cscssMoveStrategy = ((cscssMoveStrategy != null)?
(cscssMoveStrategy):
(new CSCSStrategy()));
return new TwoTableFormSheet (sCaption,
fscc,
uigGate,
cscssMoveStrategy);
}
public static TwoTableFormSheet create (String sCaption,
CountingStock csSource,
CountingStock csDest,
DataBasket db,
UIGate uigGate) {
return create (sCaption,
csSource,
csDest,
db,
uigGate,
null,
null,
false,
false,
null,
null,
null);
}
public static TwoTableFormSheet create (String sCaption,
final StoringStock ssSource,
final StoringStock ssDest,
final DataBasket db,
UIGate uigGate,
final Comparator cmpSource,
final Comparator cmpDest,
final TableEntryDescriptor tedSource,
final TableEntryDescriptor tedDest,
SSSSStrategy sssssMoveStrategy) {
FormSheetContentCreator fscc = new FormSheetContentCreator() {
protected void createFormSheetContent (FormSheet fs) {
final TwoTableFormSheet ttfs = (TwoTableFormSheet) fs;
JStoringStockTable jsstSource = new JStoringStockTable (ssSource,
db,
cmpSource,
((tedSource != null)?
(tedSource):
(new DefaultStockItemTED())));
jsstSource.setSelectionObserver (ttfs.m_anLeftSelection);
final util.swing.AbstractTableModel atmSource = (util.swing.AbstractTableModel) jsstSource.getModel();
ttfs.m_atmLeftModel = atmSource;
JStoringStockTable jsstDest = new JStoringStockTable (ssDest,
db,
cmpDest,
((tedDest != null)?
(tedDest):
(new DefaultStockItemTED())));
jsstDest.setSelectionObserver (ttfs.m_anRightSelection);
final util.swing.AbstractTableModel atmDest = (util.swing.AbstractTableModel) jsstDest.getModel();
ttfs.m_atmRightModel = atmDest;
JButton jbRight = new JButton (getResourceText (BUTTON_RIGHT));
JButton jbLeft = new JButton (getResourceText (BUTTON_LEFT));
JPanel jpForm = new JPanel();
jpForm.setLayout (new BoxLayout (jpForm, BoxLayout.X_AXIS));
jpForm.add (new JScrollPane (jsstSource));
jpForm.add (createCentralBox (jbRight, jbLeft, null, ttfs.getStrategy()));
jpForm.add (new JScrollPane (jsstDest));
if (ttfs.getStrategy().canMoveToDest()) {
jbRight.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
StockItem si = (StockItem) atmSource.getRecord (ttfs.m_anLeftSelection[0]);
if (si != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((SSSSStrategy) ttfs.getStrategy()).getMoveToDestProcess (p, sp, ssSource, ssDest, db, si, ttfs));
}
}
}
});
}
if (ttfs.getStrategy().canMoveToSource()) {
jbLeft.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
StockItem si = (StockItem) atmDest.getRecord (ttfs.m_anRightSelection[0]);
if (si != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((SSSSStrategy) ttfs.getStrategy()).getMoveToSourceProcess (p, sp, ssSource, ssDest, db, si, ttfs));
}
}
}
});
}
fs.setComponent (jpForm);
}
};
sssssMoveStrategy = ((sssssMoveStrategy != null)?
(sssssMoveStrategy):
(new SSSSStrategy()));
return new TwoTableFormSheet (sCaption,
fscc,
uigGate,
sssssMoveStrategy);
}
public static TwoTableFormSheet create (String sCaption,
StoringStock ssSource,
StoringStock ssDest,
DataBasket db,
UIGate uigGate) {
return create (sCaption,
ssSource,
ssDest,
db,
uigGate,
null,
null,
null,
null,
null);
}
public static TwoTableFormSheet create (String sCaption,
final CountingStock csSource,
final DataBasket dbDest,
UIGate uigGate,
final Comparator cmpSource,
final Comparator cmpDest,
final boolean fShowZeros,
final TableEntryDescriptor tedSource,
final TableEntryDescriptor tedDest,
CSDBStrategy csdbsMoveStrategy) {
FormSheetContentCreator fscc = new FormSheetContentCreator() {
protected void createFormSheetContent (FormSheet fs) {
final TwoTableFormSheet ttfs = (TwoTableFormSheet) fs;
final int[] anCounter = { 1 };
JCountingStockTable jcstSource = new JCountingStockTable (csSource,
dbDest,
cmpSource,
fShowZeros,
((tedSource != null)?
(tedSource):
((csSource instanceof MoneyBag)?
(new DefaultMoneyBagItemTED ((Currency) csSource.getCatalog (dbDest))):
(new DefaultCountingStockItemTED()))));
jcstSource.setSelectionObserver (ttfs.m_anLeftSelection);
final util.swing.AbstractTableModel atmSource = (util.swing.AbstractTableModel) jcstSource.getModel();
ttfs.m_atmLeftModel = atmSource;
JDataBasketTable jdbtDest = new JDataBasketTable (dbDest,
DataBasketConditionImpl.allStockItemsWithSource (csSource),
new CountingStockDBEGrouper(),
cmpDest,
((tedDest != null)?
(tedDest):
(new DefaultCountingStockDBETableEntryDescriptor())));
jdbtDest.setSelectionObserver (ttfs.m_anRightSelection);
final util.swing.AbstractTableModel atmDest = (util.swing.AbstractTableModel) jdbtDest.getModel();
ttfs.m_atmRightModel = atmDest;
JTextField jtf = new JIntInput (anCounter, 1, 1, Integer.MAX_VALUE);
JButton jbRight = new JButton (getResourceText (BUTTON_RIGHT));
JButton jbLeft = new JButton (getResourceText (BUTTON_LEFT));
JPanel jpForm = new JPanel();
jpForm.setLayout (new BoxLayout (jpForm, BoxLayout.X_AXIS));
jpForm.add (new JScrollPane (jcstSource));
jpForm.add (createCentralBox (jbRight, jbLeft, jtf, ttfs.getStrategy()));
jpForm.add (new JScrollPane (jdbtDest));
if (ttfs.getStrategy().canMoveToDest()) {
jbRight.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
CountingStockTableModel.Record r = (CountingStockTableModel.Record) atmSource.getRecord (ttfs.m_anLeftSelection[0]);
if (r != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((CSDBStrategy) ttfs.getStrategy()).getMoveToDestProcess (p, sp, csSource, dbDest, r.getDescriptor(), anCounter[0], ttfs));
}
}
}
});
}
if (ttfs.getStrategy().canMoveToSource()) {
jbLeft.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
DataBasketEntry dbe = (DataBasketEntry) atmDest.getRecord (ttfs.m_anRightSelection[0]);
if (dbe != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((CSDBStrategy) ttfs.getStrategy()).getMoveToSourceProcess (p, sp, csSource, dbDest, dbe, anCounter[0], ttfs));
}
}
}
});
}
fs.setComponent (jpForm);
}
};
csdbsMoveStrategy = ((csdbsMoveStrategy != null)?
(csdbsMoveStrategy):
(new CSDBStrategy()));
return new TwoTableFormSheet (sCaption,
fscc,
uigGate,
csdbsMoveStrategy);
}
public static TwoTableFormSheet create (String sCaption,
CountingStock csSource,
DataBasket dbDest,
UIGate uigGate) {
return create (sCaption,
csSource,
dbDest,
uigGate,
null,
null,
false,
null,
null,
null);
}
public static TwoTableFormSheet create (String sCaption,
final DataBasket dbSource,
final CountingStock csDest,
UIGate uigGate,
final Comparator cmpSource,
final Comparator cmpDest,
final boolean fShowZeros,
final TableEntryDescriptor tedSource,
final TableEntryDescriptor tedDest,
DBCSStrategy dbcssMoveStrategy) {
FormSheetContentCreator fscc = new FormSheetContentCreator() {
protected void createFormSheetContent (FormSheet fs) {
final TwoTableFormSheet ttfs = (TwoTableFormSheet) fs;
final int[] anCounter = { 1 };
JDataBasketTable jdbtSource = new JDataBasketTable (dbSource,
new DataBasketConditionImpl (DataBasketKeys.STOCK_ITEM_MAIN_KEY,
null,
null,
null,
null) {
public boolean match (DataBasketEntry dbe) {
return (dbe.getDestination() == null);
}
},
new CountingStockDBEGrouper(),
cmpSource,
((tedSource != null)?
(tedSource):
(new DefaultCountingStockDBETableEntryDescriptor())));
jdbtSource.setSelectionObserver (ttfs.m_anLeftSelection);
final util.swing.AbstractTableModel atmSource = (util.swing.AbstractTableModel) jdbtSource.getModel();
ttfs.m_atmLeftModel = atmSource;
JCountingStockTable jcstDest = new JCountingStockTable (csDest,
dbSource,
cmpDest,
fShowZeros,
((tedDest != null)?
(tedDest):
((csDest instanceof MoneyBag)?
(new DefaultMoneyBagItemTED ((Currency) csDest.getCatalog (dbSource))):
(new DefaultCountingStockItemTED()))));
jcstDest.setSelectionObserver (ttfs.m_anRightSelection);
final util.swing.AbstractTableModel atmDest = (util.swing.AbstractTableModel) jcstDest.getModel();
ttfs.m_atmRightModel = atmDest;
JTextField jtf = new JIntInput (anCounter, 1, 1, Integer.MAX_VALUE);
JButton jbRight = new JButton (getResourceText (BUTTON_RIGHT));
JButton jbLeft = new JButton (getResourceText (BUTTON_LEFT));
JPanel jpForm = new JPanel();
jpForm.setLayout (new BoxLayout (jpForm, BoxLayout.X_AXIS));
jpForm.add (new JScrollPane (jdbtSource));
jpForm.add (createCentralBox (jbRight, jbLeft, jtf, ttfs.getStrategy()));
jpForm.add (new JScrollPane (jcstDest));
if (ttfs.getStrategy().canMoveToDest()) {
jbRight.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
DataBasketEntry dbe = (DataBasketEntry) atmSource.getRecord (ttfs.m_anLeftSelection[0]);
if (dbe != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((DBCSStrategy) ttfs.getStrategy()).getMoveToDestProcess (p, sp, dbSource, csDest, dbe, anCounter[0], ttfs));
}
}
}
});
}
if (ttfs.getStrategy().canMoveToSource()) {
jbLeft.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
CountingStockTableModel.Record r = (CountingStockTableModel.Record) atmDest.getRecord (ttfs.m_anRightSelection[0]);
if (r != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((DBCSStrategy) ttfs.getStrategy()).getMoveToSourceProcess (p, sp, dbSource, csDest, r.getDescriptor(), anCounter[0], ttfs));
}
}
}
});
}
fs.setComponent (jpForm);
}
};
dbcssMoveStrategy = ((dbcssMoveStrategy != null)?
(dbcssMoveStrategy):
(new DBCSStrategy()));
return new TwoTableFormSheet (sCaption,
fscc,
uigGate,
dbcssMoveStrategy);
}
public static TwoTableFormSheet create (String sCaption,
DataBasket dbSource,
CountingStock csDest,
UIGate uigGate) {
return create (sCaption,
dbSource,
csDest,
uigGate,
null,
null,
false,
null,
null,
null);
}
public static TwoTableFormSheet create (String sCaption,
final StoringStock ssSource,
final DataBasket dbDest,
UIGate uigGate,
final Comparator cmpSource,
final Comparator cmpDest,
final TableEntryDescriptor tedSource,
final TableEntryDescriptor tedDest,
SSDBStrategy ssdbsMoveStrategy) {
FormSheetContentCreator fscc = new FormSheetContentCreator() {
protected void createFormSheetContent (FormSheet fs) {
final TwoTableFormSheet ttfs = (TwoTableFormSheet) fs;
JStoringStockTable jsstSource = new JStoringStockTable (ssSource,
dbDest,
cmpSource,
((tedSource != null)?
(tedSource):
(new DefaultStockItemTED())));
jsstSource.setSelectionObserver (ttfs.m_anLeftSelection);
final util.swing.AbstractTableModel atmSource = (util.swing.AbstractTableModel) jsstSource.getModel();
ttfs.m_atmLeftModel = atmSource;
JDataBasketTable jdbtDest = new JDataBasketTable (dbDest,
DataBasketConditionImpl.allStockItemsWithSource (ssSource),
NOPDataBasketEntryGrouper.NO_GROUPS,
cmpDest,
((tedDest != null)?
(tedDest):
(new DefaultStoringStockDBETableEntryDescriptor())));
jdbtDest.setSelectionObserver (ttfs.m_anRightSelection);
final util.swing.AbstractTableModel atmDest = (util.swing.AbstractTableModel) jdbtDest.getModel();
ttfs.m_atmRightModel = atmDest;
JButton jbRight = new JButton (getResourceText (BUTTON_RIGHT));
JButton jbLeft = new JButton (getResourceText (BUTTON_LEFT));
JPanel jpForm = new JPanel();
jpForm.setLayout (new BoxLayout (jpForm, BoxLayout.X_AXIS));
jpForm.add (new JScrollPane (jsstSource));
jpForm.add (createCentralBox (jbRight, jbLeft, null, ttfs.getStrategy()));
jpForm.add (new JScrollPane (jdbtDest));
if (ttfs.getStrategy().canMoveToDest()) {
jbRight.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
final StockItem si = (StockItem) atmSource.getRecord (ttfs.m_anLeftSelection[0]);
if (si != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((SSDBStrategy) ttfs.getStrategy()).getMoveToDestProcess (p, sp, ssSource, dbDest, si, ttfs));
}
}
}
});
}
if (ttfs.getStrategy().canMoveToSource()) {
jbLeft.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
final DataBasketEntry dbe = (DataBasketEntry) atmDest.getRecord (ttfs.m_anRightSelection[0]);
if (dbe != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((SSDBStrategy) ttfs.getStrategy()).getMoveToSourceProcess (p, sp, ssSource, dbDest, dbe, ttfs));
}
}
}
});
}
fs.setComponent (jpForm);
}
};
ssdbsMoveStrategy = ((ssdbsMoveStrategy != null)?
(ssdbsMoveStrategy):
(new SSDBStrategy()));
return new TwoTableFormSheet (sCaption,
fscc,
uigGate,
ssdbsMoveStrategy);
}
public static TwoTableFormSheet create (String sCaption,
StoringStock ssSource,
DataBasket dbDest,
UIGate uigGate) {
return create (sCaption,
ssSource,
dbDest,
uigGate,
null,
null,
null,
null,
null);
}
public static TwoTableFormSheet create (String sCaption,
final DataBasket dbSource,
final StoringStock ssDest,
UIGate uigGate,
final Comparator cmpSource,
final Comparator cmpDest,
final TableEntryDescriptor tedSource,
final TableEntryDescriptor tedDest,
DBSSStrategy dbsssMoveStrategy) {
FormSheetContentCreator fscc = new FormSheetContentCreator() {
protected void createFormSheetContent (FormSheet fs) {
final TwoTableFormSheet ttfs = (TwoTableFormSheet) fs;
JDataBasketTable jdbtSource = new JDataBasketTable (dbSource,
new DataBasketConditionImpl (DataBasketKeys.STOCK_ITEM_MAIN_KEY,
null,
null,
null,
null) {
public boolean match (DataBasketEntry dbe) {
return (dbe.getDestination() == null);
}
},
NOPDataBasketEntryGrouper.NO_GROUPS,
cmpSource,
((tedSource != null)?
(tedSource):
(new DefaultStoringStockDBETableEntryDescriptor())));
jdbtSource.setSelectionObserver (ttfs.m_anLeftSelection);
final util.swing.AbstractTableModel atmSource = (util.swing.AbstractTableModel) jdbtSource.getModel();
ttfs.m_atmLeftModel = atmSource;
JStoringStockTable jsstDest = new JStoringStockTable (ssDest,
dbSource,
cmpDest,
((tedDest != null)?
(tedDest):
(new DefaultStockItemTED())));
jsstDest.setSelectionObserver (ttfs.m_anRightSelection);
final util.swing.AbstractTableModel atmDest = (util.swing.AbstractTableModel) jsstDest.getModel();
ttfs.m_atmRightModel = atmDest;
JButton jbRight = new JButton (getResourceText (BUTTON_RIGHT));
JButton jbLeft = new JButton (getResourceText (BUTTON_LEFT));
JPanel jpForm = new JPanel();
jpForm.setLayout (new BoxLayout (jpForm, BoxLayout.X_AXIS));
jpForm.add (new JScrollPane (jdbtSource));
jpForm.add (createCentralBox (jbRight, jbLeft, null, ttfs.getStrategy()));
jpForm.add (new JScrollPane (jsstDest));
if (ttfs.getStrategy().canMoveToDest()) {
jbRight.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
final DataBasketEntry dbe = (DataBasketEntry) atmSource.getRecord (ttfs.m_anLeftSelection[0]);
if (dbe != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((DBSSStrategy) ttfs.getStrategy()).getMoveToDestProcess (p, sp, dbSource, ssDest, dbe, ttfs));
}
}
}
});
}
if (ttfs.getStrategy().canMoveToSource()) {
jbLeft.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
final StockItem si = (StockItem) atmDest.getRecord (ttfs.m_anRightSelection[0]);
if (si != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((DBSSStrategy) ttfs.getStrategy()).getMoveToSourceProcess (p, sp, dbSource, ssDest, si, ttfs));
}
}
}
});
}
fs.setComponent (jpForm);
}
};
dbsssMoveStrategy = ((dbsssMoveStrategy != null)?
(dbsssMoveStrategy):
(new DBSSStrategy()));
return new TwoTableFormSheet (sCaption,
fscc,
uigGate,
dbsssMoveStrategy);
}
public static TwoTableFormSheet create (String sCaption,
DataBasket dbSource,
StoringStock ssDest,
UIGate uigGate) {
return create (sCaption,
dbSource,
ssDest,
uigGate,
null,
null,
null,
null,
null);
}
public static TwoTableFormSheet create (String sCaption,
final Catalog cSource,
final Catalog cDest,
final DataBasket db,
UIGate uigGate,
final Comparator cmpSource,
final Comparator cmpDest,
final TableEntryDescriptor tedSource,
final TableEntryDescriptor tedDest,
CCStrategy ccsMoveStrategy) {
FormSheetContentCreator fscc = new FormSheetContentCreator() {
protected void createFormSheetContent (FormSheet fs) {
final TwoTableFormSheet ttfs = (TwoTableFormSheet) fs;
JCatalogTable jctSource = new JCatalogTable (cSource,
db,
cmpSource,
((tedSource != null)?
(tedSource):
((cSource instanceof Currency)?
(new DefaultCurrencyItemTED ((Currency) cSource)):
(new DefaultCatalogItemTED()))));
jctSource.setSelectionObserver (ttfs.m_anLeftSelection);
final util.swing.AbstractTableModel atmSource = (util.swing.AbstractTableModel) jctSource.getModel();
ttfs.m_atmLeftModel = atmSource;
JCatalogTable jctDest = new JCatalogTable (cDest,
db,
cmpDest,
((tedDest != null)?
(tedDest):
((cDest instanceof Currency)?
(new DefaultCurrencyItemTED ((Currency) cDest)):
(new DefaultCatalogItemTED()))));
jctDest.setSelectionObserver (ttfs.m_anRightSelection);
final util.swing.AbstractTableModel atmDest = (util.swing.AbstractTableModel) jctDest.getModel();
ttfs.m_atmRightModel = atmDest;
JButton jbRight = new JButton (getResourceText (BUTTON_RIGHT));
JButton jbLeft = new JButton (getResourceText (BUTTON_LEFT));
JPanel jpForm = new JPanel();
jpForm.setLayout (new BoxLayout (jpForm, BoxLayout.X_AXIS));
jpForm.add (new JScrollPane (jctSource));
jpForm.add (createCentralBox (jbRight, jbLeft, null, ttfs.getStrategy()));
jpForm.add (new JScrollPane (jctDest));
if (ttfs.getStrategy().canMoveToDest()) {
jbRight.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
final CatalogItem ci = (CatalogItem) atmSource.getRecord (ttfs.m_anLeftSelection[0]);
if (ci != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((CCStrategy) ttfs.getStrategy()).getMoveToDestProcess (p, sp, cSource, cDest, db, ci, ttfs));
}
}
}
});
}
if (ttfs.getStrategy().canMoveToSource()) {
jbLeft.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
final CatalogItem ci = (CatalogItem) atmDest.getRecord (ttfs.m_anRightSelection[0]);
if (ci != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((CCStrategy) ttfs.getStrategy()).getMoveToSourceProcess (p, sp, cSource, cDest, db, ci, ttfs));
}
}
}
});
}
fs.setComponent (jpForm);
}
};
ccsMoveStrategy = ((ccsMoveStrategy != null)?
(ccsMoveStrategy):
(new CCStrategy()));
return new TwoTableFormSheet (sCaption,
fscc,
uigGate,
ccsMoveStrategy);
}
public static TwoTableFormSheet create (String sCaption,
Catalog cSource,
Catalog cDest,
DataBasket db,
UIGate uigGate) {
return create (sCaption,
cSource,
cDest,
db,
uigGate,
null,
null,
null,
null,
null);
}
public static TwoTableFormSheet create (String sCaption,
final Catalog cSource,
final DataBasket dbDest,
UIGate uigGate,
final Comparator cmpSource,
final Comparator cmpDest,
final TableEntryDescriptor tedSource,
final TableEntryDescriptor tedDest,
CDBStrategy cdbsMoveStrategy) {
FormSheetContentCreator fscc = new FormSheetContentCreator() {
protected void createFormSheetContent (FormSheet fs) {
final TwoTableFormSheet ttfs = (TwoTableFormSheet) fs;
JCatalogTable jctSource = new JCatalogTable (cSource,
dbDest,
cmpSource,
((tedSource != null)?
(tedSource):
((cSource instanceof Currency)?
(new DefaultCurrencyItemTED ((Currency) cSource)):
(new DefaultCatalogItemTED()))));
jctSource.setSelectionObserver (ttfs.m_anLeftSelection);
final util.swing.AbstractTableModel atmSource = (util.swing.AbstractTableModel) jctSource.getModel();
ttfs.m_atmLeftModel = atmSource;
JDataBasketTable jdbtDest = new JDataBasketTable (dbDest,
DataBasketConditionImpl.allCatalogItemsWithSource (cSource),
null,
cmpDest,
((tedDest != null)?
(tedDest):
(new DefaultCatalogItemDBETableEntryDescriptor())));
jdbtDest.setSelectionObserver (ttfs.m_anRightSelection);
final util.swing.AbstractTableModel atmDest = (util.swing.AbstractTableModel) jdbtDest.getModel();
ttfs.m_atmRightModel = atmDest;
JButton jbRight = new JButton (getResourceText (BUTTON_RIGHT));
JButton jbLeft = new JButton (getResourceText (BUTTON_LEFT));
JPanel jpForm = new JPanel();
jpForm.setLayout (new BoxLayout (jpForm, BoxLayout.X_AXIS));
jpForm.add (new JScrollPane (jctSource));
jpForm.add (createCentralBox (jbRight, jbLeft, null, ttfs.getStrategy()));
jpForm.add (new JScrollPane (jdbtDest));
if (ttfs.getStrategy().canMoveToDest()) {
jbRight.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
CatalogItem ci = (CatalogItem) atmSource.getRecord (ttfs.m_anLeftSelection[0]);
if (ci != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((CDBStrategy) ttfs.getStrategy()).getMoveToDestProcess (p, sp, cSource, dbDest, ci, ttfs));
}
}
}
});
}
if (ttfs.getStrategy().canMoveToSource()) {
jbLeft.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
DataBasketEntry dbe = (DataBasketEntry) atmDest.getRecord (ttfs.m_anRightSelection[0]);
if (dbe != null) {
CatalogItem ci = (CatalogItem) dbe.getValue();
if (ci != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((CDBStrategy) ttfs.getStrategy()).getMoveToSourceProcess (p, sp, cSource, dbDest, ci, ttfs));
}
}
}
}
});
}
fs.setComponent (jpForm);
}
};
cdbsMoveStrategy = ((cdbsMoveStrategy != null)?
(cdbsMoveStrategy):
(new CDBStrategy()));
return new TwoTableFormSheet (sCaption,
fscc,
uigGate,
cdbsMoveStrategy);
}
public static TwoTableFormSheet create (String sCaption,
final Catalog cSource,
final DataBasket dbDest,
UIGate uigGate) {
return create (sCaption,
cSource,
dbDest,
uigGate,
null,
null,
null,
null,
null);
}
public static TwoTableFormSheet create (String sCaption,
final DataBasket dbSource,
final Catalog cDest,
UIGate uigGate,
final Comparator cmpSource,
final Comparator cmpDest,
final TableEntryDescriptor tedSource,
final TableEntryDescriptor tedDest,
DBCStrategy dbcsMoveStrategy) {
FormSheetContentCreator fscc = new FormSheetContentCreator() {
protected void createFormSheetContent (FormSheet fs) {
final TwoTableFormSheet ttfs = (TwoTableFormSheet) fs;
JDataBasketTable jdbtSource = new JDataBasketTable (dbSource,
new DataBasketConditionImpl (DataBasketKeys.CATALOG_ITEM_MAIN_KEY,
null,
null,
null,
null) {
public boolean match (DataBasketEntry dbe) {
return (dbe.getDestination() == null);
}
},
null,
cmpSource,
((tedSource != null)?
(tedSource):
(new DefaultCountingStockDBETableEntryDescriptor())));
jdbtSource.setSelectionObserver (ttfs.m_anLeftSelection);
final util.swing.AbstractTableModel atmSource = (util.swing.AbstractTableModel) jdbtSource.getModel();
ttfs.m_atmLeftModel = atmSource;
JCatalogTable jctDest = new JCatalogTable (cDest,
dbSource,
cmpDest,
((tedDest != null)?
(tedDest):
((cDest instanceof Currency)?
(new DefaultCurrencyItemTED ((Currency) cDest)):
(new DefaultCatalogItemTED()))));
jctDest.setSelectionObserver (ttfs.m_anRightSelection);
final util.swing.AbstractTableModel atmDest = (util.swing.AbstractTableModel) jctDest.getModel();
ttfs.m_atmRightModel = atmDest;
JButton jbRight = new JButton (getResourceText (BUTTON_RIGHT));
JButton jbLeft = new JButton (getResourceText (BUTTON_LEFT));
JPanel jpForm = new JPanel();
jpForm.setLayout (new BoxLayout (jpForm, BoxLayout.X_AXIS));
jpForm.add (new JScrollPane (jdbtSource));
jpForm.add (createCentralBox (jbRight, jbLeft, null, ttfs.getStrategy()));
jpForm.add (new JScrollPane (jctDest));
if (ttfs.getStrategy().canMoveToDest()) {
jbRight.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
CatalogItem ci = (CatalogItem) ((DataBasketEntry) atmSource.getRecord (ttfs.m_anLeftSelection[0])).getValue();
if (ci != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((DBCStrategy) ttfs.getStrategy()).getMoveToDestProcess (p, sp, dbSource, cDest, ci, ttfs));
}
}
}
});
}
if (ttfs.getStrategy().canMoveToSource()) {
jbLeft.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
CatalogItem ci = (CatalogItem) atmDest.getRecord (ttfs.m_anRightSelection[0]);
if (ci != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((DBCStrategy) ttfs.getStrategy()).getMoveToSourceProcess (p, sp, dbSource, cDest, ci, ttfs));
}
}
}
});
}
fs.setComponent (jpForm);
}
};
dbcsMoveStrategy = ((dbcsMoveStrategy != null)?
(dbcsMoveStrategy):
(new DBCStrategy()));
return new TwoTableFormSheet (sCaption,
fscc,
uigGate,
dbcsMoveStrategy);
}
public static TwoTableFormSheet create (String sCaption,
DataBasket dbSource,
Catalog cDest,
UIGate uigGate) {
return create (sCaption,
dbSource,
cDest,
uigGate,
null,
null,
null,
null,
null);
}
public static TwoTableFormSheet create (String sCaption,
final Catalog cSource,
final StoringStock ssDest,
final DataBasket db,
UIGate uigGate,
final Comparator cmpSource,
final Comparator cmpDest,
final TableEntryDescriptor tedSource,
final TableEntryDescriptor tedDest,
CSSStrategy csssMoveStrategy) {
FormSheetContentCreator fscc = new FormSheetContentCreator() {
protected void createFormSheetContent (FormSheet fs) {
final TwoTableFormSheet ttfs = (TwoTableFormSheet) fs;
JCatalogTable jctSource = new JCatalogTable (cSource,
db,
cmpSource,
((tedSource != null)?
(tedSource):
((cSource instanceof Currency)?
(new DefaultCurrencyItemTED ((Currency) cSource)):
(new DefaultCatalogItemTED()))));
jctSource.setSelectionObserver (ttfs.m_anLeftSelection);
final util.swing.AbstractTableModel atmSource = (util.swing.AbstractTableModel) jctSource.getModel();
ttfs.m_atmLeftModel = atmSource;
JStoringStockTable jsstDest = new JStoringStockTable (ssDest,
db,
cmpDest,
((tedDest != null)?
(tedDest):
(new DefaultStockItemTED())));
jsstDest.setSelectionObserver (ttfs.m_anRightSelection);
final util.swing.AbstractTableModel atmDest = (util.swing.AbstractTableModel) jsstDest.getModel();
ttfs.m_atmRightModel = atmDest;
JButton jbRight = new JButton (getResourceText (BUTTON_RIGHT));
JButton jbLeft = new JButton (getResourceText (BUTTON_LEFT));
JPanel jpForm = new JPanel();
jpForm.setLayout (new BoxLayout (jpForm, BoxLayout.X_AXIS));
jpForm.add (new JScrollPane (jctSource));
jpForm.add (createCentralBox (jbRight, jbLeft, null, ttfs.getStrategy()));
jpForm.add (new JScrollPane (jsstDest));
if (ttfs.getStrategy().canMoveToDest()) {
jbRight.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
CatalogItem ci = (CatalogItem) atmSource.getRecord (ttfs.m_anLeftSelection[0]);
if (ci != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((CSSStrategy) ttfs.getStrategy()).getMoveToDestProcess (p, sp, cSource, ssDest, db, ci, ttfs));
}
}
}
});
}
if (ttfs.getStrategy().canMoveToSource()) {
jbLeft.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
StockItem si = (StockItem) atmDest.getRecord (ttfs.m_anRightSelection[0]);
if (si != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((CSSStrategy) ttfs.getStrategy()).getMoveToSourceProcess (p, sp, cSource, ssDest, db, si, ttfs));
}
}
}
});
}
fs.setComponent (jpForm);
}
};
return new TwoTableFormSheet (sCaption,
fscc,
uigGate,
csssMoveStrategy);
}
public static TwoTableFormSheet create (String sCaption,
Catalog cSource,
StoringStock ssDest,
DataBasket db,
UIGate uigGate,
CSSStrategy csssMoveStrategy) {
return create (sCaption,
cSource,
ssDest,
db,
uigGate,
null,
null,
null,
null,
csssMoveStrategy);
}
public static TwoTableFormSheet create (String sCaption,
final Catalog cSource,
final CountingStock csDest,
final DataBasket db,
UIGate uigGate,
final Comparator cmpSource,
final Comparator cmpDest,
final boolean fShowZeros,
final TableEntryDescriptor tedSource,
final TableEntryDescriptor tedDest,
CCSStrategy ccssMoveStrategy) {
FormSheetContentCreator fscc = new FormSheetContentCreator() {
protected void createFormSheetContent (FormSheet fs) {
final TwoTableFormSheet ttfs = (TwoTableFormSheet) fs;
final int[] anCounter = { 1 };
JCatalogTable jctSource = new JCatalogTable (cSource,
db,
cmpSource,
((tedSource != null)?
(tedSource):
((cSource instanceof Currency)?
(new DefaultCurrencyItemTED ((Currency) cSource)):
(new DefaultCatalogItemTED()))));
jctSource.setSelectionObserver (ttfs.m_anLeftSelection);
final util.swing.AbstractTableModel atmSource = (util.swing.AbstractTableModel) jctSource.getModel();
ttfs.m_atmLeftModel = atmSource;
JCountingStockTable jcstDest = new JCountingStockTable (csDest,
db,
cmpDest,
fShowZeros,
((tedDest != null)?
(tedDest):
((csDest instanceof MoneyBag)?
(new DefaultMoneyBagItemTED ((Currency) csDest.getCatalog (db))):
(new DefaultCountingStockItemTED()))));
jcstDest.setSelectionObserver (ttfs.m_anRightSelection);
final util.swing.AbstractTableModel atmDest = (util.swing.AbstractTableModel) jcstDest.getModel();
ttfs.m_atmRightModel = atmDest;
JTextField jtf = new JIntInput (anCounter, 1, 1, Integer.MAX_VALUE);
JButton jbRight = new JButton (getResourceText (BUTTON_RIGHT));
JButton jbLeft = new JButton (getResourceText (BUTTON_LEFT));
JPanel jpForm = new JPanel();
jpForm.setLayout (new BoxLayout (jpForm, BoxLayout.X_AXIS));
jpForm.add (new JScrollPane (jctSource));
jpForm.add (createCentralBox (jbRight, jbLeft, jtf, ttfs.getStrategy()));
jpForm.add (new JScrollPane (jcstDest));
if (ttfs.getStrategy().canMoveToDest()) {
jbRight.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
CatalogItem ci = (CatalogItem) atmSource.getRecord (ttfs.m_anLeftSelection[0]);
if (ci != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((CCSStrategy) ttfs.getStrategy()).getMoveToDestProcess (p, sp, cSource, csDest, db, ci, anCounter[0], ttfs));
}
}
}
});
}
if (ttfs.getStrategy().canMoveToSource()) {
jbLeft.addActionListener (new ActionActionListener (fs) {
public void doAction (SaleProcess p, final SalesPoint sp) {
CountingStockTableModel.Record r = (CountingStockTableModel.Record) atmDest.getRecord (ttfs.m_anRightSelection[0]);
if (r != null) {
UIGate uig = ttfs.getGate();
if (uig != null) {
uig.setNextTransition (((CCSStrategy) ttfs.getStrategy()).getMoveToSourceProcess (p, sp, cSource, csDest, db, r.getDescriptor(), anCounter[0], ttfs));
}
}
}
});
}
fs.setComponent (jpForm);
}
};
ccssMoveStrategy = ((ccssMoveStrategy != null)?
(ccssMoveStrategy):
(new CCSStrategy()));
return new TwoTableFormSheet (sCaption,
fscc,
uigGate,
ccssMoveStrategy);
}
public static TwoTableFormSheet create (String sCaption,
Catalog cSource,
CountingStock csDest,
DataBasket db,
UIGate uigGate) {
return create (sCaption,
cSource,
csDest,
db,
uigGate,
null,
null,
false,
null,
null,
null);
}
private static final Box createCentralBox (JButton jbRight,
JButton jbLeft,
JTextField jtf,
MoveStrategy ms) {
Box b = Box.createVerticalBox();
b.add (Box.createGlue());
if (jtf != null) {
jtf.setMaximumSize (new java.awt.Dimension (jbRight.getMaximumSize().width * 2 - 1, jtf.getMinimumSize().height));
b.add (jtf);
}
if (ms.canMoveToDest()) {
b.add (jbRight);
}
if (ms.canMoveToSource()) {
b.add (jbLeft);
}
b.add (Box.createGlue());
Box bButtonBar = Box.createHorizontalBox();
bButtonBar.add (Box.createGlue());
bButtonBar.add (b);
bButtonBar.add (Box.createGlue());
return bButtonBar;
}
public static final String BUTTON_LEFT = "2TableFormSheet.button.left";
public static final String BUTTON_RIGHT = "2TableFormSheet.button.right";
private static ResourceBundle s_rbTexts = new ListResourceBundle() {
protected Object[][] getContents() {
return s_aaoContents;
}
private final Object[][] s_aaoContents = {
{BUTTON_RIGHT, ">>"},
{BUTTON_LEFT, "<<"}
};
};
private static final Object s_oResourceLock = new Object();
public static final void setTextResource (ResourceBundle rb) {
synchronized (s_oResourceLock) {
s_rbTexts = rb;
}
}
public static final String getResourceText (String sKey) {
synchronized (s_oResourceLock) {
return s_rbTexts.getString (sKey);
}
}
}