summaryrefslogtreecommitdiff
path: root/src/antidote
diff options
context:
space:
mode:
authormetasim <dev-null@apache.org>2001-02-25 12:34:23 +0000
committermetasim <dev-null@apache.org>2001-02-25 12:34:23 +0000
commitcfa93603e73e635d31be01cdb31dc9959a5ea35c (patch)
treef781999958ab44d4845388a34fbf27bb19a34e43 /src/antidote
parent2ff201801b557593afe6cf9dcd4d4c4f4da65b39 (diff)
downloadant-cfa93603e73e635d31be01cdb31dc9959a5ea35c.tar.gz
By Christoph Wilhelms: Externalization of strings and removal of
dependency ordering capability. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268736 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/antidote')
-rwxr-xr-xsrc/antidote/org/apache/tools/ant/gui/modules/edit/DependentTargetChooser.java357
-rw-r--r--src/antidote/org/apache/tools/ant/gui/resources/antidote.properties17
2 files changed, 169 insertions, 205 deletions
diff --git a/src/antidote/org/apache/tools/ant/gui/modules/edit/DependentTargetChooser.java b/src/antidote/org/apache/tools/ant/gui/modules/edit/DependentTargetChooser.java
index 9af1e9c86..f1d31955c 100755
--- a/src/antidote/org/apache/tools/ant/gui/modules/edit/DependentTargetChooser.java
+++ b/src/antidote/org/apache/tools/ant/gui/modules/edit/DependentTargetChooser.java
@@ -61,9 +61,6 @@ import org.w3c.dom.NodeList;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
-import java.awt.GridBagLayout;
-import java.awt.GridBagConstraints;
-import java.awt.Insets;
import java.awt.Frame;
import java.awt.Dimension;
import java.awt.event.ActionListener;
@@ -81,6 +78,7 @@ import javax.swing.table.TableColumn;
import org.apache.tools.ant.gui.util.WindowUtils;
import org.apache.tools.ant.gui.acs.ACSProjectElement;
import org.apache.tools.ant.gui.acs.ACSTargetElement;
+import org.apache.tools.ant.gui.core.ResourceManager;
/**
* Dialog for choosing dependent targes comfortable.
@@ -92,18 +90,14 @@ public class DependentTargetChooser extends JDialog {
// "Business"-Object
private ACSTargetElement _target = null;
// Tables
- private JTable _srcTable = null;
- private JTable _dstTable = null;
- private JButton _append = null;
- private JButton _remove = null;
- private JButton _moveUp = null;
- private JButton _moveDown = null;
+ private JTable _targetsTable = null;
// Major Elements;
private JPanel _commandButtonPanel = null;
- private JPanel _selectionPanel = null;
// CommandButtons
private JButton _ok = null;
private JButton _cancel = null;
+ // common
+ private ResourceManager _resources = new ResourceManager();
private static ActionHandler _handler = null;
@@ -131,127 +125,22 @@ public class DependentTargetChooser extends JDialog {
this.setContentPane(container);
container.setLayout(new BorderLayout());
+ JScrollPane tableScrollPane = new JScrollPane();
+ tableScrollPane.setViewportView(getTargetsTable());
+
// Populate container
container.add(getCommandButtonPanel(), BorderLayout.SOUTH);
- container.add(getSelectionPanel(), BorderLayout.CENTER);
+ container.add(tableScrollPane, BorderLayout.CENTER);
// Apply model - must be done this late, because it relies
// on an instntiated GUI
setTarget(target);
// Set an initial size and pack it
- container.setPreferredSize(new Dimension(500,200));
+ container.setPreferredSize(new Dimension(350,250));
pack();
}
- /**
- * Lazily get the selectionPanel with 2 tables and 4 buttons
- * @return the created JPanel
- */
- private JPanel getSelectionPanel() {
- if (_selectionPanel == null) {
- _selectionPanel = new JPanel();
- _selectionPanel.setLayout(new GridBagLayout());
-
- // LEFT Table
- JScrollPane srcSP = new JScrollPane();
- srcSP.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
- srcSP.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
- _srcTable = createTargetsTable();
- srcSP.setViewportView(_srcTable);
-
- GridBagConstraints srcSPConstr = new GridBagConstraints();
- srcSPConstr.fill = GridBagConstraints.BOTH;
- srcSPConstr.anchor = GridBagConstraints.CENTER;
- srcSPConstr.gridx = 0; srcSPConstr.gridy = 0;
- srcSPConstr.weightx = 1.0; srcSPConstr.weighty = 2.0;
- srcSPConstr.gridwidth = 1; srcSPConstr.gridheight = 2;
- srcSPConstr.insets = new Insets(5,5,0,5);
- _selectionPanel.add(srcSP, srcSPConstr);
-
- // Append Button
- _append = new JButton();
- _append.setIcon(new ImageIcon(getClass().getResource("/org/apache/tools/ant/gui/resources/enter.gif")));
- _append.setPreferredSize(new Dimension(28, 28));
- _append.setMaximumSize(new Dimension(28, 28));
- _append.setMinimumSize(new Dimension(28, 28));
- _append.addActionListener(_handler);
-
- GridBagConstraints appendConstr = new GridBagConstraints();
- appendConstr.fill = GridBagConstraints.NONE;
- appendConstr.anchor = GridBagConstraints.SOUTH;
- appendConstr.gridx = 1; appendConstr.gridy = 0;
- appendConstr.weightx = 0.0; appendConstr.weighty = 1.0;
- appendConstr.gridwidth = 1; appendConstr.gridheight = 1;
- appendConstr.insets = new Insets(0,0,2,0);
- _selectionPanel.add(_append, appendConstr);
-
- // Remove Button
- _remove = new JButton();
- _remove.setIcon(new ImageIcon(getClass().getResource("/org/apache/tools/ant/gui/resources/exit.gif")));
- _remove.setPreferredSize(new Dimension(28, 28));
- _remove.setMaximumSize(new Dimension(28, 28));
- _remove.setMinimumSize(new Dimension(28, 28));
- _remove.addActionListener(_handler);
- GridBagConstraints removeConstr = new GridBagConstraints();
- removeConstr.fill = GridBagConstraints.NONE;
- removeConstr.anchor = GridBagConstraints.NORTH;
- removeConstr.gridx = 1; removeConstr.gridy = 1;
- removeConstr.weightx = 0.0; removeConstr.weighty = 1.0;
- removeConstr.gridwidth = 1; removeConstr.gridheight = 1;
- removeConstr.insets = new Insets(3,0,0,0);
- _selectionPanel.add(_remove, removeConstr);
-
- // RIGHT Table
- JScrollPane dstSP = new JScrollPane();
- dstSP.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
- dstSP.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
- _dstTable = createTargetsTable();
- dstSP.setViewportView(_dstTable);
-
- GridBagConstraints dstSPConstr = new GridBagConstraints();
- dstSPConstr.fill = GridBagConstraints.BOTH;
- dstSPConstr.anchor = GridBagConstraints.CENTER;
- dstSPConstr.gridx = 2; dstSPConstr.gridy = 0;
- dstSPConstr.weightx = 1.0; dstSPConstr.weighty = 2.0;
- dstSPConstr.gridwidth = 1; dstSPConstr.gridheight = 2;
- dstSPConstr.insets = new Insets(5,5,0,5);
- _selectionPanel.add(dstSP, dstSPConstr);
-
- // Move Up Button
- _moveUp = new JButton();
- _moveUp.setIcon(new ImageIcon(getClass().getResource("/org/apache/tools/ant/gui/resources/up.gif")));
- _moveUp.setPreferredSize(new Dimension(28, 28));
- _moveUp.setMaximumSize(new Dimension(28, 28));
- _moveUp.setMinimumSize(new Dimension(28, 28));
- _moveUp.addActionListener(_handler);
- GridBagConstraints moveUpConstr = new GridBagConstraints();
- moveUpConstr.fill = GridBagConstraints.NONE;
- moveUpConstr.anchor = GridBagConstraints.CENTER;
- moveUpConstr.gridx = 3; moveUpConstr.gridy = 0;
- moveUpConstr.weightx = 0.0; moveUpConstr.weighty = 1.0;
- moveUpConstr.gridwidth = 1; moveUpConstr.gridheight = 1;
- moveUpConstr.insets = new Insets(0,0,0,5);
- _selectionPanel.add(_moveUp, moveUpConstr);
-
- // Move Up Button
- _moveDown = new JButton();
- _moveDown.setIcon(new ImageIcon(getClass().getResource("/org/apache/tools/ant/gui/resources/down.gif")));
- _moveDown.setPreferredSize(new Dimension(28, 28));
- _moveDown.setMaximumSize(new Dimension(28, 28));
- _moveDown.setMinimumSize(new Dimension(28, 28));
- _moveDown.addActionListener(_handler);
- GridBagConstraints moveDownConstr = new GridBagConstraints();
- moveDownConstr.fill = GridBagConstraints.NONE;
- moveDownConstr.anchor = GridBagConstraints.CENTER;
- moveDownConstr.gridx = 3; moveDownConstr.gridy = 1;
- moveDownConstr.weightx = 0.0; moveDownConstr.weighty = 1.0;
- moveDownConstr.gridwidth = 1; moveDownConstr.gridheight = 1;
- moveDownConstr.insets = new Insets(0,0,0,5);
- _selectionPanel.add(_moveDown, moveDownConstr);
- }
- return _selectionPanel;
- }
/**
* Lazily get the commandButtonPanel
@@ -264,10 +153,13 @@ public class DependentTargetChooser extends JDialog {
btnLayout.setAlignment(FlowLayout.RIGHT);
_commandButtonPanel.setLayout(btnLayout);
- _ok = new JButton("OK");
+ _ok = new JButton(_resources.getString(getClass(), "ok"));
+ _ok.setMnemonic('O');
_ok.addActionListener(_handler);
getRootPane().setDefaultButton(_ok);
- _cancel = new JButton("Cancel");
+ getRootPane().setDefaultButton(_ok);
+ _cancel = new JButton(_resources.getString(getClass(), "cancel"));
+ _cancel.setMnemonic('c');
_cancel.addActionListener(_handler);
_commandButtonPanel.add(_ok);
@@ -276,7 +168,6 @@ public class DependentTargetChooser extends JDialog {
return _commandButtonPanel;
}
-
/**
* Writer method for the model-element
* @param ACSTargetElement the new Target model element.
@@ -285,38 +176,16 @@ public class DependentTargetChooser extends JDialog {
_target = newTarget;
// fill source-TableModel with "sister-targets"
- TargetsTableModel srcModel = (TargetsTableModel)_srcTable.getModel();
- srcModel.setTargets(getCoTargets(newTarget));
- srcModel.fireTableDataChanged();
-
- // fill dest-TableModel with selected depends-targets
- TargetsTableModel dstModel = (TargetsTableModel)_dstTable.getModel();
- dstModel.setTargets(fillDependsList(newTarget));
- dstModel.fireTableDataChanged();
+ SelectableTargetsTableModel model = (SelectableTargetsTableModel) _targetsTable.getModel();
+ model.setTargets(getCoTargets(newTarget));
+ model.preselectTargets(newTarget.getDepends());
+ model.fireTableDataChanged();
}
/**
- * Fills a List with all sister- or depending-targets of a single target
+ * Fills a List with all sister-targets of a single target
* @return filled or empty List
*/
- private List fillDependsList(ACSTargetElement aTarget) {
- List retVal = new ArrayList();
-
- String[] dependNames = aTarget.getDepends();
- int length = dependNames.length;
- ArrayList allTargets = getCoTargets (aTarget);
- int allLen = allTargets.size();
-
- for (int i = 0; i < length; i++)
- {
- for (int j = 0; j < allLen; j++) {
- ACSTargetElement currentElement = (ACSTargetElement)allTargets.get(j);
- if (currentElement.getName().equalsIgnoreCase(dependNames[i].trim())) retVal.add(currentElement);
- }
- }
- return retVal;
- }
-
private ArrayList getCoTargets (ACSTargetElement aTarget) {
ACSProjectElement parentProject = null;
// Caution is the mother of wisdom ;-)
@@ -340,46 +209,148 @@ public class DependentTargetChooser extends JDialog {
}
/**
- * Checks if a String is part of an existing dependent task list
- * @return true, if it is a dependent target
+ * Lazily get a target-table
+ * @return created JTable
*/
- private boolean checkDepends(String name, ACSTargetElement aTarget) {
- String[] depend = aTarget.getDepends();
- for( int i= 0; i < depend.length; i++) {
- if (name.equalsIgnoreCase(depend[i])) return true;
+ private JTable getTargetsTable() {
+ if (_targetsTable == null) {
+ _targetsTable = new JTable();
+ _targetsTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
+ _targetsTable.setAutoCreateColumnsFromModel(false);
+ _targetsTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ // Coulumn showing the selection of the Target
+ TableColumn selectCol = new TableColumn();
+ selectCol.setHeaderValue(_resources.getString(getClass(), "selection"));
+ selectCol.setModelIndex(0);
+ selectCol.setPreferredWidth(70);
+ selectCol.setMaxWidth(70);
+ selectCol.setResizable(false);
+ // Coulumn showing the Target
+ TableColumn targetCol = new TableColumn();
+ targetCol.setHeaderValue(_resources.getString(getClass(), "target"));
+ targetCol.setModelIndex(1);
+ targetCol.setPreferredWidth(150);
+ targetCol.setMaxWidth(150);
+ targetCol.setResizable(true);
+ // Coulumn showing the description of targets
+ TableColumn descrCol = new TableColumn();
+ descrCol.setHeaderValue(_resources.getString(getClass(), "description"));
+ descrCol.setModelIndex(2);
+ descrCol.setPreferredWidth(250);
+ descrCol.setResizable(false);
+ _targetsTable.addColumn(selectCol);
+ _targetsTable.addColumn(targetCol);
+ _targetsTable.addColumn(descrCol);
+ _targetsTable.setModel(new SelectableTargetsTableModel());
}
- return false;
+ return _targetsTable;
}
/**
- * Creates a target-table with two columns - we need two of them!
- * @return created JTable
+ * A decorator for TargetsTableModel to allow selection of targets.
+ *
+ * @see org.apache.tools.ant.gui.modules.edit.TargetsTableModel
*/
- private JTable createTargetsTable() {
- JTable table = new JTable();
- table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
- table.setAutoCreateColumnsFromModel(false);
- table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- // Coulumn showing the Target
- TableColumn targetCol = new TableColumn();
- targetCol.setHeaderValue("Target");
- targetCol.setModelIndex(0);
- targetCol.setPreferredWidth(150);
- targetCol.setMaxWidth(150);
- targetCol.setResizable(true);
- // Coulumn showing the description of targets
- TableColumn descrCol = new TableColumn();
- descrCol.setHeaderValue("Description");
- descrCol.setModelIndex(1);
- descrCol.setPreferredWidth(250);
- descrCol.setResizable(false);
- table.addColumn(targetCol);
- table.addColumn(descrCol);
- table.setModel(new TargetsTableModel());
+ private class SelectableTargetsTableModel extends TargetsTableModel {
+ private boolean[] _selected = new boolean[0];
- return table;
- }
+ /**
+ * Change the entire model.
+ * @param List of ACSTargetElements
+ */
+ public void setTargets(List newTargets) {
+ _selected = new boolean[newTargets.size()];
+ super.setTargets(newTargets);
+ }
+
+ /**
+ * @param Stringarray of target-names
+ */
+ public void preselectTargets(String[] targetNames) {
+ int i = 0, j = 0;
+ int iDim = getRowCount();
+ int jDim = targetNames.length;
+ for (i = 0; i < iDim; i++) {
+ String name = getTarget(i).getName();
+ for( j= 0; j < jDim; j++) {
+ if (name.equalsIgnoreCase(targetNames[j])) _selected[i] = true;
+ }
+ }
+ }
+
+ /**
+ * @param int columnIndex
+ * @return String.class
+ */
+ public Class getColumnClass(int columnIndex) {
+ if (columnIndex == 0) return Boolean.class;
+ else return String.class;
+ }
+
+ /**
+ * @return 3
+ */
+ public int getColumnCount() {
+ return 3;
+ }
+
+ /**
+ * @return true in case of the first column.
+ */
+ public boolean isCellEditable(int row, int col) {
+ return (col == 0);
+ }
+ /**
+ * @param row and column in table
+ * @return the requested object to be shown.
+ */
+ public Object getValueAt(int row, int col) {
+ ACSTargetElement rowObj = getTarget(row);
+ switch (col) {
+ case 0: return new Boolean(_selected[row]);
+ case 1: return rowObj.getName();
+ case 2: return rowObj.getDescription();
+ default: return "";
+ }
+ }
+
+ /**
+ * @param new value resulting from the editor
+ * @param row and column in table
+ */
+ public void setValueAt(Object newValue, int row, int col) {
+ if (col == 0) {
+ _selected[row] = ((Boolean)newValue).booleanValue();
+ }
+ }
+
+ public int getSelectedTargetCount() {
+ int retVal = 0;
+ int length = getRowCount();
+ for (int i = 0; i < length; i++) {
+ if (_selected[i]) retVal++;
+ }
+ return retVal;
+ }
+
+ /**
+ * @return a StringArray (String[]) containing the names of all selected targets.
+ */
+ public String[] getSelectedTargetsAsStringArray() {
+ int length = getRowCount();
+ String[] retVal = new String[getSelectedTargetCount()];
+ int i = 0, j = 0;
+
+ for (i = 0; i < length; i++) {
+ if (_selected[i]) {
+ retVal[j] = getTarget(i).getName();
+ j++;
+ }
+ }
+ return retVal;
+ }
+ }
/**
* Ihis handler is the ActionListener for each button.
@@ -391,33 +362,15 @@ public class DependentTargetChooser extends JDialog {
*/
public void actionPerformed(ActionEvent e) {
// Get some initial values needed later
- TargetsTableModel srcModel = (TargetsTableModel)_srcTable.getModel();
- TargetsTableModel dstModel = (TargetsTableModel)_dstTable.getModel();
- int srcRow = _srcTable.getSelectedRow();
- int dstRow = _dstTable.getSelectedRow();
// Evaluate EventSource
if (e.getSource()==_ok) {
// OK: take the selected targets and leave
- _target.setDepends( dstModel.getTargetsAsStringArray() );
+ _target.setDepends( ((SelectableTargetsTableModel)_targetsTable.getModel()).getSelectedTargetsAsStringArray() );
dispose();
} else if (e.getSource()==_cancel) {
// just close dialog
dispose();
- } else if (e.getSource()==_moveUp) {
- // Move dependent target up (one row)
- dstModel.moveTarget(dstRow, -1);
- _dstTable.getSelectionModel().setSelectionInterval(dstRow - 1, dstRow - 1);
- } else if (e.getSource()==_moveDown) {
- // Move dependent target down (one row)
- dstModel.moveTarget(dstRow, 1);
- _dstTable.getSelectionModel().setSelectionInterval(dstRow + 1, dstRow + 1);
- } else if (e.getSource()==_append) {
- // Append selected target to depends
- if (srcRow >= 0) dstModel.addTarget(srcModel.getTarget(srcRow));
- } else if (e.getSource()==_remove) {
- // Remove dependent target
- if (dstRow >= 0) dstModel.removeTarget(dstRow);
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/antidote/org/apache/tools/ant/gui/resources/antidote.properties b/src/antidote/org/apache/tools/ant/gui/resources/antidote.properties
index 60cc2f868..93f49f960 100644
--- a/src/antidote/org/apache/tools/ant/gui/resources/antidote.properties
+++ b/src/antidote/org/apache/tools/ant/gui/resources/antidote.properties
@@ -26,6 +26,20 @@ org.apache.tools.ant.gui.Antidote.top.modules=\
org.apache.tools.ant.gui.modules.edit.PropertyEditor.name=Properties
+# DependentTargetChooser part of the DependentTargetPropertyEditor
+org.apache.tools.ant.gui.modules.edit.DependentTargetChooser.ok=OK
+org.apache.tools.ant.gui.modules.edit.DependentTargetChooser.cancel=Cancel
+org.apache.tools.ant.gui.modules.edit.DependentTargetChooser.target=Target
+org.apache.tools.ant.gui.modules.edit.DependentTargetChooser.description=Description
+org.apache.tools.ant.gui.modules.edit.DependentTargetChooser.upIcon=up.gif
+org.apache.tools.ant.gui.modules.edit.DependentTargetChooser.downIcon=down.gif
+org.apache.tools.ant.gui.modules.edit.DependentTargetChooser.addIcon=enter.gif
+org.apache.tools.ant.gui.modules.edit.DependentTargetChooser.removeIcon=exit.gif
+org.apache.tools.ant.gui.modules.edit.DependentTargetChooser.up=Move dependent target up
+org.apache.tools.ant.gui.modules.edit.DependentTargetChooser.down=Move dependent target down
+org.apache.tools.ant.gui.modules.edit.DependentTargetChooser.add=Add target to dependent list
+org.apache.tools.ant.gui.modules.edit.DependentTargetChooser.remove=Remove target from dependent list
+
org.apache.tools.ant.gui.modules.edit.ElementNavigator.name=Project
org.apache.tools.ant.gui.modules.edit.ElementNavigator.popupActions=\
newTarget, newTask, newProperty
@@ -116,6 +130,3 @@ org.apache.tools.ant.gui.About.message=\
<p>Icons Copyright &copy; 1998 Dean S. Jones (deansjones@hotmail.com)<br> \
http://jfa.javalobby.org/projects/icons</p> \
</html>
-
-
-