ManageTasksPanel.java revision c73e8d55f04419c98b9a4d977aafeff39539f0ce
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2009 Sun Microsystems, Inc.
*/
/**
* The panel displaying the list of scheduled tasks.
*
*/
public class ManageTasksPanel extends StatusGenericPanel
{
private static final long serialVersionUID = -8034784684412532193L;
private JLabel lNoTasksFound;
/**
* Remove task button.
*/
private JButton cancelTask;
/**
* The scroll that contains the list of tasks (actually is a table).
*/
private JScrollPane tableScroll;
/**
* The table of tasks.
*/
/**
* The model of the table.
*/
private TaskTableModel tableModel;
private ManageTasksMenuBar menuBar;
private GenericDialog operationViewDlg;
private JPanel detailsPanel;
private JLabel noDetailsLabel;
// The panel containing all the labels and values of the details.
private JPanel detailsSubpanel;
/**
* Default constructor.
*
*/
public ManageTasksPanel()
{
super();
createLayout();
}
/**
* {@inheritDoc}
*/
{
}
/**
* {@inheritDoc}
*/
public boolean requiresScroll()
{
return false;
}
/**
* {@inheritDoc}
*/
{
}
/**
* {@inheritDoc}
*/
public void okClicked()
{
// Nothing to do, it only contains a close button.
}
/**
* {@inheritDoc}
*/
public JMenuBar getMenuBar()
{
{
}
return menuBar;
}
/**
* {@inheritDoc}
*/
public Component getPreferredFocusComponent()
{
return taskTable;
}
/**
* Returns the selected cancelable tasks in the list.
* @param onlyCancelable add only the cancelable tasks.
* @return the selected cancelable tasks in the list.
*/
{
{
if (row != -1)
{
{
}
}
}
return tasks;
}
/**
* Creates the components and lays them in the panel.
* @param gbc the grid bag constraints to be used.
*/
private void createLayout()
{
lNoTasksFound.setVisible(false);
// Done to provide a good size to the table.
tableModel = new TaskTableModel();
cancelTask.setOpaque(false);
{
/**
* {@inheritDoc}
*/
{
}
});
{
/**
* {@inheritDoc}
*/
{
}
};
}
/**
* Creates the details panel.
*
*/
private void createDetailsPanel()
{
detailsPanel.setOpaque(false);
detailsSubpanel.setOpaque(false);
}
/**
* Method called when the table is selected.
*
*/
private void tableSelected()
{
tasks = getSelectedTasks(false);
boolean displayContents = false;
{
}
{
}
else
{
if (taskSpecificAttrs.isEmpty())
{
}
else
{
displayContents = true;
{
gbc);
{
}
else
{
}
}
}
}
revalidate();
repaint();
}
/**
* Creates a list with task descriptors. This is done simply to have a good
* initial size for the table.
* @return a list with bogus task descriptors.
*/
{
for (int i= 0; i<numberTasks; i++)
{
String p = "ds-task-";
{
p + "id",
p + "class-name",
p + "state",
p + "scheduled-start-time",
p + "actual-start-time",
p + "completion-time",
p + "dependency-id",
p + "failed-dependency-action",
p + "log-message",
p + "notify-on-error",
p + "notify-on-completion",
p + "ds-recurring-task-schedule"
};
{
"ID",
"TheClassName",
"TheState",
"Schedule Start Time",
"Actual Start Time",
"Completion Time",
"Dependency ID",
"Failed Dependency Action",
"Log Message. Should be pretty long"+
"Log Message. Should be pretty long"+
"Log Message. Should be pretty long"+
"Log Message. Should be pretty long"+
"Log Message. Should be pretty long",
"Notify On Error",
"Notify On Completion",
"Recurring Task Schedule"
};
{
}
try
{
}
catch (Throwable t)
{
}
}
return list;
}
/**
* Creates a list with task descriptors. This is done simply to have a good
* initial size for the table.
* @return a list with bogus task descriptors.
*/
{
for (int i= 0; i<10; i++)
{
String p = "ds-task-";
{
p + "id",
p + "class-name",
p + "state",
p + "scheduled-start-time",
p + "actual-start-time",
p + "completion-time",
p + "dependency-id",
p + "failed-dependency-action",
p + "log-message",
p + "notify-on-error",
p + "notify-on-completion",
p + "ds-recurring-task-schedule"
};
{
"A very 29-backup - Sun Mar 29 00:00:00 MET 2009",
"A long task type",
"A very long task status",
"Schedule Start Time",
"Actual Start Time",
"Completion Time",
"Dependency ID",
"Failed Dependency Action",
"Log Message. Should be pretty long\n"+
"Log Message. Should be pretty long\n"+
"Log Message. Should be pretty long\n"+
"Log Message. Should be pretty long\n"+
"Log Message. Should be pretty long\n",
"Notify On Error",
"Notify On Completion",
"Recurring Task Schedule"
};
{
}
try
{
}
catch (Throwable t)
{
}
}
return list;
}
private void cancelTaskClicked()
{
Utilities.getParentDialog(this),
{
}
{
boolean confirmed = displayConfirmationDialog(
if (confirmed)
{
null,
dlg);
dlg.setVisible(true);
}
}
}
/**
* Gets the Entry object equivalent to the provided CustomSearchResult.
* The method assumes that the schema in DirectoryServer has been initialized.
* @param csr the search result.
* @return the Entry object equivalent to the provided CustomSearchResult.
* @throws OpenDsException if there is an error parsing the DN or retrieving
* the attributes definition and objectclasses in the schema of the server.
* TODO: move somewhere better.
*/
{
{
// See if this is an objectclass or an attribute. Then get the
// corresponding definition and add the value to the appropriate hash.
{
{
if (objectClass == null)
{
}
}
}
else
{
{
}
{
if (value instanceof byte[])
{
}
else
{
}
}
if (attrType.isOperational())
{
}
else
{
}
}
}
}
/**
* Parse an AttributeDescription (an attribute type name and its
* options).
* TODO: make this method in LDIFReader public.
*
* @param attrDescr
* The attribute description to be parsed.
* @return A new attribute with no values, representing the
* attribute type and its options.
*/
{
if (semicolonPos > 0)
{
while (nextPos > 0)
{
{
}
}
{
}
}
else
{
}
{
//resetting doesn't hurt and returns false.
}
return builder.toAttribute();
}
/**
* The main method to test this panel.
* @param args the arguments.
*/
{
// This is a hack to initialize configuration
new ConfigFromFile();
final ManageTasksPanel p = new ManageTasksPanel();
{
public void run()
{
try
{
// To let the dialog to be displayed
}
catch (Throwable t)
{
t.printStackTrace();
}
while (p.isVisible())
{
try
{
public void run()
{
if (visible)
{
p.updateTableSizes();
}
}
});
}
{
}
}
}
});
t.start();
public void run()
{
dlg.setVisible(true);
}
});
t = null;
}
/**
* Displays a dialog allowing the user to select which operations to display.
*
*/
private void operationViewClicked()
{
if (operationViewDlg == null)
{
Utilities.getParentDialog(this));
operationViewDlg.setModal(true);
}
operationViewDlg.setVisible(true);
if (!operationViewPanel.isCancelled())
{
}
}
/**
* {@inheritDoc}
*/
{
if (!changed)
{
{
{
changed = true;
break;
}
}
}
if (changed)
{
{
/**
* {@inheritDoc}
*/
public void run()
{
if (visible)
{
}
}
});
}
}
private void updateTableSizes()
{
}
{
}
/**
* The specific menu bar of this panel.
*
*/
class ManageTasksMenuBar extends MainMenuBar
{
private static final long serialVersionUID = 5051878116443370L;
/**
* structor.
* @param info the control panel info.
*/
{
super(info);
}
/**
* {@inheritDoc}
*/
protected void addMenus()
{
add(createViewMenuBar());
add(createHelpMenuBar());
}
/**
* Creates the view menu bar.
* @return the view menu bar.
*/
protected JMenu createViewMenuBar()
{
{
{
}
});
return menu;
}
}
}