/* * Copyrights : CNRS * Author : Oleg Lodygensky * Acknowledgment : XtremWeb-HEP is based on XtremWeb 1.8.0 by inria : http://www.xtremweb.net/ * Web : http://www.xtremweb-hep.org * * This file is part of XtremWeb-HEP. * * XtremWeb-HEP is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * XtremWeb-HEP 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 XtremWeb-HEP. If not, see . * */ /** * GroupsTableModel.java * * Purpose : This is the table model to display XtremWeb groups informations * Created : 2 octobre 2008 * * @author " + "A group is valid until you delete it.
" + "You can close the client and retreive you group later.
" + "When a group is deleted, all associated jobs are deleted.
" + GROUPLABEL + " is the name of the group"); /** * These defines submission parameter labels */ private static final String[] labels = { UID, USERLABEL, GROUPLABEL }; /** * This is the default constructor. */ public GroupsTableModel(MainFrame p) { this(p, true); } /** * This is a constructor. * * @param detail * tells whether to add a last column to get details */ public GroupsTableModel(MainFrame p, boolean detail) { super(p, new GroupInterface(), detail); } /** * This calls TableModel#getButtons() and enables all buttons * * @return a Vector of JButton * @see xtremweb.client.gui.TableModel#getButtons() */ @Override public Hashtable getButtons() { final Hashtable ret = super.getButtons(); ((JButton) (ret.get(ADD_LABEL))).setEnabled(true); ((JButton) (ret.get(DEL_LABEL))).setEnabled(true); return ret; } /** * This adds a group */ @Override public void add() { final UID groupUID = new UID(); UID userUID = null; try { userUID = getParent().getClient().getConfig().getUser().getUID(); } catch (final Exception e) { getLogger().error("user UID is not set ?!?!"); return; } final Vector newRow = new Vector(); newRow.add(groupUID); newRow.add(new String()); // user login newRow.add(new String()); // group name ViewDialog vdialog = new ViewDialog(getParent(), "Create group", labels, newRow, true); setViewDialog(vdialog); vdialog.setHelpString(HELPSTRING); final JTextField component = (JTextField) vdialog.getFields() .get(USERLABEL); component.setEditable(false); component.setText(getParent().user().getLogin()); vdialog.setVisible(true); if (vdialog.isCancelled() == true) { return; } try { final GroupInterface group = new GroupInterface(); group.setUID(groupUID); group.setOwner(userUID); group.setName(((JTextField) vdialog.getFields().get(GROUPLABEL)) .getText()); getParent().commClient().send(group); } catch (final Exception e) { getLogger().exception(e); JOptionPane.showMessageDialog(getParent(), "Can't send group : " + e, ERROR, JOptionPane.ERROR_MESSAGE); } } /** * This views a work */ @Override public void view() { super.view("Group viewer"); } /** * This retreives a Vector of work UID from server * * @see xtremweb.communications.CommAPI#getWorks() */ @Override public XMLVector getRows() throws ConnectException { try { getParent().setTitleConnected(); return getParent().commClient().getGroups(); } catch (final Exception e) { getParent().setTitleNotConnected(); getLogger().exception(e); throw new ConnectException(e.toString()); } } }