/*
* 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 2008-2009 Sun Microsystems, Inc.
*/
/**
* The panel that displays an existing index (it appears on the right of the
* 'Manage Indexes' dialog).
*
*/
{
private boolean ignoreCheckSave;
/**
* Default constructor.
*
*/
public IndexPanel()
{
super();
createLayout();
}
/**
* Creates the layout of the panel (but the contents are not populated here).
*
*/
private void createLayout()
{
p.setOpaque(false);
super.createBasicLayout(p, gbc, true);
gbc = new GridBagConstraints();
buttonPanel.setOpaque(false);
deleteIndex.setOpaque(false);
{
/**
* {@inheritDoc}
*/
{
deleteIndex();
}
});
saveChanges.setOpaque(false);
{
/**
* {@inheritDoc}
*/
{
saveIndex(false);
}
});
{
/**
* {@inheritDoc}
*/
{
}
/**
* {@inheritDoc}
*/
{
}
/**
* {@inheritDoc}
*/
{
}
});
{
/**
* {@inheritDoc}
*/
{
}
};
{
}
}
/**
* {@inheritDoc}
*/
{
return INFO_CTRL_PANEL_INDEX_PANEL_TITLE.get();
}
/**
* {@inheritDoc}
*/
{
return entryLimit;
}
/**
* {@inheritDoc}
*/
{
isLocal() ?
{
/**
* {@inheritDoc}
*/
public void run()
{
}
});
}
/**
* {@inheritDoc}
*/
public void okClicked()
{
}
/**
* Method used to know if there are unsaved changes or not. It is used by
* the index selection listener when the user changes the selection.
* @return <CODE>true</CODE> if there are unsaved changes (and so the
* selection of the index should be canceled) and <CODE>false</CODE>
* otherwise.
*/
public boolean mustCheckUnsavedChanges()
{
}
/**
* Tells whether the user chose to save the changes in the panel, to not save
* them or simply cancelled the selection in the tree.
* @return the value telling whether the user chose to save the changes in the
* panel, to not save them or simply cancelled the selection change in the
* tree.
*/
{
Utilities.getParentDialog(this));
unsavedChangesDlg.setVisible(true);
{
saveIndex(false);
{
}
}
return result;
}
/**
* Checks the enabling state of the save button.
*
*/
private void checkSaveButton()
{
{
isModified());
}
}
private void deleteIndex()
{
Utilities.getParentDialog(this),
new ArrayList<AbstractIndexDescriptor>();
{
}
{
backendName)))
{
null,
dlg);
dlg.setVisible(true);
}
}
else
{
}
}
/**
* Saves the index modifications.
* @param modal whether the progress dialog for the task must be modal or
* not.
*/
{
if (!isModified())
{
return;
}
{
{
}
{
null,
dlg);
saveChanges.setEnabled(false);
dlg.setVisible(true);
}
}
{
}
}
/**
* Updates the contents of the panel with the provided index.
* @param index the index descriptor to be used to update the panel.
*/
{
ignoreCheckSave = true;
approximate.setSelected(false);
equality.setSelected(false);
ordering.setSelected(false);
substring.setSelected(false);
presence.setSelected(false);
{
switch(type)
{
case APPROXIMATE:
approximate.setSelected(true);
break;
case PRESENCE:
presence.setSelected(true);
break;
case EQUALITY:
equality.setSelected(true);
break;
case ORDERING:
ordering.setSelected(true);
break;
case SUBSTRING:
substring.setSelected(true);
break;
}
}
{
}
if (index.isDatabaseIndex())
{
}
if (index.isDatabaseIndex())
{
warning.setVisible(true);
}
{
{
warning.setVisible(true);
}
else
{
warning.setVisible(false);
}
}
ignoreCheckSave = false;
}
/**
* Returns <CODE>true</CODE> if the index has been modified and
* <CODE>false</CODE> otherwise.
* @return <CODE>true</CODE> if the index has been modified and
* <CODE>false</CODE> otherwise.
*/
private boolean isModified()
{
}
/**
* The task in charge of modifying the index.
*
*/
{
private int entryLimitValue;
/**
* The constructor of the task.
* @param info the control panel info.
* @param dlg the progress dialog that shows the progress of the task.
*/
{
indexTypes = getTypes();
}
/**
* {@inheritDoc}
*/
{
return Type.MODIFY_INDEX;
}
/**
* {@inheritDoc}
*/
{
return backendSet;
}
/**
* {@inheritDoc}
*/
{
}
/**
* {@inheritDoc}
*/
{
boolean canLaunch = true;
{
// All the operations are incompatible if they apply to this
// backend for safety. This is a short operation so the limitation
// has not a lot of impact.
{
canLaunch = false;
}
}
return canLaunch;
}
/**
* Updates the configuration of the modified index.
* @throws OpenDsException if there is an error updating the configuration.
*/
{
boolean configHandlerUpdated = false;
try
{
if (!isServerRunning())
{
configHandlerUpdated = true;
getInfo().stopPooling();
if (getInfo().mustDeregisterConfig())
{
}
getInfo().setMustDeregisterConfig(true);
}
else
{
{
/**
* {@inheritDoc}
*/
public void run()
{
}
});
}
{
/**
* {@inheritDoc}
*/
public void run()
{
}
});
if (isServerRunning())
{
// Create additional indexes and display the equivalent command.
// Everything is done in the method createAdditionalIndexes
}
else
{
modifyIndex();
}
{
/**
* {@inheritDoc}
*/
public void run()
{
}
});
}
finally
{
if (configHandlerUpdated)
{
getInfo().startPooling();
}
}
}
/**
* Returns the LDIF representation of the modified index.
* @return the LDIF representation of the modified index.
*/
{
",cn=Backends,cn=config";
",cn=Index,"+dn);
{
}
{
}
}
{
try
{
null);
}
catch (IOException ioe)
{
throw new OfflineUpdateException(
ioe);
}
finally
{
if (ldifImportConfig != null)
{
}
}
}
/**
* Modifies index using the provided connection.
* @param ctx the connection to be used to update the index configuration.
* @throws OpenDsException if there is an error updating the server.
*/
{
{
}
{
}
{
}
}
/**
* {@inheritDoc}
*/
{
return null;
}
/**
* {@inheritDoc}
*/
{
}
/**
* Returns the full command-line path of the dsconfig command-line if we
* can provide an equivalent command-line (the server is running).
* @return the full command-line path of the dsconfig command-line if we
* can provide an equivalent command-line (the server is running).
*/
{
if (isServerRunning() && isModified())
{
return getCommandLinePath("dsconfig");
}
else
{
return null;
}
}
/**
* {@inheritDoc}
*/
public void runTask()
{
try
{
}
catch (Throwable t)
{
lastException = t;
}
}
/**
* {@inheritDoc}
*/
public void postOperation()
{
{
}
}
{
{
// To add
{
{
}
}
// To delete
{
{
}
}
{
}
{
}
}
{
}
return args;
}
}
}