diff --git a/Code/Mantid/Images/images.qrc b/Code/Mantid/Images/images.qrc
index 26fa982f0523..9bb4503dd597 100644
--- a/Code/Mantid/Images/images.qrc
+++ b/Code/Mantid/Images/images.qrc
@@ -11,6 +11,8 @@
Mantid_Logo_Transparent.png
data_replace.png
panning.png
+ replace.png
+ restore.png
folder-remote.png
diff --git a/Code/Mantid/Images/replace.png b/Code/Mantid/Images/replace.png
new file mode 100644
index 000000000000..df9f86bc58ab
Binary files /dev/null and b/Code/Mantid/Images/replace.png differ
diff --git a/Code/Mantid/Images/restore.png b/Code/Mantid/Images/restore.png
new file mode 100644
index 000000000000..95f046d6b542
Binary files /dev/null and b/Code/Mantid/Images/restore.png differ
diff --git a/Code/Mantid/MantidQt/API/CMakeLists.txt b/Code/Mantid/MantidQt/API/CMakeLists.txt
index e8f5f8d599a2..1d3c40e7e681 100644
--- a/Code/Mantid/MantidQt/API/CMakeLists.txt
+++ b/Code/Mantid/MantidQt/API/CMakeLists.txt
@@ -18,6 +18,7 @@ set ( SRC_FILES
src/Message.cpp
src/OptionsPropertyWidget.cpp
src/PlotAxis.cpp
+ src/PropertyInfoWidget.cpp
src/PropertyWidget.cpp
src/PropertyWidgetFactory.cpp
src/PythonRunner.cpp
@@ -43,6 +44,7 @@ set ( MOC_FILES
inc/MantidQtAPI/MantidDialog.h
inc/MantidQtAPI/MantidWidget.h
inc/MantidQtAPI/OptionsPropertyWidget.h
+ inc/MantidQtAPI/PropertyInfoWidget.h
inc/MantidQtAPI/PropertyWidget.h
inc/MantidQtAPI/PythonRunner.h
inc/MantidQtAPI/QtSignalChannel.h
diff --git a/Code/Mantid/MantidQt/API/inc/MantidQtAPI/BoolPropertyWidget.h b/Code/Mantid/MantidQt/API/inc/MantidQtAPI/BoolPropertyWidget.h
index ae988155d9a4..10855988fe1c 100644
--- a/Code/Mantid/MantidQt/API/inc/MantidQtAPI/BoolPropertyWidget.h
+++ b/Code/Mantid/MantidQt/API/inc/MantidQtAPI/BoolPropertyWidget.h
@@ -45,7 +45,7 @@ namespace API
BoolPropertyWidget(Mantid::Kernel::PropertyWithValue * prop, QWidget * parent = NULL, QGridLayout * layout = NULL, int row=-1);
virtual ~BoolPropertyWidget();
QString getValue() const;
- void setValue(const QString & value);
+ virtual void setValueImpl(const QString & value);
///@return the main widget of this combo of widgets
QWidget * getMainWidget() {return m_checkBox; }
diff --git a/Code/Mantid/MantidQt/API/inc/MantidQtAPI/OptionsPropertyWidget.h b/Code/Mantid/MantidQt/API/inc/MantidQtAPI/OptionsPropertyWidget.h
index f33a0273d272..5d449688b291 100644
--- a/Code/Mantid/MantidQt/API/inc/MantidQtAPI/OptionsPropertyWidget.h
+++ b/Code/Mantid/MantidQt/API/inc/MantidQtAPI/OptionsPropertyWidget.h
@@ -46,7 +46,7 @@ namespace API
OptionsPropertyWidget(Mantid::Kernel::Property * prop, QWidget * parent = NULL, QGridLayout * layout = NULL, int row=-1);
virtual ~OptionsPropertyWidget();
QString getValue() const;
- void setValue(const QString & value);
+ virtual void setValueImpl(const QString & value);
///@return the main widget of this combo of widgets
QWidget * getMainWidget() {return m_combo; }
diff --git a/Code/Mantid/MantidQt/API/inc/MantidQtAPI/PropertyInfoWidget.h b/Code/Mantid/MantidQt/API/inc/MantidQtAPI/PropertyInfoWidget.h
new file mode 100644
index 000000000000..a027684f966d
--- /dev/null
+++ b/Code/Mantid/MantidQt/API/inc/MantidQtAPI/PropertyInfoWidget.h
@@ -0,0 +1,38 @@
+#ifndef MANTID_API_PROPERTYINFOWIDGET_H
+#define MANTID_API_PROPERTYINFOWIDGET_H
+
+#include
+#include
+#include
+
+namespace MantidQt
+{
+namespace API
+{
+ /**
+ * A widget used in dialogs to display various information about a property.
+ */
+ class PropertyInfoWidget : public QFrame
+ {
+ Q_OBJECT;
+
+ public:
+ /// Enumerating the info that can be displayed by this widget.
+ enum Info { INVALID, REPLACE, RESTORE };
+
+ /// Constructor.
+ PropertyInfoWidget(QWidget *parent = 0);
+
+ /// Set the given icon's visibility.
+ void setInfoVisible( Info info, bool visible );
+ /// Set the given icon's tool tip.
+ void setInfoToolTip( Info info, const QString & toolTip );
+
+ private:
+ /// Map enum to labels.
+ QMap m_labels;
+ };
+}
+}
+
+#endif /* MANTID_API_PROPERTYINFOWIDGET_H */
diff --git a/Code/Mantid/MantidQt/API/inc/MantidQtAPI/PropertyWidget.h b/Code/Mantid/MantidQt/API/inc/MantidQtAPI/PropertyWidget.h
index 25e9f839a5f4..ead8a97e6bb0 100644
--- a/Code/Mantid/MantidQt/API/inc/MantidQtAPI/PropertyWidget.h
+++ b/Code/Mantid/MantidQt/API/inc/MantidQtAPI/PropertyWidget.h
@@ -5,6 +5,7 @@
#include
#include
#include "MantidKernel/Property.h"
+#include "MantidQtAPI/PropertyInfoWidget.h"
#include
#include
#include
@@ -56,7 +57,9 @@ namespace API
virtual QString getValue() const = 0;
/// Set the value of the property given into the GUI state.
- virtual void setValue(const QString & value) = 0;
+ void setValue(const QString & value);
+ /// Set this widget's previously-entered value.
+ void setPreviousValue(const QString & previousValue);
virtual QWidget * getMainWidget() = 0;
@@ -79,6 +82,10 @@ namespace API
void setError(const QString & error);
+ private:
+ virtual void setValueImpl(const QString & value) = 0;
+ void setRestoredStatus();
+
public slots:
void replaceWSButtonClicked();
@@ -110,8 +117,8 @@ namespace API
/// If using the GridLayout, this is the row where the widget was inserted.
int m_row;
- /// Label that is visible when the property is NOT valid.
- QLabel * m_validLbl;
+ /// Widget to display information about this property.
+ PropertyInfoWidget * m_info;
/// Documentation string (tooltip)
QString m_doc;
@@ -124,6 +131,11 @@ namespace API
/// Error message received when trying to set the value
QString m_error;
+
+ /// Whether or not the property is an output workspace.
+ bool m_isOutputWsProp;
+
+ QString m_previousValue;
};
diff --git a/Code/Mantid/MantidQt/API/inc/MantidQtAPI/TextPropertyWidget.h b/Code/Mantid/MantidQt/API/inc/MantidQtAPI/TextPropertyWidget.h
index 59ee047f2cf9..137f00e8a161 100644
--- a/Code/Mantid/MantidQt/API/inc/MantidQtAPI/TextPropertyWidget.h
+++ b/Code/Mantid/MantidQt/API/inc/MantidQtAPI/TextPropertyWidget.h
@@ -45,7 +45,7 @@ namespace API
TextPropertyWidget(Mantid::Kernel::Property * prop, QWidget * parent = NULL, QGridLayout * layout = NULL, int row=-1);
virtual ~TextPropertyWidget();
QString getValue() const;
- void setValue(const QString & value);
+ virtual void setValueImpl(const QString & value);
///@return the main widget of this combo of widgets
QWidget * getMainWidget() {return m_textbox; }
diff --git a/Code/Mantid/MantidQt/API/src/AlgorithmDialog.cpp b/Code/Mantid/MantidQt/API/src/AlgorithmDialog.cpp
index 084c162dfe8d..477eef1cd35c 100644
--- a/Code/Mantid/MantidQt/API/src/AlgorithmDialog.cpp
+++ b/Code/Mantid/MantidQt/API/src/AlgorithmDialog.cpp
@@ -975,7 +975,7 @@ void AlgorithmDialog::setPreviousValue(QWidget* widget, const QString& propName)
PropertyWidget * propWidget = qobject_cast(widget);
if (propWidget)
{
- propWidget->setValue(value);
+ propWidget->setPreviousValue(value);
return;
}
diff --git a/Code/Mantid/MantidQt/API/src/AlgorithmPropertiesWidget.cpp b/Code/Mantid/MantidQt/API/src/AlgorithmPropertiesWidget.cpp
index 95a4ea2ce2b9..2376257f52ce 100644
--- a/Code/Mantid/MantidQt/API/src/AlgorithmPropertiesWidget.cpp
+++ b/Code/Mantid/MantidQt/API/src/AlgorithmPropertiesWidget.cpp
@@ -268,7 +268,7 @@ namespace API
if (!oldValue.isEmpty())
{
prop->setValue(oldValue.toStdString());
- widget->setValue(oldValue);
+ widget->setPreviousValue(oldValue);
}
}
diff --git a/Code/Mantid/MantidQt/API/src/BoolPropertyWidget.cpp b/Code/Mantid/MantidQt/API/src/BoolPropertyWidget.cpp
index e908a4253887..3c091dc4b4c7 100644
--- a/Code/Mantid/MantidQt/API/src/BoolPropertyWidget.cpp
+++ b/Code/Mantid/MantidQt/API/src/BoolPropertyWidget.cpp
@@ -47,7 +47,7 @@ namespace API
/** Set the value into the GUI
*
* @param value :: string representation of the value */
- void BoolPropertyWidget::setValue(const QString & value)
+ void BoolPropertyWidget::setValueImpl(const QString & value)
{
QString temp = value;
if (temp.isEmpty())
diff --git a/Code/Mantid/MantidQt/API/src/OptionsPropertyWidget.cpp b/Code/Mantid/MantidQt/API/src/OptionsPropertyWidget.cpp
index b470fbccebe7..fa16e4c9bfa7 100644
--- a/Code/Mantid/MantidQt/API/src/OptionsPropertyWidget.cpp
+++ b/Code/Mantid/MantidQt/API/src/OptionsPropertyWidget.cpp
@@ -67,7 +67,7 @@ namespace API
/** Set the value into the GUI
*
* @param value :: string representation of the value */
- void OptionsPropertyWidget::setValue(const QString & value)
+ void OptionsPropertyWidget::setValueImpl(const QString & value)
{
QString temp = value;
if (temp.isEmpty())
diff --git a/Code/Mantid/MantidQt/API/src/PropertyInfoWidget.cpp b/Code/Mantid/MantidQt/API/src/PropertyInfoWidget.cpp
new file mode 100644
index 000000000000..a3e272bf09d1
--- /dev/null
+++ b/Code/Mantid/MantidQt/API/src/PropertyInfoWidget.cpp
@@ -0,0 +1,73 @@
+#include "MantidQtAPI/PropertyInfoWidget.h"
+
+#include
+#include
+#include
+
+namespace MantidQt
+{
+namespace API
+{
+ /**
+ * Constructor.
+ *
+ * @param parent :: this widget's parent
+ */
+ PropertyInfoWidget::PropertyInfoWidget(QWidget *parent)
+ : QFrame(parent), m_labels()
+ {
+ setLayout(new QHBoxLayout(this));
+ layout()->setSpacing(1);
+ layout()->setContentsMargins(0, 0, 0, 0);
+
+ QMap> pathsAndToolTips;
+ pathsAndToolTips[REPLACE] = QPair(":/replace.png", "A workspace with this name already exists and so will be overwritten.");
+ pathsAndToolTips[RESTORE] = QPair(":/restore.png", "This was a previously-entered value.");
+
+ foreach( const auto info, pathsAndToolTips.keys() )
+ {
+ const QString iconPath = pathsAndToolTips[info].first;
+ const QString toolTip = pathsAndToolTips[info].second;
+
+ auto label = new QLabel(this);
+ label->setPixmap(QPixmap(iconPath).scaledToHeight(15));
+ label->setVisible(false);
+ label->setToolTip(toolTip);
+
+ layout()->addWidget(label);
+ m_labels[info] = label;
+ }
+
+ auto label = new QLabel("*");
+ auto palette = label->palette();
+ palette.setColor(QPalette::WindowText, Qt::darkRed);
+ label->setPalette(palette);
+ label->setVisible(false);
+ layout()->addWidget(label);
+ m_labels[INVALID] = label;
+ }
+
+ /**
+ * Set the given icon's visibility.
+ *
+ * @param icon :: icon to set
+ * @param visible :: whether or not the icon should be visible
+ */
+ void PropertyInfoWidget::setInfoVisible( Info info, bool visible )
+ {
+ m_labels[info]->setVisible(visible);
+ }
+
+ /**
+ * Set the given icon's tool tip.
+ *
+ * @param icon :: icon to set
+ * @param toolTip :: the contents of the tool tip
+ */
+ void PropertyInfoWidget::setInfoToolTip( Info info, const QString & toolTip )
+ {
+ m_labels[info]->setToolTip(toolTip);
+ }
+
+}//namespace
+}//namespace
diff --git a/Code/Mantid/MantidQt/API/src/PropertyWidget.cpp b/Code/Mantid/MantidQt/API/src/PropertyWidget.cpp
index c8a8b687ddfa..2265cffde271 100644
--- a/Code/Mantid/MantidQt/API/src/PropertyWidget.cpp
+++ b/Code/Mantid/MantidQt/API/src/PropertyWidget.cpp
@@ -2,6 +2,8 @@
#include "MantidKernel/System.h"
#include "MantidKernel/EmptyValues.h"
#include "MantidAPI/IWorkspaceProperty.h"
+#include "MantidAPI/AnalysisDataService.h"
+#include "MantidQtAPI/PropertyInfoWidget.h"
#include
@@ -167,8 +169,9 @@ namespace API
*/
PropertyWidget::PropertyWidget(Mantid::Kernel::Property * prop, QWidget * parent, QGridLayout * layout, int row)
: QWidget(parent),
- m_prop(prop), m_gridLayout(layout), m_row(row),
- m_replaceWSButton(NULL)
+ m_prop(prop), m_gridLayout(layout), m_parent(NULL), m_row(row), m_info(NULL),
+ m_doc(), m_replaceWSButton(NULL), m_widgets(), m_error(), m_isOutputWsProp(false),
+ m_previousValue()
{
if (!prop)
throw std::runtime_error("NULL Property passed to the PropertyWidget constructor.");
@@ -190,21 +193,22 @@ namespace API
// Use the parent of the provided QGridLayout when adding widgets
m_parent = parent;
}
-
- // Create the validator label (that red star)
- m_validLbl = new QLabel("*");
- QPalette pal = m_validLbl->palette();
- pal.setColor(QPalette::WindowText, Qt::darkRed);
- m_validLbl->setPalette(pal);
- // Start off hidden
- m_validLbl->setVisible(false);
- // Put it in the 4th column.
- m_gridLayout->addWidget(m_validLbl, m_row, 4);
+
+ m_info = new PropertyInfoWidget(this);
+ m_gridLayout->addWidget(m_info, m_row, 4);
/// Save the documentation tooltip
m_doc = QString::fromStdString(prop->documentation());
-
+ if( !isOptionalProperty(prop) )
+ {
+ if(!m_doc.isEmpty())
+ m_doc += "\n\n";
+ m_doc += "This property is required.";
+ }
+
+ if( prop->direction() == Direction::Output && dynamic_cast(prop) )
+ m_isOutputWsProp = true;
}
//----------------------------------------------------------------------------------------------
@@ -214,6 +218,28 @@ namespace API
{
}
+ /**
+ * Set this widget's value.
+ *
+ * @param value :: the value to set
+ */
+ void PropertyWidget::setValue(const QString & value)
+ {
+ setValueImpl(value);
+ setRestoredStatus();
+ }
+
+ /**
+ * Set this widget's value as a previously-entered value.
+ *
+ * @param previousValue :: the previous value of this widget
+ */
+ void PropertyWidget::setPreviousValue(const QString & previousValue)
+ {
+ m_previousValue = previousValue;
+ setValue(previousValue);
+ }
+
//----------------------------------------------------------------------------------------------
/** Slot called when someone clicks the "replace ws button" */
void PropertyWidget::replaceWSButtonClicked()
@@ -243,6 +269,7 @@ namespace API
//m_wsbtn_tracker[btn ] = 1;
m_replaceWSButton->setToolTip("Replace input workspace");
connect(m_replaceWSButton, SIGNAL(clicked()), this, SLOT(replaceWSButtonClicked()));
+ connect(m_replaceWSButton, SIGNAL(clicked()), this, SLOT(valueChangedSlot()));
m_widgets.push_back(m_replaceWSButton);
// Place in the grid on column 2.
m_gridLayout->addWidget(m_replaceWSButton, m_row, 2);
@@ -260,14 +287,9 @@ namespace API
{
m_error = error.trimmed();
- // Show the invalid star if there was an error
- if (m_error.isEmpty())
- m_validLbl->setVisible(false);
- else
- {
- m_validLbl->setVisible(true);
- m_validLbl->setToolTip(m_error);
- }
+ // Show the invalid star if there was an error.
+ m_info->setInfoVisible(PropertyInfoWidget::INVALID, !m_error.isEmpty());
+ m_info->setInfoToolTip(PropertyInfoWidget::INVALID, m_error);
}
@@ -297,6 +319,14 @@ namespace API
}
this->setError(QString::fromStdString(error).trimmed());
+ setRestoredStatus();
+
+ if( m_isOutputWsProp )
+ {
+ const bool wsExists = Mantid::API::AnalysisDataService::Instance().doesExist(value.toStdString());
+ m_info->setInfoVisible(PropertyInfoWidget::REPLACE, wsExists);
+ }
+
// This will be caught by the GenericDialog.
emit valueChanged( QString::fromStdString(m_prop->name()) ) ;
}
@@ -321,6 +351,19 @@ namespace API
QWidget::setVisible(val);
}
+ /**
+ * "Nudge" the restored information icon.
+ */
+ void PropertyWidget::setRestoredStatus()
+ {
+ if( m_previousValue == getValue() &&
+ getValue().toStdString() != m_prop->getDefault() &&
+ !getValue().isEmpty() )
+ m_info->setInfoVisible(PropertyInfoWidget::RESTORE, true);
+ else
+ m_info->setInfoVisible(PropertyInfoWidget::RESTORE, false);
+ }
+
/**
* Given a property and its associated label, will make font adjustments to the label
* based on whether or not the property is mandatory.
diff --git a/Code/Mantid/MantidQt/API/src/TextPropertyWidget.cpp b/Code/Mantid/MantidQt/API/src/TextPropertyWidget.cpp
index 0d48233cf87e..84db0794c9c2 100644
--- a/Code/Mantid/MantidQt/API/src/TextPropertyWidget.cpp
+++ b/Code/Mantid/MantidQt/API/src/TextPropertyWidget.cpp
@@ -58,7 +58,7 @@ namespace API
/** Set the value into the GUI
*
* @param value :: string representation of the value */
- void TextPropertyWidget::setValue(const QString & value)
+ void TextPropertyWidget::setValueImpl(const QString & value)
{
QString temp = value;
if (temp.isEmpty() && !m_prop->isDefault())