* [ 1798539 ] Cannot Save a User Query
* Some UI changes for the new collapse grid features. Victor, please let me know if you don't like some of the changes.
This commit is contained in:
parent
d7ea4de2f5
commit
ff19a0323c
|
@ -7,5 +7,6 @@
|
||||||
<classpathentry kind="src" path="/looks"/>
|
<classpathentry kind="src" path="/looks"/>
|
||||||
<classpathentry kind="lib" path="/tools/lib/jfreechart-1.0.2.jar"/>
|
<classpathentry kind="lib" path="/tools/lib/jfreechart-1.0.2.jar"/>
|
||||||
<classpathentry kind="lib" path="/tools/lib/jcommon-1.0.5.jar"/>
|
<classpathentry kind="lib" path="/tools/lib/jcommon-1.0.5.jar"/>
|
||||||
|
<classpathentry kind="lib" path="/tools/lib/swinglabs-0.8.0.jar"/>
|
||||||
<classpathentry kind="output" path="build"/>
|
<classpathentry kind="output" path="build"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -169,7 +169,11 @@ public final class APanel extends CPanel
|
||||||
// tabPanel
|
// tabPanel
|
||||||
mainLayout.setHgap(2);
|
mainLayout.setHgap(2);
|
||||||
mainLayout.setVgap(2);
|
mainLayout.setVgap(2);
|
||||||
this.add(tabPanel, BorderLayout.CENTER);
|
CPanel dummy = new CPanel();
|
||||||
|
dummy.setLayout(new BorderLayout());
|
||||||
|
dummy.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
|
||||||
|
dummy.add(tabPanel, BorderLayout.CENTER);
|
||||||
|
this.add(dummy, BorderLayout.CENTER);
|
||||||
// southPanel
|
// southPanel
|
||||||
this.add(statusBar, BorderLayout.SOUTH);
|
this.add(statusBar, BorderLayout.SOUTH);
|
||||||
// northPanel
|
// northPanel
|
||||||
|
@ -819,7 +823,7 @@ public final class APanel extends CPanel
|
||||||
{
|
{
|
||||||
GridField[] findFields = mTab.getFields();
|
GridField[] findFields = mTab.getFields();
|
||||||
Find find = new Find (Env.getFrame(this), m_curWindowNo, mTab.getName(),
|
Find find = new Find (Env.getFrame(this), m_curWindowNo, mTab.getName(),
|
||||||
mTab.getAD_Table_ID(), mTab.getTableName(),
|
mTab.getAD_Tab_ID(), mTab.getAD_Table_ID(), mTab.getTableName(),
|
||||||
where.toString(), findFields, 10); // no query below 10
|
where.toString(), findFields, 10); // no query below 10
|
||||||
query = find.getQuery();
|
query = find.getQuery();
|
||||||
isCancel = (query == null);//Goodwill
|
isCancel = (query == null);//Goodwill
|
||||||
|
@ -1934,7 +1938,7 @@ public final class APanel extends CPanel
|
||||||
// Gets Fields from AD_Field_v
|
// Gets Fields from AD_Field_v
|
||||||
GridField[] findFields = GridField.createFields(m_ctx, m_curWindowNo, 0, m_curTab.getAD_Tab_ID());
|
GridField[] findFields = GridField.createFields(m_ctx, m_curWindowNo, 0, m_curTab.getAD_Tab_ID());
|
||||||
Find find = new Find (Env.getFrame(this), m_curWindowNo, m_curTab.getName(),
|
Find find = new Find (Env.getFrame(this), m_curWindowNo, m_curTab.getName(),
|
||||||
m_curTab.getAD_Table_ID(), m_curTab.getTableName(),
|
m_curTab.getAD_Tab_ID(), m_curTab.getAD_Table_ID(), m_curTab.getTableName(),
|
||||||
m_curTab.getWhereExtended(), findFields, 1);
|
m_curTab.getWhereExtended(), findFields, 1);
|
||||||
MQuery query = find.getQuery();
|
MQuery query = find.getQuery();
|
||||||
find.dispose();
|
find.dispose();
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.math.*;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.event.*;
|
import javax.swing.event.*;
|
||||||
|
@ -42,6 +43,8 @@ import org.compiere.util.*;
|
||||||
public final class Find extends CDialog
|
public final class Find extends CDialog
|
||||||
implements ActionListener, ChangeListener, DataStatusListener
|
implements ActionListener, ChangeListener, DataStatusListener
|
||||||
{
|
{
|
||||||
|
private int m_AD_Tab_ID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find Constructor
|
* Find Constructor
|
||||||
* @param owner Frame Dialog Onwer
|
* @param owner Frame Dialog Onwer
|
||||||
|
@ -53,7 +56,7 @@ public final class Find extends CDialog
|
||||||
* @param findFields
|
* @param findFields
|
||||||
* @param minRecords number of minimum records
|
* @param minRecords number of minimum records
|
||||||
*/
|
*/
|
||||||
public Find (Frame owner, int targetWindowNo, String title,
|
public Find (Frame owner, int targetWindowNo, String title, int AD_Tab_ID,
|
||||||
int AD_Table_ID, String tableName, String whereExtended,
|
int AD_Table_ID, String tableName, String whereExtended,
|
||||||
GridField[] findFields, int minRecords)
|
GridField[] findFields, int minRecords)
|
||||||
{
|
{
|
||||||
|
@ -61,6 +64,7 @@ public final class Find extends CDialog
|
||||||
log.info(title);
|
log.info(title);
|
||||||
//
|
//
|
||||||
m_targetWindowNo = targetWindowNo;
|
m_targetWindowNo = targetWindowNo;
|
||||||
|
m_AD_Tab_ID = AD_Tab_ID; //red1 new field for UserQuery [ 1798539 ]
|
||||||
m_AD_Table_ID = AD_Table_ID;
|
m_AD_Table_ID = AD_Table_ID;
|
||||||
m_tableName = tableName;
|
m_tableName = tableName;
|
||||||
m_whereExtended = whereExtended;
|
m_whereExtended = whereExtended;
|
||||||
|
@ -140,6 +144,7 @@ public final class Find extends CDialog
|
||||||
private ConfirmPanel confirmPanelA = new ConfirmPanel(true, true, false, false, false, false, true);
|
private ConfirmPanel confirmPanelA = new ConfirmPanel(true, true, false, false, false, false, true);
|
||||||
private CButton bIgnore = new CButton();
|
private CButton bIgnore = new CButton();
|
||||||
private JToolBar toolBar = new JToolBar();
|
private JToolBar toolBar = new JToolBar();
|
||||||
|
private CComboBox fQueryName = new CComboBox();
|
||||||
private CButton bSave = new CButton();
|
private CButton bSave = new CButton();
|
||||||
private CButton bNew = new CButton();
|
private CButton bNew = new CButton();
|
||||||
private CButton bDelete = new CButton();
|
private CButton bDelete = new CButton();
|
||||||
|
@ -162,7 +167,30 @@ public final class Find extends CDialog
|
||||||
private Component spaceW;
|
private Component spaceW;
|
||||||
private Component spaceS;
|
private Component spaceS;
|
||||||
private JScrollPane advancedScrollPane = new JScrollPane();
|
private JScrollPane advancedScrollPane = new JScrollPane();
|
||||||
private CTable advancedTable = new CTable();
|
private CTable advancedTable = new CTable() {
|
||||||
|
public boolean isCellEditable(int row, int column)
|
||||||
|
{
|
||||||
|
boolean editable = ( column == INDEX_COLUMNNAME
|
||||||
|
|| column == INDEX_OPERATOR );
|
||||||
|
if (!editable && row >= 0)
|
||||||
|
{
|
||||||
|
String columnName = null;
|
||||||
|
Object value =
|
||||||
|
getModel().getValueAt(row, INDEX_COLUMNNAME);
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
if (value instanceof ValueNamePair)
|
||||||
|
columnName = ((ValueNamePair)value).getValue();
|
||||||
|
else
|
||||||
|
columnName = value.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create Editor
|
||||||
|
editable = getTargetMField(columnName) != null;
|
||||||
|
}
|
||||||
|
return editable;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/** Index ColumnName = 0 */
|
/** Index ColumnName = 0 */
|
||||||
public static final int INDEX_COLUMNNAME = 0;
|
public static final int INDEX_COLUMNNAME = 0;
|
||||||
|
@ -177,6 +205,11 @@ public final class Find extends CDialog
|
||||||
public CComboBox columns = null;
|
public CComboBox columns = null;
|
||||||
/** Advanced Search Operators */
|
/** Advanced Search Operators */
|
||||||
public CComboBox operators = null;
|
public CComboBox operators = null;
|
||||||
|
private MUserQuery[] userQueries;
|
||||||
|
private ValueNamePair[] columnValueNamePairs;
|
||||||
|
|
||||||
|
private static final String FIELD_SEPARATOR = "<^>";
|
||||||
|
private static final String SEGMENT_SEPARATOR = "<~>";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static Init.
|
* Static Init.
|
||||||
|
@ -204,6 +237,9 @@ public final class Find extends CDialog
|
||||||
bIgnore.setMargin(new Insets(2, 2, 2, 2));
|
bIgnore.setMargin(new Insets(2, 2, 2, 2));
|
||||||
bIgnore.setToolTipText(Msg.getMsg(Env.getCtx(),"Ignore"));
|
bIgnore.setToolTipText(Msg.getMsg(Env.getCtx(),"Ignore"));
|
||||||
bIgnore.addActionListener(this);
|
bIgnore.addActionListener(this);
|
||||||
|
fQueryName.setToolTipText (Msg.getMsg(Env.getCtx(),"QueryName"));
|
||||||
|
fQueryName.setEditable(true);
|
||||||
|
fQueryName.addActionListener(this);
|
||||||
bSave.setIcon(new ImageIcon(org.compiere.Adempiere.class.getResource("images/Save24.gif")));
|
bSave.setIcon(new ImageIcon(org.compiere.Adempiere.class.getResource("images/Save24.gif")));
|
||||||
bSave.setMargin(new Insets(2, 2, 2, 2));
|
bSave.setMargin(new Insets(2, 2, 2, 2));
|
||||||
bSave.setToolTipText(Msg.getMsg(Env.getCtx(),"Save"));
|
bSave.setToolTipText(Msg.getMsg(Env.getCtx(),"Save"));
|
||||||
|
@ -275,8 +311,9 @@ public final class Find extends CDialog
|
||||||
toolBar.add(bIgnore, null);
|
toolBar.add(bIgnore, null);
|
||||||
toolBar.addSeparator();
|
toolBar.addSeparator();
|
||||||
toolBar.add(bNew, null);
|
toolBar.add(bNew, null);
|
||||||
toolBar.add(bSave, null);
|
|
||||||
toolBar.add(bDelete, null);
|
toolBar.add(bDelete, null);
|
||||||
|
toolBar.add(fQueryName, null);
|
||||||
|
toolBar.add(bSave, null);
|
||||||
advancedPanel.setLayout(advancedLayout);
|
advancedPanel.setLayout(advancedLayout);
|
||||||
advancedPanel.add(toolBar, BorderLayout.NORTH);
|
advancedPanel.add(toolBar, BorderLayout.NORTH);
|
||||||
advancedPanel.add(confirmPanelA, BorderLayout.SOUTH);
|
advancedPanel.add(confirmPanelA, BorderLayout.SOUTH);
|
||||||
|
@ -300,6 +337,7 @@ public final class Find extends CDialog
|
||||||
cmd_cancel();
|
cmd_cancel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} // jbInit
|
} // jbInit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -419,8 +457,41 @@ public final class Find extends CDialog
|
||||||
{
|
{
|
||||||
log.config("");
|
log.config("");
|
||||||
advancedTable.setModel(new DefaultTableModel(0, 4));
|
advancedTable.setModel(new DefaultTableModel(0, 4));
|
||||||
advancedTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
|
advancedTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
|
advancedTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
|
||||||
|
advancedTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
|
||||||
|
|
||||||
|
TableCellRenderer renderer = new ProxyRenderer(advancedTable.getDefaultRenderer(Object.class));
|
||||||
|
advancedTable.setDefaultRenderer(Object.class, renderer);
|
||||||
|
|
||||||
|
InputMap im = advancedTable.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||||
|
KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
|
||||||
|
final Action tabAction = advancedTable.getActionMap().get(im.get(tab));
|
||||||
|
Action tabActionWrapper = new AbstractAction()
|
||||||
|
{
|
||||||
|
public void actionPerformed(ActionEvent e)
|
||||||
|
{
|
||||||
|
tabAction.actionPerformed(e);
|
||||||
|
|
||||||
|
JTable table = (JTable)e.getSource();
|
||||||
|
table.requestFocusInWindow();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
advancedTable.getActionMap().put(im.get(tab), tabActionWrapper);
|
||||||
|
KeyStroke shiftTab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK);
|
||||||
|
final Action shiftTabAction = advancedTable.getActionMap().get(im.get(shiftTab));
|
||||||
|
Action shiftTabActionWrapper = new AbstractAction()
|
||||||
|
{
|
||||||
|
public void actionPerformed(ActionEvent e)
|
||||||
|
{
|
||||||
|
shiftTabAction.actionPerformed(e);
|
||||||
|
|
||||||
|
JTable table = (JTable)e.getSource();
|
||||||
|
table.requestFocusInWindow();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
advancedTable.getActionMap().put(im.get(shiftTab), shiftTabActionWrapper);
|
||||||
|
|
||||||
// 0 = Columns
|
// 0 = Columns
|
||||||
ArrayList<ValueNamePair> items = new ArrayList<ValueNamePair>();
|
ArrayList<ValueNamePair> items = new ArrayList<ValueNamePair>();
|
||||||
for (int c = 0; c < m_findFields.length; c++)
|
for (int c = 0; c < m_findFields.length; c++)
|
||||||
|
@ -440,35 +511,68 @@ public final class Find extends CDialog
|
||||||
// System.out.println(pp + " = " + field);
|
// System.out.println(pp + " = " + field);
|
||||||
items.add(pp);
|
items.add(pp);
|
||||||
}
|
}
|
||||||
ValueNamePair[] cols = new ValueNamePair[items.size()];
|
columnValueNamePairs = new ValueNamePair[items.size()];
|
||||||
items.toArray(cols);
|
items.toArray(columnValueNamePairs);
|
||||||
Arrays.sort(cols); // sort alpha
|
Arrays.sort(columnValueNamePairs); // sort alpha
|
||||||
columns = new CComboBox(cols);
|
columns = new CComboBox(columnValueNamePairs);
|
||||||
columns.addActionListener(this);
|
columns.addActionListener(this);
|
||||||
TableColumn tc = advancedTable.getColumnModel().getColumn(INDEX_COLUMNNAME);
|
TableColumn tc = advancedTable.getColumnModel().getColumn(INDEX_COLUMNNAME);
|
||||||
tc.setPreferredWidth(150);
|
tc.setPreferredWidth(150);
|
||||||
tc.setCellEditor(new DefaultCellEditor(columns));
|
FindCellEditor dce = new FindCellEditor(columns);
|
||||||
|
|
||||||
|
dce.addCellEditorListener(new CellEditorListener()
|
||||||
|
{
|
||||||
|
public void editingCanceled(ChangeEvent ce)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void editingStopped(ChangeEvent ce)
|
||||||
|
{
|
||||||
|
int col = advancedTable.getSelectedColumn();
|
||||||
|
int row = advancedTable.getSelectedRow();
|
||||||
|
if (col == INDEX_COLUMNNAME && row >= 0)
|
||||||
|
{
|
||||||
|
advancedTable.setValueAt(null, row, INDEX_VALUE);
|
||||||
|
advancedTable.setValueAt(null, row, INDEX_VALUE2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tc.setCellEditor(dce);
|
||||||
tc.setHeaderValue(Msg.translate(Env.getCtx(), "AD_Column_ID"));
|
tc.setHeaderValue(Msg.translate(Env.getCtx(), "AD_Column_ID"));
|
||||||
|
|
||||||
// 1 = Operators
|
// 1 = Operators
|
||||||
operators = new CComboBox(MQuery.OPERATORS);
|
operators = new CComboBox(MQuery.OPERATORS);
|
||||||
tc = advancedTable.getColumnModel().getColumn(INDEX_OPERATOR);
|
tc = advancedTable.getColumnModel().getColumn(INDEX_OPERATOR);
|
||||||
tc.setPreferredWidth(40);
|
tc.setPreferredWidth(40);
|
||||||
tc.setCellEditor(new DefaultCellEditor(operators));
|
dce = new FindCellEditor(operators);
|
||||||
|
tc.setCellEditor(dce);
|
||||||
tc.setHeaderValue(Msg.getMsg(Env.getCtx(), "Operator"));
|
tc.setHeaderValue(Msg.getMsg(Env.getCtx(), "Operator"));
|
||||||
|
|
||||||
// 2 = QueryValue
|
// 2 = QueryValue
|
||||||
tc = advancedTable.getColumnModel().getColumn(INDEX_VALUE);
|
tc = advancedTable.getColumnModel().getColumn(INDEX_VALUE);
|
||||||
tc.setCellEditor(new FindValueEditor(this, false));
|
FindValueEditor fve = new FindValueEditor(this, false);
|
||||||
tc.setCellRenderer(new FindValueRenderer(this, false));
|
tc.setCellEditor(fve);
|
||||||
|
tc.setCellRenderer(new ProxyRenderer(new FindValueRenderer(this, false)));
|
||||||
tc.setHeaderValue(Msg.getMsg(Env.getCtx(), "QueryValue"));
|
tc.setHeaderValue(Msg.getMsg(Env.getCtx(), "QueryValue"));
|
||||||
|
|
||||||
// 3 = QueryValue2
|
// 3 = QueryValue2
|
||||||
tc = advancedTable.getColumnModel().getColumn(INDEX_VALUE2);
|
tc = advancedTable.getColumnModel().getColumn(INDEX_VALUE2);
|
||||||
tc.setPreferredWidth(50);
|
tc.setPreferredWidth(50);
|
||||||
tc.setCellEditor(new FindValueEditor(this, true));
|
fve = new FindValueEditor(this, false);
|
||||||
tc.setCellRenderer(new FindValueRenderer(this, true));
|
tc.setCellEditor(fve);
|
||||||
|
tc.setCellRenderer(new ProxyRenderer(new FindValueRenderer(this, false)));
|
||||||
tc.setHeaderValue(Msg.getMsg(Env.getCtx(), "QueryValue2"));
|
tc.setHeaderValue(Msg.getMsg(Env.getCtx(), "QueryValue2"));
|
||||||
|
|
||||||
|
AutoCompletion.enable(columns);
|
||||||
|
AutoCompletion.enable(operators);
|
||||||
|
|
||||||
|
//user query
|
||||||
|
userQueries = MUserQuery.get(Env.getCtx(), m_AD_Tab_ID);
|
||||||
|
String[] queries = new String[userQueries.length];
|
||||||
|
for (int i = 0; i < userQueries.length; i++)
|
||||||
|
queries[i] = userQueries[i].getName();
|
||||||
|
fQueryName.setModel(new DefaultComboBoxModel(queries));
|
||||||
|
fQueryName.setValue("");
|
||||||
|
|
||||||
// No Row - Create one
|
// No Row - Create one
|
||||||
cmd_new();
|
cmd_new();
|
||||||
|
@ -530,16 +634,29 @@ public final class Find extends CDialog
|
||||||
else if (e.getSource() == bNew)
|
else if (e.getSource() == bNew)
|
||||||
cmd_new();
|
cmd_new();
|
||||||
else if (e.getSource() == bSave)
|
else if (e.getSource() == bSave)
|
||||||
cmd_save();
|
cmd_save(true);
|
||||||
else if (e.getSource() == bDelete)
|
else if (e.getSource() == bDelete)
|
||||||
cmd_delete();
|
cmd_delete();
|
||||||
//
|
//
|
||||||
else if (e.getSource() == columns)
|
else if (e.getSource() == columns)
|
||||||
{
|
{
|
||||||
ValueNamePair column = (ValueNamePair)columns.getSelectedItem();
|
String columnName = null;
|
||||||
if (column != null)
|
Object selected = columns.getSelectedItem();
|
||||||
|
if (selected != null)
|
||||||
|
{
|
||||||
|
if (selected instanceof ValueNamePair)
|
||||||
|
{
|
||||||
|
ValueNamePair column = (ValueNamePair)selected;
|
||||||
|
columnName = column.getValue();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
columnName = selected.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (columnName != null)
|
||||||
{
|
{
|
||||||
String columnName = column.getValue();
|
|
||||||
log.config("Column: " + columnName);
|
log.config("Column: " + columnName);
|
||||||
if (columnName.endsWith("_ID") || columnName.endsWith("_Acct"))
|
if (columnName.endsWith("_ID") || columnName.endsWith("_Acct"))
|
||||||
operators.setModel(new DefaultComboBoxModel(MQuery.OPERATORS_ID));
|
operators.setModel(new DefaultComboBoxModel(MQuery.OPERATORS_ID));
|
||||||
|
@ -549,15 +666,84 @@ public final class Find extends CDialog
|
||||||
operators.setModel(new DefaultComboBoxModel(MQuery.OPERATORS));
|
operators.setModel(new DefaultComboBoxModel(MQuery.OPERATORS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (e.getSource() == fQueryName)
|
||||||
|
{
|
||||||
|
Object o = fQueryName.getSelectedItem();
|
||||||
|
if (userQueries != null && o != null)
|
||||||
|
{
|
||||||
|
String selected = o.toString();
|
||||||
|
for (int i = 0; i < userQueries.length; i++)
|
||||||
|
{
|
||||||
|
if (userQueries[i].getName().equals(selected))
|
||||||
|
{
|
||||||
|
parseUserQuery(userQueries[i]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else // ConfirmPanel.A_OK and enter in fields
|
else // ConfirmPanel.A_OK and enter in fields
|
||||||
{
|
{
|
||||||
if (e.getSource() == confirmPanelA.getOKButton())
|
if (e.getSource() == confirmPanelA.getOKButton())
|
||||||
cmd_ok_Advanced();
|
cmd_ok_Advanced();
|
||||||
else
|
else if (e.getSource() == confirmPanelS.getOKButton())
|
||||||
|
cmd_ok_Simple();
|
||||||
|
else if (e.getSource() instanceof JTextField &&
|
||||||
|
tabbedPane.getSelectedIndex() == 0)
|
||||||
cmd_ok_Simple();
|
cmd_ok_Simple();
|
||||||
}
|
}
|
||||||
} // actionPerformed
|
} // actionPerformed
|
||||||
|
|
||||||
|
private void parseUserQuery(MUserQuery userQuery) {
|
||||||
|
String code = userQuery.getCode();
|
||||||
|
String[] segments = code.split(Pattern.quote(SEGMENT_SEPARATOR));
|
||||||
|
advancedTable.stopEditor(true);
|
||||||
|
DefaultTableModel model = (DefaultTableModel)advancedTable.getModel();
|
||||||
|
int cnt = model.getRowCount();
|
||||||
|
for (int i = cnt - 1; i >=0; i--)
|
||||||
|
model.removeRow(i);
|
||||||
|
|
||||||
|
for (int i = 0; i < segments.length; i++)
|
||||||
|
{
|
||||||
|
String[] fields = segments[i].split(Pattern.quote(FIELD_SEPARATOR));
|
||||||
|
model.addRow(new Object[] {null, MQuery.OPERATORS[MQuery.EQUAL_INDEX], null, null});
|
||||||
|
String columnName = null;
|
||||||
|
for (int j = 0; j < fields.length; j++)
|
||||||
|
{
|
||||||
|
if (j == INDEX_COLUMNNAME)
|
||||||
|
{
|
||||||
|
for (ValueNamePair vnp : columnValueNamePairs)
|
||||||
|
{
|
||||||
|
if (vnp.getValue().equals(fields[j]))
|
||||||
|
{
|
||||||
|
model.setValueAt(vnp, i, j);
|
||||||
|
columnName = fields[j];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (j == INDEX_OPERATOR)
|
||||||
|
{
|
||||||
|
for (ValueNamePair vnp : MQuery.OPERATORS)
|
||||||
|
{
|
||||||
|
if (vnp.getValue().equals(fields[j]))
|
||||||
|
{
|
||||||
|
model.setValueAt(vnp, i, j);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GridField field = getTargetMField(columnName);
|
||||||
|
Object value = parseString(field, fields[j]);
|
||||||
|
model.setValueAt(value, i, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
advancedTable.invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change Listener (tab change)
|
* Change Listener (tab change)
|
||||||
* @param e ChangeEbent
|
* @param e ChangeEbent
|
||||||
|
@ -571,6 +757,7 @@ public final class Find extends CDialog
|
||||||
{
|
{
|
||||||
initFindAdvanced();
|
initFindAdvanced();
|
||||||
this.getRootPane().setDefaultButton(confirmPanelA.getOKButton());
|
this.getRootPane().setDefaultButton(confirmPanelA.getOKButton());
|
||||||
|
advancedTable.requestFocusInWindow();
|
||||||
}
|
}
|
||||||
} // stateChanged
|
} // stateChanged
|
||||||
|
|
||||||
|
@ -661,7 +848,7 @@ public final class Find extends CDialog
|
||||||
m_isCancel = false; // teo_sarca [ 1708717 ]
|
m_isCancel = false; // teo_sarca [ 1708717 ]
|
||||||
// save pending
|
// save pending
|
||||||
if (bSave.isEnabled())
|
if (bSave.isEnabled())
|
||||||
cmd_save();
|
cmd_save(false);
|
||||||
if (getNoOfRecords(m_query, true) != 0)
|
if (getNoOfRecords(m_query, true) != 0)
|
||||||
dispose();
|
dispose();
|
||||||
} // cmd_ok_Advanced
|
} // cmd_ok_Advanced
|
||||||
|
@ -671,6 +858,7 @@ public final class Find extends CDialog
|
||||||
*/
|
*/
|
||||||
private void cmd_cancel()
|
private void cmd_cancel()
|
||||||
{
|
{
|
||||||
|
advancedTable.stopEditor(false);
|
||||||
log.info("");
|
log.info("");
|
||||||
m_query = null;
|
m_query = null;
|
||||||
m_total = 999999;
|
m_total = 999999;
|
||||||
|
@ -691,30 +879,34 @@ public final class Find extends CDialog
|
||||||
*/
|
*/
|
||||||
private void cmd_new()
|
private void cmd_new()
|
||||||
{
|
{
|
||||||
log.info("");
|
advancedTable.stopEditor(true);
|
||||||
DefaultTableModel model = (DefaultTableModel)advancedTable.getModel();
|
DefaultTableModel model = (DefaultTableModel)advancedTable.getModel();
|
||||||
model.addRow(new Object[] {null, MQuery.OPERATORS[MQuery.EQUAL_INDEX], null, null});
|
model.addRow(new Object[] {null, MQuery.OPERATORS[MQuery.EQUAL_INDEX], null, null});
|
||||||
|
advancedTable.requestFocusInWindow();
|
||||||
} // cmd_new
|
} // cmd_new
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save (Advanced)
|
* Save (Advanced)
|
||||||
*/
|
*/
|
||||||
private void cmd_save()
|
private void cmd_save(boolean saveQuery)
|
||||||
{
|
{
|
||||||
log.info("");
|
|
||||||
advancedTable.stopEditor(true);
|
advancedTable.stopEditor(true);
|
||||||
//
|
//
|
||||||
m_query = new MQuery(m_tableName);
|
m_query = new MQuery(m_tableName);
|
||||||
|
StringBuffer code = new StringBuffer();
|
||||||
for (int row = 0; row < advancedTable.getRowCount(); row++)
|
for (int row = 0; row < advancedTable.getRowCount(); row++)
|
||||||
{
|
{
|
||||||
// Column
|
// Column
|
||||||
Object column = advancedTable.getValueAt(row, INDEX_COLUMNNAME);
|
Object column = advancedTable.getValueAt(row, INDEX_COLUMNNAME);
|
||||||
if (column == null)
|
if (column == null)
|
||||||
continue;
|
continue;
|
||||||
String ColumnName = ((ValueNamePair)column).getValue();
|
String ColumnName = column instanceof ValueNamePair ?
|
||||||
|
((ValueNamePair)column).getValue() : column.toString();
|
||||||
String infoName = column.toString();
|
String infoName = column.toString();
|
||||||
//
|
//
|
||||||
GridField field = getTargetMField(ColumnName);
|
GridField field = getTargetMField(ColumnName);
|
||||||
|
if (field == null)
|
||||||
|
continue;
|
||||||
boolean isProductCategoryField = isProductCategoryField(field.getAD_Column_ID());
|
boolean isProductCategoryField = isProductCategoryField(field.getAD_Column_ID());
|
||||||
String ColumnSQL = field.getColumnSQL(false);
|
String ColumnSQL = field.getColumnSQL(false);
|
||||||
// Op
|
// Op
|
||||||
|
@ -736,9 +928,10 @@ public final class Find extends CDialog
|
||||||
else if (field.getDisplayType() == DisplayType.YesNo)
|
else if (field.getDisplayType() == DisplayType.YesNo)
|
||||||
infoDisplay = Msg.getMsg(Env.getCtx(), infoDisplay);
|
infoDisplay = Msg.getMsg(Env.getCtx(), infoDisplay);
|
||||||
// Value2 ******
|
// Value2 ******
|
||||||
|
Object value2 = null;
|
||||||
if (MQuery.OPERATORS[MQuery.BETWEEN_INDEX].equals(op))
|
if (MQuery.OPERATORS[MQuery.BETWEEN_INDEX].equals(op))
|
||||||
{
|
{
|
||||||
Object value2 = advancedTable.getValueAt(row, INDEX_VALUE2);
|
value2 = advancedTable.getValueAt(row, INDEX_VALUE2);
|
||||||
if (value2 == null)
|
if (value2 == null)
|
||||||
continue;
|
continue;
|
||||||
Object parsedValue2 = parseValue(field, value2);
|
Object parsedValue2 = parseValue(field, value2);
|
||||||
|
@ -759,9 +952,67 @@ public final class Find extends CDialog
|
||||||
else
|
else
|
||||||
m_query.addRestriction(ColumnSQL, Operator, parsedValue,
|
m_query.addRestriction(ColumnSQL, Operator, parsedValue,
|
||||||
infoName, infoDisplay);
|
infoName, infoDisplay);
|
||||||
|
|
||||||
|
if (code.length() > 0)
|
||||||
|
code.append(SEGMENT_SEPARATOR);
|
||||||
|
code.append(ColumnName)
|
||||||
|
.append(FIELD_SEPARATOR)
|
||||||
|
.append(Operator)
|
||||||
|
.append(FIELD_SEPARATOR)
|
||||||
|
.append(value.toString())
|
||||||
|
.append(FIELD_SEPARATOR)
|
||||||
|
.append(value2 != null ? value2.toString() : "");
|
||||||
|
}
|
||||||
|
Object selected = fQueryName.getSelectedItem();
|
||||||
|
if (selected != null && saveQuery) {
|
||||||
|
String name = selected.toString();
|
||||||
|
MUserQuery uq = MUserQuery.get(Env.getCtx(), m_AD_Tab_ID, name);
|
||||||
|
if (uq == null && code.length() > 0)
|
||||||
|
{
|
||||||
|
uq = new MUserQuery (Env.getCtx(), 0, null);
|
||||||
|
uq.setName (name);
|
||||||
|
uq.setAD_Tab_ID(m_AD_Tab_ID); //red1 UserQuery [ 1798539 ] taking in new field from Compiere
|
||||||
|
uq.setAD_User_ID(Env.getAD_User_ID(Env.getCtx())); //red1 - [ 1798539 ] missing in Compiere delayed source :-)
|
||||||
|
}
|
||||||
|
else if (uq != null && code.length() == 0)
|
||||||
|
{
|
||||||
|
if (uq.delete(true))
|
||||||
|
{
|
||||||
|
ADialog.info (m_targetWindowNo, this, "Deleted", name);
|
||||||
|
refreshUserQueries();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ADialog.warn (m_targetWindowNo, this, "DeleteError", name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
uq.setCode (code.toString());
|
||||||
|
uq.setAD_Table_ID (m_AD_Table_ID);
|
||||||
|
//
|
||||||
|
if (uq.save())
|
||||||
|
{
|
||||||
|
ADialog.info (m_targetWindowNo, this, "Saved", name);
|
||||||
|
refreshUserQueries();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ADialog.warn (m_targetWindowNo, this, "SaveError", name);
|
||||||
}
|
}
|
||||||
} // cmd_save
|
} // cmd_save
|
||||||
|
|
||||||
|
private void refreshUserQueries()
|
||||||
|
{
|
||||||
|
Object selected = fQueryName.getSelectedItem();
|
||||||
|
userQueries = MUserQuery.get(Env.getCtx(), m_AD_Tab_ID);
|
||||||
|
String[] queries = new String[userQueries.length];
|
||||||
|
for (int i = 0; i < userQueries.length; i++)
|
||||||
|
queries[i] = userQueries[i].getName();
|
||||||
|
fQueryName.setModel(new DefaultComboBoxModel(queries));
|
||||||
|
fQueryName.setSelectedItem(selected);
|
||||||
|
if (fQueryName.getSelectedIndex() < 0)
|
||||||
|
fQueryName.setValue("");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the given column.
|
* Checks the given column.
|
||||||
* @param columnId
|
* @param columnId
|
||||||
|
@ -927,17 +1178,71 @@ public final class Find extends CDialog
|
||||||
return in;
|
return in;
|
||||||
} // parseValue
|
} // parseValue
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse String
|
||||||
|
* @param field column
|
||||||
|
* @param in value
|
||||||
|
* @return data type corected value
|
||||||
|
*/
|
||||||
|
private Object parseString(GridField field, String in)
|
||||||
|
{
|
||||||
|
if (in == null)
|
||||||
|
return null;
|
||||||
|
int dt = field.getDisplayType();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Return Integer
|
||||||
|
if (dt == DisplayType.Integer
|
||||||
|
|| (DisplayType.isID(dt) && field.getColumnName().endsWith("_ID")))
|
||||||
|
{
|
||||||
|
int i = Integer.parseInt(in);
|
||||||
|
return new Integer(i);
|
||||||
|
}
|
||||||
|
// Return BigDecimal
|
||||||
|
else if (DisplayType.isNumeric(dt))
|
||||||
|
{
|
||||||
|
return DisplayType.getNumberFormat(dt).parse(in);
|
||||||
|
}
|
||||||
|
// Return Timestamp
|
||||||
|
else if (DisplayType.isDate(dt))
|
||||||
|
{
|
||||||
|
long time = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
time = DisplayType.getDateFormat_JDBC().parse(in).getTime();
|
||||||
|
return new Timestamp(time);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, in + "(" + in.getClass() + ")" + e);
|
||||||
|
time = DisplayType.getDateFormat(dt).parse(in).getTime();
|
||||||
|
}
|
||||||
|
return new Timestamp(time);
|
||||||
|
}
|
||||||
|
else if (dt == DisplayType.YesNo)
|
||||||
|
return Boolean.valueOf(in);
|
||||||
|
else
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, "Object=" + in, ex);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // parseValue
|
||||||
/**
|
/**
|
||||||
* Delete
|
* Delete
|
||||||
*/
|
*/
|
||||||
private void cmd_delete()
|
private void cmd_delete()
|
||||||
{
|
{
|
||||||
log.info("");
|
advancedTable.stopEditor(false);
|
||||||
DefaultTableModel model = (DefaultTableModel)advancedTable.getModel();
|
DefaultTableModel model = (DefaultTableModel)advancedTable.getModel();
|
||||||
int row = advancedTable.getSelectedRow();
|
int row = advancedTable.getSelectedRow();
|
||||||
if (row >= 0)
|
if (row >= 0)
|
||||||
model.removeRow(row);
|
model.removeRow(row);
|
||||||
cmd_refresh();
|
cmd_refresh();
|
||||||
|
advancedTable.requestFocusInWindow();
|
||||||
} // cmd_delete
|
} // cmd_delete
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -945,7 +1250,7 @@ public final class Find extends CDialog
|
||||||
*/
|
*/
|
||||||
private void cmd_refresh()
|
private void cmd_refresh()
|
||||||
{
|
{
|
||||||
log.info("");
|
advancedTable.stopEditor(false);
|
||||||
int records = getNoOfRecords(m_query, true);
|
int records = getNoOfRecords(m_query, true);
|
||||||
setStatusDB (records);
|
setStatusDB (records);
|
||||||
statusBar.setStatusLine("");
|
statusBar.setStatusLine("");
|
||||||
|
@ -1088,5 +1393,32 @@ public final class Find extends CDialog
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
} // getTargetMField
|
} // getTargetMField
|
||||||
|
|
||||||
|
private class ProxyRenderer implements TableCellRenderer
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Creates a Find.ProxyRenderer.
|
||||||
|
*/
|
||||||
|
public ProxyRenderer(TableCellRenderer renderer)
|
||||||
|
{
|
||||||
|
this.m_renderer = renderer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The renderer. */
|
||||||
|
private TableCellRenderer m_renderer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int)
|
||||||
|
*/
|
||||||
|
public Component getTableCellRendererComponent(final JTable table,
|
||||||
|
Object value, boolean isSelected, boolean hasFocus, final int row, final int col)
|
||||||
|
{
|
||||||
|
Component comp = m_renderer.getTableCellRendererComponent(table,
|
||||||
|
value, isSelected, hasFocus, row, col);
|
||||||
|
if (hasFocus && table.isCellEditable(row, col))
|
||||||
|
table.editCellAt(row, col);
|
||||||
|
return comp;
|
||||||
|
}
|
||||||
|
} // ProxyRenderer
|
||||||
|
|
||||||
} // Find
|
} // Find
|
||||||
|
|
|
@ -0,0 +1,154 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
|
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU General Public License for more details. *
|
||||||
|
* You should have received a copy of the GNU General Public License along *
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
|
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||||
|
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.compiere.apps.search;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
import java.beans.*;
|
||||||
|
import java.util.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.table.*;
|
||||||
|
|
||||||
|
import org.adempiere.plaf.AdempierePLAF;
|
||||||
|
import org.compiere.grid.ed.VComboBox;
|
||||||
|
import org.compiere.model.*;
|
||||||
|
import org.compiere.swing.CEditor;
|
||||||
|
import org.compiere.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cell Editor.
|
||||||
|
* <pre>
|
||||||
|
* Sequence of events:
|
||||||
|
* isCellEditable
|
||||||
|
* getTableCellEditor
|
||||||
|
* shouldSelectCell
|
||||||
|
* getCellEditorValue
|
||||||
|
* </pre>
|
||||||
|
* A new Editor is created for editable columns.
|
||||||
|
* @author Jorg Janke
|
||||||
|
* @version $Id: VCellEditor.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||||
|
*/
|
||||||
|
public final class FindCellEditor extends AbstractCellEditor
|
||||||
|
implements TableCellEditor, ActionListener
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Constructor for Grid
|
||||||
|
* @param mField
|
||||||
|
*/
|
||||||
|
public FindCellEditor (CEditor component)
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
m_editor = component;
|
||||||
|
//m_editor.addActionListener(this);
|
||||||
|
// Click
|
||||||
|
} // FindCellEditor
|
||||||
|
|
||||||
|
/** The Table Editor */
|
||||||
|
private CEditor m_editor = null;
|
||||||
|
/** Table */
|
||||||
|
private JTable m_table = null;
|
||||||
|
/** ClickCount */
|
||||||
|
private static int CLICK_TO_START = 1;
|
||||||
|
/** Logger */
|
||||||
|
private static CLogger log = CLogger.getCLogger(FindCellEditor.class);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param anEvent event
|
||||||
|
* @return true if editable
|
||||||
|
*/
|
||||||
|
public boolean isCellEditable (EventObject anEvent)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
} // isCellEditable
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets an initial value for the editor. This will cause the editor to
|
||||||
|
* stopEditing and lose any partially edited value if the editor is editing
|
||||||
|
* when this method is called.
|
||||||
|
* Returns the component that should be added to the client's Component hierarchy.
|
||||||
|
* Once installed in the client's hierarchy this component
|
||||||
|
* will then be able to draw and receive user input.
|
||||||
|
*
|
||||||
|
* @param table
|
||||||
|
* @param value
|
||||||
|
* @param isSelected
|
||||||
|
* @param row
|
||||||
|
* @param col
|
||||||
|
* @return component
|
||||||
|
*/
|
||||||
|
public Component getTableCellEditorComponent (JTable table, Object value, boolean isSelected, int row, int col)
|
||||||
|
{
|
||||||
|
if (row >= 0)
|
||||||
|
table.setRowSelectionInterval(row,row); // force moving to new row
|
||||||
|
|
||||||
|
m_table = table;
|
||||||
|
|
||||||
|
// Set Value
|
||||||
|
m_editor.setValue(value);
|
||||||
|
|
||||||
|
// Set Background/Foreground to "normal" (unselected) colors
|
||||||
|
((JComponent)m_editor).setForeground(AdempierePLAF.getTextColor_Normal());
|
||||||
|
|
||||||
|
// Other UI
|
||||||
|
((JComponent)m_editor).setFont(table.getFont());
|
||||||
|
if ( m_editor instanceof JComboBox) {
|
||||||
|
((JComboBox)m_editor).setBorder(BorderFactory.createEmptyBorder());
|
||||||
|
} else {
|
||||||
|
((JComponent)m_editor).setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
|
||||||
|
}
|
||||||
|
//
|
||||||
|
return (Component)m_editor;
|
||||||
|
} // getTableCellEditorComponent
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The editing cell should be selected or not
|
||||||
|
* @param e event
|
||||||
|
* @return true (constant)
|
||||||
|
*/
|
||||||
|
public boolean shouldSelectCell(EventObject e)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
} // shouldSelectCell
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value contained in the editor
|
||||||
|
* @return value
|
||||||
|
*/
|
||||||
|
public Object getCellEditorValue()
|
||||||
|
{
|
||||||
|
return m_editor.getValue();
|
||||||
|
} // getCellEditorValue
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action Editor - Stop Editor
|
||||||
|
* @param e event
|
||||||
|
*/
|
||||||
|
public void actionPerformed (ActionEvent e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispose
|
||||||
|
*/
|
||||||
|
public void dispose()
|
||||||
|
{
|
||||||
|
m_editor = null;
|
||||||
|
m_table = null;
|
||||||
|
} // dispose
|
||||||
|
|
||||||
|
} // FindCellEditor
|
|
@ -94,8 +94,12 @@ public final class FindValueRenderer extends DefaultTableCellRenderer
|
||||||
// Column
|
// Column
|
||||||
m_columnName = null;
|
m_columnName = null;
|
||||||
Object column = table.getModel().getValueAt(row, Find.INDEX_COLUMNNAME);
|
Object column = table.getModel().getValueAt(row, Find.INDEX_COLUMNNAME);
|
||||||
if (column != null)
|
if (column != null) {
|
||||||
m_columnName = ((ValueNamePair)column).getValue();
|
if (column instanceof ValueNamePair)
|
||||||
|
m_columnName = ((ValueNamePair)column).getValue();
|
||||||
|
else
|
||||||
|
m_columnName = column.toString();
|
||||||
|
}
|
||||||
|
|
||||||
// Between - enables valueToColumn
|
// Between - enables valueToColumn
|
||||||
m_between = false;
|
m_between = false;
|
||||||
|
|
|
@ -147,7 +147,7 @@ public class GridController extends CPanel
|
||||||
private GridController detail = null;
|
private GridController detail = null;
|
||||||
private CScrollPane mrPane = new CScrollPane();
|
private CScrollPane mrPane = new CScrollPane();
|
||||||
private CPanel xPanel = new CPanel();
|
private CPanel xPanel = new CPanel();
|
||||||
private FlowLayout xLayout = new FlowLayout();
|
private BorderLayout xLayout = new BorderLayout();
|
||||||
private VTable vTable = new VTable();
|
private VTable vTable = new VTable();
|
||||||
//FR [ 1757088 ]
|
//FR [ 1757088 ]
|
||||||
private VPanel vPanel = null;
|
private VPanel vPanel = null;
|
||||||
|
@ -185,7 +185,8 @@ public class GridController extends CPanel
|
||||||
//FR [ 1757088 ] xPanel.add(vPanel);
|
//FR [ 1757088 ] xPanel.add(vPanel);
|
||||||
xPanel.setLayout(xLayout);
|
xPanel.setLayout(xLayout);
|
||||||
xPanel.setName("gc_xPanel");
|
xPanel.setName("gc_xPanel");
|
||||||
xLayout.setAlignment(FlowLayout.LEFT);
|
xPanel.setBorder(BorderFactory.createEmptyBorder());
|
||||||
|
//xLayout.setAlignment(FlowLayout.LEFT);
|
||||||
xLayout.setHgap(0);
|
xLayout.setHgap(0);
|
||||||
xLayout.setVgap(0);
|
xLayout.setVgap(0);
|
||||||
// multi-row
|
// multi-row
|
||||||
|
@ -196,6 +197,8 @@ public class GridController extends CPanel
|
||||||
graphPanel.setBorder(null);
|
graphPanel.setBorder(null);
|
||||||
graphPanel.setName("gc_graphPanel");
|
graphPanel.setName("gc_graphPanel");
|
||||||
srPane.setDividerLocation(200);
|
srPane.setDividerLocation(200);
|
||||||
|
|
||||||
|
vPane.setBorder(BorderFactory.createEmptyBorder());
|
||||||
} // jbInit
|
} // jbInit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -301,9 +304,9 @@ public class GridController extends CPanel
|
||||||
m_aPanel = aPanel;
|
m_aPanel = aPanel;
|
||||||
setName("GC-" + mTab);
|
setName("GC-" + mTab);
|
||||||
//FR [ 1757088 ]
|
//FR [ 1757088 ]
|
||||||
vPanel = new VPanel(mWindow.getName());
|
vPanel = new VPanel(mTab.getName());
|
||||||
vPane.getViewport().add(xPanel, null);
|
vPane.getViewport().add(xPanel, null);
|
||||||
xPanel.add(vPanel);
|
xPanel.add(vPanel, BorderLayout.CENTER);
|
||||||
|
|
||||||
setTabLevel(m_mTab.getTabLevel());
|
setTabLevel(m_mTab.getTabLevel());
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import javax.swing.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
//
|
//
|
||||||
|
import org.adempiere.plaf.AdempierePLAF;
|
||||||
import org.compiere.grid.ed.*;
|
import org.compiere.grid.ed.*;
|
||||||
import org.compiere.model.*;
|
import org.compiere.model.*;
|
||||||
import org.compiere.swing.*;
|
import org.compiere.swing.*;
|
||||||
|
@ -57,6 +58,9 @@ import org.compiere.util.*;
|
||||||
*/
|
*/
|
||||||
public final class VPanel extends CTabbedPane
|
public final class VPanel extends CTabbedPane
|
||||||
{
|
{
|
||||||
|
static {
|
||||||
|
UIManager.put("TaskPaneContainer.useGradient", Boolean.FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -64,12 +68,20 @@ public final class VPanel extends CTabbedPane
|
||||||
public VPanel(String Name)
|
public VPanel(String Name)
|
||||||
{
|
{
|
||||||
//[ 1757088 ]
|
//[ 1757088 ]
|
||||||
CTabbedPane T = new CTabbedPane();
|
|
||||||
m_main.setName(Name);
|
m_main.setName(Name);
|
||||||
m_main.setLayout(new GridBagLayout());
|
m_main.setLayout(new GridBagLayout());
|
||||||
m_tablist.put("main", m_main);
|
m_tablist.put("main", m_main);
|
||||||
this.setBorder(marginBorder);
|
this.setBorder(marginBorder);
|
||||||
this.add(m_main);
|
CPanel dummy = new CPanel();
|
||||||
|
FlowLayout f = new FlowLayout();
|
||||||
|
f.setAlignment(FlowLayout.LEFT);
|
||||||
|
f.setHgap(0);
|
||||||
|
f.setVgap(0);
|
||||||
|
dummy.setBorder(BorderFactory.createEmptyBorder());
|
||||||
|
dummy.setLayout(f);
|
||||||
|
dummy.add(m_main);
|
||||||
|
dummy.setName(m_main.getName());
|
||||||
|
this.add(dummy);
|
||||||
|
|
||||||
// Set initial values of constraint
|
// Set initial values of constraint
|
||||||
m_gbc.anchor = GridBagConstraints.NORTHWEST;
|
m_gbc.anchor = GridBagConstraints.NORTHWEST;
|
||||||
|
@ -155,10 +167,10 @@ public final class VPanel extends CTabbedPane
|
||||||
m_gbc.gridx = 0;
|
m_gbc.gridx = 0;
|
||||||
m_gbc.gridy = m_line++;
|
m_gbc.gridy = m_line++;
|
||||||
m_gbc.gridwidth = 4;
|
m_gbc.gridwidth = 4;
|
||||||
org.jdesktop.swingx.JXTaskPaneContainer GroupPaneContainer = new org.jdesktop.swingx.JXTaskPaneContainer();
|
org.jdesktop.swingx.JXTaskPaneContainer GroupPaneContainer = createTaskPaneContainer();
|
||||||
org.jdesktop.swingx.JXTaskPane m_tab = new org.jdesktop.swingx.JXTaskPane();
|
org.jdesktop.swingx.JXTaskPane m_tab = new org.jdesktop.swingx.JXTaskPane();
|
||||||
|
m_tab.getContentPane().setBackground(AdempierePLAF.getFormBackground());
|
||||||
m_tab.setLayout(new BorderLayout());
|
m_tab.setLayout(new BorderLayout());
|
||||||
GroupPaneContainer.setBackground(org.compiere.plaf.CompiereColor.getDefaultBackground().getFlatColor());
|
|
||||||
GroupPaneContainer.add(m_tab);
|
GroupPaneContainer.add(m_tab);
|
||||||
m_tabincludelist.put(AD_Tab_ID, m_tab);
|
m_tabincludelist.put(AD_Tab_ID, m_tab);
|
||||||
m_gbc.anchor = GridBagConstraints.NORTHWEST;
|
m_gbc.anchor = GridBagConstraints.NORTHWEST;
|
||||||
|
@ -319,7 +331,16 @@ public final class VPanel extends CTabbedPane
|
||||||
CPanel m_tab = new CPanel(org.compiere.plaf.CompiereColor.getDefaultBackground());
|
CPanel m_tab = new CPanel(org.compiere.plaf.CompiereColor.getDefaultBackground());
|
||||||
m_tab.setLayout(new GridBagLayout());
|
m_tab.setLayout(new GridBagLayout());
|
||||||
m_tab.setName(fieldGroup);
|
m_tab.setName(fieldGroup);
|
||||||
this.add(m_tab);
|
CPanel dummy = new CPanel();
|
||||||
|
FlowLayout f = new FlowLayout();
|
||||||
|
f.setAlignment(FlowLayout.LEFT);
|
||||||
|
f.setHgap(0);
|
||||||
|
f.setVgap(0);
|
||||||
|
dummy.setLayout(f);
|
||||||
|
dummy.setBorder(BorderFactory.createEmptyBorder());
|
||||||
|
dummy.add(m_tab);
|
||||||
|
dummy.setName(m_tab.getName());
|
||||||
|
this.add(dummy);
|
||||||
m_tablist.put(fieldGroup, m_tab);
|
m_tablist.put(fieldGroup, m_tab);
|
||||||
m_oldFieldGroup= fieldGroup;
|
m_oldFieldGroup= fieldGroup;
|
||||||
return true;
|
return true;
|
||||||
|
@ -327,9 +348,9 @@ public final class VPanel extends CTabbedPane
|
||||||
}
|
}
|
||||||
else if (typeGroup == 2)
|
else if (typeGroup == 2)
|
||||||
{
|
{
|
||||||
org.jdesktop.swingx.JXTaskPaneContainer GroupPaneContainer = new org.jdesktop.swingx.JXTaskPaneContainer();
|
org.jdesktop.swingx.JXTaskPaneContainer GroupPaneContainer = createTaskPaneContainer();
|
||||||
org.jdesktop.swingx.JXTaskPane m_tab = new org.jdesktop.swingx.JXTaskPane();
|
org.jdesktop.swingx.JXTaskPane m_tab = new org.jdesktop.swingx.JXTaskPane();
|
||||||
GroupPaneContainer.setBackground(org.compiere.plaf.CompiereColor.getDefaultBackground().getFlatColor());
|
m_tab.getContentPane().setBackground(AdempierePLAF.getFormBackground());
|
||||||
|
|
||||||
m_tab.setLayout(new GridBagLayout());
|
m_tab.setLayout(new GridBagLayout());
|
||||||
m_tab.setTitle(fieldGroup);
|
m_tab.setTitle(fieldGroup);
|
||||||
|
@ -368,6 +389,16 @@ public final class VPanel extends CTabbedPane
|
||||||
return false;
|
return false;
|
||||||
} // addGroup
|
} // addGroup
|
||||||
|
|
||||||
|
private org.jdesktop.swingx.JXTaskPaneContainer createTaskPaneContainer() {
|
||||||
|
Color c = AdempierePLAF.getFormBackground();
|
||||||
|
Color containerBg = new Color(Math.max((int)(c.getRed() * 0.97), 0),
|
||||||
|
Math.max((int)(c.getGreen()*0.97), 0),
|
||||||
|
Math.max((int)(c.getBlue() *0.97), 0));
|
||||||
|
org.jdesktop.swingx.JXTaskPaneContainer GroupPaneContainer = new org.jdesktop.swingx.JXTaskPaneContainer();
|
||||||
|
GroupPaneContainer.setBackground(containerBg);
|
||||||
|
return GroupPaneContainer;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add Top (10) and right (12) gap
|
* Add Top (10) and right (12) gap
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -5,6 +5,8 @@ import java.beans.PropertyChangeListener;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.text.*;
|
import javax.swing.text.*;
|
||||||
|
|
||||||
|
import org.compiere.swing.CComboBox;
|
||||||
|
|
||||||
|
|
||||||
//phib: this is from http://www.orbital-computer.de/JComboBox
|
//phib: this is from http://www.orbital-computer.de/JComboBox
|
||||||
//with some minor revisions for Adempiere
|
//with some minor revisions for Adempiere
|
||||||
|
@ -14,7 +16,7 @@ import javax.swing.text.*;
|
||||||
* http://creativecommons.org/licenses/publicdomain/
|
* http://creativecommons.org/licenses/publicdomain/
|
||||||
*/
|
*/
|
||||||
public class AutoCompletion extends PlainDocument {
|
public class AutoCompletion extends PlainDocument {
|
||||||
VComboBox comboBox;
|
CComboBox comboBox;
|
||||||
ComboBoxModel model;
|
ComboBoxModel model;
|
||||||
JTextComponent editor;
|
JTextComponent editor;
|
||||||
// flag to indicate if setSelectedItem has been called
|
// flag to indicate if setSelectedItem has been called
|
||||||
|
@ -27,7 +29,7 @@ public class AutoCompletion extends PlainDocument {
|
||||||
KeyListener editorKeyListener;
|
KeyListener editorKeyListener;
|
||||||
FocusListener editorFocusListener;
|
FocusListener editorFocusListener;
|
||||||
|
|
||||||
public AutoCompletion(final VComboBox comboBox) {
|
public AutoCompletion(final CComboBox comboBox) {
|
||||||
this.comboBox = comboBox;
|
this.comboBox = comboBox;
|
||||||
model = comboBox.getModel();
|
model = comboBox.getModel();
|
||||||
comboBox.addActionListener(new ActionListener() {
|
comboBox.addActionListener(new ActionListener() {
|
||||||
|
@ -81,7 +83,7 @@ public class AutoCompletion extends PlainDocument {
|
||||||
highlightCompletedText(0);
|
highlightCompletedText(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void enable(VComboBox comboBox) {
|
public static void enable(CComboBox comboBox) {
|
||||||
// has to be editable
|
// has to be editable
|
||||||
comboBox.setEditable(true);
|
comboBox.setEditable(true);
|
||||||
// change the editor's document
|
// change the editor's document
|
||||||
|
|
|
@ -989,7 +989,7 @@ public class Viewer extends CFrame
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Find find = new Find (this, m_WindowNo, title,
|
Find find = new Find (this, m_WindowNo, title,
|
||||||
AD_Table_ID, tableName, "", findFields, 1);
|
AD_Tab_ID, AD_Table_ID, tableName, "", findFields, 1);
|
||||||
m_reportEngine.setQuery(find.getQuery());
|
m_reportEngine.setQuery(find.getQuery());
|
||||||
find.dispose();
|
find.dispose();
|
||||||
find = null;
|
find = null;
|
||||||
|
|
Loading…
Reference in New Issue